source: SMSSender/lib/datatypes/src/interfaces/iaccount.h @ 275:fc4bfb4b9bc4

Last change on this file since 275:fc4bfb4b9bc4 was 275:fc4bfb4b9bc4, checked in by Sämy Zehnder <saemy.zehnder@…>, 7 years ago
  • Corrected and centralized sms-counting for all gateways.
  • Synchronizing sms length with the post and sunrise gateways now.
  • Fixed bug in contact import where only already existing contact names were considered in duplicate name checking.
  • Showing the account name instead of the gateway name in the account list if no free sms count is there.
File size: 3.5 KB
Line 
1/*
2 smssender - A frontend for fast and easy SMS sending over different gateways.
3 Copyright (C) 2007-2012, 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 IACCOUNT_H_
19#define IACCOUNT_H_
20
21#include <limits.h>
22
23#include <QList>
24#include <QObject>
25#include <QSet>
26#include <QString>
27
28#include "istorable.h"
29#include "ivalidatable.h"
30
31#include "scontact.h"
32#include "sdatatypes.h"
33#include "stask.h"
34
35#include "datatypes_global.h"
36
37class IAccount;
38class IGateway;
39
40class IAccountInitTask;
41class IAccountLoginTask;
42class ISMSSendTask;
43
44class DATATYPES_SHARED_EXPORT IAccount: public QObject, public IStorable, public IValidatable {
45    Q_OBJECT
46    Q_INTERFACES(IStorable IValidatable)
47
48public:
49    enum Property {
50        Id           = 0x00,
51        Name         = 0x01,
52        Enabled      = 0x02,
53        Username     = 0x03,
54        Password     = 0x04,
55        FreeSMSCount = 0x05,
56
57        LastProperty = FreeSMSCount
58    };
59
60public:
61    virtual IGateway* gateway() const =0;
62
63    virtual int     id() const =0;
64    virtual QString name() const =0;
65    virtual bool    isEnabled() const =0;
66    virtual QString username() const =0;
67    virtual QString password() const =0;
68    virtual int     freeSMSCount() const =0;
69
70    virtual void setName(const QString& name) =0;
71    virtual void setEnabled(bool enabled) =0;
72    virtual void setUsername(const QString& username) =0;
73    virtual void setPassword(const QString& password) =0;
74
75public:
76    virtual QStringList divideMessage(const QString& text) const =0;
77    virtual int         costsForText(const QString& message) const =0;
78
79public:
80    virtual IAccountInitTask*  createInitTask() =0;
81    virtual bool               isInitialized() const =0;
82    virtual void               resetInitialization() =0;
83
84public:
85    virtual IAccountLoginTask* createLoginTask() =0;
86    virtual bool               isLoggedIn() const =0;
87    virtual void               ensureLoggedIn() =0;
88
89public:
90    virtual ISMSSendTask*      createSMSSendTask(const QString& message, const QSet<SContact>& recipients) =0;
91
92public:
93    virtual IAccount* createClonedInstance(QObject* parent) const =0;
94
95signals:
96    void idChanged(IAccount* account, int oldId);
97    void dataChanged(IAccount* account, int property);
98
99    void initStateChanged(IAccount* account);
100    void initDone(IAccount* account, STask::Result taskResult, uint specialResult); // TODO: Take the exception into this signal?
101    void initErrorOccured(IAccount* account, const EException& exception);
102
103    void loggedIn(IAccount* account);
104    void loggedOut(IAccount* account);
105
106    void smsSendingDone(IAccount* account, Account::SendingResult result);
107    void smsSendingErrorOccured(IAccount* account, const EException& exception);
108
109public:
110    IAccount(QObject* parent)
111        : QObject(parent)
112    {}
113    virtual ~IAccount() {}
114};
115Q_DECLARE_INTERFACE(IAccount, "ch.gorrion.smssender.IAccount/1.0")
116
117#endif /* IACCOUNT_H_ */
Note: See TracBrowser for help on using the repository browser.