00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef BLOBIOHANDLER_H
00025 #define BLOBIOHANDLER_H
00026
00027 #include <QObject>
00028 #include <QIODevice>
00029 #include <QVariantMap>
00030 #include <QSocketNotifier>
00031
00032 namespace SignOn {
00033
00034 class BlobIOHandler: public QObject
00035 {
00036 Q_OBJECT
00037
00038 public:
00039 BlobIOHandler(QIODevice *inputChannel,
00040 QIODevice *outputChannel,
00041 QObject *parent = 0);
00042
00043 bool sendData(const QVariantMap &map);
00044
00045 void receiveData(int expectedDataSize);
00046
00047 void setReadChannelSocketNotifier(QSocketNotifier *notifier);
00048
00049 public Q_SLOTS:
00050 void readBlob();
00051
00052 Q_SIGNALS:
00053 void dataReceived(const QVariantMap &map);
00054 void error();
00055
00056 private:
00057 void setReadNotificationEnabled(bool enable);
00058
00059 QByteArray variantMapToByteArray(const QVariantMap &map);
00060 QVariantMap byteArrayToVariantMap(const QByteArray &array);
00061 QVector<QByteArray> pageByteArray(const QByteArray &array);
00062
00063 public:
00064 QIODevice *m_readChannel;
00065 QIODevice *m_writeChannel;
00066 QByteArray m_blobBuffer;
00067 QSocketNotifier *m_readNotifier;
00068 int m_blobSize;
00069 };
00070
00071 }
00072
00073 #endif //BLOBIOHANDLER_H