source: SMSSender/frontend/business/erroraccount.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: 4.6 KB
Line 
1/*
2 smssender - A frontend for fast and easy SMS sending over different gateways.
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 FRONTEND_ERRORACCOUNT_H
19#define FRONTEND_ERRORACCOUNT_H
20
21#include "common/business/iaccount.h"
22#include "common/business/igateway.h"
23#include "common/business/ivalidator.h"
24
25#define DO_NOT_CALL_THIS(func) \
26    func { \
27        Q_ASSERT(false); \
28        EException("Internal error.") \
29                .addDebugInfo(#func) \
30                .raise(); \
31    }
32#define DO_NOT_CALL_THIS_RET(func, ret) \
33    func { \
34        Q_ASSERT(false); \
35        EException("Internal error.") \
36                .addDebugInfo(#func) \
37                .raise(); \
38        return ret; \
39    }
40
41class ErrorGateway : public IGateway {
42public:
43    explicit ErrorGateway(const QString &name);
44
45    QString name() const;
46    static bool isErrorGateway(const IGateway &gateway);
47
48#ifdef FRONTEND_GUI
49    QIcon icon() const {
50        return QIcon(":/icons/warning.png");
51    }
52#endif
53
54public:
55    DO_NOT_CALL_THIS_RET(QList<int> validRecipientCountryCodes() const, QList<int>())
56    DO_NOT_CALL_THIS_RET(QList<QChar> doublePriceChars() const, QList<QChar>())
57    DO_NOT_CALL_THIS_RET(QList<QChar> disAllowedChars() const, QList<QChar>())
58
59public:
60    DO_NOT_CALL_THIS_RET(IAccount* createAccountInstance(), NULL)
61    DO_NOT_CALL_THIS_RET(IAccountSettingsWidget* createAccountSettingsWidget(QWidget*) const, NULL)
62    DO_NOT_CALL_THIS_RET(::Persistence::IStorageHelper *createStorageHelper(Persistence::IMainStorage*), NULL)
63
64private:
65    QString m_name;
66
67    Q_DISABLE_COPY(ErrorGateway)
68};
69
70
71class ErrorAccount : public IAccount {
72    Q_OBJECT
73
74public:
75    ErrorAccount(int accountId, const QString &name, const QString &gatewayName,
76                 const EException &exception);
77    ErrorAccount(IGateway *gateway, int accountId, const QString &name, const EException &exception);
78
79    IGateway* gateway() const { return m_gateway; }
80    int id() const { return m_id; }
81    QString name() const { return m_name; }
82    bool isEnabled() const { return false; }
83
84    EException error() const;
85
86public:
87    DO_NOT_CALL_THIS_RET(int costsForText(const QString&), 0)
88    DO_NOT_CALL_THIS_RET(int fragmentSize() const, 0)
89
90    DO_NOT_CALL_THIS_RET(IValidator* createValidator() const, NULL)
91    DO_NOT_CALL_THIS_RET(Persistence::IStorageHelper* createStorageHelper(Persistence::IMainStorage*), NULL)
92
93    DO_NOT_CALL_THIS_RET(QString username() const, QString())
94    DO_NOT_CALL_THIS_RET(QString password() const, QString())
95    DO_NOT_CALL_THIS_RET(int freeSMSCount() const, 0)
96
97    DO_NOT_CALL_THIS(void setId(int))
98    DO_NOT_CALL_THIS(void setName(const QString&))
99    DO_NOT_CALL_THIS(void setEnabled(bool))
100    DO_NOT_CALL_THIS(void setUsername(const QString&))
101    DO_NOT_CALL_THIS(void setPassword(const QString&))
102
103    DO_NOT_CALL_THIS_RET(QStringList divideMessage(const QString&) const, QStringList())
104    DO_NOT_CALL_THIS_RET(int costsForText(const QString&) const, 0)
105
106    DO_NOT_CALL_THIS_RET(IAccountInitTask* createInitTask(), NULL)
107    DO_NOT_CALL_THIS_RET(bool isInitialized() const, false)
108    DO_NOT_CALL_THIS(void resetInitialization())
109    DO_NOT_CALL_THIS_RET(IAccountLoginTask* createLoginTask(), NULL)
110    DO_NOT_CALL_THIS_RET(bool isLoggedIn() const, false)
111    DO_NOT_CALL_THIS_RET(bool stillLoggedIn(), false)
112    DO_NOT_CALL_THIS(void ensureLoggedIn())
113    DO_NOT_CALL_THIS_RET(ISMSSendTask* createSMSSendTask(const QString&, const QSet<const SContact*>&), NULL)
114
115protected:
116    DO_NOT_CALL_THIS_RET(bool checkStillLoggedIn(), false)
117
118//    DO_NOT_CALL_THIS_RET(IAccountInitTask* doCreateInitTask(), NULL)
119//    DO_NOT_CALL_THIS_RET(IAccountLoginTask* doCreateLoginTask(), NULL)
120//    DO_NOT_CALL_THIS_RET(ISMSSendTask* doCreateSMSSendTask(const QString&, const QSet<SContact*>&), NULL)
121
122private:
123    int m_id;
124    QString m_name;
125
126    IGateway * const m_gateway;
127    QScopedPointer<IGateway> m_ownedGateway;
128
129    EException m_exception;
130
131    Q_DISABLE_COPY(ErrorAccount)
132};
133
134#endif /* FRONTEND_ERRORACCOUNT_H */
Note: See TracBrowser for help on using the repository browser.