Browse Source

#IQRV #comment [ResourceWatcher] 增加第三方库安装状态识别的接口实现

gifur 2 năm trước cách đây
mục cha
commit
a8a8ea5452

+ 10 - 4
Module/mod_ResourceWatcher/ResourceWatcher.xml

@@ -229,16 +229,22 @@
     </twoway>
     <twoway  name="GetThirdPartyInstallState" overlap="true">
       <req>
-        <!---1: 搜狗输入法-->
+        <!---1: 表示获取搜狗输入法的安装信息,3,自定义检测程序安装情况-->
         <param name="mode" type="int" />
-		<param name="reserved1" type="int" />
-		<param name="reserved2" type="int" />
+        <param name="reserved1" type="int" />
+        <param name="reserved2" type="int" />
+        <!--新增两个字段,该接口确认为内部使用,TODO: SpGen更新-->
+        <param name="reserverd3" type="string"/>
+        <param name="reserverd4" type="string"/>
       </req>
       <res>
-        <!--1:已安装-->
+        <!--1:已安装,0:未安装-->
         <param name="status" type="int" />
+		<!-- 安装版本信息 -->
         <param name="version" type="string"/>
+		<!-- 安装路径 -->
         <param name="path" type="string"/>
+		<!-- 对于搜狗输入法,储存安装时间 -->
         <param name="reserverd1" type="string"/>
         <param name="reserverd2" type="string"/>
         <param name="reserverd3" type="int"/>

+ 3 - 1
Module/mod_ResourceWatcher/ResourceWatcher_def_g.h

@@ -360,10 +360,12 @@ struct ResourceWatcherService_GetThirdPartyInstallState_Req
 	int mode;
 	int reserved1;
 	int reserved2;
+    CSimpleStringA reserverd3;
+    CSimpleStringA reserverd4;
 
 	void Serialize(SpBuffer &Buf)
 	{
-		auto & buf = Buf & mode & reserved1 & reserved2;
+		auto & buf = Buf & mode & reserved1 & reserved2 & reserverd3 & reserverd4;
 	}
 
 };

+ 33 - 0
Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp

@@ -431,6 +431,39 @@ void ResourceWatcherEntity::GetThirdPartyInstallState(SpReqAnsContext<ResourceWa
                 ctx->Ans.version = "";
             }
         }
+    } else if (ctx->Req.mode == 3) { //自定义安装
+        if (ctx->Req.reserverd3.IsNullOrEmpty()) {
+            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("the req rerverd3 is empty.");
+            result = Error_Param;
+        } else {
+            DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to check %s 's install status...", ctx->Req.reserverd3.GetData());
+            CSimpleStringA strSoftwareName(ctx->Req.reserverd3);
+            CSimpleStringA strSoftwareVersion(ctx->Req.reserverd4);
+            CSimpleStringA runItem = CSimpleStringA::Format("dpkg -l | grep %s | awk '{print $3}'", strSoftwareName.GetData());
+            std::string additional("");
+            std::string succStr, errStr;
+            std::string runStr(runItem.GetData());
+            if (SP::Module::Util::ShellExecute(runStr, succStr, errStr)) {
+                if (succStr.empty()) {
+                    DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("%s is not installed", strSoftwareName.GetData());
+                    ctx->Ans.status = 0;
+                } else {
+                    succStr = SP::Utility::ToTrim(succStr);
+                    if (strSoftwareVersion.IsNullOrEmpty() || strSoftwareVersion.Compare(succStr.c_str()) == 0) {
+                        DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s is installed, version: %s", strSoftwareName.GetData(), succStr.c_str());
+                        ctx->Ans.status = 1;
+                    } else {
+                        ctx->Ans.status = 2;
+                        DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s is installed, but the version<%s> is not the dream one<%s>"
+                                                                     , strSoftwareName.GetData(), succStr.c_str(), strSoftwareVersion.GetData());
+                        ctx->Ans.reserverd1 = succStr.c_str();
+                    }
+                }
+            } else {
+                DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("Execute <%s> failed.", runItem.GetData());
+                result = Error_Process;
+            }
+        }
     } else {
         result = Error_NotSupport;
     }

+ 8 - 8
Module/mod_healthmanager/mod_healthmanager.cpp

@@ -3394,7 +3394,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
 			if (tmpResult != 0) {
 				tmpMsg = CSimpleStringA::Format("连接资源管理模块失败: %s", SpStrError((ErrorCodeEnum)tmpResult));
 				pClient->SafeDelete();
-				Dbg(tmpMsg);
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)(tmpMsg);
 			}
 			else {
 				ResourceWatcherService_InstallThirdPartyProgram_Req req = {};
@@ -3403,7 +3403,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
 				req.reserved1 = req.reserved2 = 0;
 				/** 健康实体过来的调用,1表示不直接重启机器 [Gifur@202275]*/
 				req.reserved1 = 1;
-                Dbg("to install...");
+                DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to install...");
                 tmpResult = pClient->InstallThirdPartyProgram(req, ans, 120000);
                 if (tmpResult != 0) {
                     tmpMsg = CSimpleStringA::Format("调用安装请求返回错误:%s", SpStrError((ErrorCodeEnum)tmpResult));
@@ -3447,7 +3447,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
 			if (tmpResult != 0) {
 				tmpMsg = CSimpleStringA::Format("连接资源管理模块失败: %s", SpStrError((ErrorCodeEnum)tmpResult));
 				pClient->SafeDelete();
-				Dbg(tmpMsg);
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)(tmpMsg);
 			}
 			else {
 				ResourceWatcherService_GetThirdPartyInstallState_Req req = {};
@@ -3457,7 +3457,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
 				tmpResult = pClient->GetThirdPartyInstallState(req, ans, 30000);
 				if (tmpResult != 0) {
 					tmpMsg = CSimpleStringA::Format("获取安装状态请求失败: %s", SpStrError((ErrorCodeEnum)tmpResult));
-					Dbg(tmpMsg);
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)(tmpMsg);
 				}
 				else {
 					ctx->Ans.param1 = 0;
@@ -3480,14 +3480,14 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
 			if (tmpResult != 0) {
 				tmpMsg = CSimpleStringA::Format("连接资源管理模块失败: %s", SpStrError((ErrorCodeEnum)tmpResult));
 				pClient->SafeDelete();
-				Dbg(tmpMsg);
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)(tmpMsg);
 			}
 			else {
 				ResourceWatcherService_InstallThirdPartyProgram_Req req = {};
 				ResourceWatcherService_InstallThirdPartyProgram_Ans ans = {};
 				req.type = 2; //
 				req.reserved1 = req.reserved2 = 0;
-				Dbg("to install font....");
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to install font....");
 				tmpResult = pClient->InstallThirdPartyProgram(req, ans, 60000);
 				if (tmpResult != 0) {
 					tmpMsg = CSimpleStringA::Format("调用安装请求返回错误:%s", SpStrError((ErrorCodeEnum)tmpResult));
@@ -3516,7 +3516,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
 		strRootChosenFile = strRootIniFullPath + ".bak";
 		if (ExistsFileA(strRootChosenFile)) {
 			fileutil_delete_file(strRootChosenFile);
-			Dbg("to clear root.ini backup file.");
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to clear root.ini backup file.");
 		}
 
 		CSystemStaticInfo info;
@@ -3525,7 +3525,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
 		GetFunction()->OpenConfig(Config_Cache, pConfig);
 		pConfig->WriteConfigValue("TerminalDeploy", "InstallVersion", info.InstallVersion.ToString());
 
-		Dbg("received finish install cmd!");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("received finish install cmd!");
 		LogWarn(Severity_High, Error_Debug, LOG_WARN_HEALTH_INSTALL_FINISHED, "install finished");
 		result = Error_Succeed;
 	}

+ 35 - 7
addin/res/ManagerDesktop/js/guide.js

@@ -93,6 +93,7 @@ var adapterTestFailedCount = 0;
 var apdaterTestAllBefore = 0;
 
 var globalSogouNewInstall = false;
+var globalSogouNewVesion = false;
 
 
 function clearAdapterSelectedValue()
@@ -1542,7 +1543,7 @@ $(function () {
         req.restartApp = false;
         req.restartPC = false;
         req.timeout = 125000;
-
+        globalSogouNewVesion = false;
         utilStartSubmitDialog("输入法安装可能会花比较长时间,请耐心等候...");
         RVC.HealthmanagerEntityCtrl.DeployTerminal(req, function(ret) {
             utilStopSubmitDialog();
@@ -1563,13 +1564,9 @@ $(function () {
                         tip += '<br>安装时间:<strong>' + sogouinstalltm + '</strong>';
                         $('#guide_sogou_install_finished_content').html(tip);
                         SogouInstallStateSwitch(2);
-
                         if(sogouNewVersion === 1) {
-                            utilStartAlertDialog("识别到安装的是新版的输入法<br/>请先到下载网址(http://rvcterminalmonitor.paas.cmbchina.cn/#/downloads)完成UOS补丁包的下载和安装!否则影响应用外使用输入法(如果已经安装请忽略)", function() {
-                                //RVC.GuideController.gotoPage(DEPLOY.DeployStep_3rdParty_FontInstall, true);
-                            });
+                            globalSogouNewVesion = true;
                         }
-
                     } else if(sogouinstalltm != '') {
                         tip += '<br><br>版本:<strong style="color:#FF0000;">' + '无法获取版本信息' + '</strong>';
                         tip += '<br>安装时间:<strong>' + sogouinstalltm + '</strong>';
@@ -1611,6 +1608,7 @@ $(function () {
             if(ret.errorCode === 0) {
                 let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
                 if(result.result == 0) {
+                    globalSogouNewVesion = false;
                     utilStartAlertDialog('卸载成功!', function() {
                         globalSogouNewInstall = false;
                         DisplaySogouInstallState();
@@ -1678,6 +1676,7 @@ $(function () {
         req.restartApp = false;
         req.restartPC = false;
         req.timeout = 35000;
+        globalSogouNewVesion = false;
         utilStartSubmitDialog();
         RVC.HealthmanagerEntityCtrl.DeployTerminal(req, function(ret) {
             utilStopSubmitDialog();
@@ -1688,15 +1687,21 @@ $(function () {
                         var tip = '检测到输入法已安装!';
                         var sogouversion = '';
                         var sogouinstalltm = '';
+                        var sogouNewVersion = 0;
                         if(result.array2.length === 3) {
                             sogouversion = result.array2[0];
                             sogouinstalltm = result.array2[2];
+                            sogouNewVersion = result.array1[0];
                         }
                         if(sogouversion !== '') {
                             tip += '<br><br>版本:<strong>' + sogouversion + '</strong>';
                             tip += '<br>安装时间:<strong>' + sogouinstalltm + '</strong>';
                             SogouInstallStateSwitch(1);
                             $('#guide_sogou_installed_content').html(tip);
+                            if(sogouNewVersion === 1) {
+                                globalSogouNewVesion = true;
+                            }
+
                         } else if(sogouinstalltm != ''){
                             tip = '检测到输入法已安装!但相关服务进程未启动或异常,请优先重启设备,如果重启后仍出现问题,请点击下方<strong>卸载</strong>菜单后重装!'
                             tip += '<br><br>版本:<strong style="color:#FF0000;">' + '无法获取版本信息' + '</strong>';
@@ -2146,7 +2151,30 @@ $(function () {
                     RVC.GuideController.gotoPage(DEPLOY.DeployStep_GetTerminalInfo);
                 });
             } else {
-                RVC.GuideController.gotoPage(DEPLOY.DeployStep_GetTerminalInfo);
+                if(globalSogouNewVesion) {
+                    let req1 = new Request();
+                    req1.mode = 3;
+                    req1.reserved1 = 0;
+                    req1.reserved2 = 0;
+                    req1.reserverd3 = 'libdde-file-manager';
+                    req1.reserverd4 = '5.2.11.2-1';
+                    RVC.ResourceWatcherEntity.GetThirdPartyInstallState(req1, function(ret) {
+                        if(ret.errorCode === 0) {
+                            let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
+                            if(result.status == 0 || result.status == 2) {
+                                utilStartAlertDialog("检测到安装的是新版的输入法!请先到下载站点<br/>(http://rvcterminalmonitor.paas.cmbchina.cn/#/downloads)<br/>完成UOS补丁包的下载和安装!否则影响应用外使用输入法");
+                            } else if(result.status == 1) {
+                                RVC.GuideController.gotoPage(DEPLOY.DeployStep_GetTerminalInfo);
+                            }
+                        } else {
+                            utilShowToast("检测UOS补丁包安装状态失败:" + ErrorCodeStringfy(ret.errorCode), 3000, function(){
+                                RVC.GuideController.gotoPage(DEPLOY.DeployStep_GetTerminalInfo);
+                            });
+                        }
+                    });
+                } else {
+                    RVC.GuideController.gotoPage(DEPLOY.DeployStep_GetTerminalInfo);
+                }
             }
         }
     });