OSDN Git Service

ac012e2b1c14000a21be7635d0514d5f3e96b08d
[kita/kita.git] / kita / src / libkita / account.h
1 /***************************************************************************
2 *   Copyright (C) 2004 by Kita Developers                                 *
3 *   ikemo@users.sourceforge.jp                                            *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 ***************************************************************************/
10 #ifndef KITAACCOUNT_H
11 #define KITAACCOUNT_H
12
13 #include <QtCore/QByteArray>
14 #include <QtCore/QEventLoop>
15 #include <QtCore/QObject>
16
17 #include <kdemacros.h>
18
19 namespace KIO
20 {
21     class Job;
22 }
23
24 namespace Kita
25 {
26
27     /**
28     @author Hideki Ikemoto
29     */
30     class KDE_EXPORT Account : public QObject
31     {
32         Q_OBJECT
33         static Account* instance;
34
35         KIO::Job* m_job;
36         QByteArray m_data;
37         QString m_sessionID;
38         bool m_isLogged;
39         QEventLoop m_eventLoop;
40
41         Account();
42         ~Account();
43         void enter_loop();
44         bool loginInternal(const QString& userID, const QString& password);
45         static Account* getInstance();
46     private slots:
47         void slotReceiveData(KIO::Job* job, const QByteArray& data);
48         void slotResult(KIO::Job* job);
49     private:
50         Account(const Account&);
51         Account& operator=(const Account&);
52     public:
53         static const QString& getSessionId() { return getInstance() ->m_sessionID; }
54         static bool isLogged() { return getInstance() ->m_isLogged; }
55         static bool login(const QString& userID, const QString& password);
56     };
57
58 }
59
60 #endif