|
@@ -1765,17 +1765,51 @@ void ResourceWatcherEntity::FetchSystemSnapshot(
|
|
|
SpReqAnsContext<ResourceWatcherService_FetchSystemSnapshot_Req, ResourceWatcherService_FetchSystemSnapshot_Ans>::Pointer ctx)
|
|
|
{
|
|
|
CSimpleStringA info(true);
|
|
|
- const bool ret = m_fsm.GetMonitorInfo(info);
|
|
|
- if (ret) {
|
|
|
- ctx->Ans.result = 0;
|
|
|
- ctx->Ans.msg = info;
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_INFO_MONITOR_SETTINGS_GET, info);
|
|
|
+ if (ctx->Req.type == 1) {
|
|
|
+ const bool ret = m_fsm.GetMonitorInfo(info);
|
|
|
+ if (ret) {
|
|
|
+ ctx->Ans.result = 0;
|
|
|
+ ctx->Ans.msg = info;
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_INFO_MONITOR_SETTINGS_GET, info);
|
|
|
|
|
|
+ } else {
|
|
|
+ ctx->Ans.result = -1;
|
|
|
+ ctx->Ans.msg = "调用 GetMonitorInfo 接口失败";
|
|
|
+ }
|
|
|
+ ctx->Answer(Error_Succeed);
|
|
|
+ } else if (ctx->Req.type == 2) { /** 有无安装新版浏览器 [Gifur@20221219]*/
|
|
|
+ const std::string execute_newbrowser_path = "/usr/share/browser/browser";
|
|
|
+ const std::string execute_oldbrowser_path = "/usr/share/uosbrowser/uosbrowser";
|
|
|
+ int result(0);
|
|
|
+ std::string additional("");
|
|
|
+ std::string succStr, errStr;
|
|
|
+ std::string runStr("dpkg -l | grep org.deepin.browser | awk '{print $3}'");
|
|
|
+ if (SP::Module::Util::ShellExecute(runStr, succStr, errStr)) {
|
|
|
+ if (succStr.empty()) {
|
|
|
+ if (ExistsFileA(execute_oldbrowser_path.c_str())) {
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s exists!", execute_oldbrowser_path.c_str());
|
|
|
+ result = 1;
|
|
|
+ } else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("%s not exists!", execute_oldbrowser_path.c_str());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("new browser version: %s", succStr.c_str());
|
|
|
+ additional = succStr;
|
|
|
+ if (!ExistsFileA(execute_newbrowser_path.c_str())) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("%s not exists!", execute_newbrowser_path.c_str());
|
|
|
+ }
|
|
|
+ result = 2;
|
|
|
+ }
|
|
|
+ ctx->Ans.result = result;
|
|
|
+ ctx->Ans.msg = additional.c_str();
|
|
|
+ ctx->Answer(Error_Succeed);
|
|
|
+ } else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("execute '%s' failed!", runStr.c_str());
|
|
|
+ ctx->Answer(Error_Process);
|
|
|
+ }
|
|
|
} else {
|
|
|
- ctx->Ans.result = -1;
|
|
|
- ctx->Ans.msg = "调用 GetMonitorInfo 接口失败";
|
|
|
+ ctx->Answer(Error_NotSupport);
|
|
|
}
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
}
|
|
|
|
|
|
SP_BEGIN_ENTITY_MAP()
|