Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmPOS
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
fmPOS
Commits
98dd8859
Commit
98dd8859
authored
Apr 10, 2017
by
Carwyn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.更新日志模块,使用方式不需参数,但初次需要调用 InitContext() 方法,否则只打印到控制台
parent
7bdb9186
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
95 additions
and
90 deletions
+95
-90
fmp_epay
+1
-1
fmp_home
+1
-1
fmp_logger/fmp_logger.cpp
+3
-0
fmp_logger/fmp_logger_i.h
+20
-13
fmp_logger/fmp_logger_p.cpp
+6
-6
fmp_logger/fmp_logger_p.h
+0
-2
fmp_logger/version.h
+1
-1
fmp_manager/fmp_manager.cpp
+20
-22
fmp_manager/fmp_manager.h
+0
-1
fmp_manager/fmp_me_handlers.cpp
+2
-2
fmp_manager/version.h
+1
-1
fmp_network/fmp_network.cpp
+4
-2
fmp_network/version.h
+1
-1
fmp_settings
+1
-1
fmp_syncer/fmp_syncer.h
+1
-1
fmp_syncer/fmp_syncer_p.cpp
+29
-30
fmp_syncer/fmp_syncer_p.h
+0
-1
fmp_syncer/version.h
+1
-1
fmp_vip
+1
-1
include/interface/fmp_plugin_i.h
+2
-2
No files found.
fmp_epay
@
96d23ec1
Subproject commit
13eec4bf4e6d89be4f79533960526763c6f334c7
Subproject commit
96d23ec12b69333acdcff2753b418e34fca85a3d
fmp_home
@
9e475908
Subproject commit
13c338a005d646dd6e65ba489c0e0784393bf84b
Subproject commit
9e47590854aedd7757ad11bd6a5dca2df1074459
fmp_logger/fmp_logger.cpp
View file @
98dd8859
...
...
@@ -30,6 +30,7 @@ FMPLogger::FMPLogger(ctkPluginContext *context)
_file
(
0
),
_level
(
d_ptr
->
GetLogLevel
())
{
FMPLoggerInterface
::
InitContext
(
context
);
StartService
();
}
...
...
@@ -85,6 +86,8 @@ QIODevice *FMPLogger::GetIODevice()
int
FMPLogger
::
PostEvent
(
const
QString
&
topic
,
const
FMPProps
&
pps
)
{
Q_UNUSED
(
topic
);
Q_UNUSED
(
pps
);
return
FMP_NOIMPL
;
}
...
...
fmp_logger/fmp_logger_i.h
View file @
98dd8859
...
...
@@ -79,8 +79,24 @@ public:
* @return QIODevice*
*/
virtual
QIODevice
*
GetIODevice
()
=
0
;
static
FMPLoggerInterface
*
InitContext
(
ctkPluginContext
*
ctx
=
nullptr
)
{
static
FMPLoggerInterface
*
logger
=
nullptr
;
if
(
ctx
&&
!
logger
)
{
ctkServiceReference
ref
=
ctx
->
getServiceReference
<
FMPLoggerInterface
>
();
if
(
ref
)
{
logger
=
ctx
->
getService
<
FMPLoggerInterface
>
(
ref
);
}
}
return
logger
;
}
};
Q_DECLARE_INTERFACE
(
FMPLoggerInterface
,
"com.fmp.logger"
)
...
...
@@ -89,18 +105,9 @@ Q_DECLARE_INTERFACE(FMPLoggerInterface, "com.fmp.logger")
FMPLogStream(lvl, __FILE__, __FUNCTION__, __LINE__, log->GetIODevice()) : \
FMPNullLogStream(lvl, __FILE__, __FUNCTION__, __LINE__))
#define FMP_DEBUG(log) FMP_LOG(FMPLoggerInterface::LOG_DEBUG, log)
#define FMP_INFO(log) FMP_LOG(FMPLoggerInterface::LOG_INFO, log)
#define FMP_WARN(log) FMP_LOG(FMPLoggerInterface::LOG_WARNING, log)
#define FMP_ERROR(log) FMP_LOG(FMPLoggerInterface::LOG_ERROR, log)
#define FMP_LOG_CTX(lvl, ctx) ((ctx && ctx->getServiceReference<FMPLoggerInterface>()) ? \
FMP_LOG(lvl, ctx->getService<FMPLoggerInterface>(ctx->getServiceReference<FMPLoggerInterface>())) : \
FMP_LOG(lvl, ctx->getService<FMPLoggerInterface>(ctx->getServiceReference<FMPLoggerInterface>())))
#define FMP_DEBUG_CTX(ctx) FMP_LOG_CTX(FMPLoggerInterface::LOG_DEBUG, ctx)
#define FMP_INFO_CTX(ctx) FMP_LOG_CTX(FMPLoggerInterface::LOG_INFO, ctx)
#define FMP_WARN_CTX(ctx) FMP_LOG_CTX(FMPLoggerInterface::LOG_WARNING, ctx)
#define FMP_ERROR_CTX(ctx) FMP_LOG_CTX(FMPLoggerInterface::LOG_ERROR, ctx)
#define FMP_DEBUG() FMP_LOG(FMPLoggerInterface::LOG_DEBUG, FMPLoggerInterface::InitContext())
#define FMP_INFO() FMP_LOG(FMPLoggerInterface::LOG_INFO, FMPLoggerInterface::InitContext())
#define FMP_WARN() FMP_LOG(FMPLoggerInterface::LOG_WARNING, FMPLoggerInterface::InitContext())
#define FMP_ERROR() FMP_LOG(FMPLoggerInterface::LOG_ERROR, FMPLoggerInterface::InitContext())
#endif // FMP_LOGGER_I_H
fmp_logger/fmp_logger_p.cpp
View file @
98dd8859
...
...
@@ -122,10 +122,10 @@ QString FMPLoggerPrivate::_NewFileName()
QDir
log_dir
(
log_path
);
if
(
!
log_dir
.
exists
())
{
if
(
log_dir
.
mkdir
(
log_path
))
{
_FMP_INFO
<<
"Create log dir:"
<<
log_path
;
FMP_INFO
()
<<
"Create log dir:"
<<
log_path
;
}
else
{
_FMP_INFO
<<
"Create log dir"
<<
log_path
<<
"failed!"
;
FMP_INFO
()
<<
"Create log dir"
<<
log_path
<<
"failed!"
;
}
}
return
q
->
_path
+
"/"
+
_lvlmap
[
q
->
_level
]
+
"_"
+
file_index
+
".log"
;
...
...
@@ -140,7 +140,7 @@ bool FMPLoggerPrivate::_SetValue(const QString &key, QVariant v)
return
true
;
}
else
{
FMP_WARN
(
q
)
<<
"Settings service not available"
;
FMP_WARN
()
<<
"Settings service not available"
;
}
return
false
;
...
...
@@ -154,7 +154,7 @@ QVariant FMPLoggerPrivate::_GetValue(const QString &key, QVariant default_val)
return
sets
->
GetValue
(
key
);
}
else
{
FMP_WARN
(
q
)
<<
"Settings service not available"
;
FMP_WARN
()
<<
"Settings service not available"
;
}
return
default_val
;
...
...
@@ -167,8 +167,8 @@ void FMPLoggerPrivate::_KeepFileSize()
qint64
file_sz
=
q
->
_file
->
size
();
if
(
file_sz
>=
(
q
->
_max_size
*
1024
*
1024
))
{
QString
new_file_name
=
_NewFileName
();
FMP_INFO
(
q
)
<<
"Current log file size:"
<<
file_sz
<<
"reaches max value"
;
FMP_INFO
(
q
)
<<
"New log file:"
<<
new_file_name
;
FMP_INFO
()
<<
"Current log file size:"
<<
file_sz
<<
"reaches max value"
;
FMP_INFO
()
<<
"New log file:"
<<
new_file_name
;
q
->
_file
->
close
();
q
->
_file
->
setFileName
(
new_file_name
);
q
->
_file
->
open
(
QFile
::
Append
);
...
...
fmp_logger/fmp_logger_p.h
View file @
98dd8859
...
...
@@ -36,6 +36,4 @@ public:
QDateTime
_log_date
;
};
#define _FMP_INFO FMPNullLogStream(FMPLogger::LOG_INFO, __FILE__, __FUNCTION__, __LINE__)
#endif // FMP_LOGGER_P_H
fmp_logger/version.h
View file @
98dd8859
...
...
@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD
35
#define VER_BUILD
43
//! Convert version numbers to string
#define _STR(S) #S
...
...
fmp_manager/fmp_manager.cpp
View file @
98dd8859
...
...
@@ -16,7 +16,6 @@
FMPluginManager
::
FMPluginManager
()
:
_ctx
(
nullptr
),
_fw_factory
(
nullptr
),
_logger
(
nullptr
),
_setting
(
nullptr
)
{
}
...
...
@@ -46,32 +45,31 @@ int FMPluginManager::StartService()
//! 设置模块必须第一个加载
LoadPlugin
(
"fmp.settings"
);
LoadPlugin
(
"fmp.logger"
);
FMP_INFO
()
<<
"======================== Started ========================"
;
LoadPlugin
(
"fmp.network"
);
LoadPlugin
(
"fmp.syncer"
);
LoadPlugin
(
"org.commontk.eventadmin"
);
if
(
!
(
_logger
=
GetService
<
FMPLoggerInterface
>
(
_ctx
)))
{
FMP_WARN
(
_logger
)
<<
"Logger service is not ready."
;
if
(
!
FMPLoggerInterface
::
InitContext
(
_ctx
))
{
FMP_WARN
()
<<
"Logger service is not ready."
;
}
else
{
FMP_INFO
(
_logger
)
<<
"Logger service is ready."
;
FMP_INFO
()
<<
"Logger service is ready."
;
}
if
(
!
(
_setting
=
GetService
<
FMPSettingsInterface
>
(
_ctx
)))
{
FMP_WARN
(
_logger
)
<<
"Setting service is not ready."
;
FMP_WARN
()
<<
"Setting service is not ready."
;
}
else
{
FMP_INFO
(
_logger
)
<<
"Setting service is ready."
;
FMP_INFO
()
<<
"Setting service is ready."
;
}
if
(
!
(
_syncer
=
GetService
<
FMPSyncerInterface
>
(
_ctx
)))
{
FMP_WARN
(
_logger
)
<<
"Synchronizer service is not ready."
;
FMP_WARN
()
<<
"Synchronizer service is not ready."
;
}
else
{
FMP_INFO
(
_logger
)
<<
"Synchronizer service is ready."
;
FMP_INFO
()
<<
"Synchronizer service is ready."
;
}
FMP_INFO
(
_logger
)
<<
"======================== Started ========================"
;
LoadNewPlugins
();
connect
(
&
_watcher
,
SIGNAL
(
directoryChanged
(
QString
)),
SLOT
(
OnPluginsChanged
(
QString
)));
...
...
@@ -93,7 +91,7 @@ int FMPluginManager::StartService()
}
catch
(
const
ctkPluginException
&
e
)
{
FMP_ERROR
(
_logger
)
<<
e
.
cause
()
->
what
();
FMP_ERROR
()
<<
e
.
cause
()
->
what
();
exit
(
FMP_FAILURE
);
}
...
...
@@ -104,7 +102,7 @@ int FMPluginManager::StopService()
{
if
(
_fw_factory
)
{
FMP_INFO
(
_logger
)
<<
"======================== Quit ========================"
;
FMP_INFO
()
<<
"======================== Quit ========================"
;
_watcher
.
removePath
(
_fw_props
[
FMP_PROPKEY_PLUGINPATH
].
toString
());
_event_handlers
.
clear
();
...
...
@@ -120,7 +118,7 @@ int FMPluginManager::StopService()
qApp
->
quit
();
}
else
{
FMP_WARN
(
_logger
)
<<
"Stopping in progress..."
;
FMP_WARN
()
<<
"Stopping in progress..."
;
}
return
FMP_SUCCESS
;
...
...
@@ -133,7 +131,7 @@ int FMPluginManager::SetProperties(const FMPProps &props)
||
!
_fw_props
.
contains
(
FMP_PROPKEY_ENTRY
)
||
_fw_props
[
FMP_PROPKEY_PLUGINPATH
].
isNull
()
||
_fw_props
[
FMP_PROPKEY_CFG
].
isNull
()
||
_fw_props
[
FMP_PROPKEY_CFG
].
isNull
())
{
FMP_ERROR
(
_logger
)
<<
"Missing properties(PluginPath|Configuration|Entry)."
;
FMP_ERROR
()
<<
"Missing properties(PluginPath|Configuration|Entry)."
;
return
FMP_FAILURE
;
}
...
...
@@ -164,12 +162,12 @@ int FMPluginManager::LoadPlugin(const QString &plugin)
}
}
else
{
FMP_WARN
(
_logger
)
<<
"Empty plugin name."
<<
plugin
;
FMP_WARN
()
<<
"Empty plugin name."
<<
plugin
;
return
FMP_FAILURE
;
}
}
catch
(
const
ctkPluginException
&
e
)
{
FMP_WARN
(
_logger
)
<<
(
e
.
cause
()
?
e
.
cause
()
->
what
()
:
e
.
what
());
FMP_WARN
()
<<
(
e
.
cause
()
?
e
.
cause
()
->
what
()
:
e
.
what
());
return
FMP_FAILURE
;
}
...
...
@@ -201,11 +199,11 @@ int FMPluginManager::PostEvent(const QString &topic, const FMPProps &pps)
if
(
event_admin
)
{
ctkEvent
ctk_event
(
topic
,
pps
);
event_admin
->
postEvent
(
ctk_event
);
FMP_INFO
(
_logger
)
<<
"Posted event"
<<
topic
<<
"Properties:"
<<
pps
;
FMP_INFO
()
<<
"Posted event"
<<
topic
<<
"Properties:"
<<
pps
;
return
FMP_SUCCESS
;
}
else
{
FMP_WARN
(
_logger
)
<<
topic
<<
"not send: Event admin not available."
;
FMP_WARN
()
<<
topic
<<
"not send: Event admin not available."
;
}
return
FMP_FAILURE
;
...
...
@@ -213,7 +211,7 @@ int FMPluginManager::PostEvent(const QString &topic, const FMPProps &pps)
void
FMPluginManager
::
OnPluginsChanged
(
const
QString
&
path
)
{
FMP_INFO
(
_logger
)
<<
"Directory change detected:"
<<
path
;
FMP_INFO
()
<<
"Directory change detected:"
<<
path
;
LoadNewPlugins
();
QVariantList
expired_plugins
=
GetExpiredPlugins
();
...
...
@@ -352,19 +350,19 @@ QVariantList FMPluginManager::GetExpiredPlugins()
void
FMPluginManager
::
OnFrameworkEvent
(
const
ctkPluginFrameworkEvent
&
event
)
{
QSharedPointer
<
ctkPlugin
>
plugin
=
event
.
getPlugin
();
FMP_DEBUG
(
_logger
)
<<
plugin
->
getSymbolicName
()
<<
plugin
->
getVersion
()
<<
event
.
getType
();
FMP_DEBUG
()
<<
plugin
->
getSymbolicName
()
<<
plugin
->
getVersion
()
<<
event
.
getType
();
}
void
FMPluginManager
::
OnPluginEvent
(
const
ctkPluginEvent
&
event
)
{
QSharedPointer
<
ctkPlugin
>
plugin
=
event
.
getPlugin
();
FMP_DEBUG
(
_logger
)
<<
plugin
->
getSymbolicName
()
<<
plugin
->
getVersion
()
<<
event
.
getType
();
FMP_DEBUG
()
<<
plugin
->
getSymbolicName
()
<<
plugin
->
getVersion
()
<<
event
.
getType
();
}
void
FMPluginManager
::
OnServiceEvent
(
const
ctkServiceEvent
&
event
)
{
QSharedPointer
<
ctkPlugin
>
plugin
=
event
.
getServiceReference
().
getPlugin
();
FMP_DEBUG
(
_logger
)
<<
plugin
->
getSymbolicName
()
<<
plugin
->
getVersion
()
<<
event
.
getType
();
FMP_DEBUG
()
<<
plugin
->
getSymbolicName
()
<<
plugin
->
getVersion
()
<<
event
.
getType
();
}
...
...
fmp_manager/fmp_manager.h
View file @
98dd8859
...
...
@@ -68,7 +68,6 @@ private:
ctkPluginContext
*
_ctx
;
QFileSystemWatcher
_watcher
;
FMPLoggerInterface
*
_logger
;
FMPSettingsInterface
*
_setting
;
FMPSyncerInterface
*
_syncer
;
...
...
fmp_manager/fmp_me_handlers.cpp
View file @
98dd8859
...
...
@@ -27,7 +27,7 @@ void FMPUpgradeEventHandler::handleEvent(const ctkEvent &event)
}
}
else
{
FMP_DEBUG
_CTX
(
_ctx
)
<<
"No handler instance for event"
<<
event
.
getTopic
();
FMP_DEBUG
(
)
<<
"No handler instance for event"
<<
event
.
getTopic
();
}
}
...
...
@@ -40,7 +40,7 @@ void FMPQuitEventHandler::handleEvent(const ctkEvent &event)
_pm
->
deleteLater
();
}
else
{
FMP_DEBUG
_CTX
(
_ctx
)
<<
"No handler instance for event"
<<
event
.
getTopic
();
FMP_DEBUG
(
)
<<
"No handler instance for event"
<<
event
.
getTopic
();
}
}
fmp_manager/version.h
View file @
98dd8859
...
...
@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD
35
#define VER_BUILD
43
//! Convert version numbers to string
#define _STR(S) #S
...
...
fmp_network/fmp_network.cpp
View file @
98dd8859
#
include
"fmp_network.h"
#include "fmp_nw_reply.h"
#include <fmp_logger_i.h>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
...
...
@@ -9,7 +10,7 @@ FMPNetwork::FMPNetwork(ctkPluginContext *ctx)
:
_ctx
(
ctx
),
d_ptr
(
new
FMPNetworkPrivate
(
this
))
{
FMPLoggerInterface
::
InitContext
(
ctx
);
}
int
FMPNetwork
::
StartService
()
...
...
@@ -24,6 +25,8 @@ int FMPNetwork::StopService()
int
FMPNetwork
::
PostEvent
(
const
QString
&
topic
,
const
FMPProps
&
pps
)
{
Q_UNUSED
(
topic
);
Q_UNUSED
(
pps
);
return
FMP_NOIMPL
;
}
...
...
@@ -53,7 +56,6 @@ FMPSockReplyPointer FMPNetwork::Send(const FMPSocketRequest &req)
FMPNetworkPrivate
::
FMPNetworkPrivate
(
FMPNetwork
*
q
)
:
q_ptr
(
q
)
{
}
FMPHttpReplyPointer
FMPNetworkPrivate
::
HttpGet
(
const
FMPHttpRequest
&
r
)
...
...
fmp_network/version.h
View file @
98dd8859
...
...
@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD
35
#define VER_BUILD
43
//! Convert version numbers to string
#define _STR(S) #S
...
...
fmp_settings
@
121df1a2
Subproject commit
bf99eb4488c6b4b434075b04b4542e07e76eb437
Subproject commit
121df1a23284a3244b3092597fa43786cff028fd
fmp_syncer/fmp_syncer.h
View file @
98dd8859
...
...
@@ -44,8 +44,8 @@ public:
void
SetDeployPath
(
const
QString
&
path
);
private
:
FMPSyncerPrivate
*
d_ptr
;
ctkPluginContext
*
_ctx
;
FMPSyncerPrivate
*
d_ptr
;
int
_req_timeout
;
int
_sync_interval
;
QString
_partner_id
;
...
...
fmp_syncer/fmp_syncer_p.cpp
View file @
98dd8859
...
...
@@ -19,11 +19,11 @@
FMPSyncerPrivate
::
FMPSyncerPrivate
(
FMPSyncer
*
q
)
:
_inited
(
false
),
_logger
(
nullptr
),
_sets
(
nullptr
),
_nw
(
nullptr
),
q_ptr
(
q
)
{
FMPLoggerInterface
::
InitContext
(
q
->
_ctx
);
}
int
FMPSyncerPrivate
::
Init
()
...
...
@@ -32,7 +32,6 @@ int FMPSyncerPrivate::Init()
Q_Q
(
FMPSyncer
);
_sets
=
q
->
GetService
<
FMPSettingsInterface
>
(
q
->
_ctx
);
_logger
=
q
->
GetService
<
FMPLoggerInterface
>
(
q
->
_ctx
);
_nw
=
q
->
GetService
<
FMPNetworkInterface
>
(
q
->
_ctx
);
// if (_sets && _logger && _nw) {
...
...
@@ -153,7 +152,7 @@ QVariant FMPSyncerPrivate::_GetValue(const QString &k, QVariant default_val)
return
_sets
->
GetValue
(
k
,
default_val
);
}
else
{
FMP_WARN
(
_logger
)
<<
"Settings service not available"
;
FMP_WARN
()
<<
"Settings service not available"
;
}
return
default_val
;
...
...
@@ -171,7 +170,7 @@ bool FMPSyncerPrivate::_SetValue(const QString &k, QVariant val)
return
true
;
}
else
{
FMP_WARN
(
_logger
)
<<
"Settings service not available"
;
FMP_WARN
()
<<
"Settings service not available"
;
}
return
false
;
...
...
@@ -190,7 +189,7 @@ void FMPSyncerPrivate::run()
QString
task_id
;
while
(
1
)
{
FMP_INFO
(
_logger
)
<<
QString
(
"check update after %1 ms"
).
arg
(
sync_interval
);
FMP_INFO
()
<<
QString
(
"check update after %1 ms"
).
arg
(
sync_interval
);
QEventLoop
eventLoop
;
QTimer
::
singleShot
(
sync_interval
,
&
eventLoop
,
&
QEventLoop
::
quit
);
eventLoop
.
exec
();
...
...
@@ -238,7 +237,7 @@ void FMPSyncerPrivate::run()
QStringList
all_file_names
=
latest_files
.
keys
();
QStringList
downloaded_files
=
DownloadFiles
(
download_url
,
latest_files
);
if
(
all_file_names
==
downloaded_files
)
{
FMP_INFO
(
_logger
)
<<
QString
(
"Download [%1] files successful"
).
arg
(
latest_files
.
count
());
FMP_INFO
()
<<
QString
(
"Download [%1] files successful"
).
arg
(
latest_files
.
count
());
//! 记录升级任务编号
QFile
planIdFile
(
QString
(
"%1/%2/planid.txt"
).
arg
(
_deploy_dir
).
arg
(
q
->
_download_path
));
...
...
@@ -312,15 +311,15 @@ void FMPSyncerPrivate::ReportTask(const QString& tid, const QString& msg, const
report_req_jo
.
insert
(
FMP_JSONKEY_MSG
,
task_msg
);
QByteArray
report_json
=
QJsonDocument
(
report_req_jo
).
toJson
(
QJsonDocument
::
Compact
);
FMP_INFO
(
_logger
)
<<
QString
(
"report [%1]"
).
arg
(
QString
(
report_json
));
FMP_INFO
()
<<
QString
(
"report [%1]"
).
arg
(
QString
(
report_json
));
FMPHttpReplyPointer
reply
=
_nw
->
HttpPost
(
q
->
_task_report_url
,
report_json
);
if
(
reply
->
WaitResponse
()
==
FMPHttpReply
::
NO_ERROR
)
{
QString
report_rsp
=
reply
->
Response
();
FMP_INFO
(
_logger
)
<<
QString
(
"report successful [%1]"
).
arg
(
QString
(
report_rsp
));
FMP_INFO
()
<<
QString
(
"report successful [%1]"
).
arg
(
QString
(
report_rsp
));
resultFile
.
remove
();
}
else
{
FMP_ERROR
(
_logger
)
<<
QString
(
"report failed [%1]"
).
arg
(
reply
->
ErrorString
());
FMP_ERROR
()
<<
QString
(
"report failed [%1]"
).
arg
(
reply
->
ErrorString
());
}
}
}
...
...
@@ -353,24 +352,24 @@ bool FMPSyncerPrivate::GetTask(QJsonObject &task_jo)
task_req_jo
.
insert
(
FMP_JSONKEY_VERSION
,
"1.0.0"
);
QByteArray
task_req
=
QJsonDocument
(
task_req_jo
).
toJson
(
QJsonDocument
::
Compact
);
FMP_INFO
(
_logger
)
<<
QString
(
"Checking update [%1]"
).
arg
(
QString
(
task_req
));
FMP_INFO
()
<<
QString
(
"Checking update [%1]"
).
arg
(
QString
(
task_req
));
FMPHttpReplyPointer
reply
=
_nw
->
HttpPost
(
q
->
_task_url
,
task_req
);
if
(
reply
->
WaitResponse
()
==
FMPHttpReply
::
NO_ERROR
)
{
QByteArray
task_json
=
reply
->
Response
();
FMP_DEBUG
(
_logger
)
<<
"Task json:"
<<
task_json
;
FMP_DEBUG
()
<<
"Task json:"
<<
task_json
;
task_jo
=
QJsonDocument
().
fromJson
(
task_json
).
object
();
if
(
task_jo
[
FMP_JSONKEY_STATUSCODE
].
toInt
()
==
FMP_SYNCTASK_SUCCESS
)
{
FMP_INFO
(
_logger
)
<<
QString
(
"Check update successful [%1]"
).
arg
(
QString
(
task_json
));
FMP_INFO
()
<<
QString
(
"Check update successful [%1]"
).
arg
(
QString
(
task_json
));
has_task
=
true
;
}
else
{
FMP_ERROR
(
_logger
)
<<
QString
(
"check update failed [%1 - %2]"
)
FMP_ERROR
()
<<
QString
(
"check update failed [%1 - %2]"
)
.
arg
(
QString
::
number
(
task_jo
[
FMP_JSONKEY_STATUSCODE
].
toInt
()))
.
arg
(
task_jo
[
FMP_JSONKEY_MSG
].
toString
());
}
}
else
{
FMP_ERROR
(
_logger
)
<<
QString
(
"check update failed [%1]"
).
arg
(
reply
->
ErrorString
());
FMP_ERROR
()
<<
QString
(
"check update failed [%1]"
).
arg
(
reply
->
ErrorString
());
}
return
has_task
;
...
...
@@ -383,12 +382,12 @@ bool FMPSyncerPrivate::UploadFiles(const QStringList &files)
foreach
(
QString
f
,
files
)
{
QString
file_path
=
QString
(
"%1/%2"
).
arg
(
_deploy_dir
,
f
);
if
(
!
JlCompress
::
compressFile
(
file_path
+
".zip"
,
file_path
))
{
FMP_ERROR
(
_logger
)
<<
QString
(
"Compress file[%1] failed"
).
arg
(
file_path
);
FMP_ERROR
()
<<
QString
(
"Compress file[%1] failed"
).
arg
(
file_path
);
continue
;
}
QFile
file
(
file_path
+
".zip"
);
if
(
!
file
.
open
(
QFile
::
ReadOnly
))
{
FMP_ERROR
(
_logger
)
<<
QString
(
"Open file[%1] failed"
).
arg
(
file_path
+
".zip"
);
FMP_ERROR
()
<<
QString
(
"Open file[%1] failed"
).
arg
(
file_path
+
".zip"
);
continue
;
}
...
...
@@ -402,11 +401,11 @@ bool FMPSyncerPrivate::UploadFiles(const QStringList &files)
//! TODO:
//! 文件上传判断是否成功
QByteArray
rsp
=
reply
->
Response
();
FMP_INFO
(
_logger
)
<<
QString
(
"Upload file[%1] successful"
).
arg
(
file_path
+
".zip"
);
FMP_INFO
()
<<
QString
(
"Upload file[%1] successful"
).
arg
(
file_path
+
".zip"
);
uploaded_file
<<
f
;
}
else
{
FMP_ERROR
(
_logger
)
<<
QString
(
"Upload file[%1] failed. (%2)"
).
arg
(
file_path
+
".zip"
,
reply
->
ErrorString
());
FMP_ERROR
()
<<
QString
(
"Upload file[%1] failed. (%2)"
).
arg
(
file_path
+
".zip"
,
reply
->
ErrorString
());
}
}
...
...
@@ -418,12 +417,12 @@ bool FMPSyncerPrivate::UploadFiles(const QStringList &files)
bool
FMPSyncerPrivate
::
GetLatestFiles
(
const
QString
&
url
,
QMap
<
QString
,
QString
>
&
latest_files
)
{
bool
has_latest
=
false
;
FMP_INFO
(
_logger
)
<<
QString
(
"Get latest files on server [%1]"
).
arg
(
url
);
FMP_INFO
()
<<
QString
(
"Get latest files on server [%1]"
).
arg
(
url
);
FMPHttpReplyPointer
reply
=
_nw
->
HttpGet
(
url
+
"/upgradeInfos.txt"
);
if
(
reply
->
WaitResponse
()
==
FMPHttpReply
::
NO_ERROR
)
{
QByteArray
rsp
=
reply
->
Response
();
FMP_DEBUG
(
_logger
)
<<
"Get server files response:"
<<
rsp
;
FMP_DEBUG
()
<<
"Get server files response:"
<<
rsp
;
QJsonArray
file_array
=
QJsonDocument
().
fromJson
(
rsp
).
array
();
QMap
<
QString
,
QString
>
all_files
;
...
...
@@ -436,15 +435,15 @@ bool FMPSyncerPrivate::GetLatestFiles(const QString &url, QMap<QString, QString>
has_latest
=
true
;
}
else
{
FMP_INFO
(
_logger
)
<<
"Local files are up-to-date"
;
FMP_INFO
()
<<
"Local files are up-to-date"
;
}
}
else
{
FMP_WARN
(
_logger
)
<<
"No files on server"
;
FMP_WARN
()
<<
"No files on server"
;
}
}
else
{
FMP_ERROR
(
_logger
)
<<
"Get latest files failed."
<<
reply
->
ErrorString
();
FMP_ERROR
()
<<
"Get latest files failed."
<<
reply
->
ErrorString
();
}
return
has_latest
;
...
...
@@ -478,7 +477,7 @@ QString FMPSyncerPrivate::GetFileMd5(const QString &file_path)
file
.
close
();
}
else
{
FMP_INFO
(
_logger
)
<<
"Failed open file"
<<
file_path
<<
file
.
errorString
();
FMP_INFO
()
<<
"Failed open file"
<<
file_path
<<
file
.
errorString
();
}
return
md5
;
...
...
@@ -492,24 +491,24 @@ QStringList FMPSyncerPrivate::DownloadFiles(const QString &url, const QMap<QStri
foreach
(
QString
k
,
keys
)
{
QString
download_url
=
QString
(
"%1/%2.zip"
).
arg
(
url
,
k
);
QString
save_path
=
QString
(
"%1/%2/%3.zip"
).
arg
(
_deploy_dir
,
q
->
_download_path
,
k
);
FMP_INFO
(
_logger
)
<<
QString
(
"Start downloading file [%1]"
).
arg
(
download_url
);
FMP_INFO
()
<<
QString
(
"Start downloading file [%1]"
).
arg
(
download_url
);
//! 下载之前先检测文件是否下载过
QString
local_md5
=
GetFileMd5
(
save_path
.
left
(
save_path
.
lastIndexOf
(
"."
)));
if
(
local_md5
==
files
[
k
])
{
FMP_INFO
(
_logger
)
<<
"file exists"
;
FMP_INFO
()
<<
"file exists"
;
downloaded_files
<<
k
;
continue
;
}
else
{
FMP_WARN
(
_logger
)
<<
"Md5 not match, local:"
<<
local_md5
<<
"remote:"
<<
files
[
k
];
FMP_WARN
()
<<
"Md5 not match, local:"
<<
local_md5
<<
"remote:"
<<
files
[
k
];
}
//! 下载文件
QDir
().
mkpath
(
save_path
.
left
(
save_path
.
lastIndexOf
(
"/"
)));
QFile
file
(
save_path
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
{
FMP_ERROR
(
_logger
)
<<
file
.
errorString
();
FMP_ERROR
()
<<
file
.
errorString
();
continue
;
}
else
{
...
...
@@ -526,10 +525,10 @@ QStringList FMPSyncerPrivate::DownloadFiles(const QString &url, const QMap<QStri
//! 检查下载的文件MD5是否正确
local_md5
=
GetFileMd5
(
save_path
.
left
(
save_path
.
lastIndexOf
(
"."
)));
if
(
local_md5
!=
files
[
k
])
{
FMP_ERROR
(
_logger
)
<<
"Md5 not match, local:"
<<
local_md5
<<
"remote:"
<<
files
[
k
];
FMP_ERROR
()
<<
"Md5 not match, local:"
<<
local_md5
<<
"remote:"
<<
files
[
k
];
}
else
{
FMP_INFO
(
_logger
)
<<
"download file successful"
;
FMP_INFO
()
<<
"download file successful"
;
downloaded_files
<<
k
;
}
}
...
...
fmp_syncer/fmp_syncer_p.h
View file @
98dd8859
...
...
@@ -128,7 +128,6 @@ signals:
public
:
bool
_inited
;
FMPSyncer
*
q_ptr
;
FMPLoggerInterface
*
_logger
;
FMPSettingsInterface
*
_sets
;
FMPNetworkInterface
*
_nw
;
...
...
fmp_syncer/version.h
View file @
98dd8859
...
...
@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD
35
#define VER_BUILD
43
//! Convert version numbers to string
#define _STR(S) #S
...
...
fmp_vip
@
a36edc05
Subproject commit
d45d158b031945b5ca8118fe84be5ec3dcb71e1f
Subproject commit
a36edc05e4f73dbdf150f6654fde160d204617f7
include/interface/fmp_plugin_i.h
View file @
98dd8859
...
...
@@ -33,11 +33,11 @@ protected:
if
(
event_admin
)
{
ctkEvent
ctk_event
(
topic
,
pps
);
event_admin
->
postEvent
(
ctk_event
);
FMP_INFO
_CTX
(
_ctx
)
<<
"Posted event"
<<
topic
<<
"Properties:"
<<
pps
;
FMP_INFO
(
)
<<
"Posted event"
<<
topic
<<
"Properties:"
<<
pps
;
return
FMP_SUCCESS
;
}
else
{
FMP_WARN
_CTX
(
_ctx
)
<<
topic
<<
"not send: Event admin not available."
;
FMP_WARN
(
)
<<
topic
<<
"not send: Event admin not available."
;
}
return
FMP_FAILURE
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment