00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef AUTHENTICATION_H
00021 #define AUTHENTICATION_H
00022
00023 #include "gluon_player_export.h"
00024
00025 #include <core/singleton.h>
00026
00027 #include <attica/postjob.h>
00028
00029 namespace Attica
00030 {
00031 class BaseJob;
00032 class PostJob;
00033 }
00034
00035 namespace GluonPlayer
00036 {
00045 class GLUON_PLAYER_EXPORT Authentication : public GluonCore::Singleton<Authentication>
00046 {
00047 Q_OBJECT
00048
00049 public:
00054 void init();
00058 bool isInitialized();
00065 Q_INVOKABLE bool login( const QString& username, const QString& password );
00070 bool isLoggedIn();
00075 bool hasCredentials();
00080 QString username();
00085 QString password();
00086
00087 protected slots:
00088 void finishInit();
00089 void checkLoginResult( Attica::BaseJob* );
00090
00091 void onRegisterClicked(const QString& username, const QString& password, const QString& mail, const QString& firstName, const QString& lastName);
00092 void onRegisterAccountFinished(Attica::BaseJob* job);
00093
00094 signals:
00097 void initialized();
00100 void initFailed();
00103 void registered();
00106 void loggedIn();
00109 void loginFailed();
00110
00111 private:
00112 friend class GluonCore::Singleton<Authentication>;
00113 Authentication();
00114 ~Authentication();
00115 Q_DISABLE_COPY( Authentication )
00116
00117 void showRegisterError(const Attica::Metadata&);
00118
00119 bool m_initialized;
00120 bool m_loggedIn;
00121 QString m_username;
00122 QString m_password;
00123 Attica::PostJob* m_registerJob;
00124 Attica::PostJob* m_checkLoginJob;
00125 };
00126 }
00127
00128 #endif // AUTHENTICATION_H