/usr/include/bodega/networkjob.h is in libbodega-dev 0.2-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | /*
* Copyright 2012 Coherent Theory LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef BODEGA_NETWORKJOB_H
#define BODEGA_NETWORKJOB_H
#include <bodega/error.h>
#include <bodega/globals.h>
#include <QtNetwork/QNetworkReply>
#include <QtCore/QObject>
namespace Bodega {
class Session;
class BODEGA_EXPORT NetworkJob : public QObject
{
Q_OBJECT
Q_PROPERTY(QUrl url READ url CONSTANT)
Q_PROPERTY(bool finished READ isFinished NOTIFY finishedChanged)
Q_PROPERTY(bool failed READ failed NOTIFY failedChanged)
Q_PROPERTY(bool authSuccess READ authSuccess NOTIFY authSuccessChanged)
Q_PROPERTY(QString storeId READ storeId NOTIFY storeIdChanged)
Q_PROPERTY(int points READ points NOTIFY pointsChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(QVariantMap parsedJson READ parsedJson NOTIFY parsedJsonChanged)
Q_PROPERTY(Bodega::Error error READ error NOTIFY jobError)
public:
NetworkJob(QNetworkReply *reply, Session *parent, bool parseResponse = true);
~NetworkJob();
Session *session() const;
QNetworkReply *reply() const;
QUrl url() const;
bool isFinished() const;
bool authSuccess() const;
QString storeId() const;
int points() const;
qreal progress() const;
bool failed() const;
Error error() const;
bool isJsonResponse() const;
QVariantMap parsedJson() const;
Q_SIGNALS:
//FIXME job seems to be readable from qml only if the parameter is a
// QObject * instead of a NetworkJob * (same thing for error)
void jobError(Bodega::NetworkJob *job, const Bodega::Error &error);
void jobFinished(Bodega::NetworkJob *job);
void progressChanged(qreal progress);
void parsedJsonChanged(const QVariantMap &parsedJson);
void finishedChanged(bool finished);
void failedChanged(bool failed);
void authSuccessChanged(bool authSuccess);
void storeIdChanged(const QString &storeId);
void pointsChanged(int points);
protected:
virtual void netError(QNetworkReply::NetworkError code,
const QString &msg);
virtual void netFinished(const QVariantMap &jsonMap);
virtual void downloadFinished(const QString &filename);
void setProgress(qreal progress);
void parseCommon(const QVariantMap &jsonMap);
void parseErrors(const QVariantMap &jsonMap);
//For errors not related to network
void setError(const Bodega::Error &error);
void setFinished();
private:
class Private;
Private * const d;
Q_PRIVATE_SLOT(d, void netError(QNetworkReply::NetworkError code));
Q_PRIVATE_SLOT(d, void readFromNetwork());
Q_PRIVATE_SLOT(d, void netFinished());
Q_PRIVATE_SLOT(d, void downloadProgress(qint64 bytesReceived, qint64 bytesTotal));
};
}
#endif
|