Merge lp:~ted/pay-service/lp1348231-account-creation into lp:~ted/pay-service/pay-test-app

Proposed by Ted Gould
Status: Superseded
Proposed branch: lp:~ted/pay-service/lp1348231-account-creation
Merge into: lp:~ted/pay-service/pay-test-app
Diff against target: 138 lines (+60/-7)
3 files modified
CMakeLists.txt (+1/-0)
debian/control (+1/-0)
service/token-grabber-u1.cpp (+58/-7)
To merge this branch: bzr merge lp:~ted/pay-service/lp1348231-account-creation
Reviewer Review Type Date Requested Status
Ted Gould Pending
Review via email: mp+229955@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-07.

Commit message

Use libaccounts to get signals on account creation or deletion to update the stored token

Description of the change

Getting some signals from the Account Service and just asking for a refresh on them.

To post a comment you must log in.

Unmerged revisions

42. By Ted Gould

Explaining what's going on a bit

41. By Ted Gould

Adding enabled as well

40. By Ted Gould

Thinking this should really show up in the default log

39. By Ted Gould

Attaching bug

38. By Ted Gould

Move the rest of the Qt main based stuff to qDebug()

37. By Ted Gould

Clean up debug messages

36. By Ted Gould

Get the accounts manager integrated

35. By Ted Gould

Get libaccounts in here

34. By Ted Gould

Add a handler for the credentials stored signal

33. By Ted Gould

Catch up to the pay-test-app branch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-08-06 00:00:52 +0000
3+++ CMakeLists.txt 2014-08-07 15:19:02 +0000
4@@ -35,6 +35,7 @@
5 find_package (Qt5Core REQUIRED)
6
7 pkg_check_modules (SERVICE_DEPS REQUIRED
8+ accounts-qt5
9 libcurl
10 ubuntu-app-launch-2
11 dbustest-1
12
13=== modified file 'debian/control'
14--- debian/control 2014-08-06 00:00:52 +0000
15+++ debian/control 2014-08-07 15:19:02 +0000
16@@ -13,6 +13,7 @@
17 # in libstdc++ causing us issues, we explicitly select a G++
18 # version.
19 g++-4.9,
20+ libaccounts-qt5-dev,
21 libclick-0.4-dev,
22 libcurl4-gnutls-dev,
23 libdbustest1-dev,
24
25=== modified file 'service/token-grabber-u1.cpp'
26--- service/token-grabber-u1.cpp 2014-07-15 14:34:16 +0000
27+++ service/token-grabber-u1.cpp 2014-08-07 15:19:02 +0000
28@@ -20,9 +20,13 @@
29 #include "token-grabber-u1.h"
30 #include "qtbridge.h"
31
32+/* U1 Creds */
33 #include <ssoservice.h>
34 #include <token.h>
35
36+/* Accounts Service */
37+#include <Accounts/Manager>
38+
39 class TokenGrabberU1Qt: public QObject
40 {
41 Q_OBJECT
42@@ -35,22 +39,45 @@
43 private Q_SLOTS:
44 void handleCredentialsFound(const UbuntuOne::Token& token);
45 void handleCredentialsNotFound();
46+ void handleCredentialsStored();
47+ void accountChanged(Accounts::AccountId id);
48
49 private:
50 UbuntuOne::Token token;
51 UbuntuOne::SSOService service;
52+ Accounts::Manager manager;
53 };
54
55 TokenGrabberU1Qt::TokenGrabberU1Qt (QObject* parent) :
56- QObject(parent)
57+ QObject(parent),
58+ manager("ubuntuone")
59 {
60- std::cout << "Token grabber built" << std::endl;
61+ qDebug() << "Token grabber built";
62 }
63
64 void TokenGrabberU1Qt::run (void)
65 {
66- std::cout << "Token grabber running" << std::endl;
67-
68+ qDebug() << "Token grabber running";
69+
70+ /* Accounts Manager */
71+ QObject::connect(&manager,
72+ &Accounts::Manager::accountCreated,
73+ this,
74+ &TokenGrabberU1Qt::accountChanged);
75+ QObject::connect(&manager,
76+ &Accounts::Manager::accountRemoved,
77+ this,
78+ &TokenGrabberU1Qt::accountChanged);
79+ QObject::connect(&manager,
80+ &Accounts::Manager::accountUpdated,
81+ this,
82+ &TokenGrabberU1Qt::accountChanged);
83+ QObject::connect(&manager,
84+ &Accounts::Manager::enabledEvent,
85+ this,
86+ &TokenGrabberU1Qt::accountChanged);
87+
88+ /* U1 signals */
89 QObject::connect(&service,
90 &UbuntuOne::SSOService::credentialsFound,
91 this,
92@@ -59,19 +86,43 @@
93 &UbuntuOne::SSOService::credentialsNotFound,
94 this,
95 &TokenGrabberU1Qt::handleCredentialsNotFound);
96-
97+ QObject::connect(&service,
98+ &UbuntuOne::SSOService::credentialsStored,
99+ this,
100+ &TokenGrabberU1Qt::handleCredentialsStored);
101+
102+
103+
104+ service.getCredentials();
105+}
106+
107+void TokenGrabberU1Qt::accountChanged(Accounts::AccountId id)
108+{
109+ /* We don't need to worry about @id here because there
110+ can only be one U1 account for the user at a time, so
111+ we're not getting a specific account or anything. Just
112+ watching for changes */
113+ qDebug() << "Account changed, try to get a new token";
114+ token = UbuntuOne::Token();
115 service.getCredentials();
116 }
117
118 void TokenGrabberU1Qt::handleCredentialsFound(const UbuntuOne::Token& in_token)
119 {
120+ qDebug() << "Got a Token";
121 token = in_token;
122- std::cout << "Got a Token" << std::endl;
123 }
124
125 void TokenGrabberU1Qt::handleCredentialsNotFound()
126 {
127- std::cout << "No Token :-(" << std::endl;
128+ qWarning() << "No Token :-(";
129+ token = UbuntuOne::Token();
130+}
131+
132+void TokenGrabberU1Qt::handleCredentialsStored()
133+{
134+ qDebug() << "New Credentials Stored";
135+ service.getCredentials();
136 }
137
138 std::string TokenGrabberU1Qt::signUrl (std::string url, std::string type)

Subscribers

People subscribed via source and target branches

to all changes: