source: SMSSender/gateways/Schoolnet/business/account.h @ 319:1ec456878bcb

separation-frontend-backend
Last change on this file since 319:1ec456878bcb was 319:1ec456878bcb, checked in by Sämy Zehnder <saemy.zehnder@…>, 8 years ago
  • Adjusts header guards to follow common pattern based on the filename.
File size: 3.0 KB
Line 
1/*
2  Schoolnet gateway plugin - The smssender plugin for the Schoolnet sms platform.
3  Copyright (C) 2007-2014, gorrión. See http://smssender.gorrion.ch
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 3 of the License, or
8  (at your option) any later version.
9
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  GNU General Public License for more details.
14
15  You should have received a copy of the GNU General Public License
16  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef SCHOOLNET_ACCOUNT_H
19#define SCHOOLNET_ACCOUNT_H
20
21#include <QScopedPointer>
22
23#include "gateways/common/business/baseaccount.h"
24#include "gateways/Schoolnet/network/httphelper.h"
25
26namespace Schoolnet {
27namespace DeepThought {
28class AnswerToSchoolnetTask;
29class CheckQuestionStatusAtSchoolnetTask;
30} // namespace DeepThought
31
32class Gateway;
33
34class Account : public BaseAccount {
35    Q_OBJECT
36
37    friend class AccountLoginTask; // reloadOnlineParams(), httpHelper()
38    friend class BaseContactImporter; // httpHelper()
39    friend class SMSSendTask; // reloadOnlineParams(), httpHelper()
40
41    friend class DeepThought::AnswerToSchoolnetTask; // httpHelper()
42    friend class DeepThought::CheckQuestionStatusAtSchoolnetTask; // httpHelper()
43
44public:
45    enum ESendAs {
46        saNickname,
47        saNumber
48    };
49
50    enum Property {
51        SendAs = BaseAccount::LastProperty + 1,
52        UseDeepThought = SendAs + 1,
53
54        LastProperty = UseDeepThought
55    };
56
57public:
58    explicit Account(Gateway *gateway);
59    ~Account();
60
61public: /* IAccount */
62    Persistence::IStorageHelper* createStorageHelper(Persistence::IMainStorage *storage);
63    IValidator* createValidator() const;
64
65public: /* IAccount - costs */
66    int costsForText(const QString &text) const;
67    int fragmentSize() const;
68
69public: /* Properties */
70    ESendAs sendAs() const;
71    void setSendAs(ESendAs sendAs);
72
73    bool useDeepThought() const;
74    void setUseDeepThought(bool useDeepThought);
75
76    QStringList deepThoughtQuestionLanguages() const;
77    void setDeepThoughtQuestionLanguages(const QStringList& languages);
78
79protected:
80    IAccountInitTask *doCreateInitTask();
81    IAccountLoginTask *doCreateLoginTask();
82    ISMSSendTask *doCreateSMSSendTask(const QString &message, const QSet<const SContact*> &recipients);
83
84protected:
85    bool checkStillLoggedIn();
86
87private:
88    void reloadOnlineParams();
89    void parsePage(const QString& html);
90    void fetchFreeSMSCount(const QString& html);
91    bool tryFetchFreeSMSCount(const QString& html);
92
93    HttpHelper *httpHelper() const;
94
95private slots:
96    void onInitStateChanged();
97
98private:
99    QScopedPointer<HttpHelper> m_httpHelper;
100
101    ESendAs m_sendAs;
102    bool m_useDeepThought;
103    QStringList m_deepThoughtQuestionLanguages;
104};
105
106} // namespace Schoolnet
107
108#endif /* SCHOOLNET_ACCOUNT_H */
Note: See TracBrowser for help on using the repository browser.