|
@@ -4,6 +4,7 @@
|
|
|
#include "GUIConsole_msg_g.h"
|
|
|
#include <chrono>
|
|
|
#include <fstream>
|
|
|
+#include "modp_b64.h"
|
|
|
|
|
|
|
|
|
|
|
@@ -26,6 +27,7 @@ void openProcess(std::string cmdline)
|
|
|
#include <unistd.h>
|
|
|
#include <cstdlib>
|
|
|
#endif // RVC_OS_WIN
|
|
|
+#include <regex>
|
|
|
|
|
|
|
|
|
|
|
@@ -619,26 +621,139 @@ std::pair<DWORD, std::string> CGUIConsoleEntity::GetHelpInformationArr(SpReqAnsC
|
|
|
}
|
|
|
return std::pair<DWORD, std::string>(ErrorCodeEnum::Error_Succeed, "");
|
|
|
}
|
|
|
+#if(defined _WIN32 || defined _WIN64)
|
|
|
+std::string string_to_utf8(const std::string& str) {
|
|
|
+ int wcLen = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
|
|
|
+ if (wcLen > 0) {
|
|
|
+ wchar_t* pwBuf = new wchar_t[wcLen + 1];
|
|
|
+ if (pwBuf == NULL) {
|
|
|
+ return std::string();
|
|
|
+ }
|
|
|
+
|
|
|
+ memset(pwBuf, 0, sizeof(wchar_t) * (wcLen + 1));
|
|
|
+ wcLen = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, pwBuf, wcLen);
|
|
|
+ if (wcLen <= 0) {
|
|
|
+ delete[] pwBuf;
|
|
|
+ return std::string();
|
|
|
+ }
|
|
|
+
|
|
|
+ std::wstring modifyStr = pwBuf;
|
|
|
+
|
|
|
+
|
|
|
+ int ucLen = WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, 0, NULL, NULL);
|
|
|
+ //DbgEx("ucLen = %d", ucLen);
|
|
|
+ if (ucLen < 0) {
|
|
|
+ delete[] pwBuf;
|
|
|
+ return std::string();
|
|
|
+ }
|
|
|
+
|
|
|
+ char* pBuf = new char[ucLen + 1];
|
|
|
+ if (pBuf == NULL) {
|
|
|
+ delete[]pwBuf;
|
|
|
+ return std::string();
|
|
|
+ }
|
|
|
+ memset(pBuf, 0, sizeof(char) * (ucLen + 1));
|
|
|
+ ucLen = WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, pBuf, ucLen, NULL, NULL);
|
|
|
+ if (ucLen <= 0) {
|
|
|
+ delete[] pwBuf;
|
|
|
+ delete[] pBuf;
|
|
|
+ return std::string();
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string retStr(pBuf);
|
|
|
+ //DbgEx("string_to_utf8 return: %s", retStr.c_str());
|
|
|
+
|
|
|
+ if (pwBuf) {
|
|
|
+ delete[] pwBuf;
|
|
|
+ pwBuf = NULL;
|
|
|
+ }
|
|
|
+ if (pBuf) {
|
|
|
+ delete[] pBuf;
|
|
|
+ pBuf = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ return retStr;
|
|
|
+ }
|
|
|
+ return std::string();
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
|
|
|
std::pair<DWORD, std::string> CGUIConsoleEntity::GetHelpDetail(SpReqAnsContext<GUIConsoleService_GetHelpDetail_Req, GUIConsoleService_GetHelpDetail_Ans>::Pointer ctx)
|
|
|
{
|
|
|
CSimpleString tilte = ctx->Req.title;
|
|
|
+ CSmartPointer<IConfigInfo> spConfig;
|
|
|
+
|
|
|
if (tilte.Compare("runcfg", true) == 0)
|
|
|
{
|
|
|
ctx->Ans.subtitle = "root配置";
|
|
|
- ctx->Ans.detail = "root配置";
|
|
|
+ ErrorCodeEnum erroCode = GetFunction()->OpenConfig(Config_Root, spConfig);
|
|
|
+ if (!IS_SUCCEED(erroCode))
|
|
|
+ return std::pair<DWORD, std::string>(WARN_GUICONSOLE_HELP_ROOT_FAILED, "");
|
|
|
}
|
|
|
else if (tilte.Compare("centercfg", true) == 0)
|
|
|
{
|
|
|
ctx->Ans.subtitle = "集中配置";
|
|
|
- ctx->Ans.detail = "集中配置";
|
|
|
+ ErrorCodeEnum erroCode = GetFunction()->OpenConfig(Config_CenterSetting, spConfig);
|
|
|
+ if (!IS_SUCCEED(erroCode))
|
|
|
+ return std::pair<DWORD, std::string>(WARN_GUICONSOLE_HELP_CENTER_FAILED, "");
|
|
|
}
|
|
|
else if (tilte.Compare("shellcfg", true) == 0)
|
|
|
{
|
|
|
ctx->Ans.subtitle = "shell配置";
|
|
|
- ctx->Ans.detail = "shell配置";
|
|
|
+ ErrorCodeEnum erroCode = GetFunction()->OpenConfig(Config_Shell, spConfig);
|
|
|
+ if (!IS_SUCCEED(erroCode))
|
|
|
+ return std::pair<DWORD, std::string>(WARN_GUICONSOLE_HELP_SHELL_FAILED, "");
|
|
|
+ }
|
|
|
+
|
|
|
+ CAutoArray<CSimpleStringA> arrSections, arrKeys;
|
|
|
+
|
|
|
+ CSimpleStringA dstStr;
|
|
|
+ dstStr.Append("# ").Append(ctx->Ans.subtitle).Append("\n");
|
|
|
+ dstStr += "| moudle | name | value |\n";//table header
|
|
|
+ dstStr += "-----|------|-----\n";//sperate
|
|
|
+
|
|
|
+ if (Error_Succeed != spConfig->ReadAllSections(arrSections))
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Read all sections failed.");
|
|
|
+ return std::pair<DWORD, std::string>(WARN_GUICONSOLE_HELP_GETSECTION_FAILED, "");
|
|
|
}
|
|
|
|
|
|
+ for (int i = 0; i < arrSections.GetCount(); ++i)
|
|
|
+ {
|
|
|
+ spConfig->ReadAllKeys(arrSections[i].GetData(), arrKeys);
|
|
|
+ for (int j = 0; j < arrKeys.GetCount(); ++j)
|
|
|
+ {
|
|
|
+ CSimpleStringA value, tmp;
|
|
|
+ spConfig->ReadConfigValue(arrSections[i].GetData(), arrKeys[j].GetData(), value);
|
|
|
+
|
|
|
+ tmp = CSimpleStringA::Format("{\"moudle\":\"%s\", \"name\":\"%s\", \"value\":\"%s\"}",
|
|
|
+ arrSections[i].GetData(), arrKeys[j].GetData(), value.GetData());
|
|
|
+ std::string result = value.GetData();
|
|
|
+ std::string::size_type pos = 0;
|
|
|
+ while ((pos = result.find("|", pos)) != std::string::npos) {
|
|
|
+ result.replace(pos, 1, "\\|");
|
|
|
+ pos += 2; // 跳过新插入的"\\"
|
|
|
+ }
|
|
|
+
|
|
|
+ dstStr.Append("| ").Append(arrSections[i]).Append(" | ").Append(arrKeys[j]).Append(" | ").Append(result.c_str()).Append(" |\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+#if(defined _WIN32 || defined _WIN64)
|
|
|
+ dstStr = string_to_utf8(dstStr.GetData()).c_str();
|
|
|
+#endif
|
|
|
+ int base64Len = modp_b64_encode_len(dstStr.GetLength());
|
|
|
+ char *base64Data = (char*)malloc(sizeof(char) * base64Len);
|
|
|
+ modp_b64_encode(base64Data, (const char*)dstStr.GetData(), dstStr.GetLength());
|
|
|
+
|
|
|
+
|
|
|
+ ctx->Ans.detail = base64Data;
|
|
|
+
|
|
|
+ if (base64Data)
|
|
|
+ free(base64Data);
|
|
|
+
|
|
|
+
|
|
|
return std::pair<DWORD, std::string>(ErrorCodeEnum::Error_Succeed, "");
|
|
|
}
|
|
|
|