|
@@ -66,7 +66,7 @@ namespace Chromium {
|
|
|
|
|
|
CChromiumEntity::CChromiumEntity() :m_pWsServer(NULL), m_iTcpBridgePort(4504), m_pTimerListener(NULL), m_strCustomMainUrl(true)
|
|
|
, m_runAd(false), m_runMain(false), m_runExtend(false), m_runLogin(false), m_withBrowser(false), m_withMin(false), m_withClose(false)
|
|
|
- , m_withDebugMode(false), m_withMagic(false), m_withNoFileLog(false)
|
|
|
+ , m_withDebugMode(false), m_withMagic(false), m_withNoFileLog(false), m_installMode(false)
|
|
|
{
|
|
|
DbgEx("CChromiumEntity constructor");
|
|
|
|
|
@@ -216,7 +216,8 @@ namespace Chromium {
|
|
|
#endif // OPEN_PERF
|
|
|
}
|
|
|
|
|
|
- void CChromiumEntity::OnPreStart_Init(CAutoArray<CSimpleStringA>& strArgs, CSmartPointer<ITransactionContext>& pTransactionContext) {
|
|
|
+ void CChromiumEntity::OnPreStart_Init(CAutoArray<CSimpleStringA>& strArgs, CSmartPointer<ITransactionContext>& pTransactionContext)
|
|
|
+ {
|
|
|
#ifdef OPEN_PERF
|
|
|
auto profStr = CSimpleString::Format("chromiumAnalyze_%s.prof", generateTimeStr(true).c_str());
|
|
|
std::thread([](std::string str) {
|
|
@@ -224,20 +225,16 @@ namespace Chromium {
|
|
|
DbgEx("Generate chromiumAnalyze, %s", str.c_str());
|
|
|
}, profStr.GetData()).detach();
|
|
|
#endif // OPEN_PERF
|
|
|
-#if (defined _WIN32 || defined _WIN64)
|
|
|
- CModTools::get_mutable_instance().InitCModTools(this);
|
|
|
- //CModTools::get_mutable_instance().killAllChromium();
|
|
|
- //shell启动过程,已经进行了cef的kill操作。这里可能会把启动时间延长很多
|
|
|
-#else
|
|
|
+
|
|
|
+ //init the chrome params from centersetting
|
|
|
FetchCustomMainUrl(strArgs);
|
|
|
CModTools::get_mutable_instance().InitCModTools(this);
|
|
|
+
|
|
|
+#if defined(RVC_OS_LINUX)
|
|
|
+ // clear all the browser
|
|
|
CModTools::get_mutable_instance().killAllChromium();
|
|
|
DoBrowserCacheClearJob();
|
|
|
-#endif
|
|
|
|
|
|
-#if (defined _WIN32 || defined _WIN64)
|
|
|
- //SetUnhandledExceptionFilter(&printSEG);
|
|
|
-#else
|
|
|
CSimpleStringA strDbgPath;
|
|
|
GetFunction()->GetPath("Dbg", strDbgPath);
|
|
|
set_traceback_path(strDbgPath.GetData());
|
|
@@ -354,20 +351,7 @@ namespace Chromium {
|
|
|
{
|
|
|
DbgEx("can not open centerSetting, maybe fault");
|
|
|
}
|
|
|
-#if (defined _WIN32 || defined _WIN64)
|
|
|
- if (!logProducer)
|
|
|
- logProducer = create_log_producer_storage("cefclient_logger", "0", "");
|
|
|
-#else
|
|
|
- CSimpleString dbgPath;
|
|
|
- GetFunction()->GetPath("Dbg", dbgPath);
|
|
|
- std::string dstDbgPath = dbgPath.GetData();
|
|
|
- dstDbgPath.append(SPLIT_SLASH_STR).append("mod_chromium");
|
|
|
- if (InitFileLogger(dstDbgPath))
|
|
|
- DbgToFileLogger("================");
|
|
|
- else
|
|
|
- DbgEx("[ERROR]logger init failed!");
|
|
|
|
|
|
-#endif
|
|
|
CSimpleString translatePath;
|
|
|
GetFunction()->GetPath("Cfg", translatePath);
|
|
|
translatePath.Append(CSimpleStringA(SPLIT_SLASH_STR) + "UserCodeToMsgTip.ini");
|
|
@@ -417,19 +401,8 @@ namespace Chromium {
|
|
|
}
|
|
|
#endif //RVC_OS_LINUX
|
|
|
|
|
|
- //与browser进行交互所必须,移除browser的机型不需要订阅browser相关
|
|
|
- if (m_withBrowser)
|
|
|
+ if (!m_withBrowser)
|
|
|
{
|
|
|
- if (Error_Succeed != (Error = GetFunction()->SubscribeBroadcast("IEBrowser", "CustomerCmd", this, m_uidBrowserListenser))) {
|
|
|
- DbgEx("subscribe browser CustomerCmd failed!");
|
|
|
- pTransactionContext->SendAnswer(Error);
|
|
|
- }
|
|
|
- else
|
|
|
- DbgEx("subscribe browser CustomerCmd success!");
|
|
|
-
|
|
|
- if (Error_Succeed != (Error = GetFunction()->SubscribeLog(m_uidCameraListener, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "CameraConfigManage")))
|
|
|
- DbgEx("subscribe Camera log failed!"); //非必须
|
|
|
- } else {//有browser的时候不需要订阅这一堆
|
|
|
DbgEx("subscribe AccessAuthorization %s, %d",
|
|
|
Error_Succeed == (Error = GetFunction()->SubscribeLog(m_uuidAccessAuth, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "AccessAuthorization")) ? "success" : "failed", Error);
|
|
|
|
|
@@ -526,8 +499,34 @@ namespace Chromium {
|
|
|
DbgEx("open page extend %s, pid:%d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
|
|
|
}
|
|
|
|
|
|
+ void CChromiumEntity::openInstallPage()
|
|
|
+ {
|
|
|
+ LogWarn(Severity_Middle, Error_NotSupport, LOG_WARN_CHROMIUM_INSTALL_NOTSURPORT,
|
|
|
+ CSimpleStringA::Format("Not surport install mode").GetData());
|
|
|
+ return;
|
|
|
+ auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::Install);
|
|
|
+ DbgEx("open page install %s, pid:%d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
void CChromiumEntity::startWithCfg()
|
|
|
{
|
|
|
+ // init cef logger first
|
|
|
+#if (defined _WIN32 || defined _WIN64)
|
|
|
+ if (!logProducer)
|
|
|
+ logProducer = create_log_producer_storage("cefclient_logger", "0", "");
|
|
|
+#else
|
|
|
+ CSimpleString dbgPath;
|
|
|
+ GetFunction()->GetPath("Dbg", dbgPath);
|
|
|
+ std::string dstDbgPath = dbgPath.GetData();
|
|
|
+ dstDbgPath.append(SPLIT_SLASH_STR).append("mod_chromium");
|
|
|
+ if (InitFileLogger(dstDbgPath))
|
|
|
+ DbgToFileLogger("================");
|
|
|
+ else
|
|
|
+ DbgEx("[ERROR]logger init failed!");
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
OnPreStart_Init(m_strArgs, m_pTransactionContext);//初始化部分, perf ,killchromium, signal, get custom url
|
|
|
if (!OnPreStart_socketStart(m_strArgs, m_pTransactionContext)) {//OnPreStart_socketStart()->new CWebsocketServer(strStructPath, this) 时间过长
|
|
|
return;
|
|
@@ -551,12 +550,28 @@ namespace Chromium {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ openInstallPage();
|
|
|
}
|
|
|
|
|
|
void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
{
|
|
|
m_strArgs = strArgs;
|
|
|
m_pTransactionContext = pTransactionContext;
|
|
|
+ pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
+
|
|
|
+ //all the init,register,openWeb run thread
|
|
|
+ auto startFun = [&]() {
|
|
|
+ //the system info may be not complete.If the device is not install ,it can't not read the terminalNo.
|
|
|
+ CSystemStaticInfo t_sysInfo;
|
|
|
+ GetFunction()->GetSystemStaticInfo(t_sysInfo);
|
|
|
+ if (t_sysInfo.strTerminalID.GetLength() == 0)// the machine is in install mode, hence start a simple init and open the install page
|
|
|
+ {
|
|
|
+ m_installMode = true;
|
|
|
+ startWithCfg();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
CSimpleStringA t_terminalState;
|
|
|
if (ErrorCodeEnum::Error_Succeed == GetFunction()->GetSysVar("TerminalStage", t_terminalState))
|
|
@@ -565,11 +580,13 @@ namespace Chromium {
|
|
|
startWithCfg();//属于chromium重启或者其他情况,已经初始化好配置
|
|
|
}
|
|
|
else
|
|
|
- DbgEx("subscribe VtmLoader %s",
|
|
|
- (Error_Succeed == GetFunction()->SubscribeLog(m_uuidVTMLoader, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "VtmLoader")) ? "success" : "failed");
|
|
|
+ DbgEx("subscribe VtmLoader %s",
|
|
|
+ (Error_Succeed == GetFunction()->SubscribeLog(m_uuidVTMLoader, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "VtmLoader")) ? "success" : "failed");
|
|
|
+ };
|
|
|
+
|
|
|
+ boost::thread(startFun).detach();
|
|
|
|
|
|
|
|
|
- pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
}
|
|
|
|
|
|
bool CChromiumEntity::CheckIsCardStore() {
|
|
@@ -810,39 +827,6 @@ namespace Chromium {
|
|
|
|
|
|
|
|
|
|
|
|
- void CChromiumEntity::OnBusinessLimitTimerListener(void* pData)
|
|
|
- {
|
|
|
- DbgEx("定时任务检查业务禁用");
|
|
|
- // 检查是否禁用业务,做交易限制的检查
|
|
|
- TradeManageCodeEnum jobLimit = CModTools::get_mutable_instance().CheckJobLimited();
|
|
|
-
|
|
|
- DbgEx("ShowLimitScreen : TradeManageCodeEnum=%s", jobLimit._to_string());
|
|
|
-
|
|
|
-
|
|
|
- switch (jobLimit) {
|
|
|
- case TradeManageCodeEnum::Trade:
|
|
|
- CModTools::get_mutable_instance().killChromiumByName((+PAGE_TYPE::TradeManager)._to_string());
|
|
|
- break;
|
|
|
- case TradeManageCodeEnum::Disabled:
|
|
|
- {
|
|
|
- auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::disabled,
|
|
|
- std::tuple < std::string, std::string>(m_sysInfo.strTerminalID.GetData(), generateTimeStr()));
|
|
|
- DbgEx("TradeManageCodeEnum Disabled, open page %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
|
|
|
- }
|
|
|
- break;
|
|
|
- case TradeManageCodeEnum::JobUncomplete:
|
|
|
- {
|
|
|
- auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::jobuncomplete,
|
|
|
- std::tuple < std::string, std::string>(m_sysInfo.strTerminalID.GetData(), generateTimeStr()));
|
|
|
- DbgEx("TradeManageCodeEnum JobUncomplete, open page %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- GetFunction()->ResetTimer(BROWSER_TIMER_ID, BROWSER_TIMER_INTERVAL);
|
|
|
- }
|
|
|
|
|
|
void CChromiumEntity::OnBrowserCacheClean(const char* pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, ResourceWatcher::BrowserCacheClean& evt)
|
|
|
{
|
|
@@ -910,11 +894,6 @@ namespace Chromium {
|
|
|
|
|
|
}
|
|
|
|
|
|
- void CChromiumEntity::generateBussinessLimitTimer() {
|
|
|
- DbgEx("Start BusinessLimitTimer");
|
|
|
- pBusinessLimitTimerListener = new TimerOutHelper<CChromiumEntity>(this, &CChromiumEntity::OnBusinessLimitTimerListener, NULL, false);
|
|
|
- GetFunction()->SetTimer(BROWSER_TIMER_ID, pBusinessLimitTimerListener, 5000);
|
|
|
- }
|
|
|
|
|
|
int CChromiumEntity::getBrowserStartTimes() {
|
|
|
CAutoArray<CSimpleStringA> t_names;
|