瀏覽代碼

Merge branch 'master' into uat

gifur 3 年之前
父節點
當前提交
a4a986d3e6
共有 36 個文件被更改,包括 2122 次插入174 次删除
  1. 2 2
      CMakeLists.txt
  2. 9 0
      ChangeLog.in
  3. 1 1
      Module/include/DevEntityCommBase.hpp
  4. 6 4
      Module/include/DevFSMCommBase.hpp
  5. 2 0
      Module/include/EventCode.h
  6. 10 0
      Module/mod_ResourceWatcher/CMakeLists.txt
  7. 77 0
      Module/mod_ResourceWatcher/ResourceWatcher.xml
  8. 15 11
      Module/mod_ResourceWatcher/ResourceWatcherFSM.cpp
  9. 1 1
      Module/mod_ResourceWatcher/ResourceWatcherFSM.h
  10. 124 0
      Module/mod_ResourceWatcher/ResourceWatcher_client_g.h
  11. 146 26
      Module/mod_ResourceWatcher/ResourceWatcher_def_g.h
  12. 17 0
      Module/mod_ResourceWatcher/ResourceWatcher_msg_g.h
  13. 104 0
      Module/mod_ResourceWatcher/ResourceWatcher_server_g.h
  14. 699 0
      Module/mod_ResourceWatcher/XUnZipZilb.cpp
  15. 90 0
      Module/mod_ResourceWatcher/XUnZipZilb.h
  16. 498 17
      Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp
  17. 24 0
      Module/mod_ResourceWatcher/mod_ResourceWatcher.h
  18. 1 1
      Module/mod_UpgradeMgr/UpgradeTaskFSM.cpp
  19. 29 19
      Module/mod_cardissuer/CardIssuerFSM.cpp
  20. 1 1
      Module/mod_cardissuer/CardIssuer_UserErrorCode.h
  21. 27 13
      Module/mod_chromium/CModTools.cpp
  22. 5 1
      Module/mod_chromium/CModTools.h
  23. 1 1
      Module/mod_chromium/CSocketClient.cpp
  24. 7 0
      Module/mod_chromium/CStructureInterpreter.cpp
  25. 3 0
      Module/mod_chromium/CStructureInterpreter.h
  26. 20 16
      Module/mod_chromium/CWSCodec.cpp
  27. 2 0
      Module/mod_chromium/CWSCodec.h
  28. 24 36
      Module/mod_chromium/CWebsocketServer.cpp
  29. 9 2
      Module/mod_chromium/baseEx.cpp
  30. 3 1
      Module/mod_chromium/baseEx.h
  31. 66 13
      Module/mod_chromium/mod_chromium.cpp
  32. 12 3
      Module/mod_chromium/mod_chromium.h
  33. 4 0
      Module/mod_healthmanager/mod_healthmanager.cpp
  34. 57 2
      addin/res/ManagerDesktop/js/page/browser.js
  35. 20 2
      addin/res/ManagerDesktop/js/public.js
  36. 6 1
      addin/res/ManagerDesktop/prototype/browser.html

+ 2 - 2
CMakeLists.txt

@@ -92,7 +92,7 @@ endif($ENV{PIPELINE_BUILD_ID})
 # stable 稳定版本
 
 #Set the project(terminal) version
-set(RAW_VERSION_STRING "0.2.14-beta1")
+set(RAW_VERSION_STRING "0.3.0-beta1")
 string(STRIP ${RAW_VERSION_STRING} RAW_VERSION_STRING)
 
 set(VERSION_REGEX "^.?([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)")
@@ -242,7 +242,7 @@ if(CONAN_CACHE_CLEAR)
 	conan_local_remove()
 endif(CONAN_CACHE_CLEAR)
 
-conan_cmake_run(REQUIRES RvcFramework/1.0.8-dev2@LR04.02_FrameworkLib/testing
+conan_cmake_run(REQUIRES RvcFramework/1.0.8-dev3@LR04.02_FrameworkLib/testing
 	Audio/2022.0628.01@LR04.02_MediaRes/testing
 	Video/2022.0622.01@LR04.02_MediaRes/testing
 BASIC_SETUP CMAKE_TARGETS)

+ 9 - 0
ChangeLog.in

@@ -2,6 +2,15 @@
 
 *Last Built Day: @BUILD_DATE_STRING@*
 
+## V0.3.0
+* [Feature]新debian安装包
+* [Feature]支持屏幕信息快照内容的获取
+
+## V0.2.15
+* [Feature] 支持业务端重启和重装搜狗输入法
+* [Feature][Chromium] 同步Windows版本功能,优化不支持Service类型的实体的重复连接逻辑
+* [Feature][Framework] Release版本移除左上角弹窗的显示
+
 ## V0.2.14
 
 * [Feature][BugFix] 框架支持互联网化二次上线,同步更新cJSON库文件

+ 1 - 1
Module/include/DevEntityCommBase.hpp

@@ -273,7 +273,7 @@ inline void CDevAdptEntityBase::InitializeVendorLogSwitch()
             GetFunction()->GetEntityStaticInfo(GetEntityName(), staticInfo);
             DWORD dwUsrCode = fromLocal ? 0xFFFEE : 0xFFFEF;
             dwUsrCode |= (staticInfo.wEntityDevelopID << 20);
-            LogWarn(Severity_Middle, Error_Debug, dwUsrCode,
+            LogWarn(Severity_Low, Error_Debug, dwUsrCode,
                     CSimpleStringA::Format("{\"RecordLevel\":\"%s\", \"RecordType\":\"%s\", \"DeterminedBy\":\"%s\"}",
                                            stLogConfig.strLevel.GetData(),
                                            stLogConfig.strType.GetData(),

+ 6 - 4
Module/include/DevFSMCommBase.hpp

@@ -696,10 +696,12 @@ inline void CCommDevFSM<TFSM, TDevClass>::LogErrMsgEx(ErrorPackage errPkg, const
 	const CSimpleStringA alarmMsg = CSimpleStringA::Format("{\"DevSN\":\"%s\", \"Prefix\":\"%s\", \"Code\":\"%s\", \"Msg\":\"%s\"}"
                            , errPkg.devSN.GetData(), errPkg.msgHead.GetData(), SpStrError(errPkg.devErrCode), pMsgBody);
 
-	if (bToBusiness)
-		LogError(Severity_High, errPkg.devErrCode, finalErrCode, alarmMsg.GetData());
-	else
-		LogWarn(Severity_High, errPkg.devErrCode, finalErrCode, alarmMsg.GetData());
+	if (bToBusiness) {
+        LogError(Severity_High, errPkg.devErrCode, finalErrCode, alarmMsg.GetData());
+    }
+	else {
+        LogWarn(Severity_High, errPkg.devErrCode, finalErrCode, alarmMsg.GetData());
+	}
 
 	return;
 }

+ 2 - 0
Module/include/EventCode.h

@@ -886,6 +886,8 @@ ERROR_ACCESSAUTH_CONNECT_ACS}
 #define LOG_WARN_DELETE_DNS_CUST	0x50A00033
 #define LOG_ERR_DELETE_DNS_FAILED	0x50A00034
 #define LOG_INFO_MONITOR_SETTINGS	0x50A00035
+#define LOG_INFO_MONITOR_SETTINGS_GET	0x50A00036
+
 
 #define LOG_WARN_VER_DELETE	0x50A00040
 

+ 10 - 0
Module/mod_ResourceWatcher/CMakeLists.txt

@@ -18,6 +18,8 @@ set(${MODULE_PREFIX}_SRCS
     EventLogW.cpp
     mod_ResourceWatcher.cpp
     ResourceWatcherFSM.cpp
+    XUnZipZilb.cpp
+	XUnZipZilb.h
 )
 
 else()
@@ -34,6 +36,8 @@ set(${MODULE_PREFIX}_SRCS
 
     mod_ResourceWatcher.cpp
     ResourceWatcherFSM.cpp
+    XUnZipZilb.cpp
+	XUnZipZilb.h
 )
 
 endif(MSVC)
@@ -56,6 +60,12 @@ target_include_directories(${MODULE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
     ${OTHER_LIB_BASE_DIR}/libpublicFun
     ${CONAN_INCLUDE_DIRS_SOGOULIB}
     ${OTHER_LIB_BASE_DIR}/libRestfulFunc
+    ${CONAN_INCLUDE_DIRS_ZLIB}
 )
+target_link_directories(${MODULE_NAME} PRIVATE ${CONAN_LIB_DIRS_ZLIB})
 
+# 添加实体需要依赖的其他共享库(包括系统库):连接器包含的包
+set(${MODULE_PREFIX}_LIBS ${MODULE_BASE_ALL_LIBS} ${CONAN_PKG_LIBS_ZLIB})
+
+target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})  
 deploy_module(${MODULE_PREFIX} ${MODULE_NAME})

+ 77 - 0
Module/mod_ResourceWatcher/ResourceWatcher.xml

@@ -231,6 +231,8 @@
       <req>
         <!---1: 搜狗输入法-->
         <param name="mode" type="int" />
+		<param name="reserved1" type="int" />
+		<param name="reserved2" type="int" />
       </req>
       <res>
         <!--1:已安装-->
@@ -247,6 +249,8 @@
       <req>
         <!---1: 搜狗输入法-->
         <param name="type" type="int" />
+		<param name="reserved1" type="int" />
+		<param name="reserved2" type="int" />
       </req>
       <res>
         <param name="result" type="int" />
@@ -302,6 +306,69 @@
         <param name="reserverd2" type="string"/>
       </res>
     </twoway>
+
+		<!--第三方软件手工启动接口-->
+		<twoway  name="RestartThirdPartyProgram" overlap="true">
+			<req>
+				<!---1: 搜狗输入法-->
+				<param name="type" type="int" />
+				<param name="reserved1" type="int" />
+				<param name="reserved2" type="int" />
+			</req>
+			<res>
+				<param name="result" type="int" />
+				<param name="msg" type="string"/>
+				<param name="reserverd1" type="string"/>
+				<param name="reserverd2" type="string"/>
+			</res>
+		</twoway>
+
+		<!--第三方软件进程检测接口-->
+		<twoway  name="ProcessDetectThirdPartyProgram" overlap="true">
+			<req>
+				<!---1: 搜狗输入法-->
+				<param name="type" type="int" />
+				<param name="reserved1" type="int" />
+				<param name="reserved2" type="int" />
+			</req>
+			<res>
+				<param name="result" type="int" />
+				<param name="msg" type="string"/>
+				<param name="reserverd1" type="string"/>
+				<param name="reserverd2" type="string"/>
+			</res>
+		</twoway>
+
+		<!--文件清理接口-->
+		<twoway  name="FilesClean" overlap="true">
+			<req>
+				<!---1: 浏览器缓存清理-->
+				<param name="type" type="int" />
+				<param name="reserved1" type="int" />
+				<param name="reserved2" type="int" />
+			</req>
+			<res>
+				<param name="result" type="int" />
+				<param name="msg" type="string"/>
+				<param name="reserverd1" type="string"/>
+				<param name="reserverd2" type="string"/>
+			</res>
+		</twoway>
+    <!--获取系统信息-->
+    <twoway  name="FetchSystemSnapshot" overlap="true">
+      <req>
+        <!---1: 获取屏幕信息-->
+        <param name="type" type="int" />
+        <param name="reserved1" type="int" />
+        <param name="reserved2" type="int" />
+      </req>
+      <res>
+        <param name="result" type="int" />
+        <param name="msg" type="string"/>
+        <param name="reserverd1" type="string"/>
+        <param name="reserverd2" type="string"/>
+      </res>
+    </twoway>
 	</class>
 	<message name="QueryCardSwiper">
 			<param name="status" type = "int" />	
@@ -316,4 +383,14 @@
 		<!--预留参数-->
 		<param name="reversed2" type="string"/>
 	</message>
+
+	<!--缓存清理-->
+	<message name="BrowserCacheClean">
+		<!--0:不清理,1:进行清理,其他值用于后续备用-->
+		<param name="needClean" type="int"/>
+		<!--预留参数-->
+		<param name="reversed1" type="int"/>
+		<!--预留参数-->
+		<param name="reversed2" type="string"/>
+	</message>
 </entity>

+ 15 - 11
Module/mod_ResourceWatcher/ResourceWatcherFSM.cpp

@@ -432,6 +432,18 @@ void ResourceWatcherFSM::s3_on_exit()
     m_bVideoClearReady = false;
 }
 
+bool ResourceWatcherFSM::GetMonitorInfo(CSimpleStringA& outInfo)
+{
+    std::string sucContent, failedContent;
+    CSimpleStringA strCmd("xrandr | grep \" connected\" | sed -e \"s/\([A-Z0-9]\+\) connected.*/\1/\"");
+    bool ret = SP::Module::Util::ShellExecute(strCmd.GetData(), sucContent, failedContent);
+    Dbg("{%s}:{%s}{%s}", strCmd.GetData(), sucContent.c_str(), failedContent.c_str());
+    std::string msg = SP::Utility::ToTrim(sucContent);
+    SP::Utility::replaceInPlace(msg, "\n", "|");
+    outInfo = msg.c_str();
+    return ret;
+}
+
 void ResourceWatcherFSM::readVideoStoreData()
 {
     LOG_FUNCTION();
@@ -3944,13 +3956,9 @@ BOOL ResourceWatcherFSM::SetDefaultAudioDevice()
 
 void ResourceWatcherFSM::UploadMonitorSettings()
 {
-    std::string sucContent, failedContent;
-    CSimpleStringA strCmd("xrandr | grep \" connected\" | sed -e \"s/\([A-Z0-9]\+\) connected.*/\1/\"");
-    bool ret = SP::Module::Util::ShellExecute(strCmd.GetData(), sucContent, failedContent);
-    Dbg("{%s}:{%s}{%s}", strCmd.GetData(), sucContent.c_str(), failedContent.c_str());
-    std::string msg = SP::Utility::ToTrim(sucContent);
-    SP::Utility::replaceInPlace(msg, "\n", "|");
-    LogWarn(Severity_Middle, Error_Debug, LOG_INFO_MONITOR_SETTINGS, msg.c_str());
+    CSimpleStringA value(true);
+    bool res = GetMonitorInfo(value);
+    LogWarn(Severity_Low, Error_Debug, LOG_INFO_MONITOR_SETTINGS, value);
 }
 
 
@@ -4373,10 +4381,6 @@ void ResourceWatcherFSM::GetMainLinkStatus()
     {
         Dbg("Main Link disconnected [%s].", mainLink);
     }
-    else
-    {
-        Dbg("Main Link is connected [%s].", mainLink);
-    }
     
     mainDetect.mainLinkStatus = curStatus;
     mainDetect.reversed1 = 0;

+ 1 - 1
Module/mod_ResourceWatcher/ResourceWatcherFSM.h

@@ -266,9 +266,9 @@ public:
     }
 
     void UploadMonitorSettings();
+    bool GetMonitorInfo(CSimpleStringA& outInfo);
 
 private:
-
 	void readVideoStoreData();
 
 private:

+ 124 - 0
Module/mod_ResourceWatcher/ResourceWatcher_client_g.h

@@ -555,6 +555,130 @@ public:
 		return Error;
 	}
 
