void KitaMainWindow::login()
{
- Kita::Account account;
- if ( account.login( KitaConfig::userID(), KitaConfig::password() ) ) {
+ if ( Kita::Account::login( KitaConfig::userID(), KitaConfig::password() ) ) {
slotSetMainStatusbar( "Login succeeded." );
} else {
slotSetMainStatusbar( "Login failed." );
using namespace Kita;
+Account* Account::instance = 0;
+
+Account* Account::getInstance()
+{
+ if ( instance == 0 ) {
+ instance = new Account();
+ }
+ return instance;
+}
+
Account::Account()
: m_isLogged( false )
{}
bool Account::login( const QString& userID, const QString& password )
{
+ return getInstance()->loginInternal( userID, password );
+}
+
+bool Account::loginInternal( const QString& userID, const QString& password )
+{
KURL url( "https://2chv.tora3.net/futen.cgi" );
QString postData = QString("ID=") + userID + QString("&PW=") + password;
class Account : public QObject
{
Q_OBJECT
+ static Account* instance;
KIO::Job* m_job;
QCString m_data;
QString m_sessionID;
bool m_isLogged;
+ Account();
+ ~Account();
void enter_loop();
+ bool loginInternal( const QString& userID, const QString& password );
+ static Account* getInstance();
private slots:
void slotReceiveData( KIO::Job* job, const QByteArray& data );
void slotResult( KIO::Job* job );
public:
- Account();
- ~Account();
- bool login( const QString& userID, const QString& password );
+ static const QString& getSessionID() { return getInstance()->m_sessionID; }
+ static bool isLogged() { return getInstance()->m_isLogged; }
+ static bool login( const QString& userID, const QString& password );
};
}