Эх сурвалжийг харах

#IQRV #comment [ResouceWatcher] FetchSystemSnapshot 接口实现

gifur 3 жил өмнө
parent
commit
572839f196

+ 15 - 7
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);
 }
 
 

+ 1 - 1
Module/mod_ResourceWatcher/ResourceWatcherFSM.h

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

+ 22 - 0
Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp

@@ -204,6 +204,12 @@ void ResourceWatcherServiceSession::Handle_FilesClean(SpReqAnsContext<ResourceWa
     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);
@@ -1721,6 +1727,7 @@ std::string ResourceWatcherEntity::DoCheckCertainProcessStatus(const CAutoArray<
 
     return uploadInfo;
 }
+
 void ResourceWatcherEntity::FilesClean(SpReqAnsContext<ResourceWatcherService_FilesClean_Req, ResourceWatcherService_FilesClean_Ans>::Pointer ctx)
 {
     ErrorCodeEnum result(Error_Succeed);
@@ -1748,6 +1755,20 @@ void ResourceWatcherEntity::FilesClean(SpReqAnsContext<ResourceWatcherService_Fi
     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;
+    } else {
+        ctx->Ans.result = -1;
+        ctx->Ans.msg = "调用 GetMonitorInfo 接口失败";
+    }
+    ctx->Answer(Error_Succeed);
+}
 
 SP_BEGIN_ENTITY_MAP()
 SP_ENTITY(ResourceWatcherEntity)
@@ -1758,3 +1779,4 @@ SP_END_ENTITY_MAP()
 
 
 
+

+ 7 - 0
Module/mod_ResourceWatcher/mod_ResourceWatcher.h

@@ -59,7 +59,11 @@ public:
 	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;
 };
@@ -283,6 +287,9 @@ public:
 	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)

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

@@ -58,6 +58,11 @@ function browserGenPage() {
             <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>\
@@ -141,8 +146,6 @@ var browserController = (function() {
                 RVC.ResourceWatcherEntity.commErrorCallback(ret);
             }
         });
-
-
     }
 
     //V3.0
@@ -170,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;
@@ -335,6 +361,7 @@ var browserController = (function() {
         $(document).on('click', '#btn_restart_chromium', restartBrowser);
         $(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();
         

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

@@ -2359,7 +2359,8 @@ $(function () {
             UninstallThirdPartyProgram:14,
             RestartThirdPartyProgram:15,
             ProcessDetectThirdPartyProgram:16,
-            FilesClean:17
+            FilesClean:17,
+            FetchSystemSnapshot:18
         },
         methodSignature: {
             UpdateDNS : 689391692,
@@ -2370,7 +2371,8 @@ $(function () {
             UninstallThirdPartyProgram:-2137706699,
             RestartThirdPartyProgram:-534704262,
             ProcessDetectThirdPartyProgram:-1692430185,
-            FilesClean:624348486
+            FilesClean:624348486,
+            FetchSystemSnapshot:-1005346345
         },
         GetNetworkInfo: function(req, callback) {
             this.webSocketInvokeEx(req, 
@@ -2406,6 +2408,11 @@ $(function () {
             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);
         }
     });
 

+ 5 - 0
addin/res/ManagerDesktop/prototype/browser.html

@@ -216,6 +216,11 @@
                             <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>