+	ErrorCodeEnum RestartThirdPartyProgram(ResourceWatcherService_RestartThirdPartyProgram_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		auto ret = pFunc->AsyncRequest(ResourceWatcherService_Method_RestartThirdPartyProgram, ResourceWatcherService_MethodSignature_RestartThirdPartyProgram, Buf, spAsyncWait, m_context, dwTimeout);
+		m_context.clear();
+		return ret;
+	}
+	ErrorCodeEnum RestartThirdPartyProgram(ResourceWatcherService_RestartThirdPartyProgram_Req &Req, ResourceWatcherService_RestartThirdPartyProgram_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = RestartThirdPartyProgram(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum RestartThirdPartyProgram(ResourceWatcherService_RestartThirdPartyProgram_Req &Req, ResourceWatcherService_RestartThirdPartyProgram_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = RestartThirdPartyProgram(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
+	ErrorCodeEnum ProcessDetectThirdPartyProgram(ResourceWatcherService_ProcessDetectThirdPartyProgram_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		auto ret = pFunc->AsyncRequest(ResourceWatcherService_Method_ProcessDetectThirdPartyProgram, ResourceWatcherService_MethodSignature_ProcessDetectThirdPartyProgram, Buf, spAsyncWait, m_context, dwTimeout);
+		m_context.clear();
+		return ret;
+	}
+	ErrorCodeEnum ProcessDetectThirdPartyProgram(ResourceWatcherService_ProcessDetectThirdPartyProgram_Req &Req, ResourceWatcherService_ProcessDetectThirdPartyProgram_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = ProcessDetectThirdPartyProgram(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum ProcessDetectThirdPartyProgram(ResourceWatcherService_ProcessDetectThirdPartyProgram_Req &Req, ResourceWatcherService_ProcessDetectThirdPartyProgram_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = ProcessDetectThirdPartyProgram(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
+	ErrorCodeEnum FilesClean(ResourceWatcherService_FilesClean_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		auto ret = pFunc->AsyncRequest(ResourceWatcherService_Method_FilesClean, ResourceWatcherService_MethodSignature_FilesClean, Buf, spAsyncWait, m_context, dwTimeout);
+		m_context.clear();
+		return ret;
+	}
+	ErrorCodeEnum FilesClean(ResourceWatcherService_FilesClean_Req &Req, ResourceWatcherService_FilesClean_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = FilesClean(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum FilesClean(ResourceWatcherService_FilesClean_Req &Req, ResourceWatcherService_FilesClean_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = FilesClean(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
+	ErrorCodeEnum FetchSystemSnapshot(ResourceWatcherService_FetchSystemSnapshot_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		auto ret = pFunc->AsyncRequest(ResourceWatcherService_Method_FetchSystemSnapshot, ResourceWatcherService_MethodSignature_FetchSystemSnapshot, Buf, spAsyncWait, m_context, dwTimeout);
+		m_context.clear();
+		return ret;
+	}
+	ErrorCodeEnum FetchSystemSnapshot(ResourceWatcherService_FetchSystemSnapshot_Req &Req, ResourceWatcherService_FetchSystemSnapshot_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = FetchSystemSnapshot(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum FetchSystemSnapshot(ResourceWatcherService_FetchSystemSnapshot_Req &Req, ResourceWatcherService_FetchSystemSnapshot_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = FetchSystemSnapshot(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
 
 	bool SafeDelete()
 	{

+ 146 - 26
Module/mod_ResourceWatcher/ResourceWatcher_def_g.h

@@ -28,6 +28,10 @@ namespace ResourceWatcher {
 #define ResourceWatcherService_Method_GetTerminalVersionList 12
 #define ResourceWatcherService_Method_ManipulateVersion 13
 #define ResourceWatcherService_Method_UninstallThirdPartyProgram 14
+#define ResourceWatcherService_Method_RestartThirdPartyProgram 15
+#define ResourceWatcherService_Method_ProcessDetectThirdPartyProgram 16
+#define ResourceWatcherService_Method_FilesClean 17
+#define ResourceWatcherService_Method_FetchSystemSnapshot 18
 
 #define ResourceWatcherService_MethodSignature_Fetch -1944912560
 #define ResourceWatcherService_MethodSignature_GetDevInfo 296205965
@@ -45,6 +49,10 @@ namespace ResourceWatcher {
 #define ResourceWatcherService_MethodSignature_GetTerminalVersionList -504582702
 #define ResourceWatcherService_MethodSignature_ManipulateVersion -313717631
 #define ResourceWatcherService_MethodSignature_UninstallThirdPartyProgram -2137706699
+#define ResourceWatcherService_MethodSignature_RestartThirdPartyProgram -534704262
+#define ResourceWatcherService_MethodSignature_ProcessDetectThirdPartyProgram -1692430185
+#define ResourceWatcherService_MethodSignature_FilesClean 624348486
+#define ResourceWatcherService_MethodSignature_FetchSystemSnapshot -1005346345
 
 struct ResourceWatcherService_Fetch_Req
 {
@@ -157,28 +165,28 @@ struct ResourceWatcherService_OperateFile_Req
 
 struct ResourceWatcherService_OperateFile_Ans
 {
-	int result;
-	CSimpleStringA header;
-	int attachment1;
-	CSimpleStringA attachment2;
-	u__int64_t fileSize;
-	u__int64_t ftCreate;
-	u__int64_t ftModified;
-	u__int64_t ftAccess;
-	unsigned int fileAttribute;
-	unsigned int forbidAttribute;
-	int reversed1;
-	CSimpleStringA reversed2;
-	int count;
-	CAutoArray<CSimpleStringA> fileNames;
-	CAutoArray<u__int64_t> fileSizes;
-	CAutoArray<u__int64_t> ftCreates;
-	CAutoArray<u__int64_t> ftModifieds;
-	CAutoArray<u__int64_t> ftAccesses;
-	CAutoArray<unsigned int> fileAttributes;
-	CAutoArray<unsigned int> forbidAttributes;
-	CAutoArray<int> reserved1;
-	CAutoArray<CSimpleStringA> reserved2;
+    int result;
+    CSimpleStringA header;
+    int attachment1;
+    CSimpleStringA attachment2;
+    u__int64_t fileSize;
+    u__int64_t ftCreate;
+    u__int64_t ftModified;
+    u__int64_t ftAccess;
+    unsigned int fileAttribute;
+    unsigned int forbidAttribute;
+    int reversed1;
+    CSimpleStringA reversed2;
+    int count;
+    CAutoArray<CSimpleStringA> fileNames;
+    CAutoArray<u__int64_t> fileSizes;
+    CAutoArray<u__int64_t> ftCreates;
+    CAutoArray<u__int64_t> ftModifieds;
+    CAutoArray<u__int64_t> ftAccesses;
+    CAutoArray<unsigned int> fileAttributes;
+    CAutoArray<unsigned int> forbidAttributes;
+    CAutoArray<int> reserved1;
+    CAutoArray<CSimpleStringA> reserved2;
 
 	void Serialize(SpBuffer &Buf)
 	{
@@ -192,8 +200,8 @@ struct ResourceWatcherService_ExtractEventLog_Req
 	unsigned short evtName;
 	unsigned short evtLevel;
 	unsigned short duration;
-	u__int64_t startTime;
-	u__int64_t endTime;
+    u__int64_t startTime;
+    u__int64_t endTime;
 	CSimpleStringA cusEvtFileName;
 	CSimpleStringA evtSrcEventName;
 	int reversed1;
@@ -350,10 +358,12 @@ struct ResourceWatcherService_GetNetworkInfo_Ans
 struct ResourceWatcherService_GetThirdPartyInstallState_Req
 {
 	int mode;
+	int reserved1;
+	int reserved2;
 
 	void Serialize(SpBuffer &Buf)
 	{
-		auto & buf = Buf & mode;
+		auto & buf = Buf & mode & reserved1 & reserved2;
 	}
 
 };
@@ -378,10 +388,12 @@ struct ResourceWatcherService_GetThirdPartyInstallState_Ans
 struct ResourceWatcherService_InstallThirdPartyProgram_Req
 {
 	int type;
+	int reserved1;
+	int reserved2;
 
 	void Serialize(SpBuffer &Buf)
 	{
-		auto & buf = Buf & type;
+		auto & buf = Buf & type & reserved1 & reserved2;
 	}
 
 };
@@ -487,6 +499,114 @@ struct ResourceWatcherService_UninstallThirdPartyProgram_Ans
 
 };
 
+struct ResourceWatcherService_RestartThirdPartyProgram_Req
+{
+	int type;
+	int reserved1;
+	int reserved2;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & type & reserved1 & reserved2;
+	}
+
+};
+
+struct ResourceWatcherService_RestartThirdPartyProgram_Ans
+{
+	int result;
+	CSimpleStringA msg;
+	CSimpleStringA reserverd1;
+	CSimpleStringA reserverd2;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & result & msg & reserverd1 & reserverd2;
+	}
+
+};
+
+struct ResourceWatcherService_ProcessDetectThirdPartyProgram_Req
+{
+	int type;
+	int reserved1;
+	int reserved2;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & type & reserved1 & reserved2;
+	}
+
+};
+
+struct ResourceWatcherService_ProcessDetectThirdPartyProgram_Ans
+{
+	int result;
+	CSimpleStringA msg;
+	CSimpleStringA reserverd1;
+	CSimpleStringA reserverd2;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & result & msg & reserverd1 & reserverd2;
+	}
+
+};
+
+struct ResourceWatcherService_FilesClean_Req
+{
+	int type;
+	int reserved1;
+	int reserved2;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & type & reserved1 & reserved2;
+	}
+
+};
+
+struct ResourceWatcherService_FilesClean_Ans
+{
+	int result;
+	CSimpleStringA msg;
+	CSimpleStringA reserverd1;
+	CSimpleStringA reserverd2;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & result & msg & reserverd1 & reserverd2;
+	}
+
+};
+
+struct ResourceWatcherService_FetchSystemSnapshot_Req
+{
+	int type;
+	int reserved1;
+	int reserved2;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & type & reserved1 & reserved2;
+	}
+
+};
+
+struct ResourceWatcherService_FetchSystemSnapshot_Ans
+{
+	int result;
+	CSimpleStringA msg;
+	CSimpleStringA reserverd1;
+	CSimpleStringA reserverd2;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & result & msg & reserverd1 & reserverd2;
+	}
+
+};
+
 
 ///////////////////////////
 

+ 17 - 0
Module/mod_ResourceWatcher/ResourceWatcher_msg_g.h

@@ -11,9 +11,11 @@
 namespace ResourceWatcher {
 #define eMsg_QueryCardSwiper 0
 #define eMsg_MainLinkDetect 1
+#define eMsg_BrowserCacheClean 2
 
 #define eMsgSig_QueryCardSwiper 690144769
 #define eMsgSig_MainLinkDetect 46828988
+#define eMsgSig_BrowserCacheClean 1728030659
 
 struct QueryCardSwiper
 {
@@ -43,5 +45,20 @@ struct MainLinkDetect
 
 ///////////////////////////
 
+struct BrowserCacheClean
+{
+	int needClean;
+	int reversed1;
+	CSimpleStringA reversed2;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & needClean & reversed1 & reversed2;
+	}
+
+};
+
+///////////////////////////
+
 } // namespace ResourceWatcher
 #endif // __RESOURCEWATCHER_MSG_G_H

+ 104 - 0
Module/mod_ResourceWatcher/ResourceWatcher_server_g.h

@@ -142,6 +142,34 @@ public:
 				Error = Error_MethodSignatureFailed;
 			}
 			break;
+		case ResourceWatcherService_Method_RestartThirdPartyProgram:
+			if (dwSignature == ResourceWatcherService_MethodSignature_RestartThirdPartyProgram) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case ResourceWatcherService_Method_ProcessDetectThirdPartyProgram:
+			if (dwSignature == ResourceWatcherService_MethodSignature_ProcessDetectThirdPartyProgram) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case ResourceWatcherService_Method_FilesClean:
+			if (dwSignature == ResourceWatcherService_MethodSignature_FilesClean) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case ResourceWatcherService_Method_FetchSystemSnapshot:
+			if (dwSignature == ResourceWatcherService_MethodSignature_FetchSystemSnapshot) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
 		default:
 			Error = Error_MethodNotFound;
 			break;
@@ -233,6 +261,26 @@ public:
 				Error = Error_MethodSignatureFailed;
 			}
 			break;
+		case ResourceWatcherService_Method_RestartThirdPartyProgram:
+			if (dwSignature != ResourceWatcherService_MethodSignature_RestartThirdPartyProgram) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case ResourceWatcherService_Method_ProcessDetectThirdPartyProgram:
+			if (dwSignature != ResourceWatcherService_MethodSignature_ProcessDetectThirdPartyProgram) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case ResourceWatcherService_Method_FilesClean:
+			if (dwSignature != ResourceWatcherService_MethodSignature_FilesClean) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case ResourceWatcherService_Method_FetchSystemSnapshot:
+			if (dwSignature != ResourceWatcherService_MethodSignature_FetchSystemSnapshot) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
 		default:
 			Error = Error_MethodNotFound;
 			break;
@@ -320,6 +368,26 @@ public:
 	/// override by user
 	}
 
+	virtual void Handle_RestartThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_RestartThirdPartyProgram_Req, ResourceWatcherService_RestartThirdPartyProgram_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
+	virtual void Handle_ProcessDetectThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_ProcessDetectThirdPartyProgram_Req, ResourceWatcherService_ProcessDetectThirdPartyProgram_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
+	virtual void Handle_FilesClean(SpReqAnsContext<ResourceWatcherService_FilesClean_Req, ResourceWatcherService_FilesClean_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
+	virtual void Handle_FetchSystemSnapshot(SpReqAnsContext<ResourceWatcherService_FetchSystemSnapshot_Req, ResourceWatcherService_FetchSystemSnapshot_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
 	virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
 	{
 		CAutoBuffer Buf;
@@ -480,6 +548,42 @@ public:
 						Handle_UninstallThirdPartyProgram(ctx);
 					}
 					break;
+				case ResourceWatcherService_Method_RestartThirdPartyProgram:
+					{
+						SpReqAnsContext<ResourceWatcherService_RestartThirdPartyProgram_Req,ResourceWatcherService_RestartThirdPartyProgram_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<ResourceWatcherService_RestartThirdPartyProgram_Req,ResourceWatcherService_RestartThirdPartyProgram_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						pTransactionContext->GetLinkContext(ctx->link);
+						Handle_RestartThirdPartyProgram(ctx);
+					}
+					break;
+				case ResourceWatcherService_Method_ProcessDetectThirdPartyProgram:
+					{
+						SpReqAnsContext<ResourceWatcherService_ProcessDetectThirdPartyProgram_Req,ResourceWatcherService_ProcessDetectThirdPartyProgram_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<ResourceWatcherService_ProcessDetectThirdPartyProgram_Req,ResourceWatcherService_ProcessDetectThirdPartyProgram_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						pTransactionContext->GetLinkContext(ctx->link);
+						Handle_ProcessDetectThirdPartyProgram(ctx);
+					}
+					break;
+				case ResourceWatcherService_Method_FilesClean:
+					{
+						SpReqAnsContext<ResourceWatcherService_FilesClean_Req,ResourceWatcherService_FilesClean_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<ResourceWatcherService_FilesClean_Req,ResourceWatcherService_FilesClean_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						pTransactionContext->GetLinkContext(ctx->link);
+						Handle_FilesClean(ctx);
+					}
+					break;
+				case ResourceWatcherService_Method_FetchSystemSnapshot:
+					{
+						SpReqAnsContext<ResourceWatcherService_FetchSystemSnapshot_Req,ResourceWatcherService_FetchSystemSnapshot_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<ResourceWatcherService_FetchSystemSnapshot_Req,ResourceWatcherService_FetchSystemSnapshot_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						pTransactionContext->GetLinkContext(ctx->link);
+						Handle_FetchSystemSnapshot(ctx);
+					}
+					break;
 				default:
 					assert(0);
 					break;

+ 699 - 0
Module/mod_ResourceWatcher/XUnZipZilb.cpp

@@ -0,0 +1,699 @@
+#include "XUnZipZilb.h"
+#include "libtoolkit/path.h"
+#include "fileutil.h"
+#include <string.h>
+#ifdef RVC_OS_WIN
+#else
+#include <iconv.h>
+#include <sys/stat.h>
+#include <errno.h>
+#endif // RVC_OS_WIN
+#define ZIP_ZILP_MAX_FILENAME 512
+#define ZIP_ZILP_READ_SIZE 4096
+
+#define ZIP_ZILP_HOST_SYSTEM(VERSION_MADEBY)  ((uint8_t)(VERSION_MADEBY >> 8))
+#define ZIP_ZILP_HOST_SYSTEM_MSDOS            (0)
+#define ZIP_ZILP_HOST_SYSTEM_UNIX             (3)
+#define ZIP_ZILP_HOST_SYSTEM_WINDOWS_NTFS     (10)
+#define ZIP_ZILP_HOST_SYSTEM_RISCOS           (13)
+#define ZIP_ZILP_HOST_SYSTEM_OSX_DARWIN       (19)
+
+int UnZipToDir(string zipFileName, string destDirPath)
+{
+	Dbg("zipFileName %s destDirPath %s", zipFileName.c_str(), destDirPath.c_str());
+	unzFile zfile = unzOpen(zipFileName.c_str());
+	if (zfile == NULL)
+	{
+		Dbg("could open zipFile (%s)", zipFileName.c_str());
+		return -1;
+	}
+	//create directory
+	if (!ExistsDirA(destDirPath.c_str())) {
+		if (!CreateDirA(destDirPath.c_str(), true)) {
+			Dbg("create temp unzip root dir fail: %s",destDirPath.c_str());
+			return -1;
+		}
+	}
+	unz_global_info global_info;
+	if (unzGetGlobalInfo(zfile, &global_info) != UNZ_OK)
+	{
+		Dbg("could not read file global info (%s)", zipFileName.c_str());
+		unzClose(zfile);
+		return -1;
+	}
+	for (int i = 0; i < global_info.number_entry; i++) {
+		if (unZipCurrentFile(zfile, destDirPath) != UNZ_OK) {
+			Dbg("unzip fail %s", zipFileName.c_str());
+			unzClose(zfile);
+			return -1;
+		}
+		if ((i + 1) < global_info.number_entry) {
+			int ret = unzGoToNextFile(zfile);
+			if (ret != UNZ_OK) {
+				Dbg("error %d with zipfile in unzGoToNextFile", ret);
+				unzClose(zfile);
+				return -1;
+			}
+		}
+	}
+	return 0;
+}
+
+//int unZipCurrentFile(zipFile zf, string destDirPath)
+//{
+//	unz_file_info file_info;
+//	char zipFilename[ZIP_ZILP_MAX_FILENAME];
+//	memset(zipFilename, 0, ZIP_ZILP_MAX_FILENAME);
+//	
+//	string newFileName = "";
+//	bool isDir = false;
+//	if (unzGetCurrentFileInfo(zf, &file_info, zipFilename, ZIP_ZILP_MAX_FILENAME, NULL, 0, NULL, 0) != UNZ_OK)
+//	{
+//		Dbg("could not read file info");
+//		return -1;
+//	}
+//#ifdef RVC_OS_WIN
+//	if (is_str_utf8(zipFilename)) {
+//		//Dbg("file name is UTF8");
+//		newFileName = utf8_to_gbk(zipFilename);
+//	}
+//	else {
+//		//Dbg("file name is GBK");
+//		newFileName = zipFilename;
+//	}
+//#else
+//	if (!is_str_utf8(zipFilename)) {
+//		//Dbg("file name is GBK");
+//		//newFileName = gbk_to_utf8(zipFilename);
+//		unsigned char* tempName = utf8_string_create((const char*)zipFilename);
+//		if (tempName == NULL) {
+//			Dbg("get utf8 str is null");
+//			return -1;
+//		}
+//		newFileName = (const char*)tempName;
+//		free(tempName);
+//	}
+//	else {
+//		//Dbg("file name is UTF8");
+//		newFileName = zipFilename;
+//	}
+//#endif // RVC_OS_WIN
+//	Dbg("unZipCurrentFile newFileName %s", newFileName.c_str());
+//	string filestr = newFileName;
+//	//判断是文件还是文件夹
+//
+//	if (filestr.substr(filestr.length() - 1, 1) == "/") {
+//		isDir = true;
+//	}
+//
+//	if (isDir)
+//	{   //创建文件夹
+//		string dirPath = destDirPath + SPLIT_SLASH_STR + newFileName;
+//		Dbg("creating directory: %s", dirPath.c_str());
+//		if (!CreateDirA(dirPath.c_str(), true))
+//		{
+//			Dbg("creating directory fail: dirPath(%s) zipFileName(%s)", dirPath.c_str(), newFileName.c_str());
+//			return -1;
+//		}
+//	}
+//	else
+//	{   //打开zip里面的文件
+//		string fileNamePath = destDirPath + SPLIT_SLASH_STR + newFileName;
+//		Dbg("creating file:%s", fileNamePath.c_str());
+//
+//		//先创建文件的父文件夹
+//		int pos = fileNamePath.find_last_of(SPLIT_SLASH);
+//		string newFileDirPath(fileNamePath.substr(0, pos));
+//		//Dbg("creating dir:%s", newFileDirPath.c_str());
+//		if (!CreateDirA(newFileDirPath.c_str(), true)) {
+//			Dbg("creating zip file dir fail: dirPath(%s)", newFileDirPath.c_str());
+//			return -1;
+//		}
+//
+//		if (unzOpenCurrentFile(zf) != UNZ_OK)
+//		{
+//			Dbg("could not open zip file ,%s", newFileName);
+//			return -1;
+//		}
+//		// Open a file to write out the data.
+//		FILE* out = fopen(fileNamePath.c_str(), "wb");
+//
+//		if (out == NULL)
+//		{
+//			Dbg("could not open destination file, %s", fileNamePath.c_str());
+//			unzCloseCurrentFile(zf);
+//			return -1;
+//		}
+//
+//		int err = UNZ_OK;
+//		unsigned char * read_buffer= new unsigned char[ZIP_ZILP_READ_SIZE];
+//		memset(read_buffer, 0, ZIP_ZILP_READ_SIZE);
+//		do
+//		{
+//			err = unzReadCurrentFile(zf, read_buffer, ZIP_ZILP_READ_SIZE);
+//			if (err < 0)
+//			{
+//				Dbg("error %d with zipfile in unzReadCurrentFile", err);
+//				break;
+//			}
+//
+//			// Write data to file.
+//			if (err > 0)
+//			{
+//				if (fwrite(read_buffer, err, 1, out) != 1) {
+//					Dbg("error in writing extracted file");
+//					err = UNZ_ERRNO;
+//					break;
+//				}
+//			}
+//		} while (err > 0);
+//
+//		delete[] read_buffer;//删除临时对象
+//
+//		if (out!=NULL) {
+//			if (fclose(out)!=0) {
+//				Dbg("fclose new file from zip fail, %s", fileNamePath.c_str());
+//				unzCloseCurrentFile(zf);
+//				return -1;
+//			}
+//		}
+//
+//		if (err == UNZ_OK) {
+//			//正常结束
+//			err = unzCloseCurrentFile(zf);
+//			if (err != UNZ_OK) {
+//				Dbg("error %d with zipfile in unzCloseCurrentFile", err);
+//				return -1;
+//			}
+//			if (changeUnZipFileAtt(fileNamePath.c_str())!=0) {
+//				return -1;
+//			}
+//			return 0;
+//		}
+//		else {
+//			//异常结束
+//			unzCloseCurrentFile(zf); /* don't lose the error */
+//			return -1;
+//		}
+//	}
+//	return 0;
+//}
+
+int unZipCurrentFile(zipFile zf, string destDirPath)
+{
+	unz_file_info file_info;
+	char zipFilename[ZIP_ZILP_MAX_FILENAME];
+	memset(zipFilename, 0, ZIP_ZILP_MAX_FILENAME);
+	
+	string newFileName = "";
+	bool isDir = false;
+	if (unzGetCurrentFileInfo(zf, &file_info, zipFilename, ZIP_ZILP_MAX_FILENAME, NULL, 0, NULL, 0) != UNZ_OK)
+	{
+		Dbg("could not read file info");
+		return -1;
+	}
+	//转码
+#ifdef RVC_OS_WIN
+	if (is_str_utf8(zipFilename)) {
+		//Dbg("file name is UTF8");
+		newFileName = utf8_to_gbk(zipFilename);
+	}
+	else {
+		//Dbg("file name is GBK");
+		newFileName = zipFilename;
+	}
+#else
+	if (!is_str_utf8(zipFilename)) {
+		//Dbg("file name is GBK");
+		//newFileName = gbk_to_utf8(zipFilename);
+		unsigned char* tempName = utf8_string_create((const char*)zipFilename);
+		if (tempName == NULL) {
+			Dbg("get utf8 str is null");
+			return -1;
+		}
+		newFileName = (const char*)tempName;
+		free(tempName);
+	}
+	else {
+		//Dbg("file name is UTF8");
+		newFileName = zipFilename;
+	}
+#endif // RVC_OS_WIN
+
+	Dbg("unZipCurrentFile newFileName %s", newFileName.c_str());
+	string filestr = newFileName;
+	//判断是文件还是文件夹
+
+	if (filestr.substr(filestr.length() - 1, 1) == "/") {
+		isDir = true;
+	}
+
+	//替换newFileName字符串中的'/'到对应平台路径
+#ifdef RVC_OS_WIN
+	size_t fi = newFileName.find("/");//判断是否有"/"
+	if (fi != string::npos) {
+		if (!replacePlace(newFileName, "/", "\\")) {
+			Dbg("replaceInPlace zip fileName fail:zipFileName(%s)", newFileName.c_str());
+			return -1;
+		}
+	}
+#else
+	size_t fi = newFileName.find("\\");//判断是否有"\\"
+	if (fi != string::npos) {
+		if (!replacePlace(newFileName, "\\", "/")) {
+			Dbg("replaceInPlace zip fileName fail:zipFileName(%s)", newFileName.c_str());
+			return -1;
+		}
+	}
+#endif // DEBUG
+
+	if (isDir)
+	{   //创建文件夹
+		string dirPath = destDirPath + SPLIT_SLASH_STR + newFileName;
+		Dbg("creating directory: %s", dirPath.c_str());
+		if (!CreateDirA(dirPath.c_str(), true))
+		{
+			Dbg("creating directory fail: dirPath(%s) zipFileName(%s)", dirPath.c_str(), newFileName.c_str());
+			return -1;
+		}
+	}
+	else
+	{   //打开zip里面的文件
+		string fileNamePath = destDirPath + SPLIT_SLASH_STR + newFileName;
+		Dbg("creating file:%s", fileNamePath.c_str());
+
+		//先创建文件的父文件夹
+		int pos = fileNamePath.find_last_of(SPLIT_SLASH);
+		string newFileDirPath(fileNamePath.substr(0, pos));
+
+		if (!CreateDirA(newFileDirPath.c_str(), true)) {
+			Dbg("creating zip file dir fail: dirPath(%s)", newFileDirPath.c_str());
+			return -1;
+		}
+
+		if (unzOpenCurrentFile(zf) != UNZ_OK)
+		{
+			Dbg("could not open zip file ,%s", newFileName);
+			return -1;
+		}
+
+		bool isSymlink = false;
+#ifdef RVC_OS_WIN
+		isSymlink = false;//windows 默认不创建链接文件
+		//if (entry_is_symlink(file_info) == 0) {
+		//	isSymlink = true;
+		//	printf("entry is link file, %s\n", newFileName.c_str());
+		//}
+#else
+		isSymlink = false;//linux 默认不创建链接文件
+		//if (entry_is_symlink(file_info) == 0) {
+		//	isSymlink = true;
+		//	Dbg("entry is link file, %s\n", newFileName.c_str());
+		//}
+#endif
+
+		// Open a file to write out the data.
+		int saveSucc = 0;
+
+		if (isSymlink) {
+			//链接文件
+			saveSucc = saveSymlink(zf, fileNamePath);
+		}
+		else {
+			//一般文件
+			saveSucc = saveNormalFile(zf, fileNamePath);
+		}
+
+		if (saveSucc == 0) {
+			//正常结束
+			int err = unzCloseCurrentFile(zf);
+			if (err != UNZ_OK) {
+				Dbg("zipfile  unzCloseCurrentFile is %d", err);
+				return -1;
+			}
+			//文件赋权
+			if (changeUnZipFileAtt(fileNamePath.c_str()) != 0) {
+				return -1;
+			}
+			return 0;
+		}
+		else {
+			//保存异常
+			unzCloseCurrentFile(zf); /* don't lose the error */
+			return -1;
+		}
+	}
+	return 0;
+}
+
+bool is_str_utf8(const char* str)
+{
+	unsigned int nBytes = 0;//UFT8可用1-6个字节编码,ASCII用一个字节  
+	unsigned char chr = *str;
+	bool bAllAscii = true;
+
+	for (unsigned int i = 0; str[i] != '\0'; ++i) {
+		chr = *(str + i);
+		//判断是否ASCII编码,如果不是,说明有可能是UTF8,ASCII用7位编码,最高位标记为0,0xxxxxxx 
+		if (nBytes == 0 && (chr & 0x80) != 0) {
+			bAllAscii = false;
+		}
+
+		if (nBytes == 0) {
+			//如果不是ASCII码,应该是多字节符,计算字节数  
+			if (chr >= 0x80) {
+
+				if (chr >= 0xFC && chr <= 0xFD) {
+					nBytes = 6;
+				}
+				else if (chr >= 0xF8) {
+					nBytes = 5;
+				}
+				else if (chr >= 0xF0) {
+					nBytes = 4;
+				}
+				else if (chr >= 0xE0) {
+					nBytes = 3;
+				}
+				else if (chr >= 0xC0) {
+					nBytes = 2;
+				}
+				else {
+					return false;
+				}
+
+				nBytes--;
+			}
+		}
+		else {
+			//多字节符的非首字节,应为 10xxxxxx 
+			if ((chr & 0xC0) != 0x80) {
+				return false;
+			}
+			//减到为零为止
+			nBytes--;
+		}
+	}
+
+	//违返UTF8编码规则 
+	if (nBytes != 0) {
+		return false;
+	}
+
+	if (bAllAscii) { //如果全部都是ASCII, 也是UTF8
+		return true;
+	}
+
+	return true;
+}
+
+int changeUnZipFileAtt(const char* path)
+{
+#ifdef RVC_OS_WIN
+	return 0;//windows 默认返回成功
+#else
+	struct stat attr_of_del;
+	if (lstat(path, &attr_of_del) == 0)
+	{
+		//修改为775属性
+		mode_t f_attrib = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH;
+		if (chmod(path, f_attrib) != 0)
+		{
+			Dbg("set file attribute is fail,errno=%d, file=%s", errno, path);
+			return -1;
+		}
+		return 0;
+	}
+	else {
+		Dbg("get file attribute is fail,errno=%d, file=%s", errno, path);
+		return -1;
+	}
+#endif
+}
+
+bool replacePlace(string& str, string const& replaceThis, string const& withThis)
+{
+	bool replaced = false;
+	size_t i = str.find(replaceThis);
+	while (i != string::npos) {
+		replaced = true;
+		str = str.substr(0, i) + withThis + str.substr(i + replaceThis.size());
+		if (i < str.size() - withThis.size())
+			i = str.find(replaceThis, i + withThis.size());
+		else
+			i = string::npos;
+	}
+	return replaced;
+}
+
+int saveNormalFile(zipFile zf, string savePath) {
+	// Open a file to write out the data.
+	FILE* out = fopen(savePath.c_str(), "wb");
+
+	if (out == NULL)
+	{
+		Dbg("could not open destination file, %s", savePath.c_str());
+		return -1;
+	}
+
+	int err = 0;
+	unsigned char* read_buffer = new unsigned char[ZIP_ZILP_READ_SIZE];
+	memset(read_buffer, 0, ZIP_ZILP_READ_SIZE);
+	do
+	{
+		err = unzReadCurrentFile(zf, read_buffer, ZIP_ZILP_READ_SIZE);
+		if (err < 0)
+		{
+			Dbg("zipfile in unzReadCurrentFile is fail:%d", err);
+			err = -1;
+			break;
+		}
+		if (err > 0)
+		{
+			// Write data to file.
+			if (fwrite(read_buffer, err, 1, out) != 1) {
+				Dbg("writing extracted normal file is fail");
+				err = -1;
+				break;
+			}
+			else {
+				//及时写入缓存数据
+				if (fflush(out) != 0) {
+					Dbg("fflush extracted normal file is fail");
+					err = -1;
+					break;
+				}
+			}
+		}
+		if (err == 0) {
+			//已经到结尾
+			break;
+		}
+	} while (true);
+
+	delete[] read_buffer;//删除临时对象
+
+	if (out != NULL) {
+		if (fclose(out) != 0) {
+			Dbg("fclose normal file fail");
+			return -1;
+		}
+	}
+	return err;
+}
+
+int saveSymlink(zipFile zf, string savePath) {
+	//链接文件
+	char* srcPath = new char[4096];//链接的原地址路径
+	memset(srcPath, 0, 4096);
+	string destPath = savePath;//新地址
+
+	unsigned char* readStr = new unsigned char[512];
+	memset(readStr, 0, 512);
+
+	int err = 0;
+	int copy = 0;
+	do
+	{
+		err = unzReadCurrentFile(zf, readStr, 512);
+		if (err < 0)
+		{
+			Dbg("zipfile in unzReadCurrentFile is fail:%d", err);
+			err = -1;
+			break;
+		}
+		// Write data to file.
+		if (err > 0)
+		{
+			if ((copy + err) <= 4096) {
+				memcpy(srcPath + copy, readStr, err);
+				copy += err;
+			}
+			else {
+				Dbg("link content len over 4096 ,check zipfile in unzReadCurrentFile, %s ", savePath.c_str());
+				err = -1;
+				break;
+			}
+		}
+		if (err == 0) {
+			//已经到结尾
+			break;
+		}
+	} while (true);
+
+	delete[] readStr;
+
+	if (err == 0) {
+		err = os_make_symlink((const char*)srcPath, destPath.c_str());
+		delete[] srcPath; //删除临时对象
+		return err;
+	}
+	else {
+		delete[] srcPath;//删除临时对象
+		return -1;
+	}
+	return 0;
+}
+
+int entry_is_symlink(unz_file_info file_info)
+{
+	uint32_t posix_attrib = 0;
+	uint8_t system = ZIP_ZILP_HOST_SYSTEM(file_info.version);
+	int32_t err = 0;
+
+	err = zip_attrib_convert(system, file_info.external_fa, ZIP_ZILP_HOST_SYSTEM_UNIX, &posix_attrib);
+	if (err == 0) {
+		if ((posix_attrib & 0170000) == 0120000) /* S_ISLNK */
+			return 0;
+	}
+
+	return -1;
+}
+
+int zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t target_sys, uint32_t* target_attrib)
+{
+	if (target_attrib == NULL)
+		return -1;
+
+	*target_attrib = 0;
+
+	if ((src_sys == ZIP_ZILP_HOST_SYSTEM_MSDOS) || (src_sys == ZIP_ZILP_HOST_SYSTEM_WINDOWS_NTFS)) {
+		if ((target_sys == ZIP_ZILP_HOST_SYSTEM_MSDOS) || (target_sys == ZIP_ZILP_HOST_SYSTEM_WINDOWS_NTFS)) {
+			*target_attrib = src_attrib;
+			return 0;
+		}
+		if ((target_sys == ZIP_ZILP_HOST_SYSTEM_UNIX) || (target_sys == ZIP_ZILP_HOST_SYSTEM_OSX_DARWIN) || (target_sys == ZIP_ZILP_HOST_SYSTEM_RISCOS))
+			return zip_attrib_win32_to_posix(src_attrib, target_attrib);
+	}
+	else if ((src_sys == ZIP_ZILP_HOST_SYSTEM_UNIX) || (src_sys == ZIP_ZILP_HOST_SYSTEM_OSX_DARWIN) || (src_sys == ZIP_ZILP_HOST_SYSTEM_RISCOS)) {
+		if ((target_sys == ZIP_ZILP_HOST_SYSTEM_UNIX) || (target_sys == ZIP_ZILP_HOST_SYSTEM_OSX_DARWIN) || (target_sys == ZIP_ZILP_HOST_SYSTEM_RISCOS)) {
+			/* If high bytes are set, it contains unix specific attributes */
+			if ((src_attrib >> 16) != 0)
+				src_attrib >>= 16;
+
+			*target_attrib = src_attrib;
+			return 0;
+		}
+		if ((target_sys == ZIP_ZILP_HOST_SYSTEM_MSDOS) || (target_sys == ZIP_ZILP_HOST_SYSTEM_WINDOWS_NTFS))
+			return zip_attrib_posix_to_win32(src_attrib, target_attrib);
+	}
+
+	return -2;
+}
+
+int zip_attrib_posix_to_win32(uint32_t posix_attrib, uint32_t* win32_attrib)
+{
+	if (win32_attrib == NULL)
+		return -1;
+
+	*win32_attrib = 0;
+
+	/* S_IWUSR | S_IWGRP | S_IWOTH | S_IXUSR | S_IXGRP | S_IXOTH */
+	if ((posix_attrib & 0000333) == 0 && (posix_attrib & 0000444) != 0)
+		*win32_attrib |= 0x01;      /* FILE_ATTRIBUTE_READONLY */
+	/* S_IFLNK */
+	if ((posix_attrib & 0170000) == 0120000)
+		*win32_attrib |= 0x400;     /* FILE_ATTRIBUTE_REPARSE_POINT */
+	/* S_IFDIR */
+	else if ((posix_attrib & 0170000) == 0040000)
+		*win32_attrib |= 0x10;      /* FILE_ATTRIBUTE_DIRECTORY */
+	/* S_IFREG */
+	else
+		*win32_attrib |= 0x80;      /* FILE_ATTRIBUTE_NORMAL */
+
+	return 0;
+}
+
+int zip_attrib_win32_to_posix(uint32_t win32_attrib, uint32_t* posix_attrib)
+{
+	if (posix_attrib == NULL)
+		return -1;
+
+	*posix_attrib = 0000444;        /* S_IRUSR | S_IRGRP | S_IROTH */
+	/* FILE_ATTRIBUTE_READONLY */
+	if ((win32_attrib & 0x01) == 0)
+		*posix_attrib |= 0000222;   /* S_IWUSR | S_IWGRP | S_IWOTH */
+	/* FILE_ATTRIBUTE_REPARSE_POINT */
+	if ((win32_attrib & 0x400) == 0x400)
+		*posix_attrib |= 0120000;   /* S_IFLNK */
+	/* FILE_ATTRIBUTE_DIRECTORY */
+	else if ((win32_attrib & 0x10) == 0x10)
+		*posix_attrib |= 0040111;   /* S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH */
+	else
+		*posix_attrib |= 0100000;   /* S_IFREG */
+
+	return 0;
+}
+
+int os_make_symlink(const char* srcPath, const char* target_path) {
+#ifdef RVC_OS_WIN
+	return 0;//暂不实现,暂时写入后缀名是link的文件
+#else
+	if (symlink(srcPath, target_path) != 0) {
+		Dbg("symlink fail,errno = %d", errno);
+		return -1;
+	}
+	return 0;
+#endif // RVC_OS_WIN
+}
+
+#ifdef RVC_OS_WIN
+#else
+unsigned char* utf8_string_create(const char* string) {
+	iconv_t cd;
+	const char* from_encoding = "CP936";
+	size_t result = 0;
+	size_t string_length = 0;
+	size_t string_utf8_size = 0;
+	unsigned char* string_utf8 = NULL;
+	unsigned char* string_utf8_ptr = NULL;
+
+	if (string == NULL)
+		return NULL;
+
+	cd = iconv_open("UTF-8", from_encoding);
+	if (cd == (iconv_t)-1)
+		return NULL;
+
+	string_length = strlen(string);
+	string_utf8_size = string_length * 2;
+	string_utf8 = (unsigned char*)malloc((int)(string_utf8_size + 1));
+	string_utf8_ptr = string_utf8;
+
+	if (string_utf8) {
+		memset(string_utf8, 0, string_utf8_size + 1);
+
+		result = iconv(cd, (char**)&string, &string_length,
+			(char**)&string_utf8_ptr, &string_utf8_size);
+	}
+
+	iconv_close(cd);
+
+	if (result == (size_t)-1) {
+		free(string_utf8);
+		string_utf8 = NULL;
+	}
+	return string_utf8;
+}
+
+#endif //RVC_OS_WIN

+ 90 - 0
Module/mod_ResourceWatcher/XUnZipZilb.h

@@ -0,0 +1,90 @@
+#ifndef RVC_MOD_UPLOAD_XUNZIP_ZLIB_H_
+#define RVC_MOD_UPLOAD_XUNZIP_ZLIB_H_
+
+
+#include "SpBase.h"
+
+#ifdef RVC_OS_WIN
+
+#define ZLIB_WINAPI //win32 必须使用的宏
+
+#endif 
+
+#include "zip.h"
+#include "unzip.h"
+#include <iostream>
+#include <stdio.h>
+#include <string>
+#include <locale>
+#include <codecvt> 
+
+using namespace std;
+//GBK转UTF码类
+class chs_codecvt : public std::codecvt_byname<wchar_t, char, std::mbstate_t> {
+public:
+	//因不同平台,名称不同,故这里做转换,统一取出不同平台下面的GBK码
+#ifdef RVC_OS_WIN
+	chs_codecvt() : codecvt_byname("chs") { }//zh_CN.GBK or .936
+#else
+	chs_codecvt() : codecvt_byname("zh_CN.GBK") { }//.936
+#endif // RVC_OS_WIN
+};
+
+//src必须是UTF8否则抛异常
+static wstring utf8_to_wstr(const string& src)
+{
+	wstring_convert<codecvt_utf8<wchar_t>> converter;
+	return converter.from_bytes(src);
+}
+
+static string wstr_to_utf8(const wstring& src)
+{
+	wstring_convert<codecvt_utf8<wchar_t>> convert;
+	return convert.to_bytes(src);
+}
+
+static string utf8_to_gbk(const string& str)
+{
+	wstring wStr = utf8_to_wstr(str);//utf8转wstring
+	wstring_convert<chs_codecvt> converter;
+	return converter.to_bytes(wStr);//wstring转GBK
+}
+
+static string gbk_to_utf8(const string& str)
+{
+	wstring_convert<chs_codecvt> converter;
+	wstring wStr = converter.from_bytes(str);//GBK转wstring
+	return wstr_to_utf8(wStr);//wstring 转utf8
+}
+
+
+int UnZipToDir(string zipFileName, string destDirPath);
+
+int unZipCurrentFile(zipFile zf, string destDirPath);
+
+bool is_str_utf8(const char* str);
+
+int changeUnZipFileAtt(const char* path);
+
+bool replacePlace(string& str, string const& replaceThis, string const& withThis);
+
+int saveNormalFile(zipFile zf, string savePath);
+
+int saveSymlink(zipFile zf, string savePath);
+
+int entry_is_symlink(unz_file_info file_info);
+
+int zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t target_sys, uint32_t* target_attrib);
+
+int zip_attrib_posix_to_win32(uint32_t posix_attrib, uint32_t* win32_attrib);
+
+int zip_attrib_win32_to_posix(uint32_t win32_attrib, uint32_t* posix_attrib);
+
+int os_make_symlink(const char* srcPath, const char* target_path);
+#ifdef RVC_OS_WIN
+#else
+unsigned char* utf8_string_create(const char* string);
+
+#endif // RVC_OS_WIN
+
+#endif //RVC_MOD_UPLOAD_XUNZIP_ZLIB_H_

+ 498 - 17
Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp

@@ -15,9 +15,13 @@
 #include <winpr/sysinfo.h>
 #endif //RVC_OS_LINUX
 
+#include "XUnZipZilb.h"
+
 #include "publicFunExport.h"
 #include <map>
 #include <regex.h>
+#include "../mod_healthmanager/HealthManager_client_g.h"
+using namespace HealthManager;
 
 struct SogouRunVersionInfo 
 {
@@ -182,6 +186,30 @@ void ResourceWatcherServiceSession::Handle_UninstallThirdPartyProgram(SpReqAnsCo
     m_pEntity->UninstallThirdPartyProgram(ctx);
 }
 
+void ResourceWatcherServiceSession::Handle_RestartThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_RestartThirdPartyProgram_Req, ResourceWatcherService_RestartThirdPartyProgram_Ans>::Pointer ctx)
+{
+    LOG_FUNCTION();
+    m_pEntity->RestartThirdPartyProgram(ctx);
+}
+
+void ResourceWatcherServiceSession::Handle_ProcessDetectThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_ProcessDetectThirdPartyProgram_Req, ResourceWatcherService_ProcessDetectThirdPartyProgram_Ans>::Pointer ctx)
+{
+    LOG_FUNCTION();
+    m_pEntity->ProcessDetectThirdPartyProgram(ctx);
+}
+
+void ResourceWatcherServiceSession::Handle_FilesClean(SpReqAnsContext<ResourceWatcherService_FilesClean_Req, ResourceWatcherService_FilesClean_Ans>::Pointer ctx)
+{
+    LOG_FUNCTION();
+    m_pEntity->FilesClean(ctx);
+}
+
+void ResourceWatcherServiceSession::Handle_FetchSystemSnapshot(SpReqAnsContext<ResourceWatcherService_FetchSystemSnapshot_Req, ResourceWatcherService_FetchSystemSnapshot_Ans>::Pointer ctx)
+{
+    LOG_FUNCTION();
+    m_pEntity->FetchSystemSnapshot(ctx);
+}
+
 void ResourceWatcherEntity::UpdateDNS(SpReqAnsContext<ResourceWatcherService_UpdateDNS_Req, ResourceWatcherService_UpdateDNS_Ans>::Pointer ctx)
 {
     ctx->Answer(Error_NotImpl);
@@ -403,25 +431,164 @@ ErrorCodeEnum SetFileExecutePriviledge(LPCTSTR lpcszDirOrFilePath)
     return result;
 }
 
+ErrorCodeEnum ResourceWatcherEntity::GetUnzipTempDir(CSimpleStringA& strUnzipDir)
+{
+    CSimpleStringA strDownloadsPath;
+    auto rc = GetFunction()->GetPath("Downloads", strDownloadsPath);
+    assert(rc == Error_Succeed);
+
+    strUnzipDir = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", (const char*)strDownloadsPath, strUnzipDir);
+    if (strUnzipDir.IsEndWith(".zip") || strUnzipDir.IsEndWith(".cab"))
+        strUnzipDir = strUnzipDir.SubString(0, strUnzipDir.GetLength() - 4);
+
+    return Error_Succeed;
+}
+
+ErrorCodeEnum ResourceWatcherEntity::UnzipPack(const char* unZipPackName)
+{
+    CSimpleStringA strDownloadsPath;
+    auto rc = GetFunction()->GetPath("Downloads", strDownloadsPath);
+    assert(rc == Error_Succeed);
+
+    CSimpleStringA strTempPath;
+    CSmartPointer<IEntityFunction> spFunction2 = GetFunction();
+    ErrorCodeEnum rc2 = spFunction2->GetPath("Temp", strTempPath);
+    assert(rc2 == Error_Succeed);
+
+    CSimpleStringA strUnzipPath;
+    strUnzipPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", strTempPath.GetData(), unZipPackName);
+    if (strUnzipPath.IsEndWith(".zip") || strUnzipPath.IsEndWith(".cab"))
+    {
+        strUnzipPath = strUnzipPath.SubString(0, strUnzipPath.GetLength() - 4);
+    }
+
+    // 如目标目录存在,则先删除
+    if (ExistsDirA(strUnzipPath))
+    {
+        if (!RemoveDirRecursiveA(strUnzipPath)) {
+            LogError(Severity_Low, Error_NotExist, 0, CSimpleStringA::Format("remove old unzip dir [%s] fail", strUnzipPath.GetData()));
+            return  Error_NotExist;
+        }
+    }
+    // 创建临时解压目录
+    CreateDirA(strUnzipPath.GetData(), false);
+
+    // 解压
+    CSimpleStringA strZipFile = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", strDownloadsPath.GetData(), unZipPackName);
+    string zipFileStr = strZipFile.GetData();
+    string zipTempDir = strUnzipPath.GetData();
+
+    if (!ExistsFileA(strZipFile.GetData()))
+    {
+        LogError(Severity_Low, Error_NotExist, 0, CSimpleStringA::Format("pack [%s] not exists", unZipPackName));
+        return  Error_NotExist;
+    }
+
+    if (UnZipToDir(zipFileStr, zipTempDir) != 0)
+    {
+        LogError(Severity_Low, Error_Unexpect, 0, CSimpleStringA::Format("unzip pack [%s] fail", unZipPackName));
+        return  Error_NotExist;
+    }
+    return Error_Succeed;
+}
+
+
 void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_InstallThirdPartyProgram_Req, ResourceWatcherService_InstallThirdPartyProgram_Ans>::Pointer ctx)
 {
     ErrorCodeEnum result(Error_Succeed);
     ErrorCodeEnum tmpResult(Error_Succeed);
     CSimpleStringA tmpMsg(true);
 
+    Dbg("ctx-req context: %d, %d, %d", ctx->Req.type, ctx->Req.reserved1, ctx->Req.reserved2);
+
+    bool sogouInstalled = false;
+    const bool doTryRestart = (ctx->Req.reserved1 != 1);
+
     if (ctx->Req.type == 1) {//安装搜狗输入法
+        bool zipFind = false;
+        time_t newestWrite = 0;
+        CSimpleStringA newSogouPath(true);
+        CSimpleStringA strDownloadDirPath(true);
+        GetFunction()->GetPath("Downloads", strDownloadDirPath);
+        CSimpleStringA strTempDirPath(true);
+        GetFunction()->GetPath("Temp", strTempDirPath);
+
+        if (strDownloadDirPath.IsNullOrEmpty()) {
+            tmpResult = Error_Unexpect;
+            tmpMsg = CSimpleStringA::Format("搜狗安装包目录[Downloads]不存在!");
+        }
+        else
+        {
+            DIR* dp;
+            struct dirent* dirp;
+            if ((dp = opendir(strDownloadDirPath.GetData())) != NULL)
+            {
+                while ((dirp = readdir(dp)) != NULL) 
+                {
+                    CSimpleStringA tmpName(dirp->d_name);
+                    if ((tmpName.IsStartWith("sogou", true) || tmpName.IsStartWith("uos-sogou", true))
+                        && tmpName.IsEndWith(".zip", true)) {
+
+                        struct stat buf;
+                        memset(&buf, 0x00, sizeof(buf));
+                        const int ret = stat(CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", strDownloadDirPath.GetData(), dirp->d_name).GetData(), &buf);
+                        if (ret != 0) {
+                            Dbg("获取文件[%s]状态信息出错。", tmpName.GetData());
+                        } else if(buf.st_mtim.tv_sec > newestWrite){
+                            newestWrite = buf.st_mtim.tv_sec;
+                            newSogouPath = CSimpleStringA(tmpName.GetData());
+                            zipFind = true;
+                        }
+                    }
+                }
+
+                closedir(dp);
+
+                if(!zipFind)
+                {
+                    tmpResult = Error_NotExist;
+                    tmpMsg = CSimpleStringA::Format("在路径[%s]下未找到搜狗安装包!", strDownloadDirPath.GetData());
+                }
+            }
+            else
+            {
+                tmpResult = Error_NotExist;
+                tmpMsg = CSimpleStringA::Format("打开[Downloads]目录失败!");
+            }
+        }
+
+        CSimpleStringA strInstallPkgPath(true);
+        if (zipFind)
+        {
+            if (UnzipPack(newSogouPath.GetData()) != Error_Succeed)
+            {
+                tmpResult = Error_Unexpect;
+                tmpMsg = CSimpleStringA::Format("解压搜狗安装包失败!");
+            }
+            else
+            {
+                newSogouPath = newSogouPath.SubString(0, newSogouPath.GetLength() - 4);
+                strInstallPkgPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s",
+                    strTempDirPath.GetData(), newSogouPath.GetData());
+            }
+        }
+        else
+        {
+            tmpResult = GetSogouPkgDirPath(strInstallPkgPath);
+            if (tmpResult != Error_Succeed) {
+                tmpMsg =CSimpleStringA::Format(" 指定位置 [Ad] 找不到输入法安装包");
+            }
+        }
 
         Dbg("to install sogou input...");
         const bool doNotStartup(true); //安装后是否启动搜狗输入法服务,据搜狗反馈,不能通过root权限启动Sogou输入法
-        CSimpleStringA strInstallPkgPath;
-        tmpResult = GetSogouPkgDirPath(strInstallPkgPath);
-        if (tmpResult != 0) {
-            tmpMsg = CSimpleStringA::Format("指定位置找不到输入法安装包");
-        } else {
+        if(tmpResult == Error_Succeed)
+        {
             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)) {
@@ -435,13 +602,15 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
                         tmpResult = RunShellScript(app);
                         if (tmpResult != 0) {
                             tmpMsg = CSimpleStringA::Format("执行 '%s' 失败", app);
-                        } else if(!doNotStartup) {
+                        }
+                        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 {
+                            }
+                            else {
                                 Sleep(1000);
                                 do {
                                     char app[MAX_PATH] = { '\0' };
@@ -454,7 +623,8 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
                                     auto users = GetUserNameList(true);
                                     if (users.size() == 1) {
                                         sprintf(app, "su -m -p -c \"bash %s\" %s", strStartupScriptFile.GetData(), users[0].c_str());
-                                    } else {
+                                    }
+                                    else {
                                         for (auto it = users.cbegin(); it != users.cend(); ++it) {
                                             Dbg("user:%s", it->c_str());
                                         }
@@ -468,18 +638,21 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
                                     if (0 == res) {
                                         FREE(process);
                                         Dbg("execute {%s} suc", app);
-                                    } else {
+                                    }
+                                    else {
                                         tmpMsg = CSimpleStringA::Format("执行 '%s' 失败:%s", app, toolkit_strerror(res));
                                         tmpResult = Error_Process;
                                     }
                                 } while (false);
                             }
                         }
-                    } else {
+                    }
+                    else {
                         tmpMsg = CSimpleStringA::Format("%s 执行文件不存在", strInstallScriptFile.GetData());
                         tmpResult = Error_NotExist;
                     }
-                } else {
+                }
+                else {
                     tmpMsg = CSimpleStringA::Format("%s 文件不存在,请检查安装包完整性", strRunIniFilePath.GetData());
                     tmpResult = Error_NotExist;
                 }
@@ -488,7 +661,7 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
         if (tmpResult == Error_Succeed) {
             Sleep(1500);
             const CSimpleStringA strResultLogFilePath = strInstallPkgPath + SPLIT_SLASH_STR + "result.log";
-            do 
+            do
             {
                 const int maxTimes = 5;
                 int curTimes = 0;
@@ -501,13 +674,15 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
             if (!ExistsFileA(strResultLogFilePath)) {
                 tmpResult = Error_NotExist;
                 tmpMsg = CSimpleStringA::Format("安装成功标志文件不存在!");
-            } else {
+            }
+            else {
                 FILE* pResultLog = fopen(strResultLogFilePath, "r");
                 if (pResultLog == NULL) {
                     tmpResult = Error_IO;
                     tmpMsg = CSimpleStringA::Format("打开安装成功标志文件失败!%s", strerror(errno));
-                } else {
-                    char szTmp[1024] = {'\0'};
+                }
+                else {
+                    char szTmp[1024] = { '\0' };
                     int nRead = fread(szTmp, 1, sizeof(szTmp), pResultLog);
                     int installResult(-1);
                     char installMsg[256] = { '\0' };
@@ -517,7 +692,8 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
                     if (installResult != 0) {
                         tmpResult = Error_Unexpect;
                         tmpMsg = CSimpleStringA::Format("%s", szTmp);
-                    } else {
+                    }
+                    else {
                         SogouInstallInfo info;
                         info.state.dwInstalledStatus = Sogou_GetInstallStatus();
                         info.state.strInstallDate = Sogou_GetInstallTime();
@@ -538,15 +714,22 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
                         if (!info.IsInstalledSuccess()) {
                             tmpResult = Error_FailVerify;
                             tmpMsg = CSimpleStringA::Format("检测安装状态失败!");
-                        } else {
+                        }
+                        else {
                             ctx->Ans.path = info.program.strInstallDir;
                             ctx->Ans.reserverd1 = info.program.strVersion;
                             ctx->Ans.reserverd2 = info.state.GetInstallTime().ToTimeString();
+
+                            if (doTryRestart) {
+                                tmpMsg = CSimpleStringA::Format(" 从[%s]安装搜狗输入法成功,设备即将重启。", strInstallPkgPath.GetData());
+                            }
+                            sogouInstalled = true;
                         }
                     }
                 }
             }
         }
+
     } else if (ctx->Req.type == 2) {//安装花了钱的字体
 
         Dbg("to install cmb font input...%d", m_bInitMode);
@@ -616,6 +799,36 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
     ctx->Ans.result = tmpResult;
     ctx->Ans.msg = tmpMsg;
     ctx->Answer(result);
+
+    if (sogouInstalled && doTryRestart)
+    {
+        HealthManagerService_ClientBase* m_pRWClient = new HealthManagerService_ClientBase(this);
+        ErrorCodeEnum eErr = m_pRWClient->Connect();
+
+        if (eErr != Error_Succeed) {
+            Dbg("HealthManager connected failed.");
+            m_pRWClient->SafeDelete();
+            m_pRWClient = NULL;
+        }
+        else
+        {
+            HealthManagerService_ControlTerminalLife_Req detReq;
+            HealthManagerService_ControlTerminalLife_Ans detAns;
+            detReq.cmdType = 4;
+            detReq.reason = 0;
+            eErr = m_pRWClient->ControlTerminalLife(detReq, detAns, 3000);
+            if (eErr == Error_Succeed)
+            {
+                LogWarn(Severity_Middle, Error_Succeed, 0, "搜狗安装成功, 设备即将重启。");
+            }
+            else
+            {
+                LogWarn(Severity_Middle, Error_Unexpect, 0, "调用健康实体重启设备失败!");
+            }
+            m_pRWClient->GetFunction()->CloseSession();
+        }
+    }
+
     return;
 }
 
@@ -843,6 +1056,157 @@ void ResourceWatcherEntity::UninstallThirdPartyProgram(SpReqAnsContext<ResourceW
     return;
 }
 
+void ResourceWatcherEntity::RestartThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_RestartThirdPartyProgram_Req, ResourceWatcherService_RestartThirdPartyProgram_Ans>::Pointer ctx)
+{
+    ErrorCodeEnum result(Error_Succeed);
+    ErrorCodeEnum tmpResult(Error_Succeed);
+    CSimpleStringA tmpMsg(true);
+
+    if (ctx->Req.type == 1) 
+    {//重启搜狗输入法
+        static int old_process_id[2] = { -1, -1 };
+        char* relate_processes[2] = { "sogouImeWebSrv", "sogouImeService" };
+
+        int count = 3;
+        alive_process_info processes[3];
+        memset(processes, 0, sizeof(processes));
+
+        osutil_detect_unique_app(relate_processes, array_size(relate_processes), &count, processes);
+
+        CAutoArray<CSimpleStringA> msgs(array_size(relate_processes));
+        int cnt(0);
+
+        for (int i = 0; i < array_size(relate_processes); ++i) 
+        {
+            int k = -1;
+            for (int j = 0; j < count; ++j) {
+                if (strcmp(processes[j].name, relate_processes[i]) == 0) {
+                    k = j;
+                    break;
+                }
+            }
+            if (k != -1)
+            {
+                cnt++;
+                old_process_id[k] = processes[k].pid;
+
+                std::string sucContent, failedContent;
+                CSimpleStringA strCmd = CSimpleStringA::Format("kill -9 %d", old_process_id[k]);
+                bool ret = SP::Module::Util::ShellExecute(strCmd.GetData(), sucContent, failedContent);
+                Dbg("{%s}:{%s}{%s}", strCmd.GetData(), sucContent.c_str(), failedContent.c_str());
+            }
+        }
+
+        int cnt2(0);
+        if (cnt > 0)
+        {
+            ///**TODO(Gifur@7/5/2022): 待优化处理 */
+            Sleep(2000);
+
+            int newCount = 3;
+            int notSame = 0;
+            vector<CSimpleStringA> tKillmsg;
+            alive_process_info newProcesses[3];
+            memset(newProcesses, 0, sizeof(newProcesses));
+            osutil_detect_unique_app(relate_processes, array_size(relate_processes), &newCount, newProcesses);
+            for (int i = 0; i < array_size(relate_processes); ++i)
+            {
+                int k = -1;
+                for (int j = 0; j < count; ++j) {
+                    if (strcmp(newProcesses[j].name, relate_processes[i]) == 0 && newProcesses[j].pid > 0) {
+                        k = j;
+                        break;
+                    }
+                }
+                if (k != -1)
+                {
+                    cnt2++;
+                    if (newProcesses[k].pid != old_process_id[k])
+                    {
+                        notSame++;
+                    }
+                    else
+                    {
+                        tmpResult = Error_Unexpect;
+                        CSimpleStringA tmsg = CSimpleStringA::Format("{杀死当前搜狗进程[%s]失败,pid[%d]。}", 
+                            newProcesses[k].name, newProcesses[k].pid);
+                        tKillmsg.push_back(tmsg);
+                    }
+                }
+            }
+
+            if (cnt2 == 0)
+            {
+                tmpMsg = "已杀死搜狗进程。但重启搜狗进程失败,请确认守护进程正常运行。";
+                tmpResult = Error_Unexpect;
+            }
+            else
+            {
+                if (tKillmsg.size() != 0)
+                {
+                    for (int i = 0; i < tKillmsg.size(); ++i)
+                    {
+                        tmpMsg += tKillmsg[i];
+                    }
+                }
+                else
+                {
+                    tmpMsg = "已成功重启搜狗输入法进程。";
+                }
+            }
+        }
+        else
+        {
+            tmpMsg = "当前系统无搜狗进程,请确认已安装搜狗输入法,并重启计算机以尝试启动搜狗输入法!";
+            tmpResult = Error_Unexpect;
+        }
+    }
+    else
+    {
+        tmpResult = Error_NotSupport;
+        tmpMsg = CSimpleStringA::Format("接口调用参数错误。");
+    }
+
+    ctx->Ans.result = tmpResult;
+    ctx->Ans.msg = tmpMsg;
+
+    ctx->Answer(result);
+    return;
+}
+
+void ResourceWatcherEntity::ProcessDetectThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_ProcessDetectThirdPartyProgram_Req, ResourceWatcherService_ProcessDetectThirdPartyProgram_Ans>::Pointer ctx)
+{
+    ErrorCodeEnum result(Error_Succeed);
+    ErrorCodeEnum tmpResult(Error_Succeed);
+
+    CSimpleStringA tmpMsg(true);
+    std::string res("");
+
+    if (ctx->Req.type == 1) {//检测搜狗输入法进程
+        CAutoArray<CSimpleStringA> pName(2);
+        pName[0] = "sogouImeWebSrv";
+        pName[1] = "sogouImeService";
+        res = DoCheckCertainProcessStatus(pName);
+
+        if (res.length() == 0)
+        {
+            tmpResult = Error_Failed;
+            tmpMsg = "Can't find Sogou Process.";
+        }
+        else
+        {
+            tmpMsg = CSimpleStringA::Format("%s", res.c_str());
+        }
+    }
+
+
+    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: 
@@ -1292,6 +1656,122 @@ void ResourceWatcherEntity::OnSysVarEvent(const char* pszKey, const char* pszVal
 
 }
 
+
+std::string ResourceWatcherEntity::DoCheckCertainProcessStatus(const CAutoArray<CSimpleStringA>& pName)
+{
+    int pSize = pName.GetCount();
+    /*static int old_process_id[pSize];
+    memset(old_process_id, -1, sizeof(old_process_id));*/
+    vector<int> old_process_id;
+    CAutoArray<CSimpleStringA> msgs;
+    alive_process_info* processes = new alive_process_info[pSize];
+    char** relate_processes = new char* [pSize];
+    int count = pSize;
+
+    for (int i = 0; i < pSize; ++i)
+    {
+        old_process_id.push_back(-1);
+
+        CSimpleStringA temp("");
+        msgs.Append(&temp, 0, 1);
+        relate_processes[i] = const_cast<char*>(pName[i].GetData());
+        Dbg("relate_process name: %s.", relate_processes[i]);
+    }
+    Dbg("COUNT = %d!", count);
+    osutil_detect_unique_app(relate_processes, pSize, &count, processes);
+
+    int cnt(0);
+    for (int i = 0; i < pSize; ++i) {
+        int k = -1;
+        for (int j = 0; j < count; ++j) {
+            if (strcmp(processes[j].name, relate_processes[i]) == 0) {
+                k = j;
+                break;
+            }
+        }
+
+        if (k != -1 && old_process_id[i] == -1) {
+            msgs[cnt++] = CSimpleStringA::Format("{\"name\":\"%s\", \"pid\":%d}"
+                , relate_processes[i], processes[k].pid);
+            old_process_id[i] = processes[k].pid;
+
+        }
+        else if (k != -1 && (processes[k].pid != old_process_id[i])) {
+            msgs[cnt++] = CSimpleStringA::Format("{\"name\":\"%s\", \"prev\":%d, \"pid\":%d}"
+                , relate_processes[i], old_process_id[i], processes[k].pid);
+            old_process_id[i] = processes[k].pid;
+
+        }
+        else if (k == -1 && old_process_id[i] != 0) {
+            msgs[cnt++] = CSimpleStringA::Format("{\"name\":\"%s\", \"prev\":%d, \"pid\":%d}"
+                , relate_processes[i], old_process_id[i], 0);
+            old_process_id[i] = 0;
+        }
+    }
+
+    std::string uploadInfo("");
+    if (cnt > 0) {
+        if (cnt > 1) {
+            uploadInfo = "{";
+        }
+        for (int i = 0; i < cnt; ++i) {
+            if (i != 0) {
+                uploadInfo += ",";
+            }
+            uploadInfo += msgs[i].GetData();
+        }
+        if (cnt > 1) {
+            uploadInfo += "}";
+        }
+    }
+
+    return uploadInfo;
+}
+
+void ResourceWatcherEntity::FilesClean(SpReqAnsContext<ResourceWatcherService_FilesClean_Req, ResourceWatcherService_FilesClean_Ans>::Pointer ctx)
+{
+    ErrorCodeEnum result(Error_Succeed);
+    ErrorCodeEnum tmpResult(Error_Succeed);
+    CSimpleStringA tmpMsg(true);
+
+    if (ctx->Req.type == 1)//清理浏览器缓存
+    {
+        BrowserCacheClean browserCacheClean;
+        browserCacheClean.needClean = 1;
+
+        SpSendBroadcast(GetFunction(),
+            SP_MSG_OF(BrowserCacheClean), SP_MSG_SIG_OF(BrowserCacheClean), browserCacheClean);
+
+        tmpMsg = "已发送重启命令";
+    }
+    else
+    {
+        tmpResult = Error_NotExist;
+        tmpMsg = "非法的调用参数";
+    }
+
+    ctx->Ans.result = tmpResult;
+    ctx->Ans.msg = tmpMsg;
+    ctx->Answer(result);
+}
+
+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);
+
+    } else {
+        ctx->Ans.result = -1;
+        ctx->Ans.msg = "调用 GetMonitorInfo 接口失败";
+    }
+    ctx->Answer(Error_Succeed);
+}
+
 SP_BEGIN_ENTITY_MAP()
 SP_ENTITY(ResourceWatcherEntity)
 SP_END_ENTITY_MAP()
@@ -1301,3 +1781,4 @@ SP_END_ENTITY_MAP()
 
 
 
+

+ 24 - 0
Module/mod_ResourceWatcher/mod_ResourceWatcher.h

@@ -56,6 +56,14 @@ public:
 
 	virtual void Handle_UninstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_UninstallThirdPartyProgram_Req, ResourceWatcherService_UninstallThirdPartyProgram_Ans>::Pointer ctx);
 
+	virtual void Handle_RestartThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_RestartThirdPartyProgram_Req, ResourceWatcherService_RestartThirdPartyProgram_Ans>::Pointer ctx);
+
+	virtual void Handle_ProcessDetectThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_ProcessDetectThirdPartyProgram_Req, ResourceWatcherService_ProcessDetectThirdPartyProgram_Ans>::Pointer ctx);
+
+	virtual void Handle_FilesClean(SpReqAnsContext<ResourceWatcherService_FilesClean_Req, ResourceWatcherService_FilesClean_Ans>::Pointer ctx);
+
+	virtual void Handle_FetchSystemSnapshot(SpReqAnsContext<ResourceWatcherService_FetchSystemSnapshot_Req, ResourceWatcherService_FetchSystemSnapshot_Ans>::Pointer ctx);
+
 private:
 	ResourceWatcherEntity* m_pEntity;
 };
@@ -270,6 +278,18 @@ public:
 
     void InstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_InstallThirdPartyProgram_Req, ResourceWatcherService_InstallThirdPartyProgram_Ans>::Pointer ctx);
 
+	void RestartThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_RestartThirdPartyProgram_Req,
+		ResourceWatcherService_RestartThirdPartyProgram_Ans>::Pointer ctx);
+
+	void ProcessDetectThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_ProcessDetectThirdPartyProgram_Req,
+		ResourceWatcherService_ProcessDetectThirdPartyProgram_Ans>::Pointer ctx);
+
+	void FilesClean(SpReqAnsContext<ResourceWatcherService_FilesClean_Req,
+		ResourceWatcherService_FilesClean_Ans>::Pointer ctx);
+
+	void FetchSystemSnapshot(SpReqAnsContext<ResourceWatcherService_FetchSystemSnapshot_Req, ResourceWatcherService_FetchSystemSnapshot_Ans>::Pointer ctx);
+
+
 	virtual void OnSysVarEvent(const char* pszKey, const char* pszValue, const char* pszOldValue, const char* pszEntityName);
 
 #if defined(_MSC_VER)
@@ -333,6 +353,10 @@ private:
 
 		ErrorCodeEnum GetSogouPkgDirPath(CSimpleStringA& strPkgPath);
 		ErrorCodeEnum RunShellScript(LPCTSTR cmdline);
+		std::string DoCheckCertainProcessStatus(const CAutoArray<CSimpleStringA>& pName);
+
+		ErrorCodeEnum GetUnzipTempDir(CSimpleStringA& strUnzipDir);
+		ErrorCodeEnum UnzipPack(const char* unZipPackName);
 
 private:
 	ResourceWatcherFSM m_fsm;

+ 1 - 1
Module/mod_UpgradeMgr/UpgradeTaskFSM.cpp

@@ -1,4 +1,4 @@
-#include "UpgradeTaskFSM.h"
+#include "UpgradeTaskFSM.h"
 #include "fileutil.h"
 #include "iniutil.h"
 #include "memutil.h"

+ 29 - 19
Module/mod_cardissuer/CardIssuerFSM.cpp

@@ -1723,7 +1723,9 @@ ErrorCodeEnum CCardIssuerFSM::OnExit()
 					LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_EjectCard, "OnExit, issue flag is 0, to eject card");
 					eExit = MachineMoveCardFrontGate();
 					if (eExit != Error_Succeed) {
-						LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_EjectCard_Failed, "OnExit::MachineMoveCardFrontGate, eject card failed.");
+                        SetErrPackage(m_errPkg, "OnExit::MoveCard(CI_MOVECARD_FRONT_GATE)"
+                                      , m_csDevSN, eExit, MEC_DEVAPI_CARDISSUER_MoveCard);
+                        AlarmDEC(m_errPkg);
 					}
 				}
 			}
@@ -1831,12 +1833,14 @@ int CCardIssuerFSM::Reset()
 				}
 				else
 				{
+                    LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_EjectCard, "issue flag is 0, to eject card.");
 					//oiltmp to add 20131212
 					eMoveErr = MachineMoveCardFrontGate();
-					LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_EjectCard, "issue flag is 0, to eject card.");
 					if (eMoveErr != Error_Succeed)
 					{
-						LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_EjectCard_Failed, "Reset, eject card failed.");
+                        SetErrPackage(m_errPkg, "Reset::MoveCard(CI_MOVECARD_FRONT_GATE)"
+                                      , m_csDevSN, eMoveErr, MEC_DEVAPI_CARDISSUER_MoveCard);
+                        AlarmDEC(m_errPkg);
 					}
 				}
 				if (eMoveErr == Error_Succeed)
@@ -2862,12 +2866,13 @@ int CCardIssuerFSM::EjectCard(SpReqAnsContext<CardIssuerService_Eject_Req,CardIs
 		ret = 0;
 	}
 	else {
+        SetErrPackage(m_errPkg, "EjectCard::MoveCard(CI_MOVECARD_FRONT_GATE)"
+                      , m_csDevSN, eErr, MEC_DEVAPI_CARDISSUER_MoveCard);
 		if (ctx != NULL) {
             LogError(Severity_High, Error_Unexpect, CardIssuer_UserErrorCode_EjectCard_Failed, "EjectCard failed.");
-			SetErrPackage(m_errPkg, "EjectCard::MachineMoveCardFrontGate", m_csDevSN, eErr, CardIssuer_UserErrorCode_MoveCardToGate_Failed);
-			ctx->Answer(Error_Exception, AlarmDEC(m_errPkg, true, false));
+			ctx->Answer(eErr, AlarmDEC(m_errPkg, true, false));
 		} else {
-            LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_EjectCard_Failed, "EjectCard failed(NotCtx).");
+			AlarmDEC(m_errPkg);
 		}
 
 		ret = 1;
@@ -2996,13 +3001,17 @@ Err:
 				}
 				else
 				{
-					LogError(Severity_Middle, eErr4FrontGate, CardIssuer_UserErrorCode_EjectCard_Failed, "InternalAcceptCard::MachineMoveCardFrontGate failed.");
+                    SetErrPackage(m_errPkg, "InternalAcceptCard::MoveCard(CI_MOVECARD_FRONT_GATE)"
+                                  , m_csDevSN, eErr4FrontGate, MEC_DEVAPI_CARDISSUER_MoveCard);
+                    AlarmDEC(m_errPkg, true);
 					err = 2;
 				}
 			}
 		}
-		else
+		else {
 			err = 2;
+		}
+			
 	}
 	return err;
 }
@@ -3355,10 +3364,13 @@ int CCardIssuerFSM::ReadCard(SpReqAnsContext<CardIssuerService_Read_Req,CardIssu
 					ctx->Ans.ICType = 3;
 					LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_MaybeIC_Only, "<ReadCard>, maybe ic only.");
 				}
-				else
+				else if(Error_Succeed != eErr)
 				{
 					SetErrPackage(m_errPkg, "ReadCard::MagRead", m_csDevSN, eErr, MEC_DEVAPI_CARDISSUER_MagRead);
 					AlarmDEC(m_errPkg);
+				} else {
+					LogWarn(Severity_Middle, Error_DataCheck, CardIssuer_UserErrorCode_Track2Status_IS_NotOK, CSimpleStringA::Format(
+						"ReadCard::MagRead detects track2 status error: %d", magTracks.track[1].eStatus));
 				}
 			}
 
@@ -3389,14 +3401,17 @@ int CCardIssuerFSM::ReadCard(SpReqAnsContext<CardIssuerService_Read_Req,CardIssu
 		if (!m_issueStatus)
 		{
 			Dbg("ReadCarad failed, eject self");
-			ErrorCodeEnum errEject = MachineMoveCardFrontGate();
+			const ErrorCodeEnum errEject = MachineMoveCardFrontGate();
 			if (errEject == Error_Succeed)
 			{
 				Dbg("read failed.eject self");
 				bEjectSelf = true;
 			}
-			else
-				LogError(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_EjectCard_Failed, "ReadCard::MachineMoveCardFrontGate failed.");
+			else {
+                SetErrPackage(m_errPkg, "ReadCard::MoveCard(CI_MOVECARD_FRONT_GATE)"
+                              , m_csDevSN, errEject, MEC_DEVAPI_CARDISSUER_MoveCard);
+                AlarmDEC(m_errPkg, true);
+			}
 		}
 	}
 	if (GetDevStatus())
@@ -4175,14 +4190,9 @@ ErrorCodeEnum CCardIssuerFSM::MachineMoveCardBackNotHold()
 }
 ErrorCodeEnum CCardIssuerFSM::MachineMoveCardFrontGate()
 {
-	LOG_FUNCTION();
-	ErrorCodeEnum eMoveFrontGate = m_hDevHelper->MoveCard(CI_MOVECARD_FRONT_GATE);
-	if (eMoveFrontGate != Error_Succeed) {
-		SetErrPackage(m_errPkg, "MachineMoveCardFrontGate::MoveCard(CI_MOVECARD_FRONT_GATE)", m_csDevSN, eMoveFrontGate, MEC_DEVAPI_CARDISSUER_MoveCard);
-		AlarmDEC(m_errPkg);
-	}
-	return eMoveFrontGate;
+	return m_hDevHelper->MoveCard(CI_MOVECARD_FRONT_GATE);
 }
+
 int CCardIssuerFSM::QueryCardInfo()
 {
 	int ret;

+ 1 - 1
Module/mod_cardissuer/CardIssuer_UserErrorCode.h

@@ -162,6 +162,6 @@
 #define CardIssuer_UserErrorCode_QueryCardInfoOnStore_Inparam			(CardIssuer_UserErrorCode_Start + 143)	//盘库接口入参
 
 #define CardIssuer_UserErrorCode_AcceptCard_Failed					(CardIssuer_UserErrorCode_Start + 144)	//读卡失败
-
+#define CardIssuer_UserErrorCode_Track2Status_IS_NotOK			(CardIssuer_UserErrorCode_Start + 145)	//二磁道数据异常
 
 #endif //_CARDISSUER_USER_ERRORCODE_H

+ 27 - 13
Module/mod_chromium/CModTools.cpp

@@ -49,7 +49,7 @@ auto detectUrls = [](std::string urls) -> std::string {
 	std::vector<std::string> urlArr;
 	urlArr.emplace_back(urls);
 	auto checkRet = DetectActiveHttp(urlArr);
-	LogWarn(Severity_Middle, Error_Debug, LOG_SLV_CHROMIUM_URLCHECK,
+	LogWarn(Severity_Low, Error_Debug, LOG_SLV_CHROMIUM_URLCHECK,
 		CSimpleStringA::Format("check chromium url %d, %s", checkRet.first, checkRet.first ? checkRet.second.c_str() : urls.c_str()));
 	if (checkRet.first)
 		return checkRet.second.c_str();
@@ -58,7 +58,17 @@ auto detectUrls = [](std::string urls) -> std::string {
 };
 namespace Chromium {
 
-	boost::mutex g_mutexFreerdp;
+	boost::mutex g_mutexFreerdp, m_guardInterruptLock;
+
+	void CModTools::lockGuard()
+	{
+		m_guardInterruptLock.lock();
+	}
+
+	void CModTools::unlockGuard()
+	{
+		m_guardInterruptLock.unlock();
+	}
 
 	void CModTools::InitCModTools(CEntityBase* pEntity) {
 		this->m_pEntity = pEntity;
@@ -89,7 +99,7 @@ namespace Chromium {
 		m_UserMgrUrlNoSidebarMutiStr = std::get<2>(configRet);
 		m_UserMgrUrlFultureStr = std::get<3>(configRet);
 		m_UserMgrAdStr = std::get<4>(configRet);
-		notifyExist = breakdownExist = false;
+		notifyExist = breakdownExist = m_isAdOpen = false;
 		m_magicStr = uuid4_generate(8);
 		m_withMin = false;
 #if (defined _WIN32 || defined _WIN64)
@@ -126,6 +136,7 @@ namespace Chromium {
             child_process.wait();
         } while (false);
 
+		breakdownExist = m_isAdOpen = notifyExist = false;
 		DbgEx("run killAllChromium success ex");
 		return true;
 #endif
@@ -462,7 +473,7 @@ namespace Chromium {
 
 			strUOSBrowserPath.Append(strParams);
 
-            LogWarn(Severity_High, Error_Unexpect, LOG_EVT_CHROMIUM_OPEN_AD_WITH_UOSV2, strUOSBrowserPath);
+            LogWarn(Severity_Low, Error_Unexpect, LOG_EVT_CHROMIUM_OPEN_AD_WITH_UOSV2, strUOSBrowserPath);
             return strUOSBrowserPath.GetData();
 		}
 
@@ -497,7 +508,7 @@ namespace Chromium {
 
             strUOSBrowserPath.Append(strParams);
 
-            LogWarn(Severity_High, Error_Unexpect, LOG_EVT_CHROMIUM_OPEN_AD_WITH_UOS, strUOSBrowserPath);
+            LogWarn(Severity_Low, Error_Unexpect, LOG_EVT_CHROMIUM_OPEN_AD_WITH_UOS, strUOSBrowserPath);
             return strUOSBrowserPath.GetData();
         }
 
@@ -607,7 +618,7 @@ namespace Chromium {
 			strParams.Append(" ");
             strParams.Append(mainUrl.c_str());
             strUOSBrowserPath.Append(strParams);
-            LogWarn(Severity_High, Error_Unexpect, LOG_EVT_CHROMIUM_OPEN_MAIN_WITH_UOSV2, strUOSBrowserPath);
+            LogWarn(Severity_Low, Error_Unexpect, LOG_EVT_CHROMIUM_OPEN_MAIN_WITH_UOSV2, strUOSBrowserPath);
 
             return strUOSBrowserPath.GetData();
 		}
@@ -643,7 +654,7 @@ namespace Chromium {
 
 			strUOSBrowserPath.Append(strParams);
 
-            LogWarn(Severity_High, Error_Unexpect, LOG_EVT_CHROMIUM_OPEN_MAIN_WITH_UOS, strUOSBrowserPath);
+            LogWarn(Severity_Low, Error_Unexpect, LOG_EVT_CHROMIUM_OPEN_MAIN_WITH_UOS, strUOSBrowserPath);
 
 			return strUOSBrowserPath.GetData();
 		}
@@ -702,8 +713,7 @@ namespace Chromium {
 	}
 
 	std::pair<bool, std::string> CModTools::openAdPage() {
-		static bool adOpen = false;
-		if (adOpen)//only open ad in first time
+		if (m_isAdOpen)//only open ad in first time
 			return std::make_pair(false, "open AdPage failed! Already exist.");
 
 		auto AdUrlRet = getAdUrl();
@@ -715,7 +725,7 @@ namespace Chromium {
 				return std::make_pair(false, "open Ad err!");
 			else
 			{
-				adOpen = true;
+				m_isAdOpen = true;
 				return std::make_pair(true, "");
 			}
 
@@ -748,7 +758,7 @@ namespace Chromium {
 
 			auto openCefRet = openCef(strCmdLine, (m_UseUOSBrowser == 0), !(m_UseUOSBrowser == 2));//with guard
 			if (Error_Succeed == openCefRet.first) {
-                LogWarn(Severity_Middle, Error_Debug, LOG_EVT_CHROMIUM_OPEN_MAIN_URL,
+                LogWarn(Severity_Low, Error_Debug, LOG_EVT_CHROMIUM_OPEN_MAIN_URL,
                         CSimpleStringA::Format("StartChromiumBrowser %s", mainUrlRet.second.c_str()));
 
 #ifndef UNDER_PRODUCT_ENV
@@ -1121,6 +1131,9 @@ namespace Chromium {
 
     int CModTools::ToGetUOSBrowserType()
     {
+#if (defined _WIN32 || defined _WIN64)
+		return 0;
+#else
 		const std::string execute_newbrowser_path = "/usr/share/browser/browser";
         const std::string execute_oldbrowser_path = "/usr/share/uosbrowser/uosbrowser";
 
@@ -1152,6 +1165,7 @@ namespace Chromium {
 		UploadBrowserInfo(result, additional.c_str());
 
 		return result;
+#endif
     }
 
     void CModTools::UploadBrowserInfo(int usingType, LPCTSTR info)
@@ -1163,7 +1177,7 @@ namespace Chromium {
 		spConfig->ReadConfigValueInt("BrowserUse", "Type", oldType);
 		spConfig->ReadConfigValue("BrowserUse", "Version", strVersion);
 		if (oldType != usingType || strVersion.Compare(info) != 0) {
-            LogWarn(Severity_High, Error_Unexpect, LOG_EVT_CHROMIUM_BROWSER_USING_TYPE_CHANGE,
+            LogWarn(Severity_Low, Error_Unexpect, LOG_EVT_CHROMIUM_BROWSER_USING_TYPE_CHANGE,
 					CSimpleStringA::Format("{ \"type\":%d, \"version\":\"%s\"}", usingType, info));
 
             spConfig->WriteConfigValueInt("BrowserUse", "Type", usingType);
@@ -1240,7 +1254,7 @@ namespace Chromium {
 		if (pChromiumEntity != nullptr && pChromiumEntity->HasCustomMainUrl()) {
 			strFulture = pChromiumEntity->GetCustomMainUrl();
 			CSimpleStringA strTmp = CSimpleStringA::Format("更新业务中台链接为:[%s]", strFulture.GetData());
-			LogWarn(Severity_High, Error_Debug, LOG_EVT_CHROMIUM_USE_CUSTOM_FULTURE_URL, strTmp);
+			LogWarn(Severity_Low, Error_Debug, LOG_EVT_CHROMIUM_USE_CUSTOM_FULTURE_URL, strTmp);
 		}
 
 		return std::make_tuple(str, strNew, strEx, strFulture, strAd);

+ 5 - 1
Module/mod_chromium/CModTools.h

@@ -53,6 +53,9 @@ namespace Chromium {
 		CSimpleString getFultureUrl() {
 			return m_UserMgrUrlFultureStr; 
 		}
+		void lockGuard();
+
+		void unlockGuard();
 	private:
 		std::pair<CSimpleStringA, int>  ReadConfig();	//读本地配置,已废弃
 		std::tuple<CSimpleStringA, CSimpleStringA, CSimpleStringA, CSimpleStringA, CSimpleStringA> ReadCenterConfigStr(CSimpleStringA entityName = "");
@@ -96,7 +99,7 @@ namespace Chromium {
 
 		bool findRestartCode(DWORD userCode);//if true, restart the terminal
 		DWORD spiltErrMsg(std::string errMsg);//split the errmsg to usercode
-		bool notifyExist, breakdownExist;	//if notify exist, do not start other err page
+		bool notifyExist, breakdownExist, m_isAdOpen;	//if notify exist, do not start other err page
 	private:
 		CSimpleString m_strSite, m_strMachineType;
 		CSimpleString m_UserMgrUrlStr, m_UserMgrUrlNoSidebarStr, m_UserMgrUrlNoSidebarMutiStr, m_UserMgrUrlFultureStr, m_UserMgrAdStr;
@@ -105,6 +108,7 @@ namespace Chromium {
 		/** 0:使用CefClient,1:使用旧版UOS浏览器uos-browser-stable ;2:使用新版UOS浏览器org.deepin.browser  [Gifur@2022228]*/
 		int m_UseUOSBrowser;
 		bool m_isGuardMainBrowser;
+		
 	};
 
 	template<class T>

+ 1 - 1
Module/mod_chromium/CSocketClient.cpp

@@ -117,7 +117,7 @@ namespace Chromium {
 	}
 
 	ErrorCodeEnum CSocketClient::Write(CMessage* pMsg) {
-		DbgEx("CSocketClient method -> write, %s", hexdumpToString(pMsg->getPayload(), pMsg->getLength()).c_str());
+		//DbgEx("CSocketClient method -> write, %s", hexdumpToString(pMsg->getPayload(), pMsg->getLength()).c_str());
 		if (m_psocket && m_psocket->is_open())
 		{
 			//::DbgEx("m_psocket->async_send");

+ 7 - 0
Module/mod_chromium/CStructureInterpreter.cpp

@@ -53,7 +53,9 @@ namespace Chromium {
 		std::string strClassName = pClass->Attribute("name");
 		std::map<int, CMedthodInterface> functionInterface;
 		this->loadFunctionInterface(functionInterface, pClass);
+		m_inServiceEntity.insert(strEntityName);
 		this->mMethodStructureMap.insert(std::pair<std::string, std::map<int, CMedthodInterface>>(strEntityName.append(strClassName), functionInterface));
+		
 	}
 
 
@@ -164,6 +166,11 @@ namespace Chromium {
 		return &(iter->second);
 	}
 
+	bool CStructureInterpreter::checkEntityInservice(std::string entityName)
+	{
+		return m_inServiceEntity.find(entityName) != m_inServiceEntity.end();
+	}
+
 	int CStructureInterpreter::convertStringToInt(std::string s) {
 		int val;
 		std::strstream ss;

+ 3 - 0
Module/mod_chromium/CStructureInterpreter.h

@@ -2,6 +2,7 @@
 #define CStructureInterpreter_h
 
 #include <map>
+#include <unordered_set>
 #include <vector>
 #include <string>
 #include "CMethodInterface.h"
@@ -13,6 +14,7 @@ namespace Chromium {
 		explicit CStructureInterpreter(const char* path);
 		CMedthodInterface* getFunctionInterface(char* entityName, char* className, int methodID);
 		std::vector<CMedthodInterface>* getAllMessageInterface(const char* entityName);
+		bool checkEntityInservice(std::string entityName);
 	private:
 		// methods 
 		void getAllFiles();
@@ -28,6 +30,7 @@ namespace Chromium {
 		std::map<std::string, std::vector<CMedthodInterface>> mMessageStructureMap;
 		std::string mPathOfXmls;
 		std::vector<std::string> mFiles;
+		std::unordered_set<std::string> m_inServiceEntity;
 	};
 }
 

+ 20 - 16
Module/mod_chromium/CWSCodec.cpp

@@ -56,6 +56,14 @@ namespace Chromium {
 		return &obj;
 	}
 
+	bool CWSCodec::checkEntityHasService(std::string entityName)
+	{
+		if (!mInterpreter)
+			return true;//默认有service
+
+		return mInterpreter->checkEntityInservice(entityName);
+	}
+
 	void CWSCodec::setEntityHandler(CSmartPointer<IEntityFunction> p) {
 		this->m_pFunc = p;
 	}
@@ -456,8 +464,6 @@ namespace Chromium {
 		if (msg.getLength() < 12)	//End session len = 12
 			return std::string(); // 丢弃消息
 
-
-
 		// 通用反序列化
 		cJSON_AddNumberToObject(ret, "messageType", msg.getMessageType());
 		switch (msg.getMessageType()) {
@@ -466,13 +472,11 @@ namespace Chromium {
 			cJSON_AddNumberToObject(ret, "transID", replaceTransId != 0 ? replaceTransId : msg.getTransID());
 			cJSON_AddNumberToObject(ret, "isEnd", msg.getIsEnd());
 			rpos += 1;
-#if (defined _WIN32 || defined _WIN64)
-#else
-			ReadT(msg.getPayload(), userCode, &rpos);
+#if defined(RVC_OS_LINUX)
+            ReadT(msg.getPayload(), userCode, &rpos);
             /** 业务端要求返回userCode,需要改动框架,依赖信创版本框架 1.0.7-dev15 [Gifur@2021119]*/
             cJSON_AddNumberToObject(ret, "userCode", userCode);
-#endif
-            
+#endif //RVC_OS_LINUX
 			ReadT(msg.getPayload(), errorCode, &rpos);
 			cJSON_AddNumberToObject(ret, "errorCode", errorCode);
 			ReadT(msg.getPayload(), errorMsg, &rpos);
@@ -695,7 +699,7 @@ namespace Chromium {
 				CSimpleStringA bussinessId = "ChromiumAutoGen";
 				CSimpleStringA traceId = uuid4_generate(32).c_str();
 				CSimpleStringA spanId = uuid4_generate(16).c_str();
-				CSimpleStringA parentSpanId = "0000000000000000";
+				CSimpleStringA parentSpanId = "0";
 				WriteT(data, bussinessId, &wpos, &capacity);//为适配silverlight,默认写入就是unicode
 				WriteT(data, traceId, &wpos, &capacity);
 				WriteT(data, spanId, &wpos, &capacity);
@@ -815,7 +819,7 @@ namespace Chromium {
 			CSimpleStringA bussinessId = "ChromiumAutoGen";
 			CSimpleStringA traceId = uuid4_generate(32).c_str();
 			CSimpleStringA spanId = uuid4_generate(16).c_str();
-			CSimpleStringA parentSpanId = "0000000000000000";
+			CSimpleStringA parentSpanId = "0";
 			WriteT(data, bussinessId, wpos, capacity);//为适配silverlight,默认写入就是unicode
 			WriteT(data, traceId, wpos, capacity);
 			WriteT(data, spanId, wpos, capacity);
@@ -936,7 +940,7 @@ namespace Chromium {
 			CSimpleStringA bussinessId = "ChromiumAutoGen";
 			CSimpleStringA traceId = uuid4_generate(32).c_str();
 			CSimpleStringA spanId = uuid4_generate(16).c_str();
-			CSimpleStringA parentSpanId = "0000000000000000";
+			CSimpleStringA parentSpanId = "0";
 			WriteT(data, bussinessId, wpos, capacity);//为适配silverlight,默认写入就是unicode
 			WriteT(data, traceId, wpos, capacity);
 			WriteT(data, spanId, wpos, capacity);
@@ -1218,10 +1222,10 @@ namespace Chromium {
 			}
 			else if (it->mType == "array_int")
 			{
-				DbgEx("array int -> ");
+				//DbgEx("array int -> ");
 				int len = 0;
 				if (GetCJsonArraySize(js, it->mName.c_str(), len, errmsg)) {
-					DbgEx("array int -> true len = %d", len);
+					//DbgEx("array int -> true len = %d", len);
 					WriteT(data, len, wpos, capacity);
 					unsigned int d = 0;
 					for (int i = 0; i < len; ++i) {
@@ -1239,10 +1243,10 @@ namespace Chromium {
 			}
 			else if (it->mType == "array_uint")
 			{
-				DbgEx("array uint -> ");
+				//DbgEx("array uint -> ");
 				int len = 0;
 				if (GetCJsonArraySize(js, it->mName.c_str(), len, errmsg)) {
-					DbgEx("array int -> true len = %d", len);
+					//DbgEx("array int -> true len = %d", len);
 					WriteT(data, len, wpos, capacity);
 					unsigned int d = 0;
 					for (int i = 0; i < len; ++i) {
@@ -1261,10 +1265,10 @@ namespace Chromium {
 			}
 			else if (it->mType == "array_string")
 			{
-				DbgEx("array string -> ");
+				//DbgEx("array string -> ");
 				int len = 0;
 				if (GetCJsonArraySize(js, it->mName.c_str(), len, errmsg)) {
-					DbgEx("array string -> true len = %d, %s", len, it->mName.c_str());
+					//DbgEx("array string -> true len = %d", len);
 					WriteT(data, len, wpos, capacity);
 					CSimpleStringA d = "";
 					for (int i = 0; i < len; ++i) {

+ 2 - 0
Module/mod_chromium/CWSCodec.h

@@ -30,6 +30,8 @@ namespace Chromium {
 
 		std::string GetEntityName(std::string strJson);
 		std::string GetClassName(std::string strJson);
+
+		bool checkEntityHasService(std::string entityName);
 	private:
 		void DeserializeRequestAck(CMessage& msg, std::map<int, entity_def_struct>::iterator& it, int& rpos, cJSON* ret);
 		void DeserializeEvent(CMessage& msg, std::vector<CMedthodInterface>* list, int& rpos, cJSON* ret);

+ 24 - 36
Module/mod_chromium/CWebsocketServer.cpp

@@ -130,9 +130,8 @@ namespace Chromium {
 			m_esm->updateBeginSessionTime(entityName);
 			WriteToFramework(sessionBuf);
 		}
-		else {
+		else
 			DbgEx("Already begin session in 5s, %s", entityName.c_str());
-		}
 	}
 
 	void CWebsocketServer::WriteToFramework(CMessage* msg)
@@ -291,9 +290,8 @@ namespace Chromium {
 			}
 			return;
 		}
-		else if (ret.first == BeginSession) {
+		else if (ret.first == BeginSession)
 			storeEntityWithCLass(m_serializer->GetEntityName(payload), m_serializer->GetClassName(payload));
-		}
 
 		// Try to manage entity session
 		RequestProcessType processType = this->m_esm->RequestProcess(p, m_serializer->GetEntityName(payload), (long)hdl.lock().get());
@@ -304,7 +302,7 @@ namespace Chromium {
 			DbgEx("do PROCESS_NOTHING");
 			return;
 		case Chromium::PROCESS_SEND:
-			DbgEx("do PROCESS_SEND");
+			//DbgEx("do PROCESS_SEND");
 			if (nullptr != p)
 				WriteToFramework(p);
 			break;
@@ -350,12 +348,15 @@ namespace Chromium {
 		if (t_hdlArr.end() == t_hdlArr.find(hdlPos))
 			t_hdlArr[hdlPos] = pos++;
 
+
 		auto msgHandleFun = [&]() {
+			//DbgEx("CWebsocketServer -> message_handler");
 			std::string payload = msg->get_payload();
 			// proto convert here
 #if (defined _WIN32 || defined _WIN64)
 			payload = utf8_to_string(payload);//windows web utf8, terminal gbk
 #endif
+
 			std::shared_ptr<cJSON> pJson(cJSON_Parse(payload.c_str()), [](cJSON* p) {
                 if (nullptr != p) {
                     cJSON_Delete(p);
@@ -465,46 +466,22 @@ namespace Chromium {
 
 		auto checkEntityIsNoStart = [&](std::string entityName) -> bool
 		{
-			/*
-			enum EntityStateEnum
-			{
-				EntityState_NoStart = 0,		//no start before
-				EntityState_Starting,			//Entity is doing initial
-				EntityState_Idle,				//after started succeed,and have no work
-				EntityState_Busy,				//Doing Request-Answer,timing,and Pausing or coninuing work
-				EntityState_Pause,			//Pause state
-				EntityState_UnLoading,		//doing cleanning after trigger close
-				EntityState_Lost,				//Entity block not respond or exception
-				EntityState_Close,				//After close,start before
-				EntityState_Killed,				//The entity terminated as block state
-			};
-
-			*/
 			CSmartPointer<IEntityFunction> spFunc = m_pEntity->GetFunction();
 			LOG_ASSERT(spFunc != NULL);
 			CEntityStaticInfo StaticInfo;
 			CEntityRunInfo RunInfo;
-			bool result(false);
 
 			do {
+				if (Error_Succeed != spFunc->GetEntityStaticInfo(entityName.c_str(), StaticInfo))
+					break;
 
-				ErrorCodeEnum ec = spFunc->GetEntityStaticInfo(entityName.c_str(), StaticInfo);
-				if (ec != Error_Succeed) {
-					result = (ec == Error_NotExist);
-                    break;
-				}
-
-				ec = spFunc->GetEntityRunInfo(entityName.c_str(), RunInfo);
-                if (ec != Error_Succeed) {
-                    result = (ec == Error_NotExist);
-                    break;
-                }
-
-				result = (RunInfo.eState == EntityState_NoStart);
+				if (Error_Succeed != spFunc->GetEntityRunInfo(entityName.c_str(), RunInfo))
+					break;
 
+				return RunInfo.eState == EntityState_NoStart;
 			} while (false);
 
-			return result;
+			return true;
 		};
 
 
@@ -517,6 +494,7 @@ namespace Chromium {
 				boost::lock_guard<boost::mutex> lock(m_dealMsgLock);
 				std::string breakEntityStr = "";
 				std::string noStartEntity = "";
+				std::string noServerEntity = "";
 #if (defined _WIN32 || defined _WIN64)
 				for each (auto it in unlinkArr)
 #else
@@ -531,6 +509,16 @@ namespace Chromium {
 							noStartEntity.append("|").append(it);
 						continue;
 					}
+
+					if (!CWSCodec::getInstance()->checkEntityHasService(it))
+					{
+						if (noServerEntity.empty())
+							noServerEntity.append(it);
+						else
+							noServerEntity.append("|").append(it);
+						continue;
+					}
+					
 						
 
 					auto ret = getEntityClass(it);
@@ -546,7 +534,7 @@ namespace Chromium {
 						DbgEx("unable find class of entity %s", it.c_str());
 				}
 				if (!breakEntityStr.empty())
-					DbgEx("try to relink entity : %s, noStartEntity: %s", breakEntityStr.c_str(), noStartEntity.c_str());
+					DbgEx("try to relink entity : %s, noStartEntity: %s, noServerEntity: %s", breakEntityStr.c_str(), noStartEntity.c_str(), noServerEntity.c_str());
 			}
 			catch (...)
 			{

+ 9 - 2
Module/mod_chromium/baseEx.cpp

@@ -170,7 +170,7 @@ DWORD SaveCefclientLog(std::string magicStr)
 	return 0;
 }
 
-std::vector<std::string> find_files(const std::string srcPath, const std::string fileName)
+std::vector<std::string> find_files(const std::string srcPath, const std::string fileName, bool isDir)
 {
 	static boost::xpressive::sregex_compiler rc;
 	if (!rc[fileName].regex_id())
@@ -189,13 +189,20 @@ std::vector<std::string> find_files(const std::string srcPath, const std::string
 	rd_iterator end;
 	for (rd_iterator pos(srcPath); pos != end; ++pos)
 	{
-		if (!boost::filesystem::is_directory(*pos) && boost::xpressive::regex_match(pos->path().filename().string(), rc[fileName]))
+		if ((isDir ? boost::filesystem::is_directory(*pos) : !boost::filesystem::is_directory(*pos)) && boost::xpressive::regex_match(pos->path().filename().string(), rc[fileName]))
 			ret.emplace_back(pos->path().string());
 	}
 
 	return ret;
 }
 
+bool deleteDir_byFileSystem(const std::string srcPath)
+{
+	boost::system::error_code ec;
+	return boost::filesystem::remove_all(srcPath, ec);
+
+}
+
 std::string generateTimeStr(bool isSimple)
 {
 	auto tt = boost::chrono::system_clock::to_time_t(boost::chrono::system_clock::now());

+ 3 - 1
Module/mod_chromium/baseEx.h

@@ -7,13 +7,15 @@ extern void* logProducer;
 extern bool g_useMagic;
 
 void DbgEx(const char* str, ...);
-std::vector<std::string> find_files(const std::string srcPath, const std::string fileName);
+std::vector<std::string> find_files(const std::string srcPath, const std::string fileName, bool isDir = false);
 std::string generateTimeStr(bool isSimple = false);
 DWORD SaveCefclientLog(std::string magicStr);
 bool SYSTEM_ON(std::string cmdLine, bool isWait = true);
 bool InitFileLogger(std::string dbgPath);
 void DbgToFileLogger(std::string msg);
 
+bool deleteDir_byFileSystem(const std::string srcPath);
+
 
 #if (defined _WIN32 || defined _WIN64)
 #else

+ 66 - 13
Module/mod_chromium/mod_chromium.cpp

@@ -7,8 +7,8 @@
 #define SPLIT_SLASH_STR "\\"
 #else
 #include <signal.h>
-#include "fileutil.h"
 #endif
+#include "fileutil.h"
 #include "baseEx.h"
 #include "CWebsocketServer.h"
 #include "mod_chromium.h"
@@ -23,12 +23,14 @@
 #include "../mod_upload/Upload_client_g.h"
 #include <tuple>
 #include <string>
+#include <algorithm>
 #include "EventCode.h"	
 #ifdef OPEN_PERF
 #include <gperftools/profiler.h>
 #endif // OPEN_PERF
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include "../mod_CameraConfigManage/Event.h"
+#include "../mod_ResourceWatcher/ResourceWatcher_msg_g.h"
 /*
 #define LOG_EVT_BEGIN_CAMERA_CONFIG    0x21D00001
 #define LOG_EVT_END_CAMERA_CONFIG      0x21D00002
@@ -342,11 +344,11 @@ namespace Chromium {
 
 		if (!m_withBrowser)
 		{//有browser的时候不需要订阅这一堆
-			Error = GetFunction()->SubscribeLog(m_uuidAccessAuth, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "AccessAuthorization");
-			if (Error != Error_Succeed)
-				DbgEx("subscribe AccessAuthorization log failed!");
-			else
-				DbgEx("subscribe AccessAuthorization success!");
+			DbgEx("subscribe AccessAuthorization %s, %d",
+				Error_Succeed == (Error = GetFunction()->SubscribeLog(m_uuidAccessAuth, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "AccessAuthorization")) ? "success" : "failed", Error);
+
+			DbgEx("subscribe ResourceWatcher %s, %d", 
+				Error_Succeed == (Error = GetFunction()->SubscribeBroadcast("ResourceWatcher", NULL, this, m_uuidResourceWatch)) ? "success" : "failed", Error);
 
 
 			if (Error_Succeed != GetFunction()->RegistSysVarEvent("UIState", this))
@@ -379,7 +381,7 @@ namespace Chromium {
 		return true;
 }
 
-	bool CChromiumEntity::OnPreStart_openWeb(CAutoArray<CSimpleStringA>& strArgs, CSmartPointer<ITransactionContext>& pTransactionContext)
+	bool CChromiumEntity::OnPreStart_openWeb()
 	{
 		//generateBussinessLimitTimer();
 #if (defined _WIN32 || defined _WIN64)
@@ -458,7 +460,7 @@ namespace Chromium {
 			if (!OnPreStart_register(strArgs, pTransactionContext)) {
 				return;
 			}
-			if (!OnPreStart_openWeb(strArgs, pTransactionContext)) {
+			if (!OnPreStart_openWeb()) {
 				return;
 			}
 		}
@@ -483,7 +485,7 @@ namespace Chromium {
 					firstEnter = false;
 					DbgEx("first Enter main page");
 					m_firstStartMain.unlock();
-					LogWarn(Severity_Middle, Error_Debug, LOG_SLV_CHROMIUM_OPENSUCCESS,
+					LogWarn(Severity_Low, Error_Debug, LOG_SLV_CHROMIUM_OPENSUCCESS,
 						CSimpleStringA::Format("Chromium Enter main page success, %s", CModTools::get_mutable_instance().getFultureUrl().GetData()));
 				}
 				GetFunction()->UnregistSysVarEvent("UIState");
@@ -558,6 +560,8 @@ namespace Chromium {
 	/** 查看启动顺序发现集中配置实体启动在本实体之前,无法调用集中配置的接口,随将实现搬到这里来 [Gifur@2021124]*/
     void CChromiumEntity::FetchCustomMainUrl(CAutoArray<CSimpleStringA>& strArgs)
     {
+#if (defined _WIN32 || defined _WIN64)
+#else
         const int ArgsCount = strArgs.GetCount();
         LOG_TRACE("strArgs.GetCount() = %d", ArgsCount);
         for (int i = 0; i < ArgsCount; ++i) {
@@ -567,7 +571,7 @@ namespace Chromium {
             m_strCustomMainUrl = strArgs[0];
             DbgEx("Get custom main url: %s", m_strCustomMainUrl.GetData());
 			if (!m_strCustomMainUrl.IsNullOrEmpty()) {
-                LogWarn(Severity_High, Error_Debug, LOG_EVT_CHROMIUM_DETECT_CUSTOM_FULTURE_URL_FROM_START,
+                LogWarn(Severity_Low, Error_Debug, LOG_EVT_CHROMIUM_DETECT_CUSTOM_FULTURE_URL_FROM_START,
 						CSimpleStringA::Format("从模块入参获取自定义链接:%s", m_strCustomMainUrl.GetData()));
 			}
 		} else {
@@ -582,11 +586,12 @@ namespace Chromium {
                 pConfig->ReadConfigValue(strSection, "FultureUrl", m_strCustomMainUrl);
                 pConfig->ReadConfigValue(strSection, "AdUrl", strAdUrl);
 				if (!m_strCustomMainUrl.IsNullOrEmpty()) {
-                    LogWarn(Severity_High, Error_Debug, LOG_EVT_CHROMIUM_DETECT_CUSTOM_FULTURE_URL_FROM_CONFIG,
+                    LogWarn(Severity_Low, Error_Debug, LOG_EVT_CHROMIUM_DETECT_CUSTOM_FULTURE_URL_FROM_CONFIG,
 							CSimpleStringA::Format("从本地维护桌面获取自定义链接:%s", m_strCustomMainUrl.GetData()));
 				}
 			}
 		}
+#endif
     }
 
 	void CChromiumEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nLogID, const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
@@ -633,7 +638,7 @@ namespace Chromium {
 				std::tuple < std::string, std::string>(m_sysInfo.strTerminalID.GetData(), generateTimeStr()));
 			DbgEx("show Screen Camera config, open page cameraconfig %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 		}
-		break;
+			break;
 		case LOG_EVT_END_CAMERA_CONFIG://no use
 			DbgEx("end show Screen Camera config, close page cameraconfig");
 			CModTools::get_mutable_instance().killChromiumByName((+PAGE_TYPE::CameraConfig)._to_string());
@@ -725,7 +730,52 @@ namespace Chromium {
 		DbgEx("OnCustomerCmd %s", evt.cmdStr);
 	}
 #endif
+	void CChromiumEntity::OnBrowserCacheClean(const char* pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, ResourceWatcher::BrowserCacheClean& evt)
+	{
+		DbgEx("OnOnBrowserCacheClean, needClean:%d", evt.needClean);
+		ErrorCodeEnum error = Error_Succeed;
+		if (!evt.needClean)
+			return;
+
+		CSimpleString tmpCacheDir;
+		if (Error_Succeed != (error = GetFunction()->GetPath("Temp", tmpCacheDir)))
+		{
+			DbgEx("OnBrowserCacheClean get cache path err, %d", error);
+			return;
+		}
+#if (defined _WIN32 || defined _WIN64)
+		CModTools::get_mutable_instance().lockGuard();
+		CModTools::get_mutable_instance().StopChromiumBrowser(ERR_PAGE_REASON::breakdown, true);//close all tab
+		auto tmpDirArr = find_files(tmpCacheDir.GetData(), "cefCache*", true);
+
+		for (auto it = tmpDirArr.begin(); it != tmpDirArr.end(); it++)
+			LogWarn(Severity_Low, Error_Debug, LOG_EVT_CHROMIUM_BROWSER_CACHE_CLEAER, CSimpleStringA::Format("clear chromium browser cache %s %s", it->c_str(),
+				RemoveDirRecursive(it->c_str()) ? "success" : "fail"));
 
+		CModTools::get_mutable_instance().unlockGuard();
+#else
+		//uos 由于无guard,需要重启整个chromium实体
+		CModTools::get_mutable_instance().killAllChromium();
+		auto tmpDirArr = find_files(tmpCacheDir.GetData(), "cefCache*", true);
+		auto uosTmpDirArr = find_files(tmpCacheDir.GetData(), "UOSBrowser*", true);
+		std::for_each(uosTmpDirArr.begin(), uosTmpDirArr.end(), [&](std::string tmp) {
+			tmpDirArr.push_back(tmp);
+			});//insert uosTmpDirArr into tmpDirArr
+
+		for (auto it = tmpDirArr.begin(); it != tmpDirArr.end(); it++)
+			LogWarn(Severity_Low, Error_Debug, LOG_EVT_CHROMIUM_BROWSER_CACHE_CLEAER, CSimpleStringA::Format("clear chromium browser cache %s %s", it->c_str(),
+				RemoveDirRecursive(it->c_str()) ? "success" : "fail"));
+
+		if (m_pTimerListener != NULL)
+		{
+			GetFunction()->KillTimer(CHROMIUM_TIMER_ID);
+			delete m_pTimerListener;
+			m_pTimerListener = NULL;
+		}
+		OnPreStart_openWeb();//重新调用open web
+
+#endif 
+	}
 	void CChromiumEntity::generateCefclientTimer()
 	{
 		if (nullptr == m_pTimerListener)
@@ -779,6 +829,8 @@ namespace Chromium {
 
     void CChromiumEntity::DoBrowserCacheClearJob()
     {
+#if (defined _WIN32 || defined _WIN64)
+#else
         LOG_FUNCTION();
 
         CSmartPointer<IConfigInfo> spConfig;
@@ -808,7 +860,7 @@ namespace Chromium {
 
                     if (ExistsDirA(strcefCachePath)) {
                         RemoveDirRecursiveA(strcefCachePath);
-                        LogWarn(Severity_Middle, Error_Debug, LOG_EVT_CHROMIUM_BROWSER_CACHE_CLEAER,
+                        LogWarn(Severity_Low, Error_Debug, LOG_EVT_CHROMIUM_BROWSER_CACHE_CLEAER,
                                 CSimpleStringA::Format("clear chromium browser cache: %s", strcefCachePath.GetData()));
                     }
                 }
@@ -818,6 +870,7 @@ namespace Chromium {
                 spConfig->WriteConfigValue("Browser", "CacheClear", NULL);
             }
         }
+#endif
     }
 
     void CChromiumEntity::OnTaskTimerListener(void* pData)

+ 12 - 3
Module/mod_chromium/mod_chromium.h

@@ -15,9 +15,12 @@
 #endif
 #include "guitask/enum.h"
 #include "../mod_healthmanager/HealthManager_msg_g.h"
+#include "../mod_ResourceWatcher/ResourceWatcher_msg_g.h"
 #include "Chromium_server_g.h"
 #include <boost/thread/mutex.hpp>
 
+
+//ns::msg 在gcc下拼接有点问题,暂时不得不重新定义一个
 #define SP_MSG_HANDLE_NS_EX(ns, msg, ns_msg, OnMsg) \
 	case eMsg_##msg: \
 				if (eMsgSig_##msg == dwMessageSignature) { \
@@ -109,6 +112,7 @@ namespace Chromium {
 		void JobNotify();
 		void OnCustomerCmd(const char* pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, IEBrowser::CustomerCmd& evt);
 #endif
+		void OnBrowserCacheClean(const char* pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, ResourceWatcher::BrowserCacheClean& evt);
 		void generateCefclientTimer();
 		void generateBussinessLimitTimer();
 		void openMainPage();
@@ -132,7 +136,7 @@ namespace Chromium {
 		int getBrowserStartTimes();
 	private:
 		//subscribe
-		CUUID m_uidCameraListener, m_uuidAccessAuth, m_uidBrowserListenser, m_uuidAccessAuthErr, m_uuidAllFault;
+		CUUID m_uidCameraListener, m_uuidAccessAuth, m_uuidResourceWatch,m_uidBrowserListenser, m_uuidAccessAuthErr, m_uuidAllFault;
         virtual void OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nLogID, const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
                            const DWORD dwSysError, const DWORD dwUserCode, const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
                            const CAutoArray<DWORD>& Param, const char* pszEntityName, const char* pszModuleName, const char* pszMessage, const linkContext& pLinkInfo);
@@ -151,18 +155,23 @@ namespace Chromium {
 		void OnPreStart_Init(CAutoArray<CSimpleStringA>& strArgs, CSmartPointer<ITransactionContext>& pTransactionContext);
 		bool OnPreStart_socketStart(CAutoArray<CSimpleStringA>& strArgs, CSmartPointer<ITransactionContext>& pTransactionContext);
 		bool OnPreStart_register(CAutoArray<CSimpleStringA>& strArgs, CSmartPointer<ITransactionContext>& pTransactionContext);
-		bool OnPreStart_openWeb(CAutoArray<CSimpleStringA>& strArgs, CSmartPointer<ITransactionContext>& pTransactionContext);
+		bool OnPreStart_openWeb();
 		SP_BEGIN_MSG_DISPATCH_MAP(CChromiumEntity)
 #if (defined _WIN32 || defined _WIN64)
 			SP_BEGIN_ENTITY_MSG("IEBrowser")
 			SP_MSG_HANDLE_NS(IEBrowser, CustomerCmd, OnCustomerCmd)
 			SP_END_ENTITY_MSG()
+
 #endif
+
+			SP_BEGIN_ENTITY_MSG("ResourceWatcher")
+			SP_MSG_HANDLE_NS_EX(ResourceWatcher, BrowserCacheClean, ResourceWatcher::BrowserCacheClean, OnBrowserCacheClean)
+			SP_END_ENTITY_MSG()
 			//SP_BEGIN_ENTITY_MSG("HealthManager")
 			//SP_MSG_HANDLE_NS(HealthManager, TradeManage, OnTradeManage)
 			//SP_MSG_HANDLE_NS_EX(HealthManager, TerminalManager, HealthManager::TerminalManager, OnTerminalManage)
 			//SP_END_ENTITY_MSG()
-			SP_END_MSG_DISPATCH_MAP()
+		SP_END_MSG_DISPATCH_MAP()
 
 	};
 

+ 4 - 0
Module/mod_healthmanager/mod_healthmanager.cpp

@@ -3408,6 +3408,9 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
 				ResourceWatcherService_InstallThirdPartyProgram_Req req = {};
 				ResourceWatcherService_InstallThirdPartyProgram_Ans ans = {};
                 req.type = 1;
+				req.reserved1 = req.reserved2 = 0;
+				/** 健康实体过来的调用,1表示不直接重启机器 [Gifur@202275]*/
+				req.reserved1 = 1;
                 Dbg("to install...");
                 tmpResult = pClient->InstallThirdPartyProgram(req, ans, 60000);
                 if (tmpResult != 0) {
@@ -3476,6 +3479,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
                 ResourceWatcherService_InstallThirdPartyProgram_Req req = {};
                 ResourceWatcherService_InstallThirdPartyProgram_Ans ans = {};
                 req.type = 2; //
+				req.reserved1 = req.reserved2 = 0;
                 Dbg("to install font....");
                 tmpResult = pClient->InstallThirdPartyProgram(req, ans, 60000);
                 if (tmpResult != 0) {

+ 57 - 2
addin/res/ManagerDesktop/js/page/browser.js

@@ -51,13 +51,18 @@ function browserGenPage() {
         <div class="clearboth" id="browser_sogou_btn_save_div" style="padding-top:50px">\
             <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
             <div class="controls"><button class="btn_normal_long"\
-                    id="browser_sogou_btn_restart">重启搜狗输入法服务V3.0</button></div>\
+                    id="browser_sogou_btn_restart">重启搜狗输入法服务V4.0</button></div>\
         </div>\
         <div class="clearboth" id="browser_sogou_btn_fetch_div" style="padding-top:50px">\
             <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
             <div class="controls"><button class="btn_normal_long"\
                  id="browser_sogou_btn_fetch">搜狗输入法信息快照</button></div>\
         </div>\
+        <div class="clearboth" id="browser_screen_info_fetch_div" style="padding-top:50px">\
+            <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
+            <div class="controls"><button class="btn_normal_long"\
+                    id="browser_screen_info_fetch">屏幕显示信息获取</button></div>\
+        </div>\
     </div>\
     <div id="browser_activation_content" class="page_prompt_info page_scenes_info_text hide">\
     </div>\
@@ -118,6 +123,32 @@ var browserController = (function() {
         });
     }
 
+    //V4.0
+    function restartSogouProcess()
+    {
+        let req = new Request();
+        req.type = 1; //搜狗输入法
+        req.reserved1 = 0;
+        req.reserved2 = 0;
+        req.timeout = 65000;
+
+        utilStartSubmitDialog();
+        RVC.ResourceWatcherEntity.RestartThirdPartyProgram(req, function(ret) {
+            utilStopSubmitDialog();
+            if(ret.errorCode === 0) {
+                let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
+                if(result.result == 0) {
+                    utilStartAlertDialog("输入法重启成功,请退出当前页面,继续业务办理。");
+                } else {
+                    utilStartAlertDialog("重启输入法失败:[" + result.result + "] " + result.msg);
+                }
+            } else {
+                RVC.ResourceWatcherEntity.commErrorCallback(ret);
+            }
+        });
+    }
+
+    //V3.0
     function restartSogouSrv() {
 
         let req = new Request();
@@ -142,6 +173,29 @@ var browserController = (function() {
         });
     }
 
+    function FetchScreenDisplayInfo() {
+        let req = new Request();
+        req.type = 1;//屏幕信息
+        req.reserved1 = 0;
+        req.reserved2 = 0;
+        req.timeout = 20000;
+
+        utilStartSubmitDialog();
+        RVC.ResourceWatcherEntity.FetchSystemSnapshot(req, function(ret) {
+            utilStopSubmitDialog();
+            if(ret.errorCode === 0) {
+                let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
+                if(result.result == 0) {
+                    utilStartAlertDialog(result.msg);
+                } else {
+                    utilStartAlertDialog("获取信息失败:[" + result.result + "] " + result.msg);
+                }
+            } else {
+                RVC.ResourceWatcherEntity.commErrorCallback(ret);
+            }
+        });
+    }
+
     function FetchSogouInputInfo() {
         let req = new Request();
         req.configType = 0;
@@ -305,8 +359,9 @@ var browserController = (function() {
 
         $(document).on('click', '#browser_btn_save', saveButtonHandle);
         $(document).on('click', '#btn_restart_chromium', restartBrowser);
-        $(document).on('click', '#browser_sogou_btn_restart', restartSogouSrv);
+        $(document).on('click', '#browser_sogou_btn_restart', restartSogouProcess);
         $(document).on('click', '#browser_sogou_btn_fetch', FetchSogouInputInfo);
+        $(document).on('click', '#browser_screen_info_fetch', FetchScreenDisplayInfo);
         
         selectBrowserUseMode();
         

+ 20 - 2
addin/res/ManagerDesktop/js/public.js

@@ -2356,7 +2356,11 @@ $(function () {
             GetThirdPartyInstallState:10,
             GetTerminalVersionList:12,
             ManipulateVersion:13,
-            UninstallThirdPartyProgram:14
+            UninstallThirdPartyProgram:14,
+            RestartThirdPartyProgram:15,
+            ProcessDetectThirdPartyProgram:16,
+            FilesClean:17,
+            FetchSystemSnapshot:18
         },
         methodSignature: {
             UpdateDNS : 689391692,
@@ -2364,7 +2368,11 @@ $(function () {
             GetThirdPartyInstallState:-15861483,
             GetTerminalVersionList:-504582702,
             ManipulateVersion:-313717631,
-            UninstallThirdPartyProgram:-2137706699
+            UninstallThirdPartyProgram:-2137706699,
+            RestartThirdPartyProgram:-534704262,
+            ProcessDetectThirdPartyProgram:-1692430185,
+            FilesClean:624348486,
+            FetchSystemSnapshot:-1005346345
         },
         GetNetworkInfo: function(req, callback) {
             this.webSocketInvokeEx(req, 
@@ -2395,6 +2403,16 @@ $(function () {
             this.webSocketInvokeEx(req, 
                 ({id:this.methodID.UninstallThirdPartyProgram, sig:this.methodSignature.UninstallThirdPartyProgram}),
                  callback);
+        },
+        RestartThirdPartyProgram: function(req, callback) {
+            this.webSocketInvokeEx(req, 
+                ({id:this.methodID.RestartThirdPartyProgram, sig:this.methodSignature.RestartThirdPartyProgram}),
+                 callback);
+        },
+        FetchSystemSnapshot: function(req, callback) {
+            this.webSocketInvokeEx(req, 
+                ({id:this.methodID.FetchSystemSnapshot, sig:this.methodSignature.FetchSystemSnapshot}),
+                 callback);
         }
     });
 

+ 6 - 1
addin/res/ManagerDesktop/prototype/browser.html

@@ -209,13 +209,18 @@
                         <div class="clearboth" id="browser_sogou_btn_save_div" style="padding-top:50px">
                             <div class="control-label" style="margin-top: 8px;">&nbsp;</div>
                             <div class="controls"><button class="btn_normal_long"
-                                    id="browser_sogou_btn_restart">重启搜狗输入法服务V3.0</button></div>
+                                    id="browser_sogou_btn_restart">重启搜狗输入法服务V4.0</button></div>
                         </div>
                         <div class="clearboth" id="browser_sogou_btn_fetch_div" style="padding-top:50px">
                             <div class="control-label" style="margin-top: 8px;">&nbsp;</div>
                             <div class="controls"><button class="btn_normal_long"
                                     id="browser_sogou_btn_fetch">搜狗输入法信息快照</button></div>
                         </div>
+                        <div class="clearboth" id="browser_screen_info_fetch_div" style="padding-top:50px">
+                            <div class="control-label" style="margin-top: 8px;">&nbsp;</div>
+                            <div class="controls"><button class="btn_normal_long"
+                                    id="browser_screen_info_fetch">屏幕显示信息获取</button></div>
+                        </div>
                     </div>
                     <div id="browser_activation_content" class="page_prompt_info page_scenes_info_text hide">
                     </div>