-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathappcore.cpp
More file actions
executable file
·94 lines (74 loc) · 2.2 KB
/
appcore.cpp
File metadata and controls
executable file
·94 lines (74 loc) · 2.2 KB
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
84
85
86
87
88
89
90
91
#include "appcore.h"
#include <QDateTime>
#include <QDebug>
AppCore::AppCore(QObject *parent): IQCameron(parent)
{
}
AppCore::~AppCore()
{
}
/**
* @brief Запускаем Cameron
*/
bool AppCore::appStart()
{
qSetMessagePattern(">>>>%{time yyyyMMdd h:mm:ss.zzz} %{type} %{file} %{function} %{message}"); //-- Шаблон сообщений лога
//qInstallMessageHandler(myMessageHandler); //-- Перенаправим вывод лога
qInfo()<<"Start Cameron, version"<<VERSION;
_settings =new Settings(this);
_server =new Server(this);
_cameras =new Cameras(this);
_pluginsManager =new PluginsManager(this, this);
_server->setCams(_cameras);
if ( !_settings->load(_cameras, _server, _pluginsManager) ) { qWarning()<< "Error load setitngs file."; return false; }
if ( !_server->startServer() ) { qWarning()<<"Unable start server"; return false; }
qInfo()<<QString("For connect use 'rtsp://admin:pass@%1:%2/track/1'").arg(_server->host().toString()).arg(_server->port());
emit started();
return true;
}
void AppCore::myMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)
{
//-- что бы в релизе выводился context нужно в *.pro добавить DEFINES += QT_MESSAGELOGCONTEXT
QString sType="";
switch (type) {
case QtInfoMsg: { sType ="Info"; break; }
case QtDebugMsg: { sType ="Debug"; break; }
case QtWarningMsg: { sType ="Warning"; break; }
case QtCriticalMsg: { sType ="CRITICAL"; break; }
case QtFatalMsg: { sType ="FATAL"; break; }
}
QDateTime dateTime = QDateTime::currentDateTime();
// Log::instance().msg(dateTime.toString("yyyyMMdd h:mm:ss.zzz"), sType, context.category, QString("%1:%2").arg(context.function).arg(context.line), context.file, msg);
}
/**
* @brief Отдаём нашу версию
* @return
*/
QString AppCore::version() const
{
return VERSION;
}
/**
* @brief AppCore::server
* @return
*/
IServer *AppCore::server() const
{
return _server;
}
/**
* @brief AppCore::settings
* @return
*/
ISettings *AppCore::settings() const
{
return _settings;
}
/**
* @brief AppCore::pluginsManages
* @return
*/
IPluginsManager *AppCore::pluginsManager() const
{
return _pluginsManager;
}