parse username returned from data-server

This commit is contained in:
Stephen Birarda 2014-02-21 14:41:43 -08:00
parent 9d2d9c5071
commit 76e6c9342f
3 changed files with 17 additions and 3 deletions

View file

@ -3928,7 +3928,8 @@ void Application::updateWindowTitle(){
QString buildVersion = " (build " + applicationVersion() + ")";
NodeList* nodeList = NodeList::getInstance();
QString title = QString() + nodeList->getSessionUUID().toString()
QString username = AccountManager::getInstance().getUsername();
QString title = QString() + (!username.isEmpty() ? username : "") + nodeList->getSessionUUID().toString()
+ " @ " + nodeList->getDomainInfo().getHostname() + buildVersion;
qDebug("Application title set to: %s", title.toStdString().c_str());

View file

@ -58,7 +58,6 @@ AccountManager::AccountManager() :
}
void AccountManager::setRootURL(const QUrl& rootURL) {
if (_rootURL != rootURL) {
_rootURL = rootURL;
@ -71,6 +70,16 @@ void AccountManager::setRootURL(const QUrl& rootURL) {
}
}
void AccountManager::setUsername(const QString& username) {
if (_username != username) {
_username = username;
qDebug() << "Changing username to" << username;
emit usernameChanged(username);
}
}
void AccountManager::authenticatedRequest(const QString& path, QNetworkAccessManager::Operation operation,
const JSONCallbackParameters& callbackParams, const QByteArray& dataByteArray) {
QMetaObject::invokeMethod(this, "invokedRequest",
@ -224,6 +233,9 @@ void AccountManager::requestFinished() {
OAuthAccessToken freshAccessToken(rootObject);
_accessTokens.insert(rootURL, freshAccessToken);
// pull username from the response
setUsername(rootObject["user"].toObject()["username"].toString());
emit receivedAccessToken(rootURL);
// store this access token into the local settings

View file

@ -50,7 +50,7 @@ public:
void requestAccessToken(const QString& login, const QString& password);
const QString& getUsername() const { return _username; }
void setUsername(const QString& username) { _username = username; }
void setUsername(const QString& username);
public slots:
void requestFinished();
@ -58,6 +58,7 @@ public slots:
signals:
void authenticationRequired();
void receivedAccessToken(const QUrl& rootURL);
void usernameChanged(const QString& username);
private slots:
void passSuccessToCallback();
void passErrorToCallback(QNetworkReply::NetworkError errorCode);