-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSms.h
83 lines (59 loc) · 2.18 KB
/
Sms.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef SMS_H
#define SMS_H
#include <QUrl>
class QNetworkRequest;
class QJsonObject;
class SmsServer{
private:
const QUrl _urlGetSMS;
const QUrl _urlNotifyStatusSMS;
const bool _checkCetificateSSL;
QNetworkRequest *_reqGetSMS;
QNetworkRequest *_reqNotifyStatus;
public:
SmsServer(const QString &host, bool https, const QString &mobileAPI, const QString &urlGet, const QString &urlNotify = "", bool checkSSL = true);
SmsServer(const QString &urlGet, const QString &urlNotify = "", bool checkSSL = true);
~SmsServer();
inline QString server() const;
inline bool notifyServer() const;
inline const QNetworkRequest &reqGetSMS() const;
inline const QNetworkRequest &reqNotifyStatusSMS() const;
inline const QUrl &urlGet() const;
inline const QUrl &urlNotify() const;
private:
void _init();
};
QString SmsServer::server() const { return _urlGetSMS.host(); }
bool SmsServer::notifyServer() const { return _reqNotifyStatus != nullptr; }
const QNetworkRequest &SmsServer::reqGetSMS() const { return *_reqGetSMS; }
const QNetworkRequest &SmsServer::reqNotifyStatusSMS() const{ return *_reqNotifyStatus; }
const QUrl &SmsServer::urlGet() const { return _urlGetSMS; }
const QUrl &SmsServer::urlNotify() const { return _urlNotifyStatusSMS; }
class Sms {
public:
// Sms(int id, int srvIdx = 0);
Sms(const QJsonObject &json, int srvIdx = 0);
~Sms() = default;
static constexpr const char *JSON_ID = "id";
static constexpr const char *JSON_DEST = "dest";
static constexpr const char *JSON_MSG = "msg";
inline int id() const;
inline const QString &dest() const;
inline const QString &msg() const;
inline int srvIdx() const;
inline QString str() const;
private:
const int _id;
const QString _dest;
const QString _msg;
const int _srvIdx; //!< in case we need to send a response upon delivery
};
int Sms::id() const { return _id; }
const QString &Sms::dest() const { return _dest; }
const QString &Sms::msg() const { return _msg; }
int Sms::srvIdx() const { return _srvIdx; }
QString Sms::str() const
{
return QString("Sms #%1 to %2 : %3").arg(_id).arg(_dest).arg(_msg);
}
#endif // SMS_H