Merge lp:~dobey/ubuntu-push/sign-all-automatic into lp:ubuntu-push/automatic

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 414
Merged at revision: 414
Proposed branch: lp:~dobey/ubuntu-push/sign-all-automatic
Merge into: lp:ubuntu-push/automatic
Diff against target: 143 lines (+48/-41)
2 files modified
signing-helper/signing-helper.cpp (+43/-38)
signing-helper/signing.h (+5/-3)
To merge this branch: bzr merge lp:~dobey/ubuntu-push/sign-all-automatic
Reviewer Review Type Date Requested Status
Samuele Pedroni Approve
Review via email: mp+276912@code.launchpad.net

Commit message

Add support for signing methods other than POST via argv[2].

To post a comment you must log in.
Revision history for this message
Samuele Pedroni (pedronis) wrote :

same as
156. By Rodney Dawes on 2015-11-04

    Add support for signing methods other than POST via argv[2].
    Approved by: Roberto Alsina
    Merged branch lp:~dobey/ubuntu-push/sign-all-methods

looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'signing-helper/signing-helper.cpp'
2--- signing-helper/signing-helper.cpp 2014-06-04 15:52:22 +0000
3+++ signing-helper/signing-helper.cpp 2015-11-06 21:26:56 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2013-2014 Canonical Ltd.
7+ * Copyright (C) 2013-2015 Canonical Ltd.
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 3, as published
11@@ -27,6 +27,8 @@
12 * files in the program, then also delete it here.
13 */
14
15+#include "signing.h"
16+
17 #include <iostream>
18 #include <QCoreApplication>
19 #include <QDebug>
20@@ -35,44 +37,44 @@
21 #include <QTimer>
22 #include <QUrlQuery>
23
24-#include "ssoservice.h"
25-#include "token.h"
26-
27-#include "signing.h"
28-
29 namespace UbuntuOne {
30
31- SigningExample::SigningExample(QObject *parent, QString url) :
32- QObject(parent)
33- {
34- QObject::connect(&service, SIGNAL(credentialsFound(const Token&)),
35- this, SLOT(handleCredentialsFound(Token)));
36- QObject::connect(&service, SIGNAL(credentialsNotFound()),
37- this, SLOT(handleCredentialsNotFound()));
38- this->url = url;
39-
40- }
41-
42- SigningExample::~SigningExample(){
43- }
44-
45- void SigningExample::doExample()
46- {
47- service.getCredentials();
48- }
49-
50- void SigningExample::handleCredentialsFound(Token token)
51- {
52- qDebug() << "Credentials found, signing url.";
53- std::cout << token.signUrl(this->url, QStringLiteral("POST")).toStdString();
54- QCoreApplication::instance()->exit(0);
55- }
56-
57- void SigningExample::handleCredentialsNotFound()
58- {
59- qDebug() << "No credentials were found.";
60- QCoreApplication::instance()->exit(1);
61- }
62+SigningExample::SigningExample(QObject *parent, const QString& url) :
63+ QObject(parent),
64+ m_url(url),
65+ m_method("POST")
66+{
67+ QObject::connect(&service, SIGNAL(credentialsFound(const Token&)),
68+ this, SLOT(handleCredentialsFound(Token)));
69+ QObject::connect(&service, SIGNAL(credentialsNotFound()),
70+ this, SLOT(handleCredentialsNotFound()));
71+}
72+
73+SigningExample::~SigningExample(){
74+}
75+
76+void SigningExample::setMethod(const QString& method)
77+{
78+ m_method = method;
79+}
80+
81+void SigningExample::doExample()
82+{
83+ service.getCredentials();
84+}
85+
86+void SigningExample::handleCredentialsFound(Token token)
87+{
88+ qDebug() << "Credentials found, signing url.";
89+ std::cout << token.signUrl(m_url, m_method).toStdString();
90+ QCoreApplication::instance()->exit(0);
91+}
92+
93+void SigningExample::handleCredentialsNotFound()
94+{
95+ qDebug() << "No credentials were found.";
96+ QCoreApplication::instance()->exit(1);
97+}
98
99
100 } // namespace UbuntuOne
101@@ -81,10 +83,13 @@
102 int main(int argc, char *argv[])
103 {
104 QCoreApplication a(argc, argv);
105- if (argc<2) {
106+ if (argc < 2) {
107 return 2;
108 }
109 UbuntuOne::SigningExample *example = new UbuntuOne::SigningExample(&a, argv[1]);
110+ if (argc == 3) {
111+ example->setMethod(argv[2]);
112+ }
113 QObject::connect(example, SIGNAL(finished()), &a, SLOT(quit()));
114 QTimer::singleShot(0, example, SLOT(doExample()));
115 return a.exec();
116
117=== modified file 'signing-helper/signing.h'
118--- signing-helper/signing.h 2014-05-01 10:24:23 +0000
119+++ signing-helper/signing.h 2015-11-06 21:26:56 +0000
120@@ -48,9 +48,11 @@
121
122 public:
123
124- explicit SigningExample(QObject *parent = 0, QString url="https://one.ubuntu.com/api/account/");
125+ explicit SigningExample(QObject *parent = 0, const QString& url="https://one.ubuntu.com/api/account/");
126 ~SigningExample();
127
128+ void setMethod(const QString& method);
129+
130 public slots:
131
132 void doExample();
133@@ -68,8 +70,8 @@
134
135 SSOService service;
136 QNetworkAccessManager nam;
137- QString url;
138-
139+ QString m_url;
140+ QString m_method;
141 };
142
143 }

Subscribers

People subscribed via source and target branches

to all changes: