~ken-vandine/ubuntu-system-settings/lp1501428

« back to all changes in this revision

Viewing changes to plugins/system-update/network.h

  • Committer: CI Train Bot
  • Author(s): Manuel de la Pena
  • Date: 2015-09-01 13:59:08 UTC
  • mfrom: (1506.6.8 donot-query-on-error)
  • Revision ID: ci-train-bot@canonical.com-20150901135908-hhxklaq0t29q3yko
Sign the query in order to get a possible auth error from the server and stop the user from trying to do updates with invalid creds.
Approved by: Ken VanDine

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#ifndef NETWORK_H
20
20
#define NETWORK_H
21
21
 
 
22
#include <token.h>
22
23
#include <QObject>
23
24
#include <QtNetwork/QNetworkAccessManager>
24
25
#include <QtNetwork/QNetworkReply>
25
26
#include <QHash>
26
 
#include "../update.h"
 
27
 
 
28
#include "update.h"
27
29
 
28
30
#define X_CLICK_TOKEN "X-Click-Token"
29
31
 
30
32
namespace UpdatePlugin {
31
33
 
32
 
class RequestObject : public QObject
33
 
{
34
 
    Q_OBJECT
35
 
public:
36
 
    explicit RequestObject(QString oper, QObject *parent = 0) :
37
 
        QObject(parent)
38
 
    {
39
 
        operation = oper;
40
 
    }
41
 
 
42
 
    QString operation;
43
 
};
44
 
 
45
34
class Network : public QObject
46
35
{
47
36
    Q_OBJECT
49
38
    explicit Network(QObject *parent = 0);
50
39
 
51
40
    void checkForNewVersions(QHash<QString, Update*> &apps);
52
 
    void getClickToken(Update *app, const QString &url,
53
 
                       const QString &authHeader);
 
41
    void getClickToken(Update *app, const QString &url);
 
42
 
54
43
    virtual std::vector<std::string> getAvailableFrameworks();
55
44
    virtual std::string getArchitecture();
56
45
 
 
46
    void setUbuntuOneToken(UbuntuOne::Token token) { m_token = token; }
 
47
    UbuntuOne::Token getUbuntuOneToken() { return m_token; }
 
48
 
57
49
Q_SIGNALS:
58
50
    void updatesFound();
59
51
    void updatesNotFound();
64
56
    void credentialError();
65
57
 
66
58
private Q_SLOTS:
67
 
    void onReplyFinished();
 
59
    void onUpdatesCheckFinished();
68
60
    void onReplySslErrors(const QList<QSslError> & errors);
69
61
    void onReplyError(QNetworkReply::NetworkError code);
70
62
 
71
63
private:
72
64
    QNetworkAccessManager m_nam;
73
65
    QHash<QString, Update*> m_apps;
 
66
    UbuntuOne::Token m_token;
74
67
 
75
68
    QString getUrlApps();
76
69
    QString getFrameworksDir();
 
70
    bool replyIsValid(QNetworkReply *reply);
 
71
    void onTokenRequestFinished(Update* update, QNetworkReply* reply);
77
72
 
78
73
protected:
79
74
    virtual std::string architectureFromDpkg();