[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [Gluon] 80c6f23: Player lib: Add a logout operation into our librar
From: Laszlo Papp <djszapi () archlinux ! us>
Date: 2011-01-16 17:03:52
Message-ID: 20110116170352.4DEAAA6090 () git ! kde ! org
[Download RAW message or body]
commit 80c6f2366960f14baa726ac907a703eccc411618
branch master
Author: Laszlo Papp <djszapi@archlinux.us>
Date: Sun Jan 16 18:59:16 2011 -0800
Player lib: Add a logout operation into our library.
Basically the login("", .. ) would have been worked, but it is more reasonable
and better syntactic sugar step to hide the internal more in-depth details.
There is no real need for checking the result like in case the login method, so
it just simply sets the saveCredentials accordingly.
diff --git a/player/lib/authentication.cpp b/player/lib/authentication.cpp
index 39b73aa..ed2d79a 100644
--- a/player/lib/authentication.cpp
+++ b/player/lib/authentication.cpp
@@ -91,6 +91,28 @@ bool Authentication::login( const QString& username, const \
QString& password ) return false;
}
+bool Authentication::logout( )
+{
+ m_username.clear();
+ m_password.clear();
+
+ if( AtticaManager::instance()->isProviderValid() )
+ {
+ if (AtticaManager::instance()->provider().saveCredentials( m_username, \
m_password )) { + qDebug() << "Logout OK" << endl;
+ m_loggedIn = false;
+ emit loggedOut();
+ return true;
+ } else {
+ qDebug() << "Logout error" << endl;
+ emit logoutFailed();
+ return false;
+ }
+ }
+
+ return false;
+}
+
bool Authentication::isLoggedIn()
{
return m_loggedIn;
diff --git a/player/lib/authentication.h b/player/lib/authentication.h
index 585827b..8f6865c 100644
--- a/player/lib/authentication.h
+++ b/player/lib/authentication.h
@@ -64,6 +64,11 @@ namespace GluonPlayer
*/
Q_INVOKABLE bool login( const QString& username, const QString& password \
); /**
+ * use to perform a logout. Connect to the signal loggedOut() and \
logoutFailed() to know the result. + * @return true if logout was \
successfully initiated, false otherwise. + */
+ Q_INVOKABLE bool logout( );
+ /**
* use to check if we are logged in
* @return true if logged in, false otherwise
*/
@@ -104,9 +109,15 @@ namespace GluonPlayer
/** signal which is emitted if the login is complete
*/
void loggedIn();
+ /** signal which is emitted if the logout is complete
+ */
+ void loggedOut();
/** signal which is emitted when the login failed
*/
void loginFailed();
+ /** signal which is emitted when the logout failed
+ */
+ void logoutFailed();
private:
friend class GluonCore::Singleton<Authentication>;
@@ -122,6 +133,7 @@ namespace GluonPlayer
QString m_password;
Attica::PostJob* m_registerJob;
Attica::PostJob* m_checkLoginJob;
+ Attica::PostJob* m_checkLogoutJob;
};
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic