Explorar o código

Z991239-5129 #comment secure websocket by sm2

陈良瑜80374463 hai 1 ano
pai
achega
86a100ee76

+ 57 - 49
Module/mod_chromium/CModTools.cpp

@@ -86,12 +86,12 @@ namespace Chromium {
 				Error = spConfig->ReadConfigValue("Terminal", "Site", m_strSite);
 				if (Error != Error_Succeed)
 				{
-					DbgEx("ReadConfigValue, get Site value failed");
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("ReadConfigValue, get Site value failed");
 				}
 			}
 			else
 			{
-				DbgEx("ReadConfigValue, get MachineType value failed");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("ReadConfigValue, get MachineType value failed");
 			}
 		}
 
@@ -139,7 +139,7 @@ namespace Chromium {
         } while (false);
 
 		breakdownExist = m_isAdOpen = notifyExist = false;
-		DbgEx("run killAllChromium success ex");
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("run killAllChromium success ex");
 		return true;
 #endif
 	}
@@ -153,13 +153,13 @@ namespace Chromium {
 			});
 		std::future_status a1 = cur.wait_for(std::chrono::seconds(seconds));
 		if (a1 == std::future_status::deferred)
-			DbgEx("killAllChromiumByThread run delay");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("killAllChromiumByThread run delay");
 		else
 		{
 			if (a1 == std::future_status::ready)
-				DbgEx("killAllChromiumByThread run end");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("killAllChromiumByThread run end");
 			else
-				DbgEx("killAllChromiumByThread do not end, over than %d seconds", seconds);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("killAllChromiumByThread do not end, over than %d seconds", seconds);
 		}
 #endif
 
@@ -214,7 +214,7 @@ namespace Chromium {
 		bool showRebootTime = true;
 		if (rc == Error_Succeed && needGuardian.Compare("Y", false))
 			showRebootTime = false;
-		DbgEx("NeedGuardian:%s", needGuardian.GetData());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("NeedGuardian:%s", needGuardian.GetData());
 
 		switch (errType)
 		{
@@ -258,6 +258,8 @@ namespace Chromium {
 		errPageUrl.Append(" --cache-path=").Append(cachePath);
         if (g_useMagic)
 			errPageUrl.Append(" --magic-str=").Append(m_magicStr.c_str());
+		if (g_withMedia)
+			errPageUrl.Append(" --enable-media-stream=1 --enable-system-flash=1 --enable-speech-input=1");
 		errPageUrl.Append(" --no-sandbox").Append(" --hide-controls").Append(" --hide-tabs");
 		errPageUrl.Append(" --top=-1");
 
@@ -291,7 +293,7 @@ namespace Chromium {
         CSimpleString dstCmd = generateBrowserCMDForEverything(errPageUrl.GetData(), 2).c_str();
 #endif //RVC_OS_WIN
 
-		DbgEx("GenerateErrPage type=%s, dstPage=%s", errType._to_string(), dstCmd.GetData());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("GenerateErrPage type=%s, dstPage=%s", errType._to_string(), dstCmd.GetData());
 
 		return std::make_pair(true, (const char*)dstCmd.GetData());
 	}
@@ -339,15 +341,15 @@ namespace Chromium {
 		CSimpleStringA m_strLimitReason = reason;
 		if (m_strLimitReason.Compare("breakdown") != 0 && !m_strLimitReason.IsNullOrEmpty())
 		{
-			DbgEx("reason:%d, setState:%s", reason, "L");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("reason:%d, setState:%s", reason, "L");
 			this->m_pEntity->GetFunction()->SetSysVar("TradeManageState", "L", true);
 		}
 		if (m_strLimitReason.Compare("breakdown") == 0) {
-			DbgEx("reason:%d, no setState", reason);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("reason:%d, no setState", reason);
 		}
 		if (m_strLimitReason.IsNullOrEmpty())
 		{
-			DbgEx("reason:%d, setState:%s", reason, "T");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("reason:%d, setState:%s", reason, "T");
 			this->m_pEntity->GetFunction()->SetSysVar("TradeManageState", "T", true);
 		}
 	}
@@ -362,7 +364,7 @@ namespace Chromium {
             strCmdLine.Append(" --logextend=").Append(reason._to_string());
         if (reason._to_integral() == ERR_PAGE_REASON::main)
             m_isGuardMainBrowser = false;
-        DbgEx("StopChromiumBrowser cmdline:%s, current guardian main browser : %d", strCmdLine.GetData(), m_isGuardMainBrowser);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("StopChromiumBrowser cmdline:%s, current guardian main browser : %d", strCmdLine.GetData(), m_isGuardMainBrowser);
 
         SYSTEM_ON(strCmdLine.GetData());
         if (reason._to_integral() == ERR_PAGE_REASON::breakdown || reason._to_integral() == ERR_PAGE_REASON::warnPrompt)
@@ -388,7 +390,7 @@ namespace Chromium {
         CSimpleStringA strChromiumPath = GetCefHead(this->m_pEntity), strCmdLine = "";
         strCmdLine.Append(strChromiumPath).Append(" --kill");
         strCmdLine.Append(" --logextend=").Append(cefName.c_str());
-        DbgEx("StopChromiumBrowser cmdline:%s, current guardian main browser : %d", strCmdLine.GetData(), m_isGuardMainBrowser);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("StopChromiumBrowser cmdline:%s, current guardian main browser : %d", strCmdLine.GetData(), m_isGuardMainBrowser);
         SYSTEM_ON(strCmdLine.GetData());
 #else
         LogWarn(Severity_Low, Error_NotSupport, LOG_WARN_CHROMIUM_NOT_SUPPORT_TOKILL_SPECIFIED_BROWSER,
@@ -450,13 +452,15 @@ namespace Chromium {
         strCmdLine.Append(" --cache-path=").Append(cachePath);
         if (g_useMagic)
             strCmdLine.Append(" --magic-str=").Append(m_magicStr.c_str());
+		if (g_withMedia)
+			strCmdLine.Append(" --enable-media-stream=1 --enable-system-flash=1 --enable-speech-input=1");
         strCmdLine.Append(" --no-sandbox");
         strCmdLine.Append(" --hide-controls");
         strCmdLine.Append(" --hide-tabs");
         strCmdLine.Append(" --logextend=").Append((+PAGE_TYPE::Ad)._to_string());
         strCmdLine.Append(" --top=-1");
         strCmdLine.Append(" --run-extend");
-        DbgEx("cmdline : %s", strCmdLine.GetData());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("cmdline : %s", strCmdLine.GetData());
         return strCmdLine.GetData();
 #endif //RVC_OS_LINUX
 	}
@@ -480,6 +484,8 @@ namespace Chromium {
         strCmdLine.Append(" --hide-controls");
         if (g_useMagic)
             strCmdLine.Append(" --magic-str=").Append(m_magicStr.c_str());
+		if (g_withMedia)
+			strCmdLine.Append(" --enable-media-stream=1 --enable-system-flash=1 --enable-speech-input=1");
         strCmdLine.Append(" --hide-tabs");
         if (m_withDebugMode)
             strCmdLine.Append(" --remote-debugging-port=9222");
@@ -489,7 +495,7 @@ namespace Chromium {
         } else
             strCmdLine.Append(" --logextend=").Append((+PAGE_TYPE::slv)._to_string());
         strCmdLine.Append(" --errurl=file:\/\/\/").Append(getErrUrl(ERR_PAGE_REASON::main).second.c_str());
-        DbgEx("cmdline : %s", strCmdLine.GetData());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("cmdline : %s", strCmdLine.GetData());
         return strCmdLine.GetData();
     }
 #endif //RVC_OS_WIN
@@ -518,7 +524,7 @@ namespace Chromium {
 		strCmdLine.Append(" --hide-controls");
 		strCmdLine.Append(" --hide-tabs");
 		strCmdLine.Append(" --logextend=").Append((+PAGE_TYPE::Install)._to_string());
-		DbgEx("cmdline : %s", strCmdLine.GetData());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("cmdline : %s", strCmdLine.GetData());
 		return strCmdLine.GetData();
 #endif //RVC_OS_LINUX
 	}
@@ -537,6 +543,8 @@ namespace Chromium {
         strCmdLine.Append(" --hide-controls");
         if (g_useMagic)
             strCmdLine.Append(" --magic-str=").Append(m_magicStr.c_str());
+		if (g_withMedia)
+			strCmdLine.Append(" --enable-media-stream=1 --enable-system-flash=1 --enable-speech-input=1");
         strCmdLine.Append(" --hide-tabs");
         strCmdLine.Append(" --logextend=").Append(m_specialPage_temp_name.c_str());
         if (m_specialPage_temp_size.length() > 0)
@@ -545,7 +553,7 @@ namespace Chromium {
             strCmdLine.Append(" --src-pos=").Append(m_specialPage_temp_point.c_str());
         strCmdLine.Append(" --top=").Append(std::to_string((unsigned long long)m_specialPage_temp_top).c_str());
         strCmdLine.Append(" --errurl=file:\/\/\/").Append(getErrUrl(ERR_PAGE_REASON::main).second.c_str());
-        DbgEx("cmdline : %s", strCmdLine.GetData());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("cmdline : %s", strCmdLine.GetData());
         return strCmdLine.GetData();
 #else
         return generateBrowserCMDForEverything(mainUrl, 3);
@@ -695,7 +703,7 @@ namespace Chromium {
 			g_mutexFreerdp.unlock();
 			});
 
-		DbgEx("start browser %d", reason._to_integral());
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("start browser %d", reason._to_integral());
 
 		if (reason._to_integral() == ERR_PAGE_REASON::main)
 		{
@@ -703,7 +711,7 @@ namespace Chromium {
 
 			if (0 == mainUrlRet.second.length())
 			{
-				DbgEx("StartChromiumBrowser get %s url failed!", reason._to_string());
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("StartChromiumBrowser get %s url failed!", reason._to_string());
 				LogWarn(Severity_High, Error_Unexpect, LOG_EVT_CHROMIUM_DETECT_MAIN_URL_EMPTY,
 						CSimpleStringA::Format("StartChromiumBrowser get %s url failed!", reason._to_string()));
 				return std::make_pair(Error_Unexpect, 0);
@@ -724,12 +732,12 @@ namespace Chromium {
 		}
 		else if (reason._to_integral() == ERR_PAGE_REASON::extend)
 		{
-			DbgEx("do not support freerdp");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("do not support freerdp");
 		}
 		else if (reason._to_integral() == ERR_PAGE_REASON::Ad)
 		{
 			auto AdRet = openAdPage();
-			if (!AdRet.first) DbgEx("%s", AdRet.second.c_str());
+			if (!AdRet.first) DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s", AdRet.second.c_str());
 			return std::make_pair(AdRet.first ? Error_Succeed : Error_Unexpect, 0);
 		}
 		 else if (reason._to_integral() == ERR_PAGE_REASON::OutsideRequest) {
@@ -743,7 +751,7 @@ namespace Chromium {
 	        if (Error_Succeed == openCefRet.first)
 	            return std::make_pair(Error_Succeed, openCefRet.second);
 		 	else 
-				DbgEx("open cef for %s failed: %d", reason._to_string(), openCefRet.first);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open cef for %s failed: %d", reason._to_string(), openCefRet.first);
 	    }
 		 else if (reason._to_integral() == ERR_PAGE_REASON::SpecialPageFromOtherEntity)
 		{
@@ -752,14 +760,14 @@ namespace Chromium {
 			if (Error_Succeed == openCefRet.first)
 				return std::make_pair(Error_Succeed, openCefRet.second);
 			else
-				DbgEx("open cef for %s failed: %d", reason._to_string(), openCefRet.first);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open cef for %s failed: %d", reason._to_string(), openCefRet.first);
 		}
 		 else if (reason._to_integral() == ERR_PAGE_REASON::Install)
 		{
 			std::vector<std::string> installUrls;
 #ifdef DEVOPS_ON_ST /*DevOps流水线编译,ST环境*/
-			installUrls.push_back("https://deviceinstallweb.paasst.cmbchina.cn/inputTerminalNo");
-			installUrls.push_back("https://deviceinstallweb.paasst.cmbchina.cn/inputTerminalNo");
+			installUrls.push_back("https://one-account-gateway.paasuat.cmbchina.cn/auth/sso-login?client_id=78e38f5453c547ef8a0d5d10a2ed5121&response_type=code&redirect_uri=https://deviceinstallweb.paasst.cmbchina.cn/installRequire");
+			installUrls.push_back("https://one-account-gateway.paasuat.cmbchina.cn/auth/sso-login?client_id=78e38f5453c547ef8a0d5d10a2ed5121&response_type=code&redirect_uri=https://deviceinstallweb.paasst.cmbchina.cn/installRequire");
 #elif defined(DEVOPS_ON_UAT)/*DevOps流水线编译,UAT环境*/
 			installUrls.push_back("http://deviceinstallweb.paasuat.cmbchina.cn");
 			installUrls.push_back("http://deviceinstallweb.paasuat.cmbchina.com");
@@ -767,8 +775,8 @@ namespace Chromium {
 			installUrls.push_back("http://deviceinstallweb.paas.cmbchina.cn");
 			installUrls.push_back("http://deviceinstallweb.paas.cmbchina.com");
 #else/*本地编译等非DevOps环境编译的版本*/
-			installUrls.push_back("https://deviceinstallweb.paasst.cmbchina.cn/inputTerminalNo");
-			installUrls.push_back("https://deviceinstallweb.paasst.cmbchina.cn/inputTerminalNo");
+			installUrls.push_back("https://one-account-gateway.paasuat.cmbchina.cn/auth/sso-login?client_id=78e38f5453c547ef8a0d5d10a2ed5121&response_type=code&redirect_uri=https://deviceinstallweb.paasst.cmbchina.cn/installRequire");
+			installUrls.push_back("https://one-account-gateway.paasuat.cmbchina.cn/auth/sso-login?client_id=78e38f5453c547ef8a0d5d10a2ed5121&response_type=code&redirect_uri=https://deviceinstallweb.paasst.cmbchina.cn/installRequire");
 #endif
 			auto checkRet = DetectActiveHttp(installUrls);
 			if (!checkRet.first)
@@ -779,7 +787,7 @@ namespace Chromium {
 			std::string dstInstallUrl = checkRet.first ? checkRet.second : installUrls[0];
 			CSimpleString runningVer = "";
 			m_pEntity->GetFunction()->GetRunningVersion(runningVer);
-			dstInstallUrl.append("?version=").append(runningVer.GetData());
+			dstInstallUrl.append("?terminalVersion=").append(runningVer.GetData());
 			auto strCmdLine = generateInstallCmd(dstInstallUrl);
 			auto openCefRet = openCef(strCmdLine, false);
 			if (Error_Succeed == openCefRet.first)
@@ -800,7 +808,7 @@ namespace Chromium {
 			auto errPageUrl = GenerateErrPage(reason, normalParam, exParam);
 			if (!errPageUrl.first)
 			{
-				DbgEx("errPage get url failed!");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("errPage get url failed!");
 				return std::make_pair(Error_Unexpect, 0);
 			}
 			auto errPageRet = openCef(errPageUrl.second);
@@ -830,14 +838,14 @@ namespace Chromium {
 #if (defined _WIN32 || defined _WIN64)
 				auto startRet = startProcessInJob(cmdline, "");
 				if (!std::get<0>(startRet))
-					DbgEx("cefClientGuardian startProcessInJob failed!");
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("cefClientGuardian startProcessInJob failed!");
 				else
-					DbgEx("cefClientGuardian open cefclient pid:%d, cmd:%s", std::get<1>(startRet), cmdline.c_str());
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("cefClientGuardian open cefclient pid:%d, cmd:%s", std::get<1>(startRet), cmdline.c_str());
 				WaitForSingleObject(std::get<3>(startRet), INFINITE);
 				boost::mutex::scoped_lock(m_guardInterruptLock);//必须保证unlock被执行,不然就会有问题
 #else
 				boost::process::child child_process(cmdline);
-				DbgEx("open cefclient pid:%d, cmd:%s", child_process.id(), cmdline.c_str());
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open cefclient pid:%d, cmd:%s", child_process.id(), cmdline.c_str());
 				child_process.wait();
 #endif
 			}
@@ -858,7 +866,7 @@ namespace Chromium {
 	// 输入为北京时间 输出为北京时间戳
 	int CModTools::StandardToStamp(const char* str_time, bool dateOnly)
 	{
-		DbgEx("StandardToStamp str = %s", str_time);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("StandardToStamp str = %s", str_time);
 		struct tm stm;
 		int iY, iM, iD, iH, iMin, iS;
 
@@ -900,10 +908,10 @@ namespace Chromium {
 		if ((m_strSite.IsEndWith("FLB", true) || m_strSite.IsEndWith("SMM", true)) &&
 			m_strMachineType.IsEndWith("PAD", true))
 		{
-			DbgEx("isOutsidePad Yes");
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("isOutsidePad Yes");
 			return true;
 		}
-		DbgEx("isOutsidePad No");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("isOutsidePad No");
 		return false;
 	}
 
@@ -960,7 +968,7 @@ namespace Chromium {
 		auto rc = pClient->Connect();
 		if (rc != Error_Succeed)
 		{
-			DbgEx("connect to Upload entity fail: %d", rc);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("connect to Upload entity fail: %d", rc);
 			pClient->SafeDelete();
 			pClient = NULL;
 		}
@@ -972,10 +980,10 @@ namespace Chromium {
 			rc = (*pClient)(EntityResource::getLink().upgradeLink())->UploadDateList(req, ans, 10000);
 
 			if (rc != Error_Succeed)
-				DbgEx("get CreateProcessRunAs fail from FreeRDPWrap: %d", rc);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("get CreateProcessRunAs fail from FreeRDPWrap: %d", rc);
 			else
 			{
-				DbgEx("UploadDateList succeed from Upload");
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("UploadDateList succeed from Upload");
 				for (int i = 0; i < ans.uploadDateStr.GetCount(); ++i)
 				{
 					CSimpleStringA str = (CSimpleStringA)ans.uploadDateStr[i];
@@ -1000,7 +1008,7 @@ namespace Chromium {
 		errorRead = spConfig->ReadConfigValue("Record", "LastRecordTime", strLastRecordTime);
 		if (errorRead != Error_Succeed)
 		{
-			DbgEx("Read Record LastRecordTime -> Failed! Maybe LastRecordTime not exist!");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Read Record LastRecordTime -> Failed! Maybe LastRecordTime not exist!");
 			strLastRecordTime = "";
 		}
 
@@ -1013,7 +1021,7 @@ namespace Chromium {
 		{
 			if (timestamp_lastRecordTime <= *it && *it < now)
 			{
-				DbgEx("CheckTradeRecord lastRecordTime=%d, time_list=%d, now=%d", timestamp_lastRecordTime, *it, now);
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CheckTradeRecord lastRecordTime=%d, time_list=%d, now=%d", timestamp_lastRecordTime, *it, now);
 				return true;
 			}
 		}
@@ -1062,22 +1070,22 @@ namespace Chromium {
         if (SP::Module::Util::ShellExecute(runStr, succStr, errStr)) {
 			if (succStr.empty()) {
 				if (ExistsFileA(execute_oldbrowser_path_check.c_str())) {
-					DbgEx("%s exists!", execute_oldbrowser_path_check.c_str());
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s exists!", execute_oldbrowser_path_check.c_str());
 					result = 1;
 				} else {
-					DbgEx("%s not exists!", execute_oldbrowser_path_check.c_str());
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s not exists!", execute_oldbrowser_path_check.c_str());
 				}
 				LogWarn(Severity_Low, Error_Debug, LOG_EVT_CHROMIUM_BROWSER_LACK_OF_NEWONE, "have not installered new version UOS  browser");
 			} else {
-				DbgEx("new browser version: %s", succStr.c_str());
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("new browser version: %s", succStr.c_str());
 				additional = succStr;
 				if (!ExistsFileA(execute_newbrowser_path.c_str())) {
-					DbgEx("%s not exists!", execute_newbrowser_path.c_str()); 
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s not exists!", execute_newbrowser_path.c_str());
 				}
 				result = 2;
 			}
 		} else {
-			DbgEx("execute '%s' failed!", runStr.c_str());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("execute '%s' failed!", runStr.c_str());
 		}
 
 		UploadBrowserInfo(result, additional.c_str());
@@ -1118,7 +1126,7 @@ namespace Chromium {
 #if (defined _WIN32 || defined _WIN64)
 			auto startRet = startProcessInJob(cmdline, "");
 			if (!std::get<0>(startRet))
-				DbgEx("startProcessInJob failed!");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("startProcessInJob failed!");
 			return std::make_pair(std::get<0>(startRet) ? Error_Succeed : Error_Unexpect, std::get<1>(startRet));
 #else
 			auto systemStartChromium = [](std::string str, bool systemCmd) {
@@ -1143,7 +1151,7 @@ namespace Chromium {
 
 		if (Error != Error_Succeed)
 		{
-			DbgEx("stop tcp bridge server failed! error = %d", Error);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("stop tcp bridge server failed! error = %d", Error);
 			return false;
 		}
 			
@@ -1152,7 +1160,7 @@ namespace Chromium {
 
 		if (Error != Error_Succeed)
 		{
-			DbgEx("start tcp bridge server failed! error = %d", Error);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("start tcp bridge server failed! error = %d", Error);
 			return false;
 		}
 			
@@ -1176,7 +1184,7 @@ namespace Chromium {
 		table.AddEntryString(entityName, "UserMgrAd", strAd, "");
 		table.AddEntryString(entityName, "CacheHead", strCacheHead, "");
 		if (Error_Succeed == table.Load(spCerConfig))
-			DbgEx(CSimpleString::Format("read centersetting config : UserMgrUrl-%s, UserMgrUrlNoSidebar-%s, UserMgrUrlNoSidebarMuti-%s, UserMgrUrlFulture-%s, UserMgrAd-%s",
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)(CSimpleString::Format("read centersetting config : UserMgrUrl-%s, UserMgrUrlNoSidebar-%s, UserMgrUrlNoSidebarMuti-%s, UserMgrUrlFulture-%s, UserMgrAd-%s",
 				str.GetData(), strNew.GetData(), strEx.GetData(), strFulture.GetData(), strAd.GetData()));
 
 		CChromiumEntity* pChromiumEntity = reinterpret_cast<CChromiumEntity*>(m_pEntity);

+ 24 - 25
Module/mod_chromium/CSocketClient.cpp

@@ -47,13 +47,13 @@ std::pair<bool, std::string> DetectActiveHttp(std::vector<std::string> urlArr)
 		{
 			if (threadArr[i].is_ready())
 			{
-				DbgEx("Detect url %s %s", urlArr[i].c_str(), threadArr[i].get() ? "success" : "failed");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Detect url %s %s", urlArr[i].c_str(), threadArr[i].get() ? "success" : "failed");
 				if (threadArr[i].get())
 					vaildArr.emplace_back(urlArr[i]);
 			}
 
 			else
-				DbgEx("Detect url %s timeout", urlArr[i].c_str());
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Detect url %s timeout", urlArr[i].c_str());
 		}
 
 
@@ -68,7 +68,7 @@ std::pair<bool, std::string> DetectActiveHttp(std::vector<std::string> urlArr)
 			return std::make_pair(false, "");
 	}
 	catch (std::exception& e) {
-		DbgEx("DetectActiveHttp exception, %s", e.what());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("DetectActiveHttp exception, %s", e.what());
 		return std::make_pair(false, "");
 	}
 
@@ -92,7 +92,7 @@ namespace Chromium {
 		mID(id),
 		m_pEntity(pEntity)
 	{
-		::DbgEx("CSocketClient constructor ip=%s, port=%s", ipAddr, port);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient constructor ip=%s, port=%s", ipAddr, port);
 		m_psocket = sock_ptr(new socket_type(ios));
 	}
 
@@ -102,24 +102,24 @@ namespace Chromium {
 
 	ErrorCodeEnum CSocketClient::Connect() {
 		boost::system::error_code ec;
-		DbgEx("CSocketClient method -> connect thread_id = %ld, object=%ld", boost::this_thread::get_id(), this);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient method -> connect thread_id = %ld, object=%ld", boost::this_thread::get_id(), this);
 		m_psocket->connect(m_ep, ec);
 		if (ec)
 		{
 			// connect failed!
-			DbgEx("CSocketClient method -> Connect  : connect failed! Retry after 1s !");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient method -> Connect  : connect failed! Retry after 1s !");
 			// retry to connect after 3s
 			Sleep(1000);
 			m_psocket->connect(m_ep, ec);
 			if (ec)return Error_IO;
 		}
-		DbgEx("CSocketClient method -> connect  succeed!");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient method -> connect  succeed!");
 		StartSocketService();
 		return Error_Succeed;
 	}
 
 	ErrorCodeEnum CSocketClient::Close() {
-		DbgEx("CSocketClient method -> close");
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient method -> close");
 		StopSocketService();
 		boost::system::error_code ec;
 		m_psocket->close(ec);
@@ -135,7 +135,7 @@ namespace Chromium {
 			m_psocket->async_send(boost::asio::buffer(pMsg->getPayload(), pMsg->getLength()), boost::bind(&this_type::handle_write, this, boost::asio::placeholders::error));
 		}
 		else {
-			DbgEx("CSocketClient method -> write error : socket is closed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient method -> write error : socket is closed");
 			return Error_IO;
 		}
 		//::DbgEx("Leave CSocketClient method -> write");
@@ -152,32 +152,31 @@ namespace Chromium {
 	ErrorCodeEnum CSocketClient::StopSocketService() {
 		if (NULL != m_pNetThread)
 		{
-			DbgEx("CSocketClient -> StopSocketService doing interrupt");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient -> StopSocketService doing interrupt");
 			m_pNetThread->interrupt();
 			m_pNetThread->join();
 			m_pNetThread = NULL;
 		}
-		DbgEx("Socket Service stopped");
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Socket Service stopped");
 		return Error_Succeed;
 	}
 
 	void CSocketClient::handle_connect(const boost::system::error_code& err) {
-		DbgEx("CSocketClient method -> handle_connect thread_id = %ld, object=%ld", boost::this_thread::get_id(), this);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient method -> handle_connect thread_id = %ld, object=%ld", boost::this_thread::get_id(), this);
 		if (err)
 		{
 			// connect failed!
-			DbgEx("CSocketClient method -> handle_connect  : connect failed!");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient method -> handle_connect  : connect failed!");
 			// retry to connect after 3s
 			Sleep(3000);
 			m_psocket->async_connect(m_ep, boost::bind(&this_type::handle_connect, this, boost::asio::placeholders::error));
 			return;
 		}
-		DbgEx("CSocketClient method -> handle_connect  : connect succeed! socket p = %ld", m_psocket);
-		DbgEx("CSocketClient method -> handle_connect end");
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient method -> handle_connect  : connect succeed! socket p = %ld", m_psocket);
 	}
 
 	void CSocketClient::handle_close(const boost::system::error_code& err) {
-		DbgEx("CSocketClient method -> handle_close : %s", err.message().c_str());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient method -> handle_close : %s", err.message().c_str());
 		return;
 	}
 
@@ -222,7 +221,7 @@ namespace Chromium {
 		if (err)
 		{
 			// OnRecvError
-			DbgEx("CSocketClient handle_read something wrong!");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CSocketClient handle_read something wrong!");
 			return;
 		}
 
@@ -267,7 +266,7 @@ namespace Chromium {
 				}
 				catch (const std::exception&)
 				{
-					DbgEx("select exception");
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("select exception");
 				}
 
 				if (sel == 0) {
@@ -277,11 +276,11 @@ namespace Chromium {
 				}
 				else if (sel < 0 && errno != EINTR) {
 					// select error
-					DbgEx("select error sel = %d", sel);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("select error sel = %d", sel);
 					ErrorCodeEnum ec = (boost::this_thread::interruption_requested() ? ErrorCodeEnum::Error_Succeed :this->Reconnect());
 					if (Error_Succeed != ec)
 					{
-						DbgEx("Socket select error and reconnect failed. Restart this entity please!");
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Socket select error and reconnect failed. Restart this entity please!");
 						break;
 					}
 					boost::this_thread::sleep(boost::posix_time::milliseconds(100));
@@ -297,7 +296,7 @@ namespace Chromium {
 					}
 					catch (...)
 					{
-						DbgEx("first read error, %s", hexdumpToString(msg.getWriteableData(), msg.getBufferLength()).c_str());
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("first read error, %s", hexdumpToString(msg.getWriteableData(), msg.getBufferLength()).c_str());
 						msg.clear();
 						return;
 					}
@@ -307,7 +306,7 @@ namespace Chromium {
 
 					if (0 >= len || len > MAX_TRANSFER_LEN)
 					{
-						DbgEx("socket has been closed! cur Len: %d, may make the read buffer err");
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("socket has been closed! cur Len: %d, may make the read buffer err");
 						if (!boost::this_thread::interruption_requested())
 							break;
 							
@@ -330,7 +329,7 @@ namespace Chromium {
 					}
 					catch (...)
 					{
-						DbgEx("second read error, %s", hexdumpToString(msg.getWriteableData(), msg.getBufferLength()).c_str());
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("second read error, %s", hexdumpToString(msg.getWriteableData(), msg.getBufferLength()).c_str());
 						msg.clear();
 						return;
 					}
@@ -341,11 +340,11 @@ namespace Chromium {
 						this->mMessageHandler(msg, mID);
 				}
 			}
-			DbgEx("warning ! : thread_recv end!");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("warning ! : thread_recv end!");
 		}
 		catch (boost::thread_interrupted&)
 		{
-			DbgEx("Socket thread interrupted!");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Socket thread interrupted!");
 		}
 	}
 

+ 1 - 1
Module/mod_chromium/CStructureInterpreter.cpp

@@ -23,7 +23,7 @@ namespace Chromium {
 
 	void CStructureInterpreter::loadXmlFiles() {
 		this->getAllFiles();
-		DbgEx("loadXmlFiles scan xmls, size:%d", mFiles.size());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("loadXmlFiles scan xmls, size:%d", mFiles.size());
 		int i = 0;
 		for (i = 0; i < this->mFiles.size(); ++i)
 		{

+ 58 - 58
Module/mod_chromium/CWSCodec.cpp

@@ -68,17 +68,17 @@ namespace Chromium {
 	}
 
 	void CWSCodec::init(const char* xmlPath) {
-		DbgEx("CWSCodec method -> init from %s", xmlPath);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec method -> init from %s", xmlPath);
 		try {
 			mInterpreter = new CStructureInterpreter(xmlPath);
 		}
 		catch (const std::bad_alloc& e)
 		{
-			DbgEx("CWSCodec::init Memory allocation failed: %s", e.what());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::init Memory allocation failed: %s", e.what());
 		}
 		catch (const std::exception& e)
 		{
-			DbgEx("CWSCodec::init Error: %s", e.what());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::init Error: %s", e.what());
 		}
 		
 	}
@@ -107,7 +107,7 @@ namespace Chromium {
 			{
 #endif
 				if (paramInfo.mName == repeatName)
-					DbgEx("requestAck参数名字重复, error, %s", paramInfo.mName.c_str());
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("requestAck参数名字重复, error, %s", paramInfo.mName.c_str());
 			}
 		}
 		//存在脏数据,不做另外处理
@@ -125,7 +125,7 @@ namespace Chromium {
 				{
 					if (i->mName == repeatName)
 					{
-						DbgEx("requestAck参数名字重复, error, %s", i->mName);
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("requestAck参数名字重复, error, %s", i->mName);
 						t_isRepeat = true;
 					}
 
@@ -367,14 +367,14 @@ namespace Chromium {
 					cJSON_AddItemToObject(extendJs.get(), i->mName.c_str(), tmpArray2);
 				}
 				else
-					DbgEx("DeserializeBase error name -> type: %s -> %s", i->mName.c_str(), i->mType.c_str());
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("DeserializeBase error name -> type: %s -> %s", i->mName.c_str(), i->mType.c_str());
 				++i;
 			}
 		}
 		catch (...)
 		{
 			if (i != ts.mParamList.end())
-				DbgEx("DeserializeBase error:%s, %s", i->mName.c_str(), i->mType.c_str());
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("DeserializeBase error:%s, %s", i->mName.c_str(), i->mType.c_str());
 		}
 
 		char* unformateStr = cJSON_PrintUnformatted(extendJs.get());
@@ -395,7 +395,7 @@ namespace Chromium {
 		}
 		catch (...)
 		{
-			DbgEx("error DeserializeRequestAck: %s, %s, %s", p_struct->entity_name, p_struct->class_name, p_struct->methodID);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("error DeserializeRequestAck: %s, %s, %s", p_struct->entity_name, p_struct->class_name, p_struct->methodID);
 			std::string errorMsg;
 #if (defined _WIN32 || defined _WIN64)
 			for each (auto it in ts.mParamList)
@@ -403,7 +403,7 @@ namespace Chromium {
 			for (auto it : ts.mParamList)
 #endif
 				errorMsg += it.mName + "--" + it.mType + "_";
-			DbgEx(errorMsg.c_str());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)(errorMsg.c_str());
 #if (defined _WIN32 || defined _WIN64)
 			throw std::exception("error DeserializeRequestAck");
 #else
@@ -441,7 +441,7 @@ namespace Chromium {
 #endif
 				errorMsg += it.mName + "--" + it.mType + "_";
 
-			DbgEx(errorMsg.c_str());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)(errorMsg.c_str());
 #if (defined _WIN32 || defined _WIN64)
 			throw std::exception("error DeserializeRequestAck");
 #else
@@ -536,7 +536,7 @@ namespace Chromium {
 			cJSON_AddStringToObject(ret, "errorMsg", "未知消息类型");
 			break;
 		}
-		DbgEx("BufferToJson -> messageType=%d(%s), sessionID=%d(%02X), transID=%d(%02X), replaceTransID=%d(%02X), errorCode=%d(%s)", msg.getMessageType(), 
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("BufferToJson -> messageType=%d(%s), sessionID=%d(%02X), transID=%d(%02X), replaceTransID=%d(%02X), errorCode=%d(%s)", msg.getMessageType(),
 			GetMessageTypeString(msg.getMessageType()).c_str(),	msg.getSessionID(), msg.getSessionID(), srcTransId, srcTransId, replaceTransId
 			, replaceTransId, errorCode, SpStrError((ErrorCodeEnum)errorCode));
 
@@ -635,18 +635,18 @@ namespace Chromium {
 			GetCJsonIntergerValue(pJson, "methodID", st.methodID, errmsg);
 			mi = mInterpreter->getFunctionInterface(st.entity_name, st.class_name, st.methodID);		//get the mothod of the json
 			if (NULL == mi) {
-				DbgEx("JsonToBuffer : Entity or class not found in structure interpreter! entityName:%s, class_name:%s, methodId:%d", st.entity_name, st.class_name, st.methodID);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("JsonToBuffer : Entity or class not found in structure interpreter! entityName:%s, class_name:%s, methodId:%d", st.entity_name, st.class_name, st.methodID);
 				return std::make_pair(messageType, nullptr);
 			}
 			else
-				DbgEx("JsonToBuffer parse method success, entityName:%s, className:%s, methodID:%d, DstMethodName:%s, DstMethodParamNum:%d",
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("JsonToBuffer parse method success, entityName:%s, className:%s, methodID:%d, DstMethodName:%s, DstMethodParamNum:%d",
 					st.entity_name, st.class_name, st.methodID, mi->mMethodName.c_str(), mi->mRequestInterpreter.mParamList.size());	//如出错,可对比方法名和变量数量
 			if (Request == messageType) {
 				// 维护回调列表 Request
 				auto transid = json_deal::getIntergerFromCjsonObj(pJson, "transId");
 				if (transid.first == false)
 				{
-					DbgEx("CWSCodec::JsonToBuffer get transId failed");
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::JsonToBuffer get transId failed");
 					return std::make_pair(messageType, nullptr);
 				}
 				m_ackMutex.lock();
@@ -661,7 +661,7 @@ namespace Chromium {
 			auto transid = json_deal::getIntergerFromCjsonObj(pJson, "transId");
 			if (transid.first == false)
 			{
-				DbgEx("CWSCodec::JsonToBuffer get transId failed");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::JsonToBuffer get transId failed");
 				return std::make_pair(messageType, nullptr);
 			}
 			GetCJsonObjectValue(pJson, "entity", st.entity_name, errmsg);
@@ -676,10 +676,10 @@ namespace Chromium {
 			{
 				auto rc = SpSendBroadcast(m_pFunc, eMsg_ChromiumBroadcast, eMsgSig_ChromiumBroadcast, e);
 				if (Error_Succeed != rc)
-					DbgEx("Broadcast Msg Error:%d", rc);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Broadcast Msg Error:%d", rc);
 			}
 			else
-				DbgEx("json is too long, do not send out sp broadcast!");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("json is too long, do not send out sp broadcast!");
 			return std::make_pair(messageType, nullptr);
 		}
 		else if (Event == messageType)
@@ -780,13 +780,13 @@ namespace Chromium {
 		{
 			m_SerializeCache.clear();
 			if (nullptr == memcpy(m_SerializeCache.getWriteableData(), data, wpos))
-				DbgEx("memcpy err ");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("memcpy err ");
 			free(data);
 		}
 		else
 		{	//数据长度过长
 			free(data);
-			DbgEx("string too long, discard");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("string too long, discard");
 			return std::make_pair(messageType, nullptr);
 		}
 
@@ -847,21 +847,21 @@ namespace Chromium {
 		auto sessionID = json_deal::getIntergerFromCjsonObj(js, "sessionID");
 		if (sessionID.first == false)
 		{
-			DbgEx("CWSCodec::SerializeInfo get sessionId failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeInfo get sessionId failed");
 			return;
 		}
 
 		auto methodID = json_deal::getIntergerFromCjsonObj(js, "methodID");
 		if (methodID.first == false)
 		{
-			DbgEx("CWSCodec::SerializeInfo get methodID failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeInfo get methodID failed");
 			return;
 		}
 
 		auto signature = json_deal::getIntergerFromCjsonObj(js, "signature");
 		if (signature.first == false)
 		{
-			DbgEx("CWSCodec::SerializeInfo get signature failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeInfo get signature failed");
 			return;
 		}
 
@@ -873,7 +873,7 @@ namespace Chromium {
 
 		if (NULL == pI)
 		{
-			DbgEx("PI = NULL, 无法找到接口定义");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("PI = NULL, 无法找到接口定义");
 			return;// 没有对应定义
 		}
 
@@ -895,7 +895,7 @@ namespace Chromium {
 				{
 #endif
 					if (paramInfo.mName == repeatName)
-						DbgEx("request参数名字重复, error, %s", paramInfo.mName.c_str());
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("request参数名字重复, error, %s", paramInfo.mName.c_str());
 				}
 			}
 			//如果存在重复,可能数据已经脏了,所以也不需要作删除参数处理
@@ -954,7 +954,7 @@ namespace Chromium {
 		auto sessionID = json_deal::getIntergerFromCjsonObj(js, "sessionID");
 		if (sessionID.first == false)
 		{
-			DbgEx("CWSCodec::SerializeEndSession get sessionId failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeEndSession get sessionId failed");
 			return;
 		}
 		WriteT(data, sessionID.second, wpos, capacity);
@@ -966,31 +966,31 @@ namespace Chromium {
 		auto transID = json_deal::getIntergerFromCjsonObj(js, "transID");
 		if (transID.first == false)
 		{
-			DbgEx("CWSCodec::SerializeRequest get transID failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeRequest get transID failed");
 			return;
 		}
 		auto sessionID = json_deal::getIntergerFromCjsonObj(js, "sessionID");
 		if (sessionID.first == false)
 		{
-			DbgEx("CWSCodec::SerializeRequest get sessionID failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeRequest get sessionID failed");
 			return;
 		}
 		auto methodID = json_deal::getIntergerFromCjsonObj(js, "methodID");
 		if (methodID.first == false)
 		{
-			DbgEx("CWSCodec::SerializeRequest get methodID failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeRequest get methodID failed");
 			return;
 		}
 		auto signature = json_deal::getIntergerFromCjsonObj(js, "signature");
 		if (signature.first == false)
 		{
-			DbgEx("CWSCodec::SerializeRequest get signature failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeRequest get signature failed");
 			return;
 		}
 		auto timeout = json_deal::getIntergerFromCjsonObj(js, "timeout");
 		if (timeout.first == false)
 		{
-			DbgEx("CWSCodec::SerializeRequest get timeout failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeRequest get timeout failed");
 			return;
 		}
 
@@ -1004,7 +1004,7 @@ namespace Chromium {
 		if (NULL == pI)
 		{
 			// 没有对应定义
-			DbgEx("没有对应定义");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("没有对应定义");
 			return;
 		}
 
@@ -1026,7 +1026,7 @@ namespace Chromium {
 				{
 #endif
 					if (paramInfo.mName == repeatName)
-						DbgEx("request参数名字重复, error, %s", paramInfo.mName.c_str());
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("request参数名字重复, error, %s", paramInfo.mName.c_str());
 				}
 			}
 			//如果存在重复,可能数据已经脏了,所以也不需要作删除参数处理
@@ -1040,13 +1040,13 @@ namespace Chromium {
 		auto transID = json_deal::getIntergerFromCjsonObj(js, "transID");
 		if (transID.first == false)
 		{
-			DbgEx("CWSCodec::SerializeRegister get transID failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeRegister get transID failed");
 			return;
 		}
 		auto entity = json_deal::getStringFromCjsonObj(js, "entity");
 		if (entity.first == false)
 		{
-			DbgEx("CWSCodec::SerializeRegister get entity failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeRegister get entity failed");
 			return;
 		}
 
@@ -1060,7 +1060,7 @@ namespace Chromium {
 		auto transID = json_deal::getIntergerFromCjsonObj(js, "transID");
 		if (transID.first == false)
 		{
-			DbgEx("CWSCodec::SerializeUnregister get transID failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeUnregister get transID failed");
 			return;
 		}
 
@@ -1072,19 +1072,19 @@ namespace Chromium {
 		auto securityLevel = json_deal::getIntergerFromCjsonObj(js, "securityLevel");
 		if (securityLevel.first == false)
 		{
-			DbgEx("CWSCodec::SerializeUnregister get securityLevel failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeUnregister get securityLevel failed");
 			return;
 		}
 		auto eventCode = json_deal::getIntergerFromCjsonObj(js, "eventCode");
 		if (eventCode.first == false)
 		{
-			DbgEx("CWSCodec::SerializeUnregister get eventCode failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeUnregister get eventCode failed");
 			return;
 		}
 		auto message = json_deal::getStringFromCjsonObj(js, "message");
 		if (message.first == false)
 		{
-			DbgEx("CWSCodec::SerializeUnregister get message failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeUnregister get message failed");
 			return;
 		}
 
@@ -1102,19 +1102,19 @@ namespace Chromium {
 		auto securityLevel = json_deal::getIntergerFromCjsonObj(js, "securityLevel");
 		if (securityLevel.first == false)
 		{
-			DbgEx("CWSCodec::SerializeLogWarn get securityLevel failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeLogWarn get securityLevel failed");
 			return;
 		}
 		auto eventCode = json_deal::getIntergerFromCjsonObj(js, "eventCode");
 		if (eventCode.first == false)
 		{
-			DbgEx("CWSCodec::SerializeLogWarn get eventCode failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeLogWarn get eventCode failed");
 			return;
 		}
 		auto message = json_deal::getStringFromCjsonObj(js, "message");
 		if (message.first == false)
 		{
-			DbgEx("CWSCodec::SerializeLogWarn get message failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeLogWarn get message failed");
 			return;
 		}
 
@@ -1132,19 +1132,19 @@ namespace Chromium {
 		auto transID = json_deal::getIntergerFromCjsonObj(js, "transID");
 		if (transID.first == false)
 		{
-			DbgEx("CWSCodec::SerializeSetVarReq get transID failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeSetVarReq get transID failed");
 			return;
 		}
 		auto name = json_deal::getStringFromCjsonObj(js, "name");
 		if (name.first == false)
 		{
-			DbgEx("CWSCodec::SerializeSetVarReq get name failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeSetVarReq get name failed");
 			return;
 		}
 		auto value = json_deal::getStringFromCjsonObj(js, "value");
 		if (value.first == false)
 		{
-			DbgEx("CWSCodec::SerializeSetVarReq get value failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeSetVarReq get value failed");
 			return;
 		}
 
@@ -1196,13 +1196,13 @@ namespace Chromium {
 		auto  transID = json_deal::getIntergerFromCjsonObj(js, "transID");
 		if (transID.first == false)
 		{
-			DbgEx("CWSCodec::SerializeGetVarReq get transID failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeGetVarReq get transID failed");
 			return;
 		}
 		auto name = json_deal::getStringFromCjsonObj(js, "name");
 		if (name.first == false)
 		{
-			DbgEx("CWSCodec::SerializeGetVarReq get name failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec::SerializeGetVarReq get name failed");
 			return;
 		}
 
@@ -1342,7 +1342,7 @@ namespace Chromium {
 					for (size_t i = 0; i < dstLen; i++)
 						tempBlob += std::to_string((ULONGLONG)(unsigned char)bin[i]) + ",";
 
-					DbgEx(tempBlob.c_str());
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)(tempBlob.c_str());
 					WriteT(data, dstLen, wpos, capacity);
 					WriteT(data, bin, wpos, capacity, dstLen);
 
@@ -1366,7 +1366,7 @@ namespace Chromium {
 					}
 				}
 				else {
-					DbgEx("array int -> false len = %d", len);
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("array int -> false len = %d", len);
 					WriteT(data, len, wpos, capacity);
 				}
 			}
@@ -1385,7 +1385,7 @@ namespace Chromium {
 					}
 				}
 				else {
-					DbgEx("array bool -> false len = %d", len);
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("array bool -> false len = %d", len);
 					WriteT(data, len, wpos, capacity);
 				}
 			}
@@ -1399,7 +1399,7 @@ namespace Chromium {
 					unsigned int d = 0;
 					for (int i = 0; i < len; ++i) {
 						if (!GetCJsonObjectValue(cJSON_GetArrayItem(cJSON_GetObjectItem(js, it->mName.c_str()), i), d, errmsg)) {
-							DbgEx("[%d] failed %s, break", i, errmsg);
+							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("[%d] failed %s, break", i, errmsg);
 							break;
 						}
 							
@@ -1407,7 +1407,7 @@ namespace Chromium {
 					}
 				}
 				else {
-					DbgEx("array int -> false len = %d", len);
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("array int -> false len = %d", len);
 					WriteT(data, len, wpos, capacity);
 				}
 			}
@@ -1421,14 +1421,14 @@ namespace Chromium {
 					CSimpleStringA d = "";
 					for (int i = 0; i < len; ++i) {
 						if (!GetCJsonObjectValue(cJSON_GetArrayItem(cJSON_GetObjectItem(js, it->mName.c_str()), i), d, errmsg)) {
-							DbgEx("array string[%d] failed %s, break", i, errmsg);
+							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("array string[%d] failed %s, break", i, errmsg);
 							break;
 						}
 						WriteT(data, d, wpos, capacity);
 					}
 				}
 				else {
-					DbgEx("array string -> false len = %d", len);
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("array string -> false len = %d", len);
 					WriteT(data, len, wpos, capacity);
 				}
 			}
@@ -1440,7 +1440,7 @@ namespace Chromium {
 					CSimpleStringW d = "";
 					for (int i = 0; i < len; ++i) {
                         if (!GetCJsonObjectValue(cJSON_GetArrayItem(cJSON_GetObjectItem(js, it->mName.c_str()), i), d, errmsg)) {
-                            DbgEx("[%d] failed %s, break", i, errmsg);
+							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("[%d] failed %s, break", i, errmsg);
                             break;
                         }
 						WriteT(data, d, wpos, capacity);
@@ -1457,7 +1457,7 @@ namespace Chromium {
 					CSimpleStringW d = "";
 					for (int i = 0; i < len; ++i) {
                         if (!GetCJsonObjectValue(cJSON_GetArrayItem(cJSON_GetObjectItem(js, it->mName.c_str()), i), d, errmsg)) {
-                            DbgEx("[%d] failed %s, break", i, errmsg);
+							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("[%d] failed %s, break", i, errmsg);
                             break;
                         }
 						WriteT(data, d, wpos, capacity);
@@ -1468,7 +1468,7 @@ namespace Chromium {
 				}
 			}
 			else {
-				DbgEx("GeneralSerialize error name -> type: %s -> %s", it->mName.c_str(), it->mType.c_str());
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("GeneralSerialize error name -> type: %s -> %s", it->mName.c_str(), it->mType.c_str());
 			}
 			++it;
 		}
@@ -1778,7 +1778,7 @@ namespace Chromium {
 				sprintf(c, "%02X ", (unsigned char)buf[i]);
 				strcat(str, c);
 			}
-			DbgEx("buffer too long to show!show pre 50 hex! CWSCodec hex buf : %d : %s", num, str);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("buffer too long to show!show pre 50 hex! CWSCodec hex buf : %d : %s", num, str);
 			return;
 		}
 		for (i = 0; i < num; i++)
@@ -1786,7 +1786,7 @@ namespace Chromium {
 			sprintf(c, "%02X ", (unsigned char)buf[i]);
 			strcat(str, c);
 		}
-		DbgEx("CWSCodec hex buf : %s", str);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CWSCodec hex buf : %s", str);
 		return;
 	}
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 499 - 126
Module/mod_chromium/CWebsocketServer.cpp


+ 30 - 5
Module/mod_chromium/CWebsocketServer.h

@@ -15,9 +15,19 @@
 #include <memory>
 #include <vector>
 
+typedef websocketpp::server<websocketpp::config::asio> server;
+typedef websocketpp::server<websocketpp::config::asio_tls> server_wss;
+
+
+// pull out the type of messages sent by our config
+typedef websocketpp::config::asio::message_type::ptr message_ptr;
+typedef websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> context_ptr;
+
+
 namespace Chromium {
-	typedef websocketpp::server<websocketpp::config::asio> server;
-	extern server m_wsserver;
+	
+	extern server m_wsserver, m_ws_sm2_server;
+	extern server_wss m_server_wss;
 
 	class CWebsocketServer : public ISocketCallback {
 	public:
@@ -25,7 +35,9 @@ namespace Chromium {
 		
 		static void stopServer() {
 			m_wsserver.stop();
-			DbgEx("%s end", __FUNCTION__);
+			m_ws_sm2_server.stop();
+			//m_server_wss.stop();
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s end", __FUNCTION__);
 		}
 
 		~CWebsocketServer()
@@ -35,7 +47,9 @@ namespace Chromium {
 			m_doRunThread.join();
 			m_doReLinkThread.join();
 			m_wsserver.stop();
-			DbgEx("%s end", __FUNCTION__);
+			m_ws_sm2_server.stop();
+			//m_server_wss.stop();
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s end", __FUNCTION__);
 		}
 
 		void run();
@@ -48,20 +62,28 @@ namespace Chromium {
 		};
 		void do_send_notifyMsg(unsigned hdlID, unsigned transId, const std::string& reason, const std::string& errmsg, const std::string& rebootTime, const DWORD& dwSysError, const DWORD& dwUserCode);
 		//static server m_wsserver;
-
+		void do_send_msg(int hdl, std::string msg);
+		void do_send_msg(websocketpp::connection_hdl hdl, std::string msg);
 	private:
 		void message_handler(websocketpp::connection_hdl hdl, server::message_ptr msg);
+		void message_handler_ws_sm2(websocketpp::connection_hdl hdl, server::message_ptr msg);
 		void deal_msg(std::string& payload, websocketpp::connection_hdl hdl);
 		void deal_webchromium_msg(std::string& payload, websocketpp::connection_hdl hdl, int messageType);
 		void deal_sessionBreakMsg(std::string& payload, websocketpp::connection_hdl hdl);
 		void deal_logMsg(std::string& payload, websocketpp::connection_hdl hdl, int messageType);
 		void open_handler(websocketpp::connection_hdl hdl);
+		void open_handler_wss(websocketpp::connection_hdl hdl);
+		void open_handler_ws_sm2(websocketpp::connection_hdl hdl);
 		void close_handler(websocketpp::connection_hdl hdl);
+		void close_handler_wss(websocketpp::connection_hdl hdl);
+		void close_handler_ws_sm2(websocketpp::connection_hdl hdl);
 		void do_run();
 		void init_websocket();
 		void init_entity_sessions();
 		void do_sendJson(std::string js, int messageType, int hdlID, unsigned int id);
 		void do_sendJsonBroadcast(std::string js);
+		template <typename T, typename Y>
+		bool sendBroadCast(T &connections, Y &senders, std::string msg);
 		void WriteToFramework(CMessage* msg);
 #if(defined _WIN32 || defined _WIN64)
 		std::string string_to_utf8(const std::string& str);
@@ -85,6 +107,9 @@ namespace Chromium {
 		boost::asio::io_service m_ios;
 		boost::thread m_doRunThread, m_doReLinkThread;
 		std::map<unsigned int, websocketpp::connection_hdl> m_connection_hdls;
+		std::map<unsigned int, websocketpp::connection_hdl> m_connection_ws_sm2_hdls;
+		std::map<unsigned int, websocketpp::connection_hdl> m_connection_wss_hdls;
+		std::map<unsigned int, std::shared_ptr<SM2_Encrypt_Manager>> m_ws_sm2_hdls_manager;
 		std::map<std::string, std::vector<std::pair<websocketpp::connection_hdl, std::string>> > m_msg_pool;
 		std::map<std::string, std::string> m_entityAndClass;//不知道为什么不能用map<string,map<>>,猜测应该是websocketpp::connection_hdl生成问题
 		CEntityBase* m_pEntity;

+ 17 - 26
Module/mod_chromium/EntitySessionManager.cpp

@@ -51,7 +51,7 @@ namespace Chromium {
 		else
 		{
 			if ((newTransID & 0xF00000) == false)
-				DbgEx("can not find transId:%d, may be fault", newTransID);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("can not find transId:%d, may be fault", newTransID);
 			//DbgEx("can not find transId:%d, may be true:%s", newTransID, newTransID & 0xF00000 ? "true" : "false");
 			return std::make_pair(false, 0);
 		}
@@ -139,7 +139,7 @@ namespace Chromium {
 		case Broadcast:
 			return PROCESS_NOTHING;
 		default:
-			DbgEx("EntitySessionManager::RequestProcess switch default!");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("EntitySessionManager::RequestProcess switch default!");
 			ret = PROCESS_NOTHING;
 		}
 		int srcTransId = msg->getTransID();
@@ -154,11 +154,11 @@ namespace Chromium {
 		auto it = m_session_map.find(entityName);
 		if (it == m_session_map.end() || -1 == it->second)
 		{
-			DbgEx("no session found for entity : %s", UtfToGbk(entityName.c_str()).c_str());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("no session found for entity : %s", UtfToGbk(entityName.c_str()).c_str());
 			return PROCESS_STARTSESSION;
 		}
 		msg->setSessionID(it->second, false);
-		DbgEx("EntitySessionManager::ProcessWithInfo, replace sessionID:%d", it->second);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("EntitySessionManager::ProcessWithInfo, replace sessionID:%d", it->second);
 		return PROCESS_SEND;
 	}
 
@@ -179,7 +179,7 @@ namespace Chromium {
 		auto curSession = t_BeginSessionTime.find(entityName);
 		if (curSession == t_BeginSessionTime.end() || curSession->second < now_time - 5)
 		{
-			DbgEx("checkBeginSession record begin session msg, oldTime:%lld, newTime:%lld", curSession != t_BeginSessionTime.end() ? curSession->second : -1, now_time);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("checkBeginSession record begin session msg, oldTime:%lld, newTime:%lld", curSession != t_BeginSessionTime.end() ? curSession->second : -1, now_time);
 			return true;//5s内不重复发起session
 		}
 		else
@@ -187,7 +187,7 @@ namespace Chromium {
 	}
 
 	RequestProcessType EntitySessionManager::ProcessWithBeginSession(CMessage* msg, std::string entityName, unsigned int hdlID) {
-		DbgEx("EntitySessionManager::ProcessWithBeginSession");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("EntitySessionManager::ProcessWithBeginSession");
 		auto s = GetSessionIDByEntityName(entityName);
 		if (s.first && -1 != s.second)
 			return PROCESS_FINDSESSION;
@@ -206,7 +206,7 @@ namespace Chromium {
 
 	RequestProcessType EntitySessionManager::ProcessWithEndSession(CMessage* msg, std::string entityName,
 		unsigned int hdlID) {
-		DbgEx("EntitySessionManager::ProcessWithEndSession");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("EntitySessionManager::ProcessWithEndSession");
 		return PROCESS_NOTHING;
 	}
 
@@ -216,27 +216,18 @@ namespace Chromium {
 		auto it = m_session_map.find(entityName);
 		if (it == m_session_map.end() || -1 == it->second)
 		{
-			DbgEx("no session found for entity : %s", UtfToGbk(entityName.c_str()).c_str());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("no session found for entity : %s", UtfToGbk(entityName.c_str()).c_str());
 			return PROCESS_STARTSESSION;
 		}
 		msg->setSessionID(it->second, true);
 		auto transId = MakeNewTransID(msg, hdlID);
 		msg->setTransID(transId);
-		DbgEx("EntitySessionManager::ProcessWithRequest, replace sessionID:%d, replace transId:%d", it->second, transId);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("EntitySessionManager::ProcessWithRequest, replace sessionID:%d, replace transId:%d", it->second, transId);
 		return PROCESS_SEND;
 	}
 
 	RequestProcessType EntitySessionManager::ProcessWithRegister(CMessage* msg, std::string entityName, unsigned int hdlID) {
-		DbgEx("EntitySessionManager::ProcessWithRegister");
-		/*
-		auto it = m_session_map.find(entityName);
-		if (it == m_session_map.end() || -1 == it->second)
-		{
-			DbgEx("no session found for entity : %s", UtfToGbk(entityName.c_str()).c_str());
-			return PROCESS_STARTSESSION;
-		}
-		*/
-
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("EntitySessionManager::ProcessWithRegister");
 		auto _broadcast_it = m_broadcast_map.find(entityName);
 		if (_broadcast_it == m_broadcast_map.end())
 		{
@@ -281,7 +272,7 @@ namespace Chromium {
 
 	RequestProcessType EntitySessionManager::ProcessWithUnregister(CMessage* msg, std::string entityName,
 		unsigned int hdlID) {
-		DbgEx("EntitySessionManager::ProcessWithUnregister");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("EntitySessionManager::ProcessWithUnregister");
 		std::map<std::string, int>::iterator _broadcast_it = m_broadcast_map.find(entityName);
 		if (_broadcast_it == m_broadcast_map.end())
 		{
@@ -334,14 +325,14 @@ namespace Chromium {
 
 	RequestProcessType EntitySessionManager::ProcessWithSetVarReq(CMessage* msg, std::string entityName,
 		unsigned int hdlID) {
-		DbgEx("EntitySessionManager::ProcessWithSetVarReq");
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("EntitySessionManager::ProcessWithSetVarReq");
 		msg->setTransID(MakeNewTransID(msg, hdlID));
 		return PROCESS_SEND;
 	}
 
 	RequestProcessType EntitySessionManager::ProcessWithGetVarReq(CMessage* msg, std::string entityName,
 		unsigned int hdlID) {
-		DbgEx("EntitySessionManager::ProcessWithGetVarReq");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("EntitySessionManager::ProcessWithGetVarReq");
 		msg->setTransID(MakeNewTransID(msg, hdlID));
 		return PROCESS_SEND;
 	}
@@ -352,7 +343,7 @@ namespace Chromium {
 		std::string js = "{\"messageType\":1,\"transID\":" + std::to_string((LONGLONG)curSession) + ",\"functionName\":\"\",\"entity\":\"";
 		js.append(entityname.append("\",\"class\":\""));
 		js.append(className.append("\"}"));
-		DbgEx("start sessionRequest: %s", UtfToGbk(js.c_str()).c_str());
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("start sessionRequest: %s", UtfToGbk(js.c_str()).c_str());
 		return std::make_pair(curSession, js);
 	}
 
@@ -409,12 +400,12 @@ namespace Chromium {
 				return *this;//相等不处理
 			else if(sessionIt->second == -1 || session == -1)
 			{
-				DbgEx("update sessionId(regenerate):<%s><%d>", entityname.c_str(), session);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("update sessionId(regenerate):<%s><%d>", entityname.c_str(), session);
 				m_session_map.erase(sessionIt);
 				m_session_map.insert(std::make_pair(entityname, session));
 			}
 			else
-				DbgEx("session Error(src:%d), do not update sessionId:<%s><%d>", sessionIt->second, entityname.c_str(), session);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("session Error(src:%d), do not update sessionId:<%s><%d>", sessionIt->second, entityname.c_str(), session);
 		}
 		else
 			m_session_map.insert(std::make_pair(entityname, session));//not exist
@@ -537,7 +528,7 @@ namespace Chromium {
 			ProcessWithAck(msg, hdlID);
 			break;
 		default:
-			DbgEx("AckProcess default!");
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("AckProcess default!");
 			ret = ACKPROCESS_NOTHING;
 		}
 		return ret;

+ 173 - 19
Module/mod_chromium/baseEx.cpp

@@ -12,10 +12,12 @@
 #include <boost/interprocess/permissions.hpp>
 #include <boost/thread/mutex.hpp>
 #include <boost/thread/lock_guard.hpp>
+#include <boost/algorithm/hex.hpp>
 
 #include "EventCode.h"
 #include "exLog/log.h"
 #include "cJSON.h"
+#include "RVCComm.h"
 using namespace boost::interprocess;
 
 //read ini
@@ -31,6 +33,8 @@ std::map<std::string, void*> g_logProducerArr;
 bool g_useMagic = false;
 bool g_loggerInitSuccess = false;
 bool g_logToFile = true;
+bool g_withMedia = false;
+bool g_withSpecialTest = false;
 std::string g_usercodeTranslateFile = "";
 std::map<std::string, std::vector<std::string>> g_networkParse;
 std::map<std::string, clock_t> g_networkExpiredData;
@@ -194,7 +198,7 @@ bool SYSTEM_ON(std::string cmdLine, bool isWait)
 			default:
 				errMsg = "UNKNOWN";
 			}
-			DbgEx("SYSTEM_ON wait with %s failed, reason:%d-%s", par.c_str(), errorCode, errMsg.c_str());
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SYSTEM_ON wait with %s failed, reason:%d-%s", par.c_str(), errorCode, errMsg.c_str());
 			return false;
 		}
 		
@@ -216,7 +220,7 @@ bool SYSTEM_ON(std::string cmdLine, bool isWait)
 			return true;
 		else
 		{
-			DbgEx("SYSTEM_ON nowait with %s failed, reason:%d", result);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__).setAPI(__FUNCTION__)("SYSTEM_ON nowait with %s failed, reason:%d", result);
 			return false;
 		}
 	}
@@ -233,7 +237,7 @@ DWORD SaveCefclientLog(std::string magicStr)
 	try {		
 		auto removeRet = message_queue::remove(dstGuid.c_str());
 		if (!removeRet)
-			DbgEx("message_queue did not remove!");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("message_queue did not remove!");
 		boost::interprocess::permissions cur;
 		cur.set_unrestricted();
 		message_queue mq(create_only, dstGuid.c_str(), 100, sizeof(cefclientLog), cur);
@@ -265,7 +269,7 @@ DWORD SaveCefclientLog(std::string magicStr)
 	catch (interprocess_exception& ex) {
 		message_queue::remove(dstGuid.c_str());
 		g_useMagic = false;
-		DbgEx("%s run exception, for %s", dstGuid.c_str(), ex.what());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s run exception, for %s", dstGuid.c_str(), ex.what());
 		return 1;
 	}
 	g_useMagic = false;
@@ -321,7 +325,7 @@ std::string generateTimeStr(bool isSimple)
 
 void InitTranslateFile(std::string srcFile)
 {
-	DbgEx("InitTranslateFile %s", srcFile.c_str());
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("InitTranslateFile %s", srcFile.c_str());
 	g_usercodeTranslateFile = srcFile;
 }
 
@@ -347,7 +351,7 @@ std::pair<unsigned long, std::string> splitStrToUserCodeAndErrMsg(std::string sr
 		return std::make_pair(userCode, UtfToGbk(tipMsg.c_str()));
 	}
 	catch (std::exception &e) {
-		DbgEx("ini_parse failed, reason:%s", e.what());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("ini_parse failed, reason:%s", e.what());
 	}
 	
 	return std::make_pair(userCode, srcMsg);
@@ -377,7 +381,7 @@ std::string hexdumpToString(const char* buf, const int num)
 
 void hexdump(const char* buf, const int num) {
 	auto hexStr = hexdumpToString(buf, num);
-	DbgEx(hexStr.c_str());
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)(hexStr.c_str());
 }
 
 
@@ -394,13 +398,13 @@ bool modifyBySpecialStr(std::wstring& src)
 		for (auto it = specialStr.begin(); it != specialStr.end(); it++)
 			compareArr.insert(*it);
 	}
-	DbgEx("modifyBySpecialStr insert cost:%d", clock() - cur);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("modifyBySpecialStr insert cost:%d", clock() - cur);
 	cur = clock();
 
 	std::set<wchar_t> result;
 	std::set_intersection(std::begin(srcArr), std::end(srcArr), std::begin(compareArr), std::end(compareArr), std::inserter(result, std::begin(result)));
 
-	DbgEx("modifyBySpecialStr intersection cost:%d", clock() - cur);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("modifyBySpecialStr intersection cost:%d", clock() - cur);
 	cur = clock();
 
 	if (result.size() == 0)
@@ -421,7 +425,7 @@ bool modifyBySpecialStr(std::wstring& src)
 		}
 	}
 
-	DbgEx("modifyBySpecialStr modify cost:%d", clock() - cur);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("modifyBySpecialStr modify cost:%d", clock() - cur);
 	cur = clock();
 
 	return true;
@@ -442,7 +446,7 @@ bool modifyBySpecialStr(std::wstring& src)
 		else
 			pos++;
 	}
-	DbgEx("modifyBySpecialStr modify cost:%d", clock() - cur);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("modifyBySpecialStr modify cost:%d", clock() - cur);
 	return true;
 }
 
@@ -458,15 +462,15 @@ long printSEG()
 	if (dumpArr.size() > 20)
 	{
 		for (auto i = 0; i < 10; i++)
-			DbgEx("Pre SEG[%d]%X---%s(%s-%d)", i, dumpArr[i].address(), dumpArr[i].name().c_str(), dumpArr[i].source_file().c_str(), dumpArr[i].source_line());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Pre SEG[%d]%X---%s(%s-%d)", i, dumpArr[i].address(), dumpArr[i].name().c_str(), dumpArr[i].source_file().c_str(), dumpArr[i].source_line());
 
 		for (auto i = dumpArr.size() - 10; i < dumpArr.size(); i++)
-			DbgEx("Post SEG[%d]%X---%s(%s-%d)", i, dumpArr[i].address(), dumpArr[i].name().c_str(), dumpArr[i].source_file().c_str(), dumpArr[i].source_line());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Post SEG[%d]%X---%s(%s-%d)", i, dumpArr[i].address(), dumpArr[i].name().c_str(), dumpArr[i].source_file().c_str(), dumpArr[i].source_line());
 	}
 	else
 	{
 		for (auto i = 0; i < dumpArr.size(); i++)
-			DbgEx("SEG[%d]%X---%s(%s-%d)", i, dumpArr[i].address(), dumpArr[i].name().c_str(), dumpArr[i].source_file().c_str(), dumpArr[i].source_line());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SEG[%d]%X---%s(%s-%d)", i, dumpArr[i].address(), dumpArr[i].name().c_str(), dumpArr[i].source_file().c_str(), dumpArr[i].source_line());
 	}
 	return 0;
 }
@@ -484,7 +488,7 @@ std::string g_backtracePath = "";
 void seg_signal_handler(int signum)
 {
 	//boost::stacktrace::safe_dump_to(g_backtracePath.c_str());
-	DbgEx("receive signal:%d, seg_signal_handler", signum);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("receive signal:%d, seg_signal_handler", signum);
 	
 	printSEG();
 
@@ -496,7 +500,7 @@ void seg_signal_handler(int signum)
 
 void normal_signal_handle(int signum)
 {
-	DbgEx("receive signal:%d, normal_signal_handle", signum);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("receive signal:%d, normal_signal_handle", signum);
 	signal(signum, SIG_DFL);
 	raise(signum);
 }
@@ -504,7 +508,7 @@ void normal_signal_handle(int signum)
 void set_traceback_path(std::string path)
 {
 	g_backtracePath = path + "/mod_chromium/" + generateTimeStr(true) + "_chromium_backtrace.dump";
-	DbgEx("set_traceback_path %s", g_backtracePath.c_str());
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("set_traceback_path %s", g_backtracePath.c_str());
 }
 #endif
 
@@ -519,7 +523,7 @@ void receivehexdump(const char* buf, const int num) {
 			sprintf(c, "%02X ", (unsigned char)buf[i]);
 			strcat(str, c);
 		}
-		DbgEx("buffer too long to show!show pre 50 hex! receivehexdump hex buf len = %d : %s", num, str);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("buffer too long to show!show pre 50 hex! receivehexdump hex buf len = %d : %s", num, str);
 		return;
 	}
 
@@ -528,7 +532,7 @@ void receivehexdump(const char* buf, const int num) {
 		sprintf(c, "%02X ", (unsigned char)buf[i]);
 		strcat(str, c);
 	}
-	DbgEx("receivehexdump hex buf len = %d : %s", num, str);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("receivehexdump hex buf len = %d : %s", num, str);
 	return;
 }
 
@@ -686,4 +690,154 @@ std::pair<bool, double> json_deal::getDoubleFromCjsonObj(void* object, const cha
 	}
 	else
 		return std::make_pair(false, 0);
+}
+
+SM2_Encrypt_Manager::SM2_Encrypt_Manager()
+	:m_public_key_buf_len(DEFAULT_KEY_LEN),
+	m_private_key_buf_len(DEFAULT_KEY_LEN),
+	m_opposite_public_key_buf_len(DEFAULT_KEY_LEN)
+{
+	memset(m_public_key_buf, 0, DEFAULT_KEY_LEN);
+	memset(m_private_key_buf, 0, DEFAULT_KEY_LEN);
+	memset(m_opposite_public_key_buf, 0, DEFAULT_KEY_LEN);
+	GenerateSM2_key(m_public_key, m_private_key);
+	m_state = SM2ProtocolState::WAIT_KEY_EXCHANGE;
+}
+
+SM2_Encrypt_Manager::~SM2_Encrypt_Manager()
+{
+}
+bool SM2_Encrypt_Manager::GenerateSM2_key(std::string& pub, std::string& pri)
+{
+	if (!::CreateSM2KeyPair(m_public_key_buf, &m_public_key_buf_len, m_private_key_buf, &m_private_key_buf_len))
+		return false;
+
+	pub = binToHex(m_public_key_buf, m_public_key_buf_len);
+	pri = binToHex(m_private_key_buf, m_private_key_buf_len);
+	return true;
+}
+
+std::string SM2_Encrypt_Manager::binToHex(const unsigned char* data, int len)
+{
+	std::string hexString;
+
+	// 使用 boost::algorithm::hex 进行编码
+	boost::algorithm::hex(data, data + len, std::back_inserter(hexString));
+
+	return hexString;
+}
+
+void SM2_Encrypt_Manager::hexToBin(const std::string& hexStr, unsigned char* binData, int& binLen)
+{
+	binLen = hexStr.size() / 2;
+	if (binData == nullptr) {
+		// 如果 binData 为 nullptr,仅返回计算出的 binLen,不执行实际的转换
+		return;
+	}
+
+	// 使用 boost::algorithm::unhex 进行解码
+	boost::algorithm::unhex(hexStr.begin(), hexStr.end(), binData);
+}
+
+
+void SM2_Encrypt_Manager::setOpposite(const std::string pub)
+{
+	m_opposite_public_key = pub;
+	hexToBin(m_opposite_public_key, m_opposite_public_key_buf, m_opposite_public_key_buf_len);
+}
+
+std::pair<bool, std::string> SM2_Encrypt_Manager::checkSM2Enable()
+{
+	if (m_public_key.length() == 0)
+		return std::make_pair(false, "public_key is empty");
+	if (m_private_key.length() == 0)
+		return std::make_pair(false, "private_key is empty");
+	if (m_opposite_public_key.length() == 0)
+		return std::make_pair(false, "opposite public_key is empty");
+	return std::make_pair(true, "");
+}
+
+std::pair<std::string, std::string> SM2_Encrypt_Manager::EncryptMsg(std::string msg)
+{
+	unsigned char sign[DEFAULT_KEY_LEN] = "";
+	int sign_len = DEFAULT_KEY_LEN;
+
+	unsigned char* dstMsg = new unsigned char[msg.length() * 2];
+	int dstMsgLen = msg.length() * 2;
+	std::shared_ptr<void> msgClean((void*)0, [&](void*) {
+		if (dstMsg)
+		{
+			delete[]dstMsg;
+			dstMsg = nullptr;
+		}			
+		
+	});
+
+	if (!SM2SignWithSM3(m_private_key_buf, m_private_key_buf_len, (unsigned char*)msg.c_str(), msg.length(), sign, &sign_len))
+	{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SM2SignWithSM3::err, can not sign msg");
+		return std::make_pair("", "");
+	}
+
+	if(!EncWithSM2PubKey((unsigned char*)msg.c_str(), msg.length(), dstMsg, &dstMsgLen, m_opposite_public_key_buf, m_opposite_public_key_buf_len))
+	{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("EncWithSM2PubKey::err, can not encrypt msg");
+		return std::make_pair("", "");
+	}
+	return std::make_pair(binToHex(sign, sign_len), binToHex(dstMsg, dstMsgLen));
+}
+
+std::pair<bool, std::string> SM2_Encrypt_Manager::DecryptMsg(std::string sign, std::string msg)
+{
+	unsigned char* binMsg = new unsigned char[msg.length()], *outMsg = new unsigned char[msg.length() * 2], *binSign = new unsigned char[sign.length()];//normally, it is half length of msg
+	int binMsgLen = msg.length(), outMsgLen = msg.length() * 2, signLen = sign.length();
+	std::shared_ptr<void> msgClean((void*)0, [&](void*) {
+		if (binMsg) {
+			delete[] binMsg;
+			binMsg = nullptr;
+		}
+		if (outMsg) {
+			delete[] outMsg;
+			outMsg = nullptr;
+		}
+		if (binSign) {
+			delete[] binSign;
+			binSign = nullptr;
+		}
+		});
+
+	hexToBin(msg, binMsg, binMsgLen);
+	hexToBin(sign, binSign, signLen);
+
+	if (!DecWithSM2PriKey(binMsg, binMsgLen, outMsg, &outMsgLen, m_private_key_buf, m_private_key_buf_len))
+		return std::make_pair(false, "DecWithSM2PriKey::err, can not dectrypt msg");
+
+	if (!SM2VerifyWithSM3(m_opposite_public_key_buf, m_opposite_public_key_buf_len, outMsg, outMsgLen, binSign, signLen))
+		return std::make_pair(false, "SM2VerifyWithSM3::err, can not verify sign");
+
+
+	return std::make_pair(true, (char*)outMsg);
+}
+
+std::pair<bool, std::string> SM2_Encrypt_Manager::GenerateEncPubKey()
+{
+	if(!verifySM2Manager())
+		return std::make_pair(false, "GenerateEncPubKey::verifySM2Manager err");
+
+	unsigned char encPubKey[DEFAULT_KEY_LEN] = "";
+	int encPubKey_len = DEFAULT_KEY_LEN;
+
+	if(!EncWithSM2PubKey(m_public_key_buf, m_public_key_buf_len, encPubKey, &encPubKey_len, m_opposite_public_key_buf, m_opposite_public_key_buf_len))
+		return std::make_pair(false, "GenerateEncPubKey::EncWithSM2PubKey err");
+
+	return std::make_pair(true, binToHex(encPubKey, encPubKey_len));
+}
+
+bool SM2_Encrypt_Manager::verifySM2Manager()
+{
+	if (m_opposite_public_key.length() == 0 || m_public_key.length() == 0 || m_private_key.length() == 0)
+		return false;
+	if (m_opposite_public_key_buf == NULL || m_public_key_buf == NULL || m_private_key_buf == NULL)
+		return false;
+	return true;
 }

+ 39 - 1
Module/mod_chromium/baseEx.h

@@ -8,9 +8,12 @@ extern void* logProducer;
 extern std::map<std::string, void*> g_logProducerArr;
 extern bool g_useMagic;
 extern bool g_logToFile;
+extern bool g_withMedia;
 
+#define DEFAULT_KEY_LEN 256
 
-void DbgEx(const char* str, ...);
+
+//void DbgEx(const char* str, ...);
 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);
@@ -51,4 +54,39 @@ void seg_signal_handler(int signum);
 void normal_signal_handle(int signum);
 #endif
 
+typedef enum{
+	WAIT_KEY_EXCHANGE,
+	DATA_EXCHANGE
+}SM2ProtocolState;
+
+
+class SM2_Encrypt_Manager {
+public:
+	SM2_Encrypt_Manager();
+	~SM2_Encrypt_Manager();
+	bool GenerateSM2_key(std::string& pub, std::string& pri);
+	std::string binToHex(const unsigned char* data, int len);
+	void hexToBin(const std::string& hexStr, unsigned char* binData, int& binLen);
+	void setOpposite(const std::string pub);
+	std::pair<bool, std::string> checkSM2Enable();
+	std::pair<std::string, std::string> EncryptMsg(std::string msg);//return signature, encryptMsg
+	std::pair<bool, std::string> DecryptMsg(std::string sign, std::string msg);
+	std::pair<bool, std::string> GenerateEncPubKey();
+	bool verifySM2Manager();
+	SM2ProtocolState getState()
+	{
+		return m_state;
+	};
+
+	void setState(SM2ProtocolState tmpState)
+	{
+		m_state = tmpState;
+	};
 
+private:
+	unsigned char m_public_key_buf[DEFAULT_KEY_LEN], m_private_key_buf[DEFAULT_KEY_LEN], m_opposite_public_key_buf[DEFAULT_KEY_LEN];
+	int m_public_key_buf_len, m_private_key_buf_len, m_opposite_public_key_buf_len;
+	std::string m_public_key, m_private_key, m_opposite_public_key;
+	SM2ProtocolState m_state;
+	
+};

+ 82 - 69
Module/mod_chromium/mod_chromium.cpp

@@ -66,9 +66,9 @@ 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_installMode(false)
+		, m_withDebugMode(false), m_withMagic(false), m_withNoFileLog(false), m_installMode(false), m_withMedia(false), m_withSpecialTest(false)
 	{
-		DbgEx("CChromiumEntity constructor");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CChromiumEntity constructor");
 
 		//boost::thread(boost::bind(&CChromiumEntity::CefClintNotify, this)).detach(); //后台自动运行
 
@@ -101,43 +101,43 @@ namespace Chromium {
 			if (CompKey == COMPKEY_JOBOBJECT) {
 				switch (dwBytesXferred) {
 				case JOB_OBJECT_MSG_END_OF_JOB_TIME:
-					DbgEx("Job time limit reached");
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Job time limit reached");
 					break;
 
 				case JOB_OBJECT_MSG_END_OF_PROCESS_TIME:
-					DbgEx("Job process (Id=%d) time limit reached", po);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Job process (Id=%d) time limit reached", po);
 					break;
 
 				case JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT:
-					DbgEx("Too many active processes in job");
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Too many active processes in job");
 					break;
 
 				case JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO:
-					DbgEx("Job contains no active processes");
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Job contains no active processes");
 					break;
 
 				case JOB_OBJECT_MSG_NEW_PROCESS:
-					DbgEx("New process (Id=%d) in Job", po);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("New process (Id=%d) in Job", po);
 					break;
 
 				case JOB_OBJECT_MSG_EXIT_PROCESS:
-					DbgEx("Process (Id=%d) terminated", po);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Process (Id=%d) terminated", po);
 					break;
 
 				case JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS:
-					DbgEx("Process (Id=%d) terminated abnormally", po);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Process (Id=%d) terminated abnormally", po);
 					break;
 
 				case JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT:
-					DbgEx("Process (Id=%d) exceeded memory limit", po);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Process (Id=%d) exceeded memory limit", po);
 					break;
 
 				case JOB_OBJECT_MSG_JOB_MEMORY_LIMIT:
-					DbgEx("Process (Id=%d) exceeded job memory limit", po);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Process (Id=%d) exceeded job memory limit", po);
 					break;
 
 				default:
-					DbgEx("Unknown notification: %d", dwBytesXferred);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Unknown notification: %d", dwBytesXferred);
 					break;
 				}
 				CompKey = 1;
@@ -187,7 +187,7 @@ namespace Chromium {
 				return;
 			}
 			auto ret = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::OutsideRequest, std::make_tuple(strUrl.GetData(), strUrl2.GetData()));
-			DbgEx("open OutsideRequest browser page %s return %d", (LPCTSTR)strUrl, ret.first);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open OutsideRequest browser page %s return %d", (LPCTSTR)strUrl, ret.first);
 			ctx->Answer(ret.first);
 		}
 		else if (!strType.Compare((+ERR_PAGE_REASON::SpecialPageFromOtherEntity)._to_string(), true))
@@ -203,7 +203,7 @@ namespace Chromium {
 			auto ret = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::SpecialPageFromOtherEntity, 
 				std::make_tuple(strUrl.GetData(), strUrl2.GetData()));
 			
-			DbgEx("open %s browser page %s return %d", dstBrowserName.GetData(), (LPCTSTR)strUrl, ret.first);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open %s browser page %s return %d", dstBrowserName.GetData(), (LPCTSTR)strUrl, ret.first);
 			ctx->Answer(ret.first);
 		}
 		else
@@ -222,7 +222,7 @@ namespace Chromium {
 		auto profStr = CSimpleString::Format("chromiumAnalyze_%s.prof", generateTimeStr(true).c_str());
 		std::thread([](std::string str) {
 			ProfilerStart(str.c_str());//开启性能分析
-			DbgEx("Generate chromiumAnalyze, %s", str.c_str());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Generate chromiumAnalyze, %s", str.c_str());
 			}, profStr.GetData()).detach();
 #endif // OPEN_PERF
 
@@ -243,7 +243,7 @@ namespace Chromium {
 				{
 					if (SIGTERM == i)
 						signal(i, [](int signum)->void {
-						DbgEx("receive signal:%d, closeChromium", signum);
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("receive signal:%d, closeChromium", signum);
 						CModTools::get_mutable_instance().killAllChromiumByThread(3);
 						CWebsocketServer::stopServer();
 						signal(signum, SIG_DFL);
@@ -265,17 +265,17 @@ namespace Chromium {
 				const int ArgsCount = strArgs.GetCount();
 				LOG_TRACE("strArgs.GetCount() = %d", ArgsCount);
 				for (int i = 0; i < ArgsCount; ++i) {
-					DbgEx("strArgs[%d] = %s", i, strArgs[i].GetData());
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("strArgs[%d] = %s", i, strArgs[i].GetData());
 				}
 				if (ArgsCount == 1) {
 					m_strCustomMainUrl = strArgs[0];
-					DbgEx("Get custom main ulr: %s", m_strCustomMainUrl.GetData());
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Get custom main ulr: %s", m_strCustomMainUrl.GetData());
 				}
 				else if (ArgsCount == 2)
 				{
 					m_strCustomMainUrl = strArgs[0];
 					m_strCustomAdUrl = strArgs[1];
-					DbgEx("Get custom main url: %s, ad url: %s", m_strCustomMainUrl.GetData(), m_strCustomAdUrl.GetData());
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Get custom main url: %s, ad url: %s", m_strCustomMainUrl.GetData(), m_strCustomAdUrl.GetData());
 				}
 #endif
 
@@ -310,6 +310,10 @@ namespace Chromium {
 								m_withDebugMode = true;
 							else if (!trimStr.Compare("with_magic", true))
 								m_withMagic = true;
+							else if (!trimStr.Compare("with_media", true))
+								m_withMedia = true;
+							else if (!trimStr.Compare("with_specialTest", true))
+								m_withSpecialTest = true;
 							else if (!trimStr.Compare("with_nofilelog", true))
 								m_withNoFileLog = true;
 						}
@@ -321,10 +325,10 @@ namespace Chromium {
 						m_withMin = false;
 						m_withClose = false;
 #endif
-						DbgEx("MachineType: %s, find %s, readStr:%s, m_runAd:%d, m_runMain:%d, m_runExtend:%d, m_runLogin:%d, \
-							m_withBrowser:%d, with_min:%d, with_close:%d, m_withDebugMode:%d, m_withMagic:%d, m_withNoFileLog:%d",
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("MachineType: %s, find %s, readStr:%s, m_runAd:%d, m_runMain:%d, m_runExtend:%d, m_runLogin:%d, \
+							m_withBrowser:%d, with_min:%d, with_close:%d, m_withDebugMode:%d, m_withMagic:%d, m_withNoFileLog:%d, m_withMedia:%d, m_withSpecialTest:%d",
 							m_sysInfo.strMachineType.GetData(), webMaskKey.GetData(), webMaskStr.GetData(), m_runAd, m_runMain, m_runExtend, m_runLogin, m_withBrowser
-						,m_withMin, m_withClose, m_withDebugMode, m_withMagic, m_withNoFileLog);
+						,m_withMin, m_withClose, m_withDebugMode, m_withMagic, m_withNoFileLog, m_withMedia, m_withSpecialTest);
 						
 						if (m_withMin)
 							CModTools::get_mutable_instance().setWithMin(m_withMin);
@@ -332,12 +336,14 @@ namespace Chromium {
 							CModTools::get_mutable_instance().setWithClose(m_withClose);
 						
 						g_logToFile = !m_withNoFileLog;
+						g_withMedia = m_withMedia;
+						m_withSpecialTest = m_withSpecialTest;
 
 
 						int forceCacheClean = false;
 						if (Error_Succeed == spConfig->ReadConfigValueInt("Chromium", "forceCacheClean", forceCacheClean) && forceCacheClean)
 						{
-							DbgEx("forceCacheClean, call OnOnBrowserCacheClean");
+							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("forceCacheClean, call OnOnBrowserCacheClean");
 							ResourceWatcher::BrowserCacheClean evt;
 							evt.needClean = 1;
 							OnBrowserCacheClean(NULL, 0, 0, evt);
@@ -345,11 +351,11 @@ namespace Chromium {
 
 					}
 					else
-						DbgEx("can not find %s, use default", webMaskKey.GetData());
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("can not find %s, use default", webMaskKey.GetData());
 				}
 				if (!m_runAd && !m_runMain && !m_runExtend && !m_withBrowser)
 				{
-					DbgEx("can not open centerSetting, maybe fault");
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("can not open centerSetting, maybe fault");
 				}
 
 				CSimpleString translatePath;
@@ -366,6 +372,13 @@ namespace Chromium {
 
 				boost::thread(boost::bind(&CChromiumEntity::DoWithSysVarEvent, this)).detach();//用于处理sysvar,避免由于阻塞动作,导致实体卡住,lost
 		}
+				if (m_withSpecialTest)
+				{
+					CSimpleString strPath;
+					GetFunction()->GetPath("Downloads", strPath);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Downloads path %s, ", strPath.GetData());
+
+				}
 	}
 
 	bool CChromiumEntity::OnPreStart_socketStart(CAutoArray<CSimpleStringA>& strArgs, CSmartPointer<ITransactionContext>& pTransactionContext)
@@ -373,7 +386,7 @@ namespace Chromium {
 		ErrorCodeEnum Error;
 		if (Error_Succeed != (Error = GetFunction()->StartTcpBridgeServer(m_iTcpBridgePort)))
 		{
-			DbgEx("start tcp bridge server failed!");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("start tcp bridge server failed!");
 			pTransactionContext->SendAnswer(Error);
 			return false;
 		}
@@ -381,7 +394,7 @@ namespace Chromium {
 		CSimpleStringA strStructPath;
 		GetFunction()->GetPath("Base", strStructPath);
 		strStructPath.Append(CSimpleStringA(SPLIT_SLASH_STR) + "res" + SPLIT_SLASH_STR + "StructConfig" + SPLIT_SLASH_STR);
-		DbgEx("find struct config files in path %s", strStructPath.GetData());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("find struct config files in path %s", strStructPath.GetData());
 		m_pWsServer = new CWebsocketServer(strStructPath, this);
 		m_pWsServer->run();
 
@@ -397,25 +410,25 @@ namespace Chromium {
         if (Error_Succeed == Error) {
             this->GetFunction()->GetPrivilegeFunction()->RefreshFrameworkState(FrameworkState_NotDisturb);
         } else {
-            DbgEx("subscribe log for notify failed! %s", SpStrError(Error));
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("subscribe log for notify failed! %s", SpStrError(Error));
         }
 #endif //RVC_OS_LINUX
 
 		if (!m_withBrowser)
 		{
-			DbgEx("subscribe AccessAuthorization %s, %d",
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("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", 
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("subscribe ResourceWatcher %s, %d",
 				Error_Succeed == (Error = GetFunction()->SubscribeBroadcast("ResourceWatcher", NULL, this, m_uuidResourceWatch)) ? "success" : "failed", Error);
 
 
 			if (Error_Succeed != GetFunction()->RegistSysVarEvent("UIState", this))
-				DbgEx("RegistSysVarEvent UIState failed!");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("RegistSysVarEvent UIState failed!");
 			if (Error_Succeed != GetFunction()->RegistSysVarEvent("TerminalStage", this))
-				DbgEx("RegistSysVarEvent TerminalStage failed!");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("RegistSysVarEvent TerminalStage failed!");
 			if (Error_Succeed != GetFunction()->RegistSysVarEvent("CardStoreInUse", this))
-				DbgEx("RegistSysVarEvent CardStoreInUse failed!");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("RegistSysVarEvent CardStoreInUse failed!");
 		}
 
 		return true;
@@ -435,7 +448,7 @@ namespace Chromium {
 			ErrorCodeEnum rc = ErrorCodeEnum::Error_Succeed;
 			if ((rc = GetFunction()->GetSysVar("TerminalStage", t_terminalState)) != ErrorCodeEnum::Error_Succeed)
 			{
-				DbgEx("%s read TerminalStage Error %d, maybe not exist", __FUNCTION__, rc);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s read TerminalStage Error %d, maybe not exist", __FUNCTION__, rc);
 				break;
 			}
 		    else if ('A' != t_terminalState[0] &&  'Z' != t_terminalState[0])
@@ -444,20 +457,20 @@ namespace Chromium {
 					break;//run IEBrowser
 				if ('X' == t_terminalState[0])
 				{
-					DbgEx("do not begin accessAuth, terminalStage X, do nothing.");
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("do not begin accessAuth, terminalStage X, do nothing.");
 					break;
 				}
 				else if ('S' == t_terminalState[0])
 				{
 					auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::warnPrompt,
 						std::tuple <std::string, std::string>(m_sysInfo.strTerminalID.GetData(), generateTimeStr()));
-					DbgEx("access failed, open page warnPrompt %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("access failed, open page warnPrompt %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 				}
 				else
 				{
 					auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::breakdown,
 						std::tuple <std::string, std::string>(m_sysInfo.strTerminalID.GetData(), generateTimeStr()));
-					DbgEx("access failed, open page breakdown %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("access failed, open page breakdown %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 				}
 			}
 			else
@@ -491,12 +504,12 @@ namespace Chromium {
 	void CChromiumEntity::openAdPage()
 	{
 		auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::Ad);
-		DbgEx("open page Ad %s, pid:%d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open page Ad %s, pid:%d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 	}
 	void CChromiumEntity::openExtendPage()
 	{
 		auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::extend);
-		DbgEx("open page extend %s, pid:%d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open page extend %s, pid:%d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 	}
 
 	void CChromiumEntity::openInstallPage()
@@ -507,7 +520,7 @@ namespace Chromium {
 		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);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open page install %s, pid:%d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 	}
 
 
@@ -574,11 +587,11 @@ namespace Chromium {
 		CSimpleStringA t_terminalState;
 		if (ErrorCodeEnum::Error_Succeed == GetFunction()->GetSysVar("TerminalStage", t_terminalState))
 		{
-			DbgEx("OnPreStart TerminalStage:%s", t_terminalState.GetData());
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnPreStart TerminalStage:%s", t_terminalState.GetData());
 			startWithCfg();//属于chromium重启或者其他情况,已经初始化好配置
 		}
 		else
-			DbgEx("subscribe VtmLoader %s",
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("subscribe VtmLoader %s",
 				(Error_Succeed == GetFunction()->SubscribeLog(m_uuidVTMLoader, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "VtmLoader")) ? "success" : "failed");
 		};
 		
@@ -613,7 +626,7 @@ namespace Chromium {
 					if (firstEnter)
 					{
 						firstEnter = false;
-						DbgEx("first Enter main page");
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("first Enter main page");
 						m_firstStartMain.unlock();
 						LogWarn(Severity_Low, Error_Debug, LOG_SLV_CHROMIUM_OPENSUCCESS,
 							CSimpleStringA::Format("Chromium Enter main page success, %s", CModTools::get_mutable_instance().getFultureUrl().GetData()));
@@ -636,7 +649,7 @@ namespace Chromium {
 					}
 				}
 				else if (0 == CSimpleStringA("X").Compare(curEvent.value.c_str(), true))
-					DbgEx("TerminalStage X, do nothing.");
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("TerminalStage X, do nothing.");
 				else
 				{
 					if (!m_withBrowser)
@@ -644,7 +657,7 @@ namespace Chromium {
 						auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(
 							0 == CSimpleStringA("S").Compare(curEvent.value.c_str(), true) ? ERR_PAGE_REASON::warnPrompt : ERR_PAGE_REASON::breakdown,
 							std::tuple < std::string, std::string>(m_sysInfo.strTerminalID.GetData(), generateTimeStr()));
-						DbgEx("access failed, open err page %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("access failed, open err page %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 						CModTools::get_mutable_instance().StopChromiumBrowser(ERR_PAGE_REASON::main);						
 					}
 				}
@@ -656,7 +669,7 @@ namespace Chromium {
 				{
 					auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::CardStoreIsBusy,
 						std::tuple <std::string, std::string>(m_sysInfo.strTerminalID.GetData(), generateTimeStr()));
-					DbgEx("CardStoreIsBusy, open page CardStoreIsBusy %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CardStoreIsBusy, open page CardStoreIsBusy %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 				}
 				else
 					CModTools::get_mutable_instance().StopChromiumBrowser(ERR_PAGE_REASON::CardStoreIsBusy);
@@ -667,7 +680,7 @@ namespace Chromium {
 
 	void CChromiumEntity::OnSysVarEvent(const char* pszKey, const char* pszValue, const char* pszOldValue, const char* pszEntityName)
 	{
-		DbgEx("OnSysVarEvent %s, old->new:%s->%s", pszKey, pszOldValue, pszValue);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnSysVarEvent %s, old->new:%s->%s", pszKey, pszOldValue, pszValue);
 		SYS_EVENT_PARAM curEvent;
 		curEvent.key = pszKey;
 		curEvent.value = pszValue;
@@ -710,11 +723,11 @@ namespace Chromium {
         const int ArgsCount = strArgs.GetCount();
         LOG_TRACE("strArgs.GetCount() = %d", ArgsCount);
         for (int i = 0; i < ArgsCount; ++i) {
-            DbgEx("strArgs[%d] = %s", i, strArgs[i].GetData());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("strArgs[%d] = %s", i, strArgs[i].GetData());
         }
         if (ArgsCount == 1) {
             m_strCustomMainUrl = strArgs[0];
-            DbgEx("Get custom main url: %s", m_strCustomMainUrl.GetData());
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Get custom main url: %s", m_strCustomMainUrl.GetData());
 			if (!m_strCustomMainUrl.IsNullOrEmpty()) {
                 LogWarn(Severity_Low, Error_Debug, LOG_EVT_CHROMIUM_DETECT_CUSTOM_FULTURE_URL_FROM_START,
 						CSimpleStringA::Format("从模块入参获取自定义链接:%s", m_strCustomMainUrl.GetData()));
@@ -743,7 +756,7 @@ namespace Chromium {
 		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)
 	{
-		DbgEx("OnLog %x from entity %s, msg : %s", dwUserCode, NULL == pszEntityName ? "" : pszEntityName, NULL == pszMessage ? "" : pszMessage);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnLog %x from entity %s, msg : %s", dwUserCode, NULL == pszEntityName ? "" : pszEntityName, NULL == pszMessage ? "" : pszMessage);
 		if (Event_VtmLoader_GetConfig_Suc == dwUserCode || Event_VtmLoader_GetConfig_Fail == dwUserCode)
 		{
 			refreshLogLevel();//后置后需要刷新log level,因为chromium是先启动的实体
@@ -765,18 +778,18 @@ namespace Chromium {
 				{
 					for (auto it : notifyPool)
 					{
-						DbgEx("Log_Notify err, notifyPool to %d, %d", it.first, it.second);
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Log_Notify err, notifyPool to %d, %d", it.first, it.second);
 						m_pWsServer->do_send_notifyMsg(it.first, it.second, notifyReason, notifymsg, notiryRebootTime, dwSysError, dwUserCode);
 					}
 				}
 				else
 				{
 					auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::ErrNotify, { m_sysInfo.strTerminalID.GetData(), generateTimeStr() }, { notifyReason, notifymsg, notiryRebootTime, dwSysError, dwUserCode });
-					DbgEx("Log_Notify err, open page %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Log_Notify err, open page %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 				}
 			}
 			catch (std::exception& e) {
-				DbgEx("Log_Notify err, %s", e.what());
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Log_Notify err, %s", e.what());
 			}
 			return;
 	}
@@ -785,7 +798,7 @@ namespace Chromium {
 
 	void CChromiumEntity::OnTerminalManage(const char* pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, HealthManager::TerminalManager& evt)
 	{
-		DbgEx("OnTerminalManage : evt.op = %d", evt.op);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnTerminalManage : evt.op = %d", evt.op);
 		switch (evt.op)
 		{
 		case 0:
@@ -793,13 +806,13 @@ namespace Chromium {
 			{
 				auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::TerminalManagerOff,
 					std::tuple < std::string, std::string>(m_sysInfo.strTerminalID.GetData(), generateTimeStr()));
-				DbgEx("TerminalManagerState L, open page TerminalManagerOff %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("TerminalManagerState L, open page TerminalManagerOff %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 			}
 			break;
 		case 1:
 			GetFunction()->SetSysVar("TerminalManagerState", "N", true);
 			{
-				DbgEx("TerminalManagerState N, try close TerminalManager");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("TerminalManagerState N, try close TerminalManager");
 				CModTools::get_mutable_instance().killChromiumByName((+PAGE_TYPE::TerminalManager)._to_string());
 			}
 			break;
@@ -808,13 +821,13 @@ namespace Chromium {
 			{
 				auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::TerminalManagerKickOut,
 					std::tuple < std::string, std::string>(m_sysInfo.strTerminalID.GetData(), generateTimeStr()));
-				DbgEx("TerminalManagerState K, open page TerminalManagerKickOut %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("TerminalManagerState K, open page TerminalManagerKickOut %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 			}
 			break;
 		case 99:
 			GetFunction()->SetSysVar("TerminalManagerState", "N", true);
 			{
-				DbgEx("TerminalManagerState N, try close TerminalManager");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("TerminalManagerState N, try close TerminalManager");
 				CModTools::get_mutable_instance().killChromiumByName((+PAGE_TYPE::TerminalManager)._to_string());
 			}
 			break;
@@ -828,7 +841,7 @@ namespace Chromium {
 
 	void CChromiumEntity::OnBrowserCacheClean(const char* pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, ResourceWatcher::BrowserCacheClean& evt)
 	{
-		DbgEx("OnOnBrowserCacheClean, needClean:%d", evt.needClean);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnOnBrowserCacheClean, needClean:%d", evt.needClean);
 		ErrorCodeEnum error = Error_Succeed;
 		if (!evt.needClean)
 			return;
@@ -836,7 +849,7 @@ namespace Chromium {
 		CSimpleString tmpCacheDir;
 		if (Error_Succeed != (error = GetFunction()->GetPath("Temp", tmpCacheDir)) || tmpCacheDir.GetLength() == 0)
 		{
-			DbgEx("OnBrowserCacheClean get cache path err, %d", error);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnBrowserCacheClean get cache path err, %d", error);
 			return;
 		}
 #if (defined _WIN32 || defined _WIN64)
@@ -977,10 +990,10 @@ namespace Chromium {
     void CChromiumEntity::OnTaskTimerListener(void* pData)
 	{
 		static int max_restartTime = 3;
-		DbgEx("OnTaskTimerListener");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnTaskTimerListener");
 		if (max_restartTime == 0)
 		{
-			DbgEx("max_restartTime == 0, do not restart chromium");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("max_restartTime == 0, do not restart chromium");
 			GetFunction()->KillTimer(CHROMIUM_TIMER_ID);
 			return;
 		}
@@ -995,7 +1008,7 @@ namespace Chromium {
 
 		auto rc = CModTools::get_mutable_instance().StartChromiumBrowser();
 		max_restartTime--;
-		DbgEx("TaskTimerListen, startChromiumBrowser, rc:%d, pid:%d", rc.first, rc.second);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("TaskTimerListen, startChromiumBrowser, rc:%d, pid:%d", rc.first, rc.second);
 		if (0 == rc.first)
 			GetFunction()->KillTimer(CHROMIUM_TIMER_ID);
 
@@ -1006,22 +1019,22 @@ namespace Chromium {
 			HANDLE defaultProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, rc.second);
 			if (defaultProcess == nullptr)
 			{
-				DbgEx("OnTaskTimerListener, openProcess failed");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnTaskTimerListener, openProcess failed");
 				return;
 			}
 			auto ret = assigntoJob(defaultProcess, rc.second);
 			if (!ret.first)
-				DbgEx("OnTaskTimerListener, assigntoJob failed");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnTaskTimerListener, assigntoJob failed");
 			else
 			{
 				auto monitorThread = [&](HANDLE job, HANDLE process) {
 					while (1)
 					{
 						if (WaitForSingleObject(process, 10) != WAIT_OBJECT_0)	//process end
-							DbgEx("default cefclient.exe job:%d, process:%d checkOpen", job, process);
+							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("default cefclient.exe job:%d, process:%d checkOpen", job, process);
 						else
 						{
-							DbgEx("default cefclient.exe job:%d, process:%d check Closed, try to restart", job, process);
+							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("default cefclient.exe job:%d, process:%d check Closed, try to restart", job, process);
 
 							TerminateJobObject(job, 0);
 							max_restartTime--;
@@ -1041,12 +1054,12 @@ namespace Chromium {
 
 		if (Error_Succeed != rc.first)
 		{
-			DbgEx("OnTaskTimerListener will be called after %d secs, rest restart time %d", 15, max_restartTime);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnTaskTimerListener will be called after %d secs, rest restart time %d", 15, max_restartTime);
 			if (max_restartTime)
 				GetFunction()->ResetTimer(CHROMIUM_TIMER_ID, 15000);
 		}
 		else {
-			DbgEx("OnTaskTimerListener rc = succeed");
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnTaskTimerListener rc = succeed");
 			GetFunction()->KillTimer(CHROMIUM_TIMER_ID);
 		}
 #endif

+ 2 - 1
Module/mod_chromium/mod_chromium.h

@@ -121,7 +121,8 @@ namespace Chromium {
 		HANDLE m_hThreadIOCP;
 		CSimpleStringA m_strCustomMainUrl, m_strCustomAdUrl;
 		bool m_runAd/*广告*/, m_runMain/*业务*/, m_runExtend/*低柜副屏*/, m_runLogin/*用户桌面,可能木有用*/, m_withBrowser/*是否需要与browser交互*/;
-		bool m_withDebugMode/*是否启动debug模式*/, m_withMagic/*启用随机共享内存*/, m_withNoFileLog/*是否不需要本地日志落盘*/;
+		bool m_withDebugMode/*是否启动debug模式*/, m_withMagic/*启用随机共享内存*/, m_withNoFileLog/*是否不需要本地日志落盘*/, m_withMedia/*开启多媒体选项*/;
+		bool m_withSpecialTest/*开启一些终端功能的测试*/;
 		bool m_withMin, m_withClose, m_installMode;
 
 		boost::container::deque<SYS_EVENT_PARAM> m_eventArr;

+ 3 - 3
Module/mod_chromium/processControl.cpp

@@ -89,13 +89,13 @@ std::pair<bool, HANDLE> assigntoJob(HANDLE process, int pid)
 			return std::make_pair(true, hd);
 		else
 		{
-			DbgEx("AssignProcessToJobObject err! process: %d, %d", process, pid);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("AssignProcessToJobObject err! process: %d, %d", process, pid);
 			return std::make_pair(false, (HANDLE)NULL);
 		}
 	}
 	else
 	{
-		DbgEx("CreateJobObjectA err!");
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CreateJobObjectA err!");
 		return std::make_pair(false, (HANDLE)NULL);
 	}
 }
@@ -124,7 +124,7 @@ std::tuple<bool, DWORD, HANDLE, HANDLE> startProcessInJob(std::string program, s
 	}
 	if (!processInfo.hProcess)
 	{
-		DbgEx("CreateProcess failed!, %s, %s", program.c_str(), args.c_str());
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CreateProcess failed!, %s, %s", program.c_str(), args.c_str());
 		return std::make_tuple(false, 0, (HANDLE)NULL, (HANDLE)NULL);
 	}
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio