فهرست منبع

#IQRV #comment [ResourceWatcher] 支持输入法卸载

gifur 3 سال پیش
والد
کامیت
d1d64b9edb

+ 188 - 119
Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp

@@ -176,6 +176,12 @@ void ResourceWatcherServiceSession::Handle_ManipulateVersion(SpReqAnsContext<Res
     m_pEntity->ManipulateVersion(ctx);
 }
 
+void ResourceWatcherServiceSession::Handle_UninstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_UninstallThirdPartyProgram_Req, ResourceWatcherService_UninstallThirdPartyProgram_Ans>::Pointer ctx)
+{
+    LOG_FUNCTION();
+    m_pEntity->UninstallThirdPartyProgram(ctx);
+}
+
 void ResourceWatcherEntity::UpdateDNS(SpReqAnsContext<ResourceWatcherService_UpdateDNS_Req, ResourceWatcherService_UpdateDNS_Ans>::Pointer ctx)
 {
     ctx->Answer(Error_NotImpl);
@@ -284,8 +290,8 @@ void ResourceWatcherEntity::GetThirdPartyInstallState(SpReqAnsContext<ResourceWa
         info.program.strVersion = Sogou_GetVersion();
         const int maxTimes = 5;
         int curTimes = 0;
-        while (info.program.strVersion.IsNullOrEmpty() && curTimes < maxTimes) {
-            Sleep(2000);
+        while (info.state.dwInstalledStatus == 0 && info.program.strVersion.IsNullOrEmpty() && curTimes < maxTimes) {
+            Sleep(1200);
             info.program.strVersion = Sogou_GetVersion();
             curTimes++;
         }
@@ -406,130 +412,79 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
     if (ctx->Req.type == 1) {//安装搜狗输入法
 
         Dbg("to install sogou input...");
-        const bool doNotStartup(true);
-
+        const bool doNotStartup(true); //安装后是否启动搜狗输入法服务,据搜狗反馈,不能通过root权限启动Sogou输入法
         CSimpleStringA strInstallPkgPath;
-        CSimpleStringA strAdDataDirPath(true);
-        tmpResult = GetFunction()->GetPath("Ad", strAdDataDirPath);
-        if (strAdDataDirPath.IsNullOrEmpty() && m_bInitMode) {
-            strAdDataDirPath = "/opt/rvc/adData";
-        }
-
-        if (strAdDataDirPath.IsNullOrEmpty()) {
-            tmpResult = Error_Unexpect;
-            tmpMsg = "获取安装包路径Ad失败";
+        tmpResult = GetSogouPkgDirPath(strInstallPkgPath);
+        if (tmpResult != 0) {
+            tmpMsg = CSimpleStringA::Format("指定位置找不到输入法安装包");
         } else {
-            array_header_t* subs;
-            subs = fileutil_get_sub_dirs_a(strAdDataDirPath);
-            if (subs) {
-                for (int i = 0; i < subs->nelts; ++i) {
-                    char* dir = ARRAY_IDX(subs, i, char*);
-                    const char* dirname = &dir[strAdDataDirPath.GetLength() + 1];
-                    if (CSimpleStringA(dirname).IsStartWith("sogou", true)) {
-                        if (strInstallPkgPath.IsNullOrEmpty()) {
-                            Dbg("found it: %s", dir);
-                            strInstallPkgPath = dir;
-                        } else if(strInstallPkgPath.Compare(dir) < 0) {
-                            Dbg("replace %s with %s", (LPCTSTR)strInstallPkgPath, dir);
-                            strInstallPkgPath = dir;
-                        }
-                        //break;
-                    }
-                }
-                toolkit_array_free2(subs);
-            }
-
-            if (strInstallPkgPath.IsNullOrEmpty()) {
-                tmpMsg = CSimpleStringA::Format("%s 路径下找不到输入法安装包文件夹", strAdDataDirPath.GetData());
+            tmpResult = SetFileExecutePriviledge(strInstallPkgPath);
+            if (tmpResult != Error_Succeed) {
+                tmpMsg = CSimpleStringA::Format("%s 修改文件夹权限失败", strInstallPkgPath.GetData());
                 tmpResult = Error_NotExist;
             } else {
-
-                tmpResult = SetFileExecutePriviledge(strInstallPkgPath);
-                if (tmpResult != Error_Succeed) {
-                    tmpMsg = CSimpleStringA::Format("%s 修改文件夹权限失败", strInstallPkgPath.GetData());
-                    tmpResult = Error_NotExist;
-                } else {
-                    CSimpleStringA strRunIniFilePath = strInstallPkgPath + SPLIT_SLASH_STR + "Run.ini";
-                    if (ExistsFileA(strRunIniFilePath)) {
-                        char* p = inifile_read_str(strRunIniFilePath, "Action", "ToRun", "");
-                        CSimpleStringA strInstallScriptFile(strInstallPkgPath + SPLIT_SLASH_STR + p);
-                        toolkit_free(p);
-                        Dbg("install script file: %s", strInstallScriptFile.GetData());
-                        if (ExistsFileA(strInstallScriptFile)) {
-                            do {
-                                char app[MAX_PATH] = { '\0' };
-                                tk_process_t* process = NULL;
-                                tk_process_option_t option;
-                                option.exit_cb = NULL;
-                                option.file = NULL;
-                                option.flags = 0;
-
-                                sprintf(app, "bash %s", strInstallScriptFile.GetData());
-                                option.params = app;
-                                const int res = process_spawn(&option, &process);
-                                if (0 == res) {
-                                    FREE(process);
-                                    Dbg("execute {%s} suc", strInstallScriptFile.GetData());
-                                } else {
-                                    tmpMsg = CSimpleStringA::Format("执行 '%s' 失败:%s", app, toolkit_strerror(res));
-                                    tmpResult = Error_Process;
-                                }
-
-                            } while (false);
-
-                            if (!doNotStartup) {
-                                CSimpleStringA strStartupScriptFile(strInstallPkgPath + SPLIT_SLASH_STR + "startup_service.sh");
-                                Dbg("startup script file: %s", strStartupScriptFile.GetData());
-                                if (!ExistsFileA(strStartupScriptFile)) {
-                                    tmpMsg = CSimpleStringA::Format("%s 启动脚本文件不存在,请重启设备再次验证", strStartupScriptFile.GetData());
-                                    tmpResult = Error_NotExist;
-                                } else {
-                                    Sleep(1000);
-                                    do {
-                                        char app[MAX_PATH] = { '\0' };
-                                        tk_process_t* process = NULL;
-                                        tk_process_option_t option;
-                                        option.exit_cb = NULL;
-                                        option.file = NULL;
-                                        option.flags = 0;
+                CSimpleStringA strRunIniFilePath = strInstallPkgPath + SPLIT_SLASH_STR + "Run.ini";
+                if (ExistsFileA(strRunIniFilePath)) {
+                    char* p = inifile_read_str(strRunIniFilePath, "Action", "ToRun", "");
+                    CSimpleStringA strInstallScriptFile(strInstallPkgPath + SPLIT_SLASH_STR + p);
+                    toolkit_free(p);
+                    Dbg("install script file: %s", strInstallScriptFile.GetData());
+                    if (ExistsFileA(strInstallScriptFile)) {
+                        char app[MAX_PATH] = { '\0' };
+                        sprintf(app, "bash %s", strInstallScriptFile.GetData());
+                        tmpResult = RunShellScript(app);
+                        if (tmpResult != 0) {
+                            tmpMsg = CSimpleStringA::Format("执行 '%s' 失败", app);
+                        } else if(!doNotStartup) {
+                            CSimpleStringA strStartupScriptFile(strInstallPkgPath + SPLIT_SLASH_STR + "startup_service.sh");
+                            Dbg("startup script file: %s", strStartupScriptFile.GetData());
+                            if (!ExistsFileA(strStartupScriptFile)) {
+                                tmpMsg = CSimpleStringA::Format("%s 启动脚本文件不存在,请重启设备再次验证", strStartupScriptFile.GetData());
+                                tmpResult = Error_NotExist;
+                            } else {
+                                Sleep(1000);
+                                do {
+                                    char app[MAX_PATH] = { '\0' };
+                                    tk_process_t* process = NULL;
+                                    tk_process_option_t option;
+                                    option.exit_cb = NULL;
+                                    option.file = NULL;
+                                    option.flags = 0;
 #if 0
-                                        auto users = GetUserNameList(true);
-                                        if (users.size() == 1) {
-                                            sprintf(app, "su -m -p -c \"bash %s\" %s", strStartupScriptFile.GetData(), users[0].c_str());
-                                        } else {
-                                            for (auto it = users.cbegin(); it != users.cend(); ++it) {
-                                                Dbg("user:%s", it->c_str());
-                                            }
-                                            sprintf(app, "bash %s", strStartupScriptFile.GetData());
+                                    auto users = GetUserNameList(true);
+                                    if (users.size() == 1) {
+                                        sprintf(app, "su -m -p -c \"bash %s\" %s", strStartupScriptFile.GetData(), users[0].c_str());
+                                    } else {
+                                        for (auto it = users.cbegin(); it != users.cend(); ++it) {
+                                            Dbg("user:%s", it->c_str());
                                         }
-#else
                                         sprintf(app, "bash %s", strStartupScriptFile.GetData());
+                                    }
+#else
+                                    sprintf(app, "bash %s", strStartupScriptFile.GetData());
 #endif
-                                        option.params = app;
-                                        const int res = process_spawn(&option, &process);
-                                        if (0 == res) {
-                                            FREE(process);
-                                            Dbg("execute {%s} suc", app);
-                                        } else {
-                                            tmpMsg = CSimpleStringA::Format("执行 '%s' 失败:%s", app, toolkit_strerror(res));
-                                            tmpResult = Error_Process;
-                                        }
-                                    } while (false);
-                                }
+                                    option.params = app;
+                                    const int res = process_spawn(&option, &process);
+                                    if (0 == res) {
+                                        FREE(process);
+                                        Dbg("execute {%s} suc", app);
+                                    } else {
+                                        tmpMsg = CSimpleStringA::Format("执行 '%s' 失败:%s", app, toolkit_strerror(res));
+                                        tmpResult = Error_Process;
+                                    }
+                                } while (false);
                             }
-                        } else {
-                            tmpMsg = CSimpleStringA::Format("%s 执行文件不存在", strInstallScriptFile.GetData());
-                            tmpResult = Error_NotExist;
                         }
-
                     } else {
-                        tmpMsg = CSimpleStringA::Format("%s 文件不存在,请检查安装包完整性", strRunIniFilePath.GetData());
+                        tmpMsg = CSimpleStringA::Format("%s 执行文件不存在", strInstallScriptFile.GetData());
                         tmpResult = Error_NotExist;
                     }
+                } else {
+                    tmpMsg = CSimpleStringA::Format("%s 文件不存在,请检查安装包完整性", strRunIniFilePath.GetData());
+                    tmpResult = Error_NotExist;
                 }
             }
         }
-
         if (tmpResult == Error_Succeed) {
             Sleep(1500);
             const CSimpleStringA strResultLogFilePath = strInstallPkgPath + SPLIT_SLASH_STR + "result.log";
@@ -564,21 +519,21 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
                         tmpMsg = CSimpleStringA::Format("%s", szTmp);
                     } else {
                         SogouInstallInfo info;
+                        info.state.dwInstalledStatus = Sogou_GetInstallStatus();
+                        info.state.strInstallDate = Sogou_GetInstallTime();
+                        info.program.strInstallDir = Sogou_GetInstallPath();
                         info.program.strVersion = Sogou_GetVersion();
                         const int maxTimes = 5;
                         int curTimes = 0;
-                        while (!doNotStartup && info.program.strVersion.IsNullOrEmpty() && curTimes < maxTimes) {
-                            Sleep(2000);
+                        while (!doNotStartup && info.state.dwInstalledStatus == 0 && info.program.strVersion.IsNullOrEmpty() && curTimes < maxTimes) {
+                            Sleep(1200);
                             info.program.strVersion = Sogou_GetVersion();
                             curTimes++;
                         }
-                        info.state.dwInstalledStatus = Sogou_GetInstallStatus();
-                        info.state.strInstallDate = Sogou_GetInstallTime();
-                        info.program.strInstallDir = Sogou_GetInstallPath();
+                        Dbg("InstallTime: %s", info.state.GetInstallTime().ToTimeString().GetData());
                         Dbg("%d, %s, %s, %s"
                             , info.state.dwInstalledStatus, info.state.strInstallDate.GetData()
                             , info.program.strInstallDir.GetData(), info.program.strVersion.GetData());
-                        Dbg("InstallTime: %s", info.state.GetInstallTime().ToTimeString().GetData());
 
                         if (!info.IsInstalledSuccess()) {
                             tmpResult = Error_FailVerify;
@@ -825,6 +780,63 @@ void ResourceWatcherEntity::ManipulateVersion(SpReqAnsContext<ResourceWatcherSer
     ctx->Answer(result);
 }
 
+void ResourceWatcherEntity::UninstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_UninstallThirdPartyProgram_Req, ResourceWatcherService_UninstallThirdPartyProgram_Ans>::Pointer ctx)
+{
+    ErrorCodeEnum result(Error_Succeed);
+    ErrorCodeEnum tmpResult(Error_Succeed);
+    CSimpleStringA tmpMsg(true);
+
+    if (ctx->Req.type == 1) {
+        Dbg("to uninstall sogou input...");
+        CSimpleStringA strInstallPkgPath;
+        tmpResult = GetSogouPkgDirPath(strInstallPkgPath);
+        if (tmpResult == Error_Succeed) {
+            do 
+            {
+                tmpResult = SetFileExecutePriviledge(strInstallPkgPath);
+                if (tmpResult != Error_Succeed) {
+                    tmpMsg = CSimpleStringA::Format("%s 修改文件夹权限失败", strInstallPkgPath.GetData());
+                    tmpResult = Error_NoPrivilege;
+                    break;
+                }
+                const CSimpleStringA strShutdownScriptFile = strInstallPkgPath + SPLIT_SLASH_STR + "shutdown_service.sh";
+                const CSimpleStringA strUninstallScriptFile = strInstallPkgPath + SPLIT_SLASH_STR + "uninstall_sogouime.sh";
+                if (!ExistsFileA(strShutdownScriptFile)) {
+                    tmpMsg = CSimpleStringA::Format("%s 文件不存在!", strShutdownScriptFile.GetData());
+                    tmpResult = Error_InvalidState;
+                    break;
+                }
+                if (!ExistsFileA(strUninstallScriptFile)) {
+                    tmpMsg = CSimpleStringA::Format("%s 文件不存在!", strUninstallScriptFile.GetData());
+                    tmpResult = Error_InvalidState;
+                    break;
+                }
+                char app[MAX_PATH] = { '\0' };
+                sprintf(app, "bash %s", strShutdownScriptFile.GetData());
+                tmpResult = RunShellScript(app);
+                if (tmpResult != 0) {
+                    tmpMsg = CSimpleStringA::Format("执行 '%s' 失败", app);
+                } else {
+                    Sleep(300);
+                    sprintf(app, "bash %s", strUninstallScriptFile.GetData());
+                    tmpResult = RunShellScript(app);
+                    if (tmpResult != 0) {
+                        tmpMsg = CSimpleStringA::Format("执行 '%s' 失败", app);
+                    } else {
+                        Sleep(100);
+                    }
+                }
+            } while (false);
+        }
+    } else {
+        result = Error_NotSupport;
+    }
+    ctx->Ans.result = tmpResult;
+    ctx->Ans.msg = tmpMsg;
+    ctx->Answer(result);
+    return;
+}
+
 #if defined(RVC_OS_WIN)
 //1: 32bit process running at 64bit platform
 //0: 
@@ -970,10 +982,10 @@ ErrorCodeEnum ResourceWatcherEntity::DoCheckInstallStateJob()
     info.program.strInstallDir = Sogou_GetInstallPath();
     info.program.strVersion = Sogou_GetVersion();
     /** 重试获取版本号 [Gifur@2022224]*/
-    const int maxTimes = 8;
+    const int maxTimes = 3;
     int curTimes = 0;
-    while (info.program.strVersion.IsNullOrEmpty() && curTimes < maxTimes) {
-        Sleep(1000);
+    while (info.state.dwInstalledStatus == 0 && info.program.strVersion.IsNullOrEmpty() && curTimes < maxTimes) {
+        Sleep(1500);
         info.program.strVersion = Sogou_GetVersion();
         curTimes++;
     }
@@ -1206,6 +1218,63 @@ std::vector<std::string> ResourceWatcherEntity::GetUserNameList(bool bExcludeRoo
 }
 
 
+ErrorCodeEnum ResourceWatcherEntity::GetSogouPkgDirPath(CSimpleStringA& strPkgPath)
+{
+    CSimpleStringA strAdDataDirPath(true);
+    CSimpleStringA strInstallPkgPath(true);
+    ErrorCodeEnum result = GetFunction()->GetPath("Ad", strAdDataDirPath);
+    if (strAdDataDirPath.IsNullOrEmpty() && m_bInitMode) {
+        strAdDataDirPath = "/opt/rvc/adData";
+    }
+    if (strAdDataDirPath.IsNullOrEmpty()) {
+        return Error_Unexpect;
+    }
+    array_header_t* subs;
+    subs = fileutil_get_sub_dirs_a(strAdDataDirPath);
+    if (subs) {
+        for (int i = 0; i < subs->nelts; ++i) {
+            char* dir = ARRAY_IDX(subs, i, char*);
+            const char* dirname = &dir[strAdDataDirPath.GetLength() + 1];
+            if (CSimpleStringA(dirname).IsStartWith("sogou", true)) {
+                if (strInstallPkgPath.IsNullOrEmpty()) {
+                    Dbg("found it: %s", dir);
+                    strInstallPkgPath = dir;
+                } else if (strInstallPkgPath.Compare(dir) < 0) {
+                    Dbg("replace %s with %s", (LPCTSTR)strInstallPkgPath, dir);
+                    strInstallPkgPath = dir;
+                }
+            }
+        }
+        toolkit_array_free2(subs);
+    }
+    if (strInstallPkgPath.IsNullOrEmpty()) {
+        return Error_NotExist;
+    }
+
+    strPkgPath = strInstallPkgPath;
+    return Error_Succeed;
+}
+
+ErrorCodeEnum ResourceWatcherEntity::RunShellScript(LPCTSTR cmdline)
+{
+    char app[MAX_PATH] = { '\0' };
+    tk_process_t* process = NULL;
+    tk_process_option_t option;
+    option.exit_cb = NULL;
+    option.file = NULL;
+    option.flags = 0;
+    option.params = (char*)cmdline;
+    const int res = process_spawn(&option, &process);
+    if (0 == res) {
+        Dbg("execute {%s}, pid: %d", cmdline, process->pid);
+        FREE(process);
+        return Error_Succeed;
+    } else {
+        Dbg("execute {%s} failed: %d", cmdline, res);
+        return Error_Unexpect;
+    }
+}
+
 void ResourceWatcherEntity::OnSysVarEvent(const char* pszKey, const char* pszValue, const char* pszOldValue, const char* pszEntityName)
 {
     Dbg("OnSysVarEvent pszKey = %s, pszValue = %s", pszKey, pszValue);

+ 7 - 15
Module/mod_ResourceWatcher/mod_ResourceWatcher.h

@@ -54,6 +54,8 @@ public:
 
 	virtual void Handle_ManipulateVersion(SpReqAnsContext<ResourceWatcherService_ManipulateVersion_Req, ResourceWatcherService_ManipulateVersion_Ans>::Pointer ctx);
 
+	virtual void Handle_UninstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_UninstallThirdPartyProgram_Req, ResourceWatcherService_UninstallThirdPartyProgram_Ans>::Pointer ctx);
+
 private:
 	ResourceWatcherEntity* m_pEntity;
 };
@@ -224,6 +226,8 @@ public:
 
     void ManipulateVersion(SpReqAnsContext<ResourceWatcherService_ManipulateVersion_Req, ResourceWatcherService_ManipulateVersion_Ans>::Pointer ctx);
 
+    void UninstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_UninstallThirdPartyProgram_Req, ResourceWatcherService_UninstallThirdPartyProgram_Ans>::Pointer ctx);
+
 
 	void OperateFile(
 		SpReqAnsContext<ResourceWatcherService_OperateFile_Req, 
@@ -254,19 +258,6 @@ public:
 
     void InstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_InstallThirdPartyProgram_Req, ResourceWatcherService_InstallThirdPartyProgram_Ans>::Pointer ctx);
 
-	/*void OnSysVarEvent(const char* pszKey, const char* pszValue, const char* pszOldValue, const char* pszEntityName)
-	{
-		Dbg("OnSysVarEvent pszKey = %s, pszValue = %s", pszKey, pszValue);
-		if ((_strnicmp(pszKey, "UIState", strlen("UIState")) == 0))
-		{
-			if (_strnicmp(pszValue, "M", strlen("M")) == 0)
-			{
-				m_fsm.DeleteVersionPackage();
-			}
-		}
-
-	}*/
-
 	virtual void OnSysVarEvent(const char* pszKey, const char* pszValue, const char* pszOldValue, const char* pszEntityName);
 
 #if defined(_MSC_VER)
@@ -306,8 +297,6 @@ private:
 				/** 让进入首页之后才获取输入法信息 [Gifur@20211212]*/
 				if(/*TRUE || */err == Error_Succeed && strState == "M") {
 
-					//m_fsm.DeleteVersionPackage();
-
 					Dbg("to check Sogou input install state...");
 					if(Error_Succeed == DoCheckInstallStateJob()) {
 						GetFunction()->KillTimer(ENT_TIMERID_CHECK_SOGOU_INPUT_INSTALLED_STATE);
@@ -330,6 +319,9 @@ private:
 
 		std::vector<std::string> GetUserNameList(bool bExcludeRoot = false);
 
+		ErrorCodeEnum GetSogouPkgDirPath(CSimpleStringA& strPkgPath);
+		ErrorCodeEnum RunShellScript(LPCTSTR cmdline);
+
 private:
 	ResourceWatcherFSM m_fsm;
 	CUUID m_uiCardSwiperStatusListener;

+ 2 - 2
Module/mod_healthmanager/mod_healthmanager.cpp

@@ -3205,7 +3205,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
                 ResourceWatcherService_GetThirdPartyInstallState_Ans ans = {};
 				req.mode = 1;
 				Dbg("to invoke...");
-				tmpResult = pClient->GetThirdPartyInstallState(req, ans, 10000);
+				tmpResult = pClient->GetThirdPartyInstallState(req, ans, 30000);
                 if (tmpResult != 0) {
                     tmpMsg = CSimpleStringA::Format("获取安装状态请求失败: %s", SpStrError((ErrorCodeEnum)tmpResult));
                     Dbg(tmpMsg);
@@ -3273,7 +3273,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
                 ResourceWatcherService_GetThirdPartyInstallState_Ans ans = {};
                 req.mode = 2;
                 Dbg("to invoke...");
-                tmpResult = pClient->GetThirdPartyInstallState(req, ans, 10000);
+                tmpResult = pClient->GetThirdPartyInstallState(req, ans, 30000);
                 if (tmpResult != 0) {
                     tmpMsg = CSimpleStringA::Format("获取安装状态请求失败: %s", SpStrError((ErrorCodeEnum)tmpResult));
                     Dbg(tmpMsg);

+ 13 - 6
addin/res/ManagerDesktop/guide.html

@@ -189,14 +189,21 @@
                                 安装成功!
                             </div>
                         </div>
-                        <div class="clearboth" align="center" style="padding-top:80px;">
-                            <div id="guide_sogou_install_next" style="position: relative;"
-                                class="btn_normal_long hide" onclick="">下一步
-                            </div>
-                            <div id="guide_sogou_install_start" style="position: relative;"
-                                class="btn_normal_long hide" onclick="">安装
+                        <div align="center" id="guide_sogou_install_unsuccessful_div"  class=" hide" style="padding-top:100px;width:570px;padding-left:240px;">
+                            <div class="pull-left ic_warning clearboth"></div>
+                            <div class="pull-left text-left" id="guide_sogou_install_unsuccessful_content" style="width:540px;padding-top:2px;">
+                                检测到输入法已安装!但相关服务进程未启动或异常,请重启设备或卸载重新安装输入法!
                             </div>
                         </div>
+                        <div class="clearboth" align="center" style="padding-top:80px;">
+                            <div class="controls_short" style="margin-left: 100px;">
+                                <button class="btn_normal_short"
+                                id="guide_sogou_install_start">安装</button></div>
+                        <div class="controls_short"><button class="btn_normal_short"
+                            id="guide_sogou_uninstall_start">卸载</button></div>
+                            <div class="controls_short"><button class="btn_normal_short"
+                                id="guide_sogou_install_next">下一步</button></div>
+                        </div>
                     </div>
                     <div class="guide_table_bottom">&nbsp;</div>
                 </div>

+ 133 - 23
addin/res/ManagerDesktop/js/guide.js

@@ -53,7 +53,7 @@ var CENTERSETTING_URL = {
     DEV : '',
     ST : 'http://centerconfig.paasst.cmbchina.cn',
     UAT : '',
-    PRD : 'https://centerconfig.paas.cmbchina.com' 
+    PRD : 'https://centerconfig.paas.cmbchina.cn' 
 }
 
 function DisplayVendorFriendName(abbr)
@@ -85,6 +85,8 @@ var globalServerUsingHeadOffice = true;
 var adapterTestFailedCount = 0;
 var apdaterTestAllBefore = 0;
 
+var globalSogouNewInstall = false;
+
 
 function clearAdapterSelectedValue()
 {
@@ -1448,22 +1450,42 @@ $(function () {
     
     function SogouInstallStateSwitch(installState)
     {
-        if(installState === 0) {
+        if(installState === 0) {//未安装
             $('#guide_sogou_installed_div').hide();
             $('#guide_sogou_noinstall_div').show();
-            $('#guide_sogou_install_next').hide();
-            $('#guide_sogou_install_start').show();
-        } else if(installState === 1) {
+            $('#guide_sogou_install_finished_div').hide();
+            $('#guide_sogou_install_unsuccessful_div').hide();
+
+            setBtnStatus(false, 'guide_sogou_install_next');
+            setBtnStatus(true, 'guide_sogou_install_start');
+            setBtnStatus(false, 'guide_sogou_uninstall_start');
+        } else if(installState === 1) {//已安装
             $('#guide_sogou_noinstall_div').hide();
             $('#guide_sogou_installed_div').show();
-            $('#guide_sogou_install_start').hide();
-            $('#guide_sogou_install_next').show();
-        } else if(installState === 2) {
+            $('#guide_sogou_install_finished_div').hide();
+            $('#guide_sogou_install_unsuccessful_div').hide();
+
+            setBtnStatus(false, 'guide_sogou_install_start');
+            setBtnStatus(true, 'guide_sogou_install_next');
+            setBtnStatus(true, 'guide_sogou_uninstall_start');
+        } else if(installState === 2) {//安装成功
             $('#guide_sogou_noinstall_div').hide();
             $('#guide_sogou_installed_div').hide();
-            $('#guide_sogou_install_start').hide();
-            $('#guide_sogou_install_next').show();
+            $('#guide_sogou_install_unsuccessful_div').hide();
             $('#guide_sogou_install_finished_div').show();
+
+            setBtnStatus(false, 'guide_sogou_install_start');
+            setBtnStatus(true, 'guide_sogou_install_next');
+            setBtnStatus(true, 'guide_sogou_uninstall_start');
+        } else if(installState === 3) {//安装成功,但是启动不成功,需要重启
+            $('#guide_sogou_noinstall_div').hide();
+            $('#guide_sogou_installed_div').hide();
+            $('#guide_sogou_install_unsuccessful_div').show();
+            $('#guide_sogou_install_finished_div').hide();
+
+            setBtnStatus(false, 'guide_sogou_install_start');
+            setBtnStatus(false, 'guide_sogou_install_next');
+            setBtnStatus(true, 'guide_sogou_uninstall_start');
         }
     }
 
@@ -1507,7 +1529,7 @@ $(function () {
         let req = new Request();
         req.preStep = DeployStepChain.SogouInstall[preStepIndex];
         req.currStep = DeployStepChain.SogouInstall[curStepIndex];
-        req.nextStep = DeployStepChain.SogouInstall[nextStepIndex];
+        req.nextStep = DeployStepChain.SogouInstall[curStepIndex];
         req.param1 = 0;
         req.param2 = 0;
         req.param3 = '';
@@ -1527,13 +1549,37 @@ $(function () {
             if(ret.errorCode === 0) {
                 let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
                 if(result.result == 0) {
-                    SogouInstallStateSwitch(2);
+                    
                     var tip = '安装成功!';
+                    var sogouversion = '';
+                    var sogouinstalltm = '';
                     if(result.array2.length === 3) {
-                        tip += '<br><br>版本:<strong>' + result.array2[0] + '</strong>';
-                        tip += '<br>安装时间:<strong>' + result.array2[2] + '</strong>';
+                        sogouversion = result.array2[0];
+                        sogouinstalltm = result.array2[2];
+                    }
+                    if(sogouversion !== '') {
+                        tip += '<br><br>版本:<strong>' + sogouversion + '</strong>';
+                        tip += '<br>安装时间:<strong>' + sogouinstalltm + '</strong>';
+                        $('#guide_sogou_install_finished_content').html(tip);
+                        SogouInstallStateSwitch(2);
+                    } else if(sogouinstalltm != '') {
+                        tip += '<br><br>版本:<strong style="color:#FF0000;">' + '无法获取版本信息' + '</strong>';
+                        tip += '<br>安装时间:<strong>' + sogouinstalltm + '</strong>';
+                        $('#guide_sogou_install_unsuccessful_content').html(tip);
+                        SogouInstallStateSwitch(3);
+                        utilStartConfirmDialog('安装成功!输入法服务需重启设备生效,是否立即重启设备?', function() {
+                            RVC.HealthmanagerEntityCtrl.RestartPC(true);
+                            RVC.GuideController.hideAllPage();
+                            RVC.GuideController.hideAllRebootTipElem();
+                            $('#guide_reboot_loading').show();
+                            $('#guide_reboot_page').show(); 
+                        }, function() {
+                            setBtnStatus(true, 'guide_sogou_install_next');
+                            globalSogouNewInstall = true;
+                        }, '立即重启', '稍后处理');
+                    } else {
+                        $('#guide_sogou_install_finished_content').html(tip);
                     }
-                    $('#guide_sogou_install_finished_content').html(tip);
                 } else {
                     utilStartAlertDialog("安装失败:[" + result.result + "] " + result.additionalMsg);
                 }
@@ -1543,6 +1589,33 @@ $(function () {
         });
     }
 
+    function UninstallSogouInput()
+    {
+        let req = new Request();
+        req.type = 1; //搜狗输入法
+        req.reserved1 = 0;
+        req.reserved2 = 0;
+        req.timeout = 65000;
+
+        utilStartSubmitDialog();
+        RVC.ResourceWatcherEntity.UninstallThirdPartyProgram(req, function(ret) {
+            utilStopSubmitDialog();
+            if(ret.errorCode === 0) {
+                let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
+                if(result.result == 0) {
+                    utilStartAlertDialog('卸载成功!', function() {
+                        globalSogouNewInstall = false;
+                        DisplaySogouInstallState();
+                    });
+                } else {
+                    utilStartAlertDialog("卸载失败:[" + result.result + "] " + result.msg);
+                }
+            } else {
+                RVC.ResourceWatcherEntity.commErrorCallback(ret);
+            }
+        });
+    }
+
     function DisplayFontInstallState()
     {
         let req = new Request();
@@ -1596,19 +1669,35 @@ $(function () {
         req.additional = 0;
         req.restartApp = false;
         req.restartPC = false;
-
+        req.timeout = 35000;
+        utilStartSubmitDialog();
         RVC.HealthmanagerEntityCtrl.DeployTerminal(req, function(ret) {
+            utilStopSubmitDialog();
             if(ret.errorCode === 0) {
                 let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
                 if(result.result == 0) {
                     if(result.param1 === 1) {
-                        SogouInstallStateSwitch(1);
                         var tip = '检测到输入法已安装!';
+                        var sogouversion = '';
+                        var sogouinstalltm = '';
                         if(result.array2.length === 3) {
-                            tip += '<br><br>版本:<strong>' + result.array2[0] + '</strong>';
-                            tip += '<br>安装时间:<strong>' + result.array2[2] + '</strong>';
+                            sogouversion = result.array2[0];
+                            sogouinstalltm = result.array2[2];
+                        }
+                        if(sogouversion !== '') {
+                            tip += '<br><br>版本:<strong>' + sogouversion + '</strong>';
+                            tip += '<br>安装时间:<strong>' + sogouinstalltm + '</strong>';
+                            SogouInstallStateSwitch(1);
+                            $('#guide_sogou_installed_content').html(tip);
+                        } else if(sogouinstalltm != ''){
+                            tip = '检测到输入法已安装!但相关服务进程未启动或异常,请优先重启设备,如果重启后仍出现问题,请点击下方<strong>卸载</strong>菜单后重装!'
+                            tip += '<br><br>版本:<strong style="color:#FF0000;">' + '无法获取版本信息' + '</strong>';
+                            tip += '<br>安装时间:<strong>' + sogouinstalltm + '</strong>';
+                            SogouInstallStateSwitch(3);
+                            $('#guide_sogou_install_unsuccessful_content').html(tip);
+                        } else {
+                            $('#guide_sogou_installed_content').html(tip);
                         }
-                        $('#guide_sogou_installed_content').html(tip);
                         console.log(tip);
                     } else {
                         SogouInstallStateSwitch(0);
@@ -1787,6 +1876,7 @@ $(function () {
                     }
                     break;
                 case DEPLOY.DeployStep_3rdParty_SogouInstall:
+                    globalSogouNewInstall = false;
                     DisplaySogouInstallState();
                     break;
                 case DEPLOY.DeployStep_3rdParty_FontInstall:
@@ -2013,16 +2103,36 @@ $(function () {
     });
 
     $(document).on('click', '#guide_sogou_install_next', function() {
-        RVC.GuideController.gotoPage(DEPLOY.DeployStep_GetTerminalInfo);
+        if(isButtonEnable('guide_sogou_install_next')) {
+            if(globalSogouNewInstall) {
+                utilStartAlertDialog('系统检测到安装输入法后未重启设备,请务必在后续业务中验证输入法功能前重启一次设备!', function(){
+                    RVC.GuideController.gotoPage(DEPLOY.DeployStep_GetTerminalInfo);
+                });
+            } else {
+                RVC.GuideController.gotoPage(DEPLOY.DeployStep_GetTerminalInfo);
+            }
+        }
     });
 
     $(document).on('click', '#guide_sogou_install_start', function() {
-        InstallSogouInput();
+        if(isButtonEnable('guide_sogou_install_start')) {
+            InstallSogouInput();
+        }
+    });
+
+    $(document).on('click', '#guide_sogou_uninstall_start', function() {
+        if(isButtonEnable('guide_sogou_uninstall_start')) {
+            utilStartConfirmDialog('确定要卸载当前输入法?', function() {
+                UninstallSogouInput();
+            })
+        }
     });
 
     //字体安装按钮
     $(document).on('click', '#guide_font_confirm_install', function() {
-        InstallSpecifiesFont();
+        if(isButtonEnable('guide_font_confirm_install')) {
+            InstallSpecifiesFont();
+        }
     });
 
     //字体安装页面下一步按钮

+ 1 - 1
addin/res/ManagerDesktop/js/page/networkdetect.js

@@ -35,7 +35,7 @@ function networkdetectGenPage() {
             <div class="clearboth" style="padding-top:70px"></div> \
             <div class="clearboth" style="display: block;">\
             <div class="clearboth wps_connect_way_title">常用地址参考:</div>\
-            <div style="margin-top: 10px; display: block;"><div class="control-label" style="margin-top: 8px;">集中配置微服务地址:</div><div class="controls" style="margin-top: 10px;"><div>https://centerconfig.paas.cmbchina.com/api/terminal/center/config</div></div></div>\
+            <div style="margin-top: 10px; display: block;"><div class="control-label" style="margin-top: 8px;">集中配置微服务地址:</div><div class="controls" style="margin-top: 10px;"><div>https://centerconfig.paas.cmbchina.cn/api/terminal/center/config</div></div></div>\
             </div>\
             <div class="clearboth" style="display: block;">\
             <div style="margin-top: 40px; display: block;"><div class="control-label" style="margin-top: 8px;">终端信息查询地址:</div><div class="controls" style="margin-top: 10px;"><div>https://rvcgateway.paas.cmbchina.cn</div></div></div>\

+ 3 - 8
addin/res/ManagerDesktop/js/public.js

@@ -2366,20 +2366,15 @@ $(function () {
             ManipulateVersion:-313717631,
             UninstallThirdPartyProgram:-2137706699
         },
-
         GetNetworkInfo: function(req, callback) {
             this.webSocketInvokeEx(req, 
                 ({id:this.methodID.GetNetworkInfo, sig:this.methodSignature.GetNetworkInfo}),
                  callback);
         },
         UpdateDNS: function(req, callback) {
-            req.entity = this.entityName;
-            req.class = this.className;
-            req.methodID = this.methodID.UpdateDNS;
-            req.signature = this.methodSignature.UpdateDNS;
-
-            this.webSocketInvoke(req, callback);
-
+            this.webSocketInvokeEx(req, 
+                ({id:this.methodID.UpdateDNS, sig:this.methodSignature.UpdateDNS}),
+                 callback);
         },
         GetThirdPartyInstallState: function(req, callback) {
             this.webSocketInvokeEx(req, 

+ 0 - 1
addin/res/RunScript/install_sogouime.sh

@@ -4,7 +4,6 @@ MY_PATH="`dirname \"$0\"`"              # relative
 MY_PATH="`( cd \"$MY_PATH\" && pwd )`"  # absolutized and normalized
 
 echo "[SOGOULOG] === Install Start === "
-echo "${MY_PATH}" > $MY_PATH/result.log
 echo "result=-1&msg=install begin ---------" > $MY_PATH/result.log
 
 bash $MY_PATH/shutdown_service.sh