-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
70 lines (53 loc) · 1.92 KB
/
main.cpp
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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "SmsSender.h"
#include "SmsJsonPolling.h"
#ifdef __DEBUG__
#include <QSslSocket>
#endif
#define __LOCAL_DB__ 1
#ifdef __LOCAL_DB__
#define SRV_HOST "http://192.168.1.42"
#define SSL_CHECK 1
#define STATIC_JSON "/sms.json"
#else
#define SRV_HOST "https://xxx.xxx.xxx.xxx"
#define SSL_CHECK 0
#endif
#define URL_GET "/smsGet.cgi"
#define URL_NOTIFY "/smsNotify.cgi"
#define MOBILE_API "c171c0acb21adaa3fb34f1f05e9467e3"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
#ifdef __DEBUG__
qDebug() << QString("SSL support: %1, build version: %2, system version: %3").arg(QSslSocket::supportsSsl() ? "yes" : "no").arg(
QSslSocket::sslLibraryBuildVersionString()).arg(QSslSocket::sslLibraryVersionString());
#endif
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
SmsJsonPolling *smsPolling = SmsJsonPolling::getInstance();
#ifdef STATIC_JSON
smsPolling->addServerUrl(QString("%1%2").arg(SRV_HOST).arg(STATIC_JSON));
#else
smsPolling->addServerUrl(
QString("%1%2?mobile=%3").arg(SRV_HOST).arg(URL_GET).arg(MOBILE_API),
QString("%1%2?mobile=%3").arg(SRV_HOST).arg(URL_NOTIFY).arg(MOBILE_API),
SSL_CHECK
);
#endif
smsPolling->onJsonPolling();
#ifdef __DEBUG__
engine.rootContext()->setContextProperty("cppSmsSender", SmsSender::getInstance());
#endif
engine.rootContext()->setContextProperty("cppSmsPolling", smsPolling);
engine.load(url);
return app.exec();
}