Impl GetUserInfo

This commit is contained in:
Changhua
2023-04-11 23:26:38 +08:00
parent 5800bba855
commit b39ab1e5e4
6 changed files with 77 additions and 8 deletions
+27
View File
@@ -163,6 +163,28 @@ bool func_get_db_tables(char *db, uint8_t *out, size_t *len)
return true;
}
bool func_get_user_info(uint8_t *out, size_t *len)
{
Response rsp = Response_init_default;
rsp.func = Functions_FUNC_GET_USER_INFO;
rsp.which_msg = Response_ui_tag;
UserInfo_t ui = GetUserInfo();
rsp.msg.ui.wxid = (char *)ui.wxid.c_str();
rsp.msg.ui.name = (char *)ui.name.c_str();
rsp.msg.ui.mobile = (char *)ui.mobile.c_str();
rsp.msg.ui.home = (char *)ui.home.c_str();
pb_ostream_t stream = pb_ostream_from_buffer(out, *len);
if (!pb_encode(&stream, Response_fields, &rsp)) {
LOG_ERROR("Encoding failed: {}", PB_GET_ERROR(&stream));
return false;
}
*len = stream.bytes_written;
return true;
}
bool func_send_txt(TextMsg txt, uint8_t *out, size_t *len)
{
Response rsp = Response_init_default;
@@ -506,6 +528,11 @@ static bool dispatcher(uint8_t *in, size_t in_len, uint8_t *out, size_t *out_len
ret = func_get_db_tables(req.msg.str, out, out_len);
break;
}
case Functions_FUNC_GET_USER_INFO: {
LOG_DEBUG("[Functions_FUNC_GET_USER_INFO]");
ret = func_get_user_info(out, out_len);
break;
}
case Functions_FUNC_SEND_TXT: {
LOG_DEBUG("[Functions_FUNC_SEND_TXT]");
ret = func_send_txt(req.msg.txt, out, out_len);
+12
View File
@@ -25,3 +25,15 @@ string GetSelfWxid()
return "empty_wxid";
}
}
UserInfo_t GetUserInfo()
{
UserInfo_t ui;
ui.wxid = GetSelfWxid();
ui.name = GET_STRING_FROM_P(g_WeChatWinDllAddr + g_WxCalls.ui.nickName);
ui.mobile = GET_STRING_FROM_P(g_WeChatWinDllAddr + g_WxCalls.ui.mobile);
ui.home = GET_STRING(g_WeChatWinDllAddr + g_WxCalls.ui.home);
return ui;
}
+4
View File
@@ -2,7 +2,11 @@
#include <string>
#include "pb_types.h"
using namespace std;
string GetHomePath();
string GetSelfWxid();
UserInfo_t GetUserInfo();