|
@@ -11,6 +11,12 @@
|
|
|
#include <boost/process.hpp>
|
|
|
#include <boost/thread.hpp>
|
|
|
#include "CommEntityUtil.hpp"
|
|
|
+#include <SDL2/SDL.h>
|
|
|
+//#include <winpr/wnd.h>
|
|
|
+#define HWND_TOP (0)
|
|
|
+#define HWND_BOTTOM (1)
|
|
|
+#define HWND_TOPMOST (-1)
|
|
|
+#define HWND_NOTOPMOST (-2)
|
|
|
#endif
|
|
|
#include "baseEx.h"
|
|
|
#include "CModTools.h"
|
|
@@ -25,7 +31,7 @@
|
|
|
#include "EventCode.h"
|
|
|
#include "url_encoder.h"
|
|
|
#include "SpUtility.h"
|
|
|
-#include <winpr/wnd.h>
|
|
|
+
|
|
|
|
|
|
|
|
|
void SystemRunTest(const std::string& systemCmd);
|
|
@@ -543,17 +549,112 @@ namespace Chromium {
|
|
|
#endif //RVC_OS_LINUX
|
|
|
}
|
|
|
|
|
|
- std::string CModTools::generateCommonPage(std::string url, std::string name, std::string size, std::string point, int top)
|
|
|
+ std::string CModTools::generateCommonPage(std::string url, std::string name, int width, int height, int point_x, int point_y, int top)
|
|
|
{
|
|
|
#if defined(RVC_OS_LINUX)
|
|
|
- return generateBrowserCMDForEverything(url, 0); //need change later, because common page may not run in full-screen mode
|
|
|
+ CSimpleStringA strBasePath(true);
|
|
|
+ this->m_pEntity->GetFunction()->GetPath("BaseDir", strBasePath);
|
|
|
+ std::string strPath(strBasePath.GetData());
|
|
|
+ const std::string execute_newbrowser_path = strPath + SPLIT_SLASH_STR + "res" + SPLIT_SLASH_STR + "RunScript" + SPLIT_SLASH_STR + "startBrower.sh";
|
|
|
+ const std::string execute_oldbrowser_path = strPath + SPLIT_SLASH_STR + "res" + SPLIT_SLASH_STR + "RunScript" + SPLIT_SLASH_STR + "startUOSBrower.sh";
|
|
|
+ CSimpleStringA strParams(true);
|
|
|
+ if (width > 0 && height > 0)
|
|
|
+ strParams.Append(" --window-size=").Append(std::to_string(width).c_str()).Append(",").Append(std::to_string(height).c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("1");
|
|
|
+
|
|
|
+ do
|
|
|
+ {
|
|
|
+ if (point_x != -1 && point_y != -1)
|
|
|
+ {
|
|
|
+ strParams.Append(" --window-position=").Append(std::to_string(point_x).c_str()).Append(",").Append(std::to_string(point_y).c_str());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ SDL_DisplayMode mode;
|
|
|
+ if (SDL_GetDesktopDisplayMode(0, &mode) != 0) {
|
|
|
+ // 错误处理
|
|
|
+ SDL_Quit();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 获取屏幕的宽度和高度
|
|
|
+ int screen_width = mode.w;
|
|
|
+ int screen_height = mode.h;
|
|
|
+ SDL_Quit();
|
|
|
+
|
|
|
+ point_x = (screen_width - width) / 2;
|
|
|
+ point_y = (screen_height - height) / 2;
|
|
|
+ strParams.Append(" --window-position=").Append(std::to_string(point_x).c_str()).Append(",").Append(std::to_string(point_y).c_str());
|
|
|
+
|
|
|
+ } while (false);
|
|
|
+
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("2");
|
|
|
+
|
|
|
+ //旧版浏览器(系统自带)
|
|
|
+ if (m_UseUOSBrowser == 1) {
|
|
|
+
|
|
|
+ CSimpleStringA strUOSBrowserPath(execute_oldbrowser_path.c_str());
|
|
|
+ strParams.Append(" --new-window --no-first-run --disable-popup-blocking --disable-notifications --disable-desktop-notifications ");
|
|
|
+ strParams.Append(" --allow-running-insecure-content --disable-infobars --disable-suggestions-service --disable-save-password-bubble --disable-component-update");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ CSimpleStringA tempPath;
|
|
|
+ this->m_pEntity->GetFunction()->GetPath("Temp", tempPath);
|
|
|
+ CSimpleStringA cachePath(tempPath);
|
|
|
+ cachePath.Append(CSimpleStringA(SPLIT_SLASH_STR)).Append("UOSBrowser_").Append(name.c_str());
|
|
|
+ strParams.Append(" --disk-cache-dir=").Append(cachePath);
|
|
|
+ strParams.Append(" --disk-cache-size=").Append("2147483647"); //2G
|
|
|
+ if (g_withMedia)
|
|
|
+ strParams.Append(" --use-fake-ui-for-media-stream");
|
|
|
+
|
|
|
+ CSimpleStringA usrDataPath(tempPath);
|
|
|
+ usrDataPath.Append(SPLIT_SLASH_STR).Append("UOSBrowserConfig_").Append(name.c_str());
|
|
|
+ strParams.Append(" --user-data-dir=").Append(usrDataPath);
|
|
|
+ strParams.Append(" --app=").Append(url.c_str());
|
|
|
+ strUOSBrowserPath.Append(strParams);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("3");
|
|
|
+ return strUOSBrowserPath.GetData();
|
|
|
+ }
|
|
|
+
|
|
|
+ //新版浏览器
|
|
|
+ if (m_UseUOSBrowser == 2) {
|
|
|
+
|
|
|
+ CSimpleStringA strUOSBrowserPath(execute_newbrowser_path.c_str());
|
|
|
+ strParams.Append(" --kiosk --incognito --allow-running-insecure-content --new-window");
|
|
|
+
|
|
|
+ CSimpleStringA tempPath;
|
|
|
+ this->m_pEntity->GetFunction()->GetPath("Temp", tempPath);
|
|
|
+ CSimpleStringA cachePath(tempPath);
|
|
|
+ cachePath.Append(CSimpleStringA(SPLIT_SLASH_STR)).Append("Browser_").Append(name.c_str());
|
|
|
+ strParams.Append(" --disk-cache-dir=").Append(cachePath);
|
|
|
+ strParams.Append(" --disk-cache-size=").Append("2147483647"); //2G
|
|
|
+ if (g_withMedia)
|
|
|
+ strParams.Append(" --use-fake-ui-for-media-stream");
|
|
|
+
|
|
|
+ CSimpleStringA usrDataPath(tempPath);
|
|
|
+ usrDataPath.Append(SPLIT_SLASH_STR).Append("BrowserConfig_").Append(name.c_str());
|
|
|
+ strParams.Append(" --user-data-dir=").Append(usrDataPath);
|
|
|
+ strParams.Append(" --app=").Append(url.c_str());
|
|
|
+ strUOSBrowserPath.Append(strParams);
|
|
|
+ return strUOSBrowserPath.GetData();
|
|
|
+ }
|
|
|
+ return std::string("");
|
|
|
#else
|
|
|
CSimpleStringA strChromiumPath = GetCefHead(this->m_pEntity), strCmdLine = "";
|
|
|
strCmdLine.Append(strChromiumPath).Append(" --url=").Append(url.c_str());
|
|
|
- if(size.length() > 0)
|
|
|
- strCmdLine.Append(" --center-size=").Append(size.c_str());
|
|
|
- if(point.length() > 0)
|
|
|
- strCmdLine.Append(" --src-pos=").Append(point.c_str());
|
|
|
+ if (width > 0 && height > 0)
|
|
|
+ strCmdLine.Append(" --center-size=").Append(std::to_string(width).c_str()).Append("*").Append(std::to_string(height).c_str());
|
|
|
+ if (point_x != -1 && point_y != -1)
|
|
|
+ {
|
|
|
+ strCmdLine.Append(" --src-pos=").Append(std::to_string(point_x).c_str()).Append("*").Append(std::to_string(point_y).c_str());
|
|
|
+ }
|
|
|
CSimpleStringA cachePath;
|
|
|
this->m_pEntity->GetFunction()->GetPath("Temp", cachePath);
|
|
|
cachePath.Append(CSimpleStringA(SPLIT_SLASH_STR)).Append("cefCache_").Append(m_strCacheHead.length() > 0 ? m_strCacheHead.c_str() : "").Append(name.c_str());
|
|
@@ -754,7 +855,7 @@ namespace Chromium {
|
|
|
g_mutexFreerdp.unlock();
|
|
|
});
|
|
|
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("start browser %d", reason._to_integral());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("start browser %d, %s", reason._to_integral(), reason._to_string());
|
|
|
|
|
|
if (reason._to_integral() == ERR_PAGE_REASON::main)
|
|
|
{
|
|
@@ -816,7 +917,8 @@ namespace Chromium {
|
|
|
else if (reason._to_integral() == ERR_PAGE_REASON::startup)
|
|
|
{
|
|
|
auto url = std::string(R"(file:///)") + getErrUrl(reason).second;
|
|
|
- auto strCmdline = generateCommonPage(url, (+ERR_PAGE_REASON::startup)._to_string(), "900*600", "", (int)HWND_NOTOPMOST);
|
|
|
+ auto strCmdline = generateCommonPage(url, (+ERR_PAGE_REASON::startup)._to_string(), 900, 600, -1, -1, (int)HWND_NOTOPMOST);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("startup page %s", strCmdline.c_str());
|
|
|
auto openCefRet = openCef(strCmdline, false);
|
|
|
if (Error_Succeed == openCefRet.first)
|
|
|
return std::make_pair(Error_Succeed, openCefRet.second);
|
|
@@ -827,7 +929,8 @@ namespace Chromium {
|
|
|
else if (reason._to_integral() == ERR_PAGE_REASON::performance_monitor)
|
|
|
{
|
|
|
auto url = std::string(R"(file:///)") + getErrUrl(reason).second;
|
|
|
- auto strCmdline = generateCommonPage(url, (+ERR_PAGE_REASON::performance_monitor)._to_string(), "900*600", "", (int)HWND_NOTOPMOST);
|
|
|
+ auto strCmdline = generateCommonPage(url, (+ERR_PAGE_REASON::performance_monitor)._to_string(), 900, 600, -1, -1, (int)HWND_NOTOPMOST);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("startup page %s", strCmdline.c_str());
|
|
|
auto openCefRet = openCef(strCmdline, false);
|
|
|
if (Error_Succeed == openCefRet.first)
|
|
|
return std::make_pair(Error_Succeed, openCefRet.second);
|
|
@@ -911,7 +1014,7 @@ namespace Chromium {
|
|
|
return std::make_pair(Error_Unexpect, 0);
|
|
|
}
|
|
|
|
|
|
- std::pair<ErrorCodeEnum, int> CModTools::startCommonPage(std::string name, std::string url, std::string size, std::string point, std::string top)
|
|
|
+ std::pair<ErrorCodeEnum, int> CModTools::startCommonPage(std::string name, std::string url, int width, int height, int point_x, int point_y, std::string top)
|
|
|
{
|
|
|
CSimpleString topStr = top.c_str();
|
|
|
int top_param = (int)HWND_NOTOPMOST;
|
|
@@ -924,14 +1027,14 @@ namespace Chromium {
|
|
|
else if (topStr.Compare("bottom", true) == 0)
|
|
|
top_param = (int)HWND_BOTTOM;
|
|
|
|
|
|
- auto strCmdline = generateCommonPage(url, name, size, point, top_param);
|
|
|
+ auto strCmdline = generateCommonPage(url, name, width, height, point_x, point_y, top_param);
|
|
|
auto openCefRet = openCef(strCmdline, false);
|
|
|
if (Error_Succeed == openCefRet.first)
|
|
|
return std::make_pair(Error_Succeed, openCefRet.second);
|
|
|
else
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open cef %s size:%s at %s in layer %s failed: %d"
|
|
|
- , name.c_str(), size.c_str(), point.c_str(), top.c_str(), openCefRet.first);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open cef %s size:%d*%d at %d*%d in layer %s failed: %d"
|
|
|
+ , name.c_str(), width, height, height, point_x, point_y, top.c_str(), openCefRet.first);
|
|
|
return std::make_pair(openCefRet.first, openCefRet.first);
|
|
|
}
|
|
|
|