|
@@ -9,6 +9,7 @@ using namespace FreeRDPWrap;
|
|
|
#include <mutex>
|
|
|
#include <thread>
|
|
|
#include "path.h"
|
|
|
+#include "fileutil.h"
|
|
|
#include <boost/process.hpp>
|
|
|
#include <boost/thread.hpp>
|
|
|
#endif
|
|
@@ -25,6 +26,10 @@ using namespace FreeRDPWrap;
|
|
|
#include "EventCode.h"
|
|
|
#include "url_encoder.h"
|
|
|
|
|
|
+#include "CommEntityUtil.hpp"
|
|
|
+
|
|
|
+void SystemRunTest(const std::string& systemCmd);
|
|
|
+
|
|
|
|
|
|
extern std::pair<bool, std::string> DetectActiveHttp(std::vector<std::string> urlArr);
|
|
|
|
|
@@ -126,6 +131,11 @@ namespace Chromium {
|
|
|
child_process.wait();
|
|
|
} while (false);
|
|
|
|
|
|
+ do {
|
|
|
+ boost::process::child child_process("sudo killall -9 browser");
|
|
|
+ child_process.wait();
|
|
|
+ } while (false);
|
|
|
+
|
|
|
DbgEx("run killAllChromium success ex");
|
|
|
return true;
|
|
|
#endif
|
|
@@ -414,7 +424,43 @@ namespace Chromium {
|
|
|
|
|
|
std::string CModTools::generateAdCmd(std::string AdUrl) {
|
|
|
|
|
|
- if (m_bUseUOSBrowser) {
|
|
|
+ if (m_UseUOSBrowser == 2) {
|
|
|
+
|
|
|
+ CSimpleStringA strUOSBrowserPath("browser");
|
|
|
+ CSimpleStringA strParams(true);
|
|
|
+ CSimpleStringA tempPath;
|
|
|
+ this->m_pEntity->GetFunction()->GetPath("Temp", tempPath);
|
|
|
+ CSimpleStringA cachePath(tempPath);
|
|
|
+
|
|
|
+ cachePath.Append(CSimpleStringA(SPLIT_SLASH_STR)).Append("UOSBrowser2_").Append((+ERR_PAGE_REASON::Ad)._to_string());
|
|
|
+ strParams.Append(" --disk-cache-dir=").Append(cachePath);
|
|
|
+ strParams.Append(" --disk-cache-size=").Append("2147483647"); //2G
|
|
|
+ CSimpleStringA usrDataPath(tempPath);
|
|
|
+ usrDataPath.Append(CSimpleStringA(SPLIT_SLASH_STR)).Append("UOSBrowserConfig2_").Append((+ERR_PAGE_REASON::Ad)._to_string());
|
|
|
+ strParams.Append(" --user-data-dir=").Append(usrDataPath);
|
|
|
+
|
|
|
+ std::string additionalParam = getAdditionalUOSBrowserSettings(2, 0);
|
|
|
+ if (!additionalParam.empty()) {
|
|
|
+ strParams.Append(" ");
|
|
|
+ strParams.Append(additionalParam.c_str());
|
|
|
+ }
|
|
|
+
|
|
|
+ additionalParam = getAdditionalUOSBrowserSettings(2, 2);
|
|
|
+ if (!additionalParam.empty()) {
|
|
|
+ strParams.Append(" ");
|
|
|
+ strParams.Append(additionalParam.c_str());
|
|
|
+ }
|
|
|
+
|
|
|
+ strParams.Append(" ");
|
|
|
+ strParams.Append(AdUrl.c_str());
|
|
|
+
|
|
|
+ strUOSBrowserPath.Append(strParams);
|
|
|
+
|
|
|
+ LogWarn(Severity_High, Error_Unexpect, LOG_EVT_CHROMIUM_OPEN_AD_WITH_UOSV2, strUOSBrowserPath);
|
|
|
+ return strUOSBrowserPath.GetData();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_UseUOSBrowser == 1) {
|
|
|
|
|
|
CSimpleStringA strUOSBrowserPath("uos-browser ");
|
|
|
//CSimpleStringA strParams("--new-window --window-position=1280,1024 --window-size=1920,1080");
|
|
@@ -426,16 +472,15 @@ namespace Chromium {
|
|
|
|
|
|
cachePath.Append(CSimpleStringA(SPLIT_SLASH_STR)).Append("UOSBrowser_").Append((+ERR_PAGE_REASON::Ad)._to_string());
|
|
|
strParams.Append(" --disk-cache-dir=").Append(cachePath);
|
|
|
- strParams.Append(" --disk-cache-size=").Append("2147483648"); //2G
|
|
|
+ strParams.Append(" --disk-cache-size=").Append("2147483647"); //2G
|
|
|
|
|
|
CSimpleStringA usrDataPath(tempPath);
|
|
|
usrDataPath.Append(CSimpleStringA(SPLIT_SLASH_STR)).Append("UOSBrowserConfig_").Append((+ERR_PAGE_REASON::Ad)._to_string());
|
|
|
strParams.Append(" --user-data-dir=").Append(usrDataPath);
|
|
|
|
|
|
- //strParams.Append(" --app=\"");
|
|
|
strParams.Append(" ");
|
|
|
|
|
|
- std::string additionalParam = getAdditionalUOSBrowserSettings();
|
|
|
+ std::string additionalParam = getAdditionalUOSBrowserSettings(1, 0);
|
|
|
if (!additionalParam.empty()) {
|
|
|
strParams.Append(additionalParam.c_str());
|
|
|
strParams.Append(" ");
|
|
@@ -473,15 +518,31 @@ namespace Chromium {
|
|
|
}
|
|
|
|
|
|
|
|
|
- std::string CModTools::getAdditionalUOSBrowserSettings(int nType /*= 0*/)
|
|
|
+ std::string CModTools::getAdditionalUOSBrowserSettings(int nBrowswerType, int nMonitorType)
|
|
|
{
|
|
|
std::string result("");
|
|
|
- CSimpleStringA section("UOSBrowserCmd");
|
|
|
- if (nType == 1) {
|
|
|
- section = "UOSBrowserCmdMain";
|
|
|
- } else if(nType == 2) {
|
|
|
- section = "UOSBrowserCmdVice";
|
|
|
- } else if (nType != 0) {
|
|
|
+ CSimpleStringA section(true);
|
|
|
+ if (nBrowswerType == 1) {
|
|
|
+ section = "UOSBrowserCmd";
|
|
|
+ if (nMonitorType == 1) {
|
|
|
+ section = "UOSBrowserCmdMain";
|
|
|
+ } else if (nMonitorType == 2) {
|
|
|
+ section = "UOSBrowserCmdVice";
|
|
|
+ } else if (nMonitorType != 0) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ } else if (nBrowswerType == 2) {
|
|
|
+ section = "UOSBrowserCmd2";
|
|
|
+ if (nMonitorType == 1) {
|
|
|
+ section = "UOSBrowserCmdMain2";
|
|
|
+ } else if (nMonitorType == 2) {
|
|
|
+ section = "UOSBrowserCmdVice2";
|
|
|
+ } else if (nMonitorType != 0) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (section.IsNullOrEmpty()) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -504,7 +565,47 @@ namespace Chromium {
|
|
|
|
|
|
std::string CModTools::generateCefclientCmd(bool isExtend, std::string mainUrl)
|
|
|
{
|
|
|
- if (m_bUseUOSBrowser && !isExtend) {
|
|
|
+
|
|
|
+ if (m_UseUOSBrowser == 2 && !isExtend) {
|
|
|
+
|
|
|
+ CSimpleStringA strUOSBrowserPath("browser");
|
|
|
+ CSimpleStringA strParams(true);
|
|
|
+
|
|
|
+ CSimpleStringA tempPath;
|
|
|
+ this->m_pEntity->GetFunction()->GetPath("Temp", tempPath);
|
|
|
+ CSimpleStringA cachePath(tempPath);
|
|
|
+
|
|
|
+ cachePath.Append(CSimpleStringA(SPLIT_SLASH_STR)).Append("UOSBrowser2_")
|
|
|
+ .Append(isExtend ? (+ERR_PAGE_REASON::extend)._to_string() : (+ERR_PAGE_REASON::main)._to_string());
|
|
|
+ strParams.Append(" --disk-cache-dir=").Append(cachePath);
|
|
|
+ strParams.Append(" --disk-cache-size=").Append("2147483647"); //2G
|
|
|
+
|
|
|
+ CSimpleStringA usrDataPath(tempPath);
|
|
|
+ usrDataPath.Append(SPLIT_SLASH_STR).Append("UOSBrowserConfig2_")
|
|
|
+ .Append(isExtend ? (+ERR_PAGE_REASON::extend)._to_string() : (+ERR_PAGE_REASON::main)._to_string());
|
|
|
+ strParams.Append(" --user-data-dir=").Append(usrDataPath);
|
|
|
+
|
|
|
+ std::string additionalParam = getAdditionalUOSBrowserSettings(2, 0);
|
|
|
+ if (!additionalParam.empty()) {
|
|
|
+ strParams.Append(" ");
|
|
|
+ strParams.Append(additionalParam.c_str());
|
|
|
+ }
|
|
|
+
|
|
|
+ additionalParam = getAdditionalUOSBrowserSettings(2, 1);
|
|
|
+ if (!additionalParam.empty()) {
|
|
|
+ strParams.Append(" ");
|
|
|
+ strParams.Append(additionalParam.c_str());
|
|
|
+ }
|
|
|
+
|
|
|
+ strParams.Append(" ");
|
|
|
+ strParams.Append(mainUrl.c_str());
|
|
|
+ strUOSBrowserPath.Append(strParams);
|
|
|
+ LogWarn(Severity_High, Error_Unexpect, LOG_EVT_CHROMIUM_OPEN_MAIN_WITH_UOSV2, strUOSBrowserPath);
|
|
|
+
|
|
|
+ return strUOSBrowserPath.GetData();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_UseUOSBrowser == 1 && !isExtend) {
|
|
|
|
|
|
CSimpleStringA strUOSBrowserPath("uos-browser ");
|
|
|
CSimpleStringA strParams("--new-window --kiosk");
|
|
@@ -516,7 +617,7 @@ namespace Chromium {
|
|
|
cachePath.Append(CSimpleStringA(SPLIT_SLASH_STR)).Append("UOSBrowser_")
|
|
|
.Append(isExtend ? (+ERR_PAGE_REASON::extend)._to_string() : (+ERR_PAGE_REASON::main)._to_string());
|
|
|
strParams.Append(" --disk-cache-dir=").Append(cachePath);
|
|
|
- strParams.Append(" --disk-cache-size=").Append("2147483648"); //2G
|
|
|
+ strParams.Append(" --disk-cache-size=").Append("2147483647"); //2G
|
|
|
|
|
|
CSimpleStringA usrDataPath(tempPath);
|
|
|
usrDataPath.Append(SPLIT_SLASH_STR).Append("UOSBrowserConfig_")
|
|
@@ -525,7 +626,7 @@ namespace Chromium {
|
|
|
|
|
|
strParams.Append(" ");
|
|
|
|
|
|
- std::string additionalParam = getAdditionalUOSBrowserSettings();
|
|
|
+ std::string additionalParam = getAdditionalUOSBrowserSettings(1, 0);
|
|
|
if (!additionalParam.empty()) {
|
|
|
strParams.Append(additionalParam.c_str());
|
|
|
strParams.Append(" ");
|
|
@@ -636,7 +737,7 @@ namespace Chromium {
|
|
|
|
|
|
auto strCmdLine = generateMainCmd(mainUrlRet.second);
|
|
|
|
|
|
- auto openCefRet = openCef(strCmdLine, !m_bUseUOSBrowser);//with guard
|
|
|
+ auto openCefRet = openCef(strCmdLine, m_UseUOSBrowser == 0);//with guard
|
|
|
if (Error_Succeed == openCefRet.first) {
|
|
|
LogWarn(Severity_Middle, Error_Debug, LOG_EVT_CHROMIUM_OPEN_MAIN_URL,
|
|
|
CSimpleStringA::Format("StartChromiumBrowser %s", mainUrlRet.second.c_str()));
|
|
@@ -1006,9 +1107,62 @@ namespace Chromium {
|
|
|
m_pEntity->GetFunction()->OpenConfig(Config_Cache, spConfig);
|
|
|
CSimpleStringA value(true);
|
|
|
spConfig->ReadConfigValue("BusinessBrowserType", "FultureEx", value);
|
|
|
- m_bUseUOSBrowser = (value.IsNullOrEmpty() || (value.Compare("1") != 0));
|
|
|
+ if (!(value.IsNullOrEmpty() || (value.Compare("1") != 0))) {
|
|
|
+ m_UseUOSBrowser = 0;
|
|
|
+ } else {
|
|
|
+ m_UseUOSBrowser = ToGetUOSBrowserType();
|
|
|
+ }
|
|
|
} else {
|
|
|
- m_bUseUOSBrowser = true;
|
|
|
+ m_UseUOSBrowser = ToGetUOSBrowserType();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int CModTools::ToGetUOSBrowserType()
|
|
|
+ {
|
|
|
+ const std::string execute_newbrowser_path = "/usr/share/browser/browser";
|
|
|
+ const std::string execute_oldbrowser_path = "/usr/share/uosbrowser/uosbrowser";
|
|
|
+
|
|
|
+ int result(0);
|
|
|
+ std::string additional("");
|
|
|
+
|
|
|
+ std::string succStr, errStr;
|
|
|
+ std::string runStr("dpkg -l | grep org.deepin.browser | awk '{print $3}'");
|
|
|
+ if (SP::Module::Util::ShellExecute(runStr, succStr, errStr)) {
|
|
|
+ if (succStr.empty()) {
|
|
|
+ if (ExistsFileA(execute_oldbrowser_path.c_str())) {
|
|
|
+ result = 1;
|
|
|
+ } else {
|
|
|
+ Dbg("%s not exists!", execute_oldbrowser_path.c_str());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Dbg("new browser version: %s", succStr.c_str());
|
|
|
+ additional = succStr;
|
|
|
+ if (!ExistsFileA(execute_newbrowser_path.c_str())) { Dbg("%s not exists!", execute_newbrowser_path.c_str()); }
|
|
|
+ result = 2;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Dbg("execute '%s' failed!", runStr.c_str());
|
|
|
+ }
|
|
|
+
|
|
|
+ UploadBrowserInfo(result, additional.c_str());
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ void CModTools::UploadBrowserInfo(int usingType, LPCTSTR info)
|
|
|
+ {
|
|
|
+ CSmartPointer<IConfigInfo> spConfig;
|
|
|
+ this->m_pEntity->GetFunction()->OpenConfig(Config_Run, spConfig);
|
|
|
+ int oldType(0);
|
|
|
+ CSimpleStringA strVersion;
|
|
|
+ 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,
|
|
|
+ CSimpleStringA::Format("{ \"type\":%d, \"version\":\"%s\"}", usingType, info));
|
|
|
+
|
|
|
+ spConfig->WriteConfigValueInt("BrowserUse", "Type", usingType);
|
|
|
+ spConfig->WriteConfigValue("BrowserUse", "Version", info);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1089,7 +1243,6 @@ namespace Chromium {
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-
|
|
|
std::pair<ErrorCodeEnum, int> CModTools::openCef(std::string cmdline, bool isGuard)
|
|
|
{
|
|
|
if (isGuard) {
|
|
@@ -1106,7 +1259,8 @@ namespace Chromium {
|
|
|
return std::make_pair(std::get<0>(startRet) ? Error_Succeed : Error_Unexpect, std::get<1>(startRet));
|
|
|
#else
|
|
|
auto systemStartChromium = [](std::string str) {
|
|
|
- system(str.c_str());
|
|
|
+ //system(str.c_str());
|
|
|
+ SystemRunTest(str);
|
|
|
};
|
|
|
boost::thread(systemStartChromium, cmdline).detach();
|
|
|
#endif
|