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
=== modified file 'libubuntuoneauth/identityprovider.cpp'
--- libubuntuoneauth/identityprovider.cpp 2013-07-02 19:12:47 +0000
+++ libubuntuoneauth/identityprovider.cpp 2013-07-02 19:12:47 +0000
@@ -60,31 +60,32 @@
6060
61void IdentityProvider::OnOAuthTokenGranted(const OAuthTokenResponse& token)61void IdentityProvider::OnOAuthTokenGranted(const OAuthTokenResponse& token)
62{62{
63 qWarning() << "OAuth token received for " << token.token_name();
64
63 emit OAuthTokenGranted(token);65 emit OAuthTokenGranted(token);
64
65 qWarning() << "OAuth token received for " << token.token_name();
66}66}
6767
68void IdentityProvider::OnPasswordTokenGranted(const PasswordTokenResponse& token)68void IdentityProvider::OnPasswordTokenGranted(const PasswordTokenResponse& token)
69{69{
70 qWarning() << "Password token received for " << token.email();
71
70 emit PasswordTokenGranted(token);72 emit PasswordTokenGranted(token);
71
72 qWarning() << "Password token received for " << token.email();
73}73}
7474
75void IdentityProvider::OnAccountGranted(const AccountResponse& account)75void IdentityProvider::OnAccountGranted(const AccountResponse& account)
76{76{
77 qWarning() << "Account created for " << account.email();
78
77 emit AccountGranted(account);79 emit AccountGranted(account);
78
79 qWarning() << "Account created for " << account.email();
80}80}
8181
82void IdentityProvider::OnErrorOccurred(const ErrorResponse& error)82void IdentityProvider::OnErrorOccurred(const ErrorResponse& error)
83{83{
84 emit ErrorOccurred(error);
85
86 qWarning("Error occurred creating account: %d (%s)",84 qWarning("Error occurred creating account: %d (%s)",
87 error.code(), error.message().toUtf8().data());85 error.code(), error.message().toUtf8().data());
86
87 emit ErrorOccurred(error);
88
88}89}
8990
90} /* end UbuntuOne namespace */91} /* end UbuntuOne namespace */
9192
=== modified file 'libubuntuoneauth/keyring.cpp'
--- libubuntuoneauth/keyring.cpp 2013-05-28 13:28:49 +0000
+++ libubuntuoneauth/keyring.cpp 2013-07-02 19:12:47 +0000
@@ -54,7 +54,7 @@
5454
55 if (error != NULL) {55 if (error != NULL) {
56 QString message(error->message);56 QString message(error->message);
57 qCritical() << message;57 qCritical() << "Error in secret_password_lookup: " << message;
58 emit keyring->keyringError(message);58 emit keyring->keyringError(message);
59 g_error_free(error);59 g_error_free(error);
60 } else if (password == NULL) {60 } else if (password == NULL) {
6161
=== modified file 'libubuntuoneauth/ssoservice.cpp'
--- libubuntuoneauth/ssoservice.cpp 2013-07-02 19:12:47 +0000
+++ libubuntuoneauth/ssoservice.cpp 2013-07-02 19:12:47 +0000
@@ -48,11 +48,14 @@
48 _nam = new QNetworkAccessManager(this);48 _nam = new QNetworkAccessManager(this);
4949
50 connect(_keyring, SIGNAL(tokenFound(const Token&)),50 connect(_keyring, SIGNAL(tokenFound(const Token&)),
51 this, SLOT(credentialsAcquired(const Token&)));51 this, SLOT(handleCredentialsFound(const Token&)));
52 connect(_keyring, SIGNAL(tokenNotFound()),
53 this, SLOT(handleCredentialsNotFound()));
54
52 connect(_keyring, SIGNAL(tokenStored()),55 connect(_keyring, SIGNAL(tokenStored()),
53 this, SLOT(credentialsSet()));56 this, SLOT(handleTokenStored()));
54 connect(_keyring, SIGNAL(tokenDeleted()),57 connect(_keyring, SIGNAL(tokenDeleted()),
55 this, SLOT(credentialsCleared()));58 this, SLOT(handleTokenDeleted()));
5659
57 connect(&(_provider),60 connect(&(_provider),
58 SIGNAL(OAuthTokenGranted(const OAuthTokenResponse&)),61 SIGNAL(OAuthTokenGranted(const OAuthTokenResponse&)),
@@ -70,9 +73,20 @@
70 _keyring->findToken();73 _keyring->findToken();
71 }74 }
7275
73 void SSOService::credentialsAcquired(const Token& token)76 void SSOService::handleCredentialsNotFound()
74 {77 {
75 emit this->credentialsFound(token);78 emit credentialsNotFound();
79 }
80
81 void SSOService::handleCredentialsFound(const Token& token)
82 {
83 emit credentialsFound(token);
84 }
85
86 void SSOService::handleTokenStored()
87 {
88 emit credentialsStored(_pendingPing);
89 _pendingPing = Token();
76 }90 }
7791
78 void SSOService::registerUser(QString email, QString password,92 void SSOService::registerUser(QString email, QString password,
@@ -168,7 +182,6 @@
168 _keyring->storeToken(_pendingPing);182 _keyring->storeToken(_pendingPing);
169183
170 reply->deleteLater();184 reply->deleteLater();
171 _pendingPing = Token();
172 }185 }
173186
174 void SSOService::invalidateCredentials()187 void SSOService::invalidateCredentials()
175188
=== modified file 'libubuntuoneauth/ssoservice.h'
--- libubuntuoneauth/ssoservice.h 2013-07-02 19:12:47 +0000
+++ libubuntuoneauth/ssoservice.h 2013-07-02 19:12:47 +0000
@@ -49,16 +49,17 @@
4949
50 signals:50 signals:
51 void credentialsDeleted();51 void credentialsDeleted();
52 void credentialsStored();52 void credentialsStored(const Token& token);
53 void credentialsFound(const Token& token);53 void credentialsFound(const Token& token);
54 void credentialsNotFound(QString id);54 void credentialsNotFound();
55 void requestFailed(const ErrorResponse& error);55 void requestFailed(const ErrorResponse& error);
5656
57 private slots:57 private slots:
58 void accountPinged(QNetworkReply*);58 void accountPinged(QNetworkReply*);
59 void credentialsSet() { emit credentialsStored(); };59 void handleTokenStored();
60 void credentialsCleared() { emit credentialsDeleted(); };60 void handleTokenDeleted() { emit credentialsDeleted(); };
61 void credentialsAcquired(const Token& token);61 void handleCredentialsFound(const Token& token);
62 void handleCredentialsNotFound();
62 void tokenReceived(const OAuthTokenResponse& token);63 void tokenReceived(const OAuthTokenResponse& token);
63 void accountRegistered(const AccountResponse& account);64 void accountRegistered(const AccountResponse& account);
64 void errorOcurred(const ErrorResponse&);65 void errorOcurred(const ErrorResponse&);
6566
=== modified file 'music-login/ssowizard.cpp'
--- music-login/ssowizard.cpp 2013-07-02 19:12:47 +0000
+++ music-login/ssowizard.cpp 2013-07-02 19:12:47 +0000
@@ -81,8 +81,8 @@
81 QObject::connect(&(this->downloader), SIGNAL(fileDownloaded(QString&)),81 QObject::connect(&(this->downloader), SIGNAL(fileDownloaded(QString&)),
82 this, SLOT(imageDownloaded(QString&)));82 this, SLOT(imageDownloaded(QString&)));
8383
84 QObject::connect(&(this->_service), SIGNAL(credentialsStored()),84 QObject::connect(&(this->_service), SIGNAL(credentialsStored(const Token&)),
85 this, SLOT(accountAuthenticated()));85 this, SLOT(accountAuthenticated(Token)));
86 QObject::connect(&(this->_service), SIGNAL(credentialsFound(const Token&)),86 QObject::connect(&(this->_service), SIGNAL(credentialsFound(const Token&)),
87 this, SLOT(openUrlAndFinish(Token)));87 this, SLOT(openUrlAndFinish(Token)));
8888
@@ -142,7 +142,7 @@
142 this->_service.login(email, password);142 this->_service.login(email, password);
143}143}
144144
145void SSOWizard::accountAuthenticated()145void SSOWizard::accountAuthenticated(Token token)
146{146{
147 this->_service.getCredentials();147 this->_service.getCredentials();
148}148}
149149
=== modified file 'music-login/ssowizard.h'
--- music-login/ssowizard.h 2013-05-24 21:09:26 +0000
+++ music-login/ssowizard.h 2013-07-02 19:12:47 +0000
@@ -67,7 +67,7 @@
67 void registerAndBuy(QString email, QString password, QString name);67 void registerAndBuy(QString email, QString password, QString name);
68 void showPageLogin();68 void showPageLogin();
6969
70 void accountAuthenticated();70 void accountAuthenticated(Token);
71 void openUrlAndFinish(Token);71 void openUrlAndFinish(Token);
72 void serviceFailed(const ErrorResponse&);72 void serviceFailed(const ErrorResponse&);
7373

Subscribers

People subscribed via source and target branches

to all changes: