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 bool isReading() const { return m_isReading; }
00049
00050 public Q_SLOTS:
00051 void readBlob();
00052
00053 Q_SIGNALS:
00054 void dataReceived(const QVariantMap &map);
00055 void error();
00056
00057 private:
00058 void setReadNotificationEnabled(bool enable);
00059
00060 QByteArray variantMapToByteArray(const QVariantMap &map);
00061 QVariantMap byteArrayToVariantMap(const QByteArray &array);
00062 QVector<QByteArray> pageByteArray(const QByteArray &array);
00063
00064 public:
00065 QIODevice *m_readChannel;
00066 QIODevice *m_writeChannel;
00067 QByteArray m_blobBuffer;
00068 QSocketNotifier *m_readNotifier;
00069 int m_blobSize;
00070 bool m_isReading;
00071 };
00072
00073 }
00074
00075 #endif //BLOBIOHANDLER_H