Merge lp:~mikemc/ubuntuone-credentials/slot-and-signal-improvements into lp:ubuntuone-credentials

Proposed by Mike McCracken
Status: Merged
Approved by: dobey
Approved revision: 32
Merged at revision: 28
Proposed branch: lp:~mikemc/ubuntuone-credentials/slot-and-signal-improvements
Merge into: lp:ubuntuone-credentials
Prerequisite: lp:~mikemc/ubuntuone-credentials/remove-sso-api-subdir
Diff against target: 174 lines (+40/-25)
6 files modified
libubuntuoneauth/identityprovider.cpp (+9/-8)
libubuntuoneauth/keyring.cpp (+1/-1)
libubuntuoneauth/ssoservice.cpp (+20/-7)
libubuntuoneauth/ssoservice.h (+6/-5)
music-login/ssowizard.cpp (+3/-3)
music-login/ssowizard.h (+1/-1)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-credentials/slot-and-signal-improvements
Reviewer Review Type Date Requested Status
dobey (community) Approve
Review via email: mp+170688@code.launchpad.net

Commit message

Improvements to available slots and signals on ssoservice object.

Description of the change

Improvements to available slots and signals on ssoservice object.

- connect credentialsNotFound signal
- change credentialsStored signal to include token, and do not clear _pendingPing until after tokenStored signal, so clients can access new tokens created by login/register as well as old ones found in keyring
- rename slots to be clearer what they are connected to and avoid needing to use lots of synonyms
- also improve logging to make control flow obvious

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
review: Approve
31. By Mike McCracken

merge with trunk, fix conflict

Revision history for this message
dobey (dobey) wrote :

The fixes to code in music-login to deal with the signal/slots API changes in here, will need to be done in this branch as well, so we don't end up with a broken app in the interim.

review: Needs Fixing
32. By Mike McCracken

Fix broken signals in music store login app

Revision history for this message
Mike McCracken (mikemc) wrote :

rev 32 fixes the music login app

Revision history for this message
dobey (dobey) wrote :

