2
* Copyright © 2014 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Ted Gould <ted.gould@canonical.com>
20
#include "token-grabber-u1.h"
23
#include <ssoservice.h>
26
class TokenGrabberU1Qt: public QObject
31
explicit TokenGrabberU1Qt (QObject* parent = 0);
33
std::string signUrl(std::string url, std::string type);
36
void handleCredentialsFound(const UbuntuOne::Token& token);
37
void handleCredentialsNotFound();
40
UbuntuOne::Token token;
41
UbuntuOne::SSOService service;
44
TokenGrabberU1Qt::TokenGrabberU1Qt (QObject* parent) :
47
std::cout << "Token grabber built" << std::endl;
50
void TokenGrabberU1Qt::run (void)
52
std::cout << "Token grabber running" << std::endl;
54
QObject::connect(&service,
55
&UbuntuOne::SSOService::credentialsFound,
57
&TokenGrabberU1Qt::handleCredentialsFound);
58
QObject::connect(&service,
59
&UbuntuOne::SSOService::credentialsNotFound,
61
&TokenGrabberU1Qt::handleCredentialsNotFound);
63
service.getCredentials();
66
void TokenGrabberU1Qt::handleCredentialsFound(const UbuntuOne::Token& in_token)
69
std::cout << "Got a Token" << std::endl;
72
void TokenGrabberU1Qt::handleCredentialsNotFound()
74
std::cout << "No Token :-(" << std::endl;
77
std::string TokenGrabberU1Qt::signUrl (std::string url, std::string type)
81
auto qretval = token.signUrl(url.c_str(), type.c_str());
82
retval = std::string(qretval.toUtf8());
87
TokenGrabberU1::TokenGrabberU1 (void)
89
//qt = std::make_shared<TokenGrabberU1Qt>();
90
qtfuture = qt::core::world::enter_with_task_and_expect_result<std::shared_ptr<TokenGrabberU1Qt>>([]()
92
auto qtgrabber = std::make_shared<TokenGrabberU1Qt>();
98
TokenGrabberU1::~TokenGrabberU1 (void)
102
std::string TokenGrabberU1::signUrl (std::string url, std::string type)
104
if (qtfuture.valid())
106
return qtfuture.get()->signUrl(url, type);
113
#include "token-grabber-u1.moc"