The conversion from "const Token&" -> "Token" in the signal/slot handling to update the music-login app for the changes is a bit weird, but if it works, it works.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntuoneauth/identityprovider.cpp'
2--- libubuntuoneauth/identityprovider.cpp 2013-07-02 19:12:47 +0000
3+++ libubuntuoneauth/identityprovider.cpp 2013-07-02 19:12:47 +0000
4@@ -60,31 +60,32 @@
5
6 void IdentityProvider::OnOAuthTokenGranted(const OAuthTokenResponse& token)
7 {
8+ qWarning() << "OAuth token received for " << token.token_name();
9+
10 emit OAuthTokenGranted(token);
11-
12- qWarning() << "OAuth token received for " << token.token_name();
13 }
14
15 void IdentityProvider::OnPasswordTokenGranted(const PasswordTokenResponse& token)
16 {
17+ qWarning() << "Password token received for " << token.email();
18+
19 emit PasswordTokenGranted(token);
20-
21- qWarning() << "Password token received for " << token.email();
22 }
23
24 void IdentityProvider::OnAccountGranted(const AccountResponse& account)
25 {
26+ qWarning() << "Account created for " << account.email();
27+
28 emit AccountGranted(account);
29-
30- qWarning() << "Account created for " << account.email();
31 }
32
33 void IdentityProvider::OnErrorOccurred(const ErrorResponse& error)
34 {
35- emit ErrorOccurred(error);
36-
37 qWarning("Error occurred creating account: %d (%s)",
38 error.code(), error.message().toUtf8().data());
39+
40+ emit ErrorOccurred(error);
41+
42 }
43
44 } /* end UbuntuOne namespace */
45
46=== modified file 'libubuntuoneauth/keyring.cpp'
47--- libubuntuoneauth/keyring.cpp 2013-05-28 13:28:49 +0000
48+++ libubuntuoneauth/keyring.cpp 2013-07-02 19:12:47 +0000
49@@ -54,7 +54,7 @@
50
51 if (error != NULL) {
52 QString message(error->message);
53- qCritical() << message;
54+ qCritical() << "Error in secret_password_lookup: " << message;
55 emit keyring->keyringError(message);
56 g_error_free(error);
57 } else if (password == NULL) {
58
59=== modified file 'libubuntuoneauth/ssoservice.cpp'
60--- libubuntuoneauth/ssoservice.cpp 2013-07-02 19:12:47 +0000
61+++ libubuntuoneauth/ssoservice.cpp 2013-07-02 19:12:47 +0000
62@@ -48,11 +48,14 @@
63 _nam = new QNetworkAccessManager(this);
64
65 connect(_keyring, SIGNAL(tokenFound(const Token&)),
66- this, SLOT(credentialsAcquired(const Token&)));
67+ this, SLOT(handleCredentialsFound(const Token&)));
68+ connect(_keyring, SIGNAL(tokenNotFound()),
69+ this, SLOT(handleCredentialsNotFound()));
70+
71 connect(_keyring, SIGNAL(tokenStored()),
72- this, SLOT(credentialsSet()));
73+ this, SLOT(handleTokenStored()));
74 connect(_keyring, SIGNAL(tokenDeleted()),
75- this, SLOT(credentialsCleared()));
76+ this, SLOT(handleTokenDeleted()));
77
78 connect(&(_provider),
79 SIGNAL(OAuthTokenGranted(const OAuthTokenResponse&)),
80@@ -70,9 +73,20 @@
81 _keyring->findToken();
82 }
83
84- void SSOService::credentialsAcquired(const Token& token)
85- {
86- emit this->credentialsFound(token);
87+ void SSOService::handleCredentialsNotFound()
88+ {
89+ emit credentialsNotFound();
90+ }
91+
92+ void SSOService::handleCredentialsFound(const Token& token)
93+ {
94+ emit credentialsFound(token);
95+ }
96+
97+ void SSOService::handleTokenStored()
98+ {
99+ emit credentialsStored(_pendingPing);
100+ _pendingPing = Token();
101 }
102
103 void SSOService::registerUser(QString email, QString password,
104@@ -168,7 +182,6 @@
105 _keyring->storeToken(_pendingPing);
106
107 reply->deleteLater();
108- _pendingPing = Token();
109 }
110
111 void SSOService::invalidateCredentials()
112
113=== modified file 'libubuntuoneauth/ssoservice.h'
114--- libubuntuoneauth/ssoservice.h 2013-07-02 19:12:47 +0000
115+++ libubuntuoneauth/ssoservice.h 2013-07-02 19:12:47 +0000
116@@ -49,16 +49,17 @@
117
118 signals:
119 void credentialsDeleted();
120- void credentialsStored();
121+ void credentialsStored(const Token& token);
122 void credentialsFound(const Token& token);
123- void credentialsNotFound(QString id);
124+ void credentialsNotFound();
125 void requestFailed(const ErrorResponse& error);
126
127 private slots:
128 void accountPinged(QNetworkReply*);
129- void credentialsSet() { emit credentialsStored(); };
130- void credentialsCleared() { emit credentialsDeleted(); };
131- void credentialsAcquired(const Token& token);
132+ void handleTokenStored();
133+ void handleTokenDeleted() { emit credentialsDeleted(); };
134+ void handleCredentialsFound(const Token& token);
135+ void handleCredentialsNotFound();
136 void tokenReceived(const OAuthTokenResponse& token);
137 void accountRegistered(const AccountResponse& account);
138 void errorOcurred(const ErrorResponse&);
139
140=== modified file 'music-login/ssowizard.cpp'
141--- music-login/ssowizard.cpp 2013-07-02 19:12:47 +0000
142+++ music-login/ssowizard.cpp 2013-07-02 19:12:47 +0000
143@@ -81,8 +81,8 @@
144 QObject::connect(&(this->downloader), SIGNAL(fileDownloaded(QString&)),
145 this, SLOT(imageDownloaded(QString&)));
146
147- QObject::connect(&(this->_service), SIGNAL(credentialsStored()),
148- this, SLOT(accountAuthenticated()));
149+ QObject::connect(&(this->_service), SIGNAL(credentialsStored(const Token&)),
150+ this, SLOT(accountAuthenticated(Token)));
151 QObject::connect(&(this->_service), SIGNAL(credentialsFound(const Token&)),
152 this, SLOT(openUrlAndFinish(Token)));
153
154@@ -142,7 +142,7 @@
155 this->_service.login(email, password);
156 }
157
158-void SSOWizard::accountAuthenticated()
159+void SSOWizard::accountAuthenticated(Token token)
160 {
161 this->_service.getCredentials();
162 }
163
164=== modified file 'music-login/ssowizard.h'
165--- music-login/ssowizard.h 2013-05-24 21:09:26 +0000
166+++ music-login/ssowizard.h 2013-07-02 19:12:47 +0000
167@@ -67,7 +67,7 @@
168 void registerAndBuy(QString email, QString password, QString name);
169 void showPageLogin();
170
171- void accountAuthenticated();
172+ void accountAuthenticated(Token);
173 void openUrlAndFinish(Token);
174 void serviceFailed(const ErrorResponse&);
175

Subscribers

People subscribed via source and target branches

to all changes: