From b1db01ef5b2f7713a3e59b3acfee904e88f507a4 Mon Sep 17 00:00:00 2001 From: "dengyucheng@finogeeks.com" Date: Thu, 22 Sep 2022 16:52:19 +0800 Subject: [PATCH] fix --- examples/README.md | 2 +- examples/gtk/main.c | 9 +- examples/pyqt/main.py | 8 +- examples/qt/README.md | 2 +- examples/qt/demo/demo.pro | 2 +- examples/qt/demo/main.cpp | 30 +- examples/win32/finclip-win32-demo.cpp | 8 +- .../finclip-win32-demo.cpp | 435 ------------------ examples/win32_dll/finclip-win32-demo.cpp | 19 +- examples/win32_dll/finclip-win32-demo.h | 3 + src/finclip_api.h | 153 ------ src/finclip_api_const.h | 92 ---- 12 files changed, 44 insertions(+), 719 deletions(-) delete mode 100644 examples/win32_dll/enc_temp_folder/dd1bb4d8b09d7f757cb85643f01617/finclip-win32-demo.cpp delete mode 100644 src/finclip_api.h delete mode 100644 src/finclip_api_const.h diff --git a/examples/README.md b/examples/README.md index 7f95dc8..8db885a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -5,7 +5,7 @@ 选择对应的release包, 并解压至指定位置 ``` 以win x64为例: -[下载finclip二进制包](https://github.com/finogeeks/finclip-desktop-demo/releases)到`vendor`的对应目录下,如`vendor/win/x64` +[下载finclip二进制包](https://www.finclip.com/downloads/)到`vendor`的对应目录下,如`vendor/win/x64`并解压 ``` diff --git a/examples/gtk/main.c b/examples/gtk/main.c index 2cc48d3..3226b55 100644 --- a/examples/gtk/main.c +++ b/examples/gtk/main.c @@ -53,13 +53,12 @@ static void add_callback(GtkWidget *widget, gpointer user_data) { IFinConfigPacker *packer = finclip_packer_factory_get_config_packer(factory); IFinConfig *config = finclip_config_packer_new_config(packer); finclip_config_set_app_store(config, 1); - finclip_config_set_app_key(config, - "22LyZEib0gLTQdU3MUauAQVLIkNNhTSGIN42gXzlAsk="); - finclip_config_set_secret(config, "ae55433be2f62915"); - finclip_config_set_domain(config, "https://finchat-mop-b.finogeeks.club"); + finclip_config_set_app_key(config, ""); + finclip_config_set_secret(config, ""); + finclip_config_set_domain(config, ""); finclip_config_packer_add_config(packer, config); finclip_initialize(packer); - finclip_start_applet(NULL, 1, "60e3c059949a5300014d0c07", "", NULL, "", NULL); + finclip_start_applet(NULL, 1, "", "", NULL, "", NULL); } /********************************************************* nameentry_callback */ diff --git a/examples/pyqt/main.py b/examples/pyqt/main.py index e457a4c..c1d57b8 100644 --- a/examples/pyqt/main.py +++ b/examples/pyqt/main.py @@ -31,13 +31,13 @@ def start_finclip(): config = finclip.finclip_config_packer_new_config(packer) finclip.finclip_config_set_app_store(config, 1) finclip.finclip_config_set_app_key(config, - "22LyZEib0gLTQdU3MUauAQVLIkNNhTSGIN42gXzlAsk=") - finclip.finclip_config_set_secret(config, "ae55433be2f62915") + "") + finclip.finclip_config_set_secret(config, "") finclip.finclip_config_set_domain( - config, "https://finchat-mop-b.finogeeks.club") + config, "") if sys.platform == 'win32': finclip.finclip_config_set_value( - config, finclip.FINCLIP_CONFIG_EXE_PATH, "C:/project/finclipsdk-desktop/build/core/Debug/finclip.exe") + config, finclip.FINCLIP_CONFIG_EXE_PATH, "") finclip.finclip_config_packer_add_config(packer, config) # callback.thisown = 0 finclip.finclip_register_callback_cpp( diff --git a/examples/qt/README.md b/examples/qt/README.md index 9417c54..f4b751c 100644 --- a/examples/qt/README.md +++ b/examples/qt/README.md @@ -1,6 +1,6 @@ # 通用步骤与功能介绍 -快速开始前请先阅读以下链接 +快速开始前请先阅读以下文档 [Finclip桌面版Demo集成指引与功能介绍](https://github.com/finogeeks/finclip-desktop-demo/tree/master/examples/README.md) diff --git a/examples/qt/demo/demo.pro b/examples/qt/demo/demo.pro index d351c24..0cd23ec 100644 --- a/examples/qt/demo/demo.pro +++ b/examples/qt/demo/demo.pro @@ -25,7 +25,7 @@ win32 { message("x86_64 build") ## Windows x64 (64bit) specific build here LIBS += "../../../vendor/win/x64/FinClipSDKWrapper.lib" - INCLUDEPATH += "../../../src" + INCLUDEPATH += "../../../vendor/win/x64" QMAKE_POST_LINK=robocopy ../../../vendor/win/x64 . /E } else { message("x86 build") diff --git a/examples/qt/demo/main.cpp b/examples/qt/demo/main.cpp index b1657db..f995dd5 100644 --- a/examples/qt/demo/main.cpp +++ b/examples/qt/demo/main.cpp @@ -6,24 +6,22 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - std::string appkey = "22LyZEib0gLTQdU3MUauAQVLIkNNhTSGIN42gXzlAsk="; - std::string secret = "ae55433be2f62915"; - std::string domain = "https://finchat-mop-b.finogeeks.club:443"; - int app_store = 1; - - auto* factory = finclip_get_packer_factory(); - auto* packer = finclip_packer_factory_get_config_packer(factory); - auto* config = finclip_config_packer_new_config(packer); - finclip_config_packer_add_config(packer, config); - finclip_config_set_app_store(config, app_store); - finclip_config_set_app_key(config, appkey.c_str()); - finclip_config_set_secret(config, secret.c_str()); - finclip_config_set_domain(config, domain.c_str()); - finclip_config_set_start_flag(config, kAppletSync); - finclip_config_set_show_loading(config, false); + std::string appkey = ""; + std::string secret = ""; + std::string domain = ""; + std::string app_store = "1"; + auto *factory = finclip_get_packer_factory(); + auto *packer = finclip_packer_factory_get_config_packer(factory); finclip_initialize(packer); - finclip_start_applet(app_store, "60e3c059949a5300014d0c07"); + FinclipParams *config = finclip_create_params(); + finclip_params_set(config, FINCLIP_CONFIG_APPSTORE, "1"); + finclip_params_set(config, FINCLIP_CONFIG_APPKEY, appkey.c_str()); + finclip_params_set(config, FINCLIP_CONFIG_SECRET, secret.c_str()); + finclip_params_set(config, FINCLIP_CONFIG_DOMAIN, domain.c_str()); + finclip_config_packer_add_config(packer, config); + + finclip_start_applet(app_store.c_str(), ""); FinclipQtDemo w; w.show(); return a.exec(); diff --git a/examples/win32/finclip-win32-demo.cpp b/examples/win32/finclip-win32-demo.cpp index 1d4311a..3e6d9e7 100644 --- a/examples/win32/finclip-win32-demo.cpp +++ b/examples/win32/finclip-win32-demo.cpp @@ -346,10 +346,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, MONITORINFO mi = {sizeof(mi)}; if (!GetMonitorInfo(hmon, &mi)) return 0; - wstring domain(L"https://finchat-mop-b.finogeeks.club:443"); - wstring appkey(L"22LyZEib0gLTQdU3MUauAQVLIkNNhTSGIN42gXzlAsk="); - wstring appid(L"60e3c059949a5300014d0c07"); - wstring secret(L"ae55433be2f62915"); + wstring domain(L""); + wstring appkey(L""); + wstring appid(L""); + wstring secret(L""); auto path = std::filesystem::current_path(); if (std::filesystem::exists("config.json")) { diff --git a/examples/win32_dll/enc_temp_folder/dd1bb4d8b09d7f757cb85643f01617/finclip-win32-demo.cpp b/examples/win32_dll/enc_temp_folder/dd1bb4d8b09d7f757cb85643f01617/finclip-win32-demo.cpp deleted file mode 100644 index 073a0e4..0000000 --- a/examples/win32_dll/enc_temp_folder/dd1bb4d8b09d7f757cb85643f01617/finclip-win32-demo.cpp +++ /dev/null @@ -1,435 +0,0 @@ -// FinClip.cpp : Defines the entry point for the application. -// -#include "resource.h" - -// Windows Header Files -#include -// C RunTime Header Files -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "finclip-win32-demo.h" -#include "json.hpp" - -#define MAX_LOADSTRING 100 - -using namespace std; -HINSTANCE hInst; -HWND gHwnd; // current instance -WCHAR szTitle[MAX_LOADSTRING]; // The title bar text -WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name - -ATOM MyRegisterClass(HINSTANCE hInstance); -ATOM MyRegisterClass1(HINSTANCE hInstance); -BOOL InitInstance(HINSTANCE, int); -LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); -HWND hWnd_appkey; -HWND hWnd_secret; -HWND hWnd_appid; -HWND hWnd_domain; -HWND hWnd_type; -HWND hWnd_container; -HWND hWnd_applet; -BOOL is_initialized = FALSE; -std::string offline_base_path; -std::string offline_applet_path; -HINSTANCE dll; - -std::string Utf8Encode(const std::wstring& wstr, int cp = CP_UTF8) { - if (wstr.empty()) return std::string(); - int size_needed = - WideCharToMultiByte(cp, 0, &wstr[0], static_cast(wstr.size()), - nullptr, 0, nullptr, nullptr); - std::string str(size_needed, 0); - WideCharToMultiByte(cp, 0, &wstr[0], static_cast(wstr.size()), &str[0], - size_needed, nullptr, nullptr); - return str; -} - -// Convert an UTF8 string to a wide Unicode String -std::wstring Utf8Decode(const std::string& str, int cp = CP_UTF8) { - if (str.empty()) return std::wstring(); - int size_needed = MultiByteToWideChar( - cp, 0, &str[0], static_cast(str.size()), nullptr, 0); - std::wstring wstr(size_needed, 0); - MultiByteToWideChar(cp, 0, &str[0], static_cast(str.size()), &wstr[0], - size_needed); - return wstr; -} - -int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, - _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, - _In_ int nCmdShow) { - SetProcessDPIAware(); - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); - - LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); - LoadStringW(hInstance, IDC_FINCLIPWIN32DEMO, szWindowClass, MAX_LOADSTRING); - - MyRegisterClass(hInstance); - MyRegisterClass1(hInstance); - if (InitInstance(hInstance, nCmdShow) == 0) { - return FALSE; - } - - HACCEL hAccelTable = LoadAccelerators(hInstance, nullptr); - - MSG msg; - - while (GetMessage(&msg, nullptr, 0, 0)) { - if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - return static_cast(msg.wParam); -} - -ATOM MyRegisterClass(HINSTANCE hInstance) { - WNDCLASSEXW wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, nullptr); - wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wcex.lpszMenuName = nullptr; - wcex.lpszClassName = szWindowClass; - wcex.hIconSm = LoadIcon(wcex.hInstance, nullptr); - - return RegisterClassExW(&wcex); -} - -ATOM MyRegisterClass1(HINSTANCE hInstance) { - WNDCLASSEXW wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, nullptr); - wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wcex.lpszMenuName = nullptr; - wcex.lpszClassName = L"child_finclip"; - wcex.hIconSm = LoadIcon(wcex.hInstance, nullptr); - - return RegisterClassExW(&wcex); -} - -BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { - hInst = hInstance; // Store instance handle in our global variable - HWND hwnd = - CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, - 0, 1000, 1200, nullptr, nullptr, hInstance, nullptr); - HMONITOR hmon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi = {sizeof(mi)}; - if (!GetMonitorInfo(hmon, &mi)) return FALSE; - if (hwnd == nullptr) { - return FALSE; - } - int width = 450; - int height = 1000; - SetWindowPos(hwnd, nullptr, mi.rcMonitor.left, mi.rcMonitor.top, width, - height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); - gHwnd = hwnd; - ShowWindow(hwnd, nCmdShow); - UpdateWindow(hwnd); - - return TRUE; -} - -void InitFinclipsdk(const std::string& app_store, const std::wstring& wappkey, - const std::wstring& wsecret, const std::wstring& wdomain) { - if (is_initialized != 0) { - return; - } - dll = LoadLibrary( - LR"(C:\project\finclipsdk-desktop\build\wrapper\Debug\FinClipSDKWrapper.dll)"); - if (dll == nullptr) { - return; - } - auto fin_get_packer_factory = reinterpret_cast( - GetProcAddress(dll, "finclip_get_packer_factory")); - auto fin_packer_factory_get_config_packer = - reinterpret_cast( - GetProcAddress(dll, "finclip_packer_factory_get_config_packer")); - auto fin_config_packer_add_config = - reinterpret_cast( - GetProcAddress(dll, "finclip_config_packer_add_config")); - - auto fin_initialize = reinterpret_cast( - GetProcAddress(dll, "finclip_initialize")); - auto fin_start_applet = reinterpret_cast( - GetProcAddress(dll, "finclip_start_applet")); - auto fin_register_api = reinterpret_cast( - GetProcAddress(dll, "finclip_register_api")); - auto fin_create_params = reinterpret_cast( - GetProcAddress(dll, "finclip_create_params")); - auto fin_destory_params = reinterpret_cast( - GetProcAddress(dll, "finclip_destory_params")); - auto fin_params_set = reinterpret_cast( - GetProcAddress(dll, "finclip_params_set")); - - std::string appkey = Utf8Encode(wappkey); - std::string secret = Utf8Encode(wsecret); - std::string domain = Utf8Encode(wdomain); - - auto* factory = fin_get_packer_factory(); - auto* packer = fin_packer_factory_get_config_packer(factory); - fin_initialize(packer); - auto* config = fin_create_params(); - fin_params_set(config, FINCLIP_CONFIG_APPSTORE, "1"); - fin_params_set(config, FINCLIP_CONFIG_APPKEY, appkey.c_str()); - fin_params_set(config, FINCLIP_CONFIG_SECRET, secret.c_str()); - fin_params_set(config, FINCLIP_CONFIG_DOMAIN, domain.c_str()); - std::string exe_path = R"(C:\Users\yx\Downloads\1.2.1-alpha-debug.73 (1)\finclip\FinClip.exe)"; - fin_params_set(config, FINCLIP_CONFIG_EXE_PATH, exe_path.c_str()); - - fin_config_packer_add_config(packer, config); - // 启动 - // fin_start_applet(app_store, appid.c_str(), nullptr); - //fin_destory_params(config); - is_initialized = TRUE; -} - -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, - LPARAM lParam) { - switch (message) { - case WM_COMMAND: - if (LOWORD(wParam) == IDM_SENDMESSAGE) { - WCHAR appid[1024]; - GetWindowText(hWnd_appid, appid, 1023); - std::wstring wappid(appid); - // CleanCache(); - break; - } - // 打开隐藏小程序进程的例子 - if (LOWORD(wParam) == IDM_SENDMESSAGE_1) { - // 小程序启动过一次, 调用unbind后, 再次打开 - WCHAR appid[1024]; - GetWindowText(hWnd_appid, appid, 1023); - std::wstring wappid(appid); - // 重新显示小程序 - // StartApplet(hWnd_container, 0, Utf8Encode(wappid).c_str(), "", - // nullptr, - // "", nullptr); - // 宿主处理自己的窗口 - ShowWindow(hWnd_container, SW_SHOWNORMAL); - break; - } - if (LOWORD(wParam) == IDM_SENDMESSAGE_2) { - // 关闭但不销毁(隐藏)小程序进程, - // CloseApplet(hWnd_container, false); - // 宿主处理自己的窗口 - ShowWindow(hWnd_container, SW_HIDE); - break; - } - // open按钮处理逻辑 - if (LOWORD(wParam) == IDM_START_APPLET) { - WCHAR key[1024]; - GetWindowText(hWnd_appkey, key, 1023); - WCHAR secret[1024]; - GetWindowText(hWnd_secret, secret, 1023); - WCHAR appid[1024]; - GetWindowText(hWnd_appid, appid, 1023); - WCHAR domain[1024]; - GetWindowText(hWnd_domain, domain, 1023); - WCHAR type[1024]; - GetWindowText(hWnd_type, type, 1023); - std::wstring wappkey(key); - std::wstring wsecret(secret); - std::wstring wappid(appid); - std::wstring wdomain(domain); - std::wstring wtype(type); - std::string appstore = "1"; - if (wappkey.length() == 0) { - MessageBox(nullptr, L"无效的appKey", L"错误", 0); - return 0; - } - if (wsecret.length() == 0) { - MessageBox(nullptr, L"无效的Secret", L"错误", 0); - return 0; - } - if (wappid.length() == 0) { - MessageBox(nullptr, L"无效的appid", L"错误", 0); - return 0; - } - if (wdomain.length() == 0) { - MessageBox(nullptr, L"无效的domain", L"错误", 0); - return 0; - } - if (wtype.length() == 0) { - MessageBox(nullptr, L"无效的type", L"错误", 0); - return 0; - } - InitFinclipsdk(appstore, wappkey, wsecret, wdomain); - auto fin_start_applet = reinterpret_cast( - GetProcAddress(dll, "finclip_start_applet")); - fin_start_applet(appstore.c_str(), Utf8Encode(wappid).c_str()); - } - break; - case WM_SIZE: { - if (hWnd_container == hWnd) { - // 嵌入模式须重新设置窗口大小 - WCHAR type[1024]; - GetWindowText(hWnd_type, type, 1023); - std::wstring wtype(type); - if (wtype == L"1") { - WCHAR appid[1024]; - GetWindowText(hWnd_appid, appid, 1023); - RECT rect; - GetClientRect(hWnd_container, &rect); - // SetAppletPos(Utf8Encode(std::wstring(appid)).c_str(), 0, 0, - // rect.right - rect.left, rect.bottom - rect.top, true); - } - } - break; - } - case WM_DESTROY: { - if (hWnd == hWnd_container) { - // 收到WM_DESTROY消息, 表示容器窗口被销毁, 需要SDK的资源 - // CloseApplet(hWnd, true); - hWnd_container = nullptr; - return 0; - } - if (hWnd == gHwnd) { - // 只有主窗口关闭时退出进程 - PostQuitMessage(0); - } - break; - } - case WM_CREATE: { - if (hWnd_appkey != nullptr) - return DefWindowProcW(hWnd, message, wParam, lParam); - CreateWindowW(L"static", L"AppKEY", WS_CHILD | WS_VISIBLE, 20, 20, 60, 30, - hWnd, (HMENU)1, ((LPCREATESTRUCT)lParam)->hInstance, - nullptr); - - CreateWindowW(L"static", L"Secret", WS_CHILD | WS_VISIBLE, 20, 60, 60, 30, - hWnd, (HMENU)2, ((LPCREATESTRUCT)lParam)->hInstance, - nullptr); - - CreateWindowW(L"static", L"appid", WS_CHILD | WS_VISIBLE, 20, 100, 60, 30, - hWnd, (HMENU)2, ((LPCREATESTRUCT)lParam)->hInstance, - nullptr); - CreateWindowW(L"static", L"domain", WS_CHILD | WS_VISIBLE, 20, 140, 60, - 30, hWnd, (HMENU)2, ((LPCREATESTRUCT)lParam)->hInstance, - nullptr); - - CreateWindowW(L"static", L"window_type", WS_CHILD | WS_VISIBLE, 20, 180, - 60, 30, hWnd, (HMENU)2, ((LPCREATESTRUCT)lParam)->hInstance, - nullptr); - HMONITOR hmon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi = {sizeof(mi)}; - if (!GetMonitorInfo(hmon, &mi)) return 0; - - wstring domain(L"https://finchat-mop-b.finogeeks.club:443"); - wstring appkey(L"22LyZEib0gLTQdU3MUauAQVLIkNNhTSGIN42gXzlAsk="); - wstring appid(L"60e3c059949a5300014d0c07"); - wstring secret(L"ae55433be2f62915"); - - auto path = std::filesystem::current_path(); - if (std::filesystem::exists("config.json")) { - std::ifstream t("config.json"); - std::stringstream buffer; - buffer << t.rdbuf(); - auto obj = nlohmann::json::parse(buffer.str()); - auto field = obj.find("domain"); - if (field != obj.end() && field.value().is_string()) { - auto s = field.value().get(); - domain = wstring(s.begin(), s.end()); - } - field = obj.find("appkey"); - if (field != obj.end() && field.value().is_string()) { - auto s = field.value().get(); - appkey = wstring(s.begin(), s.end()); - } - field = obj.find("appid"); - if (field != obj.end() && field.value().is_string()) { - auto s = field.value().get(); - appid = wstring(s.begin(), s.end()); - } - field = obj.find("secret"); - if (field != obj.end() && field.value().is_string()) { - auto s = field.value().get(); - secret = wstring(s.begin(), s.end()); - } - field = obj.find("offline_applet_path"); - if (field != obj.end() && field.value().is_string()) { - auto s = field.value().get(); - offline_applet_path = string(s.begin(), s.end()); - } - field = obj.find("offline_base_path"); - if (field != obj.end() && field.value().is_string()) { - auto s = field.value().get(); - offline_base_path = string(s.begin(), s.end()); - } - } - hWnd_appkey = CreateWindowW( - L"EDIT", appkey.c_str(), WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT, - 100, 20, 300, 30, hWnd, (HMENU)IDM_APPLET_APPKEY, - ((LPCREATESTRUCT)lParam)->hInstance, nullptr); - - hWnd_secret = CreateWindowW( - L"EDIT", secret.c_str(), WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT, - 100, 60, 300, 30, hWnd, (HMENU)IDM_APPLET_SECRET, - ((LPCREATESTRUCT)lParam)->hInstance, nullptr); - // 5ea0401463cb900001d73865 wxdemo - // 5ea0412663cb900001d73867 webview - // 5ea6d3bad262a7000141280d quote - hWnd_appid = CreateWindowW( - L"EDIT", appid.c_str(), WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT, - 100, 100, 300, 30, hWnd, (HMENU)IDM_APPLET_APPID, - ((LPCREATESTRUCT)lParam)->hInstance, nullptr); - hWnd_domain = CreateWindowW( - L"EDIT", domain.c_str(), WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT, - 100, 140, 300, 30, hWnd, (HMENU)IDM_APPLET_DOMAIN, - ((LPCREATESTRUCT)lParam)->hInstance, nullptr); - - hWnd_type = CreateWindowW( - L"EDIT", L"0", WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT, 100, 180, - 300, 30, hWnd, (HMENU)IDM_APPLET_DOMAIN, - ((LPCREATESTRUCT)lParam)->hInstance, nullptr); - int button_y = 240; - CreateWindowW(L"BUTTON", L"open", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, - 100, button_y, 200, 50, hWnd, (HMENU)IDM_START_APPLET, - ((LPCREATESTRUCT)lParam)->hInstance, nullptr); - button_y += 60; - CreateWindowW(L"BUTTON", L"cleancache", - WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 100, button_y, 200, - 50, hWnd, (HMENU)IDM_SENDMESSAGE, - ((LPCREATESTRUCT)lParam)->hInstance, nullptr); - button_y += 60; - CreateWindowW(L"BUTTON", L"bind_applet", - WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 100, button_y, 200, - 50, hWnd, (HMENU)IDM_SENDMESSAGE_1, - ((LPCREATESTRUCT)lParam)->hInstance, nullptr); - button_y += 60; - CreateWindowW(L"BUTTON", L"unbind_applet", - WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 100, button_y, 200, - 50, hWnd, (HMENU)IDM_SENDMESSAGE_2, - ((LPCREATESTRUCT)lParam)->hInstance, nullptr); - - } break; - } - return DefWindowProcW(hWnd, message, wParam, lParam); -} diff --git a/examples/win32_dll/finclip-win32-demo.cpp b/examples/win32_dll/finclip-win32-demo.cpp index 3fb8410..23ee928 100644 --- a/examples/win32_dll/finclip-win32-demo.cpp +++ b/examples/win32_dll/finclip-win32-demo.cpp @@ -163,7 +163,7 @@ void InitFinclipsdk(const std::string& app_store, const std::wstring& wappkey, return; } dll = LoadLibrary( - LR"(C:\project\finclipsdk-desktop\build\wrapper\Debug\FinClipSDKWrapper.dll)"); + LR"(C:\project\finclipsdk-desktop\build\wrapper\Release\FinClipSDKWrapper.dll)"); if (dll == nullptr) { return; } @@ -296,12 +296,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, GetWindowText(hWnd_type, type, 1023); std::wstring wtype(type); if (wtype == L"1") { + // 根据实际情况取出appid WCHAR appid[1024]; GetWindowText(hWnd_appid, appid, 1023); + // 根据实际情况获取变化后的窗口大小 RECT rect; GetClientRect(hWnd_container, &rect); - // SetAppletPos(Utf8Encode(std::wstring(appid)).c_str(), 0, 0, - // rect.right - rect.left, rect.bottom - rect.top, true); + auto finclip_dll_set_position = reinterpret_cast( + GetProcAddress(dll, "finclip_set_position")); + finclip_dll_set_position(Utf8Encode(appid).c_str(), 0, 0, + rect.right - rect.left, + rect.bottom - rect.top); } } break; @@ -344,10 +349,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, MONITORINFO mi = {sizeof(mi)}; if (!GetMonitorInfo(hmon, &mi)) return 0; - wstring domain(L"https://finchat-mop-b.finogeeks.club:443"); - wstring appkey(L"22LyZEib0gLTQdU3MUauAQVLIkNNhTSGIN42gXzlAsk="); - wstring appid(L"60e3c059949a5300014d0c07"); - wstring secret(L"ae55433be2f62915"); + wstring domain(L""); + wstring appkey(L""); + wstring appid(L""); + wstring secret(L""); auto path = std::filesystem::current_path(); if (std::filesystem::exists("config.json")) { diff --git a/examples/win32_dll/finclip-win32-demo.h b/examples/win32_dll/finclip-win32-demo.h index c3c7109..ee6d000 100644 --- a/examples/win32_dll/finclip-win32-demo.h +++ b/examples/win32_dll/finclip-win32-demo.h @@ -17,6 +17,9 @@ typedef int(FINSTDMETHODCALLTYPE *findll_initialize)( IFinConfigPacker *configpacker); typedef int(FINSTDMETHODCALLTYPE *findll_start_applet)(const char *appstore, const char *appid); +typedef int(FINSTDMETHODCALLTYPE *findll_set_position)(const char *appid, + int left, int top, + int width, int height); typedef int(FINSTDMETHODCALLTYPE *findll_invoke_api)( FinClipApiType type, const char *app_id, const char *api_name, const char *params, FinclipApiCallback callback, void *input); diff --git a/src/finclip_api.h b/src/finclip_api.h deleted file mode 100644 index 0483da6..0000000 --- a/src/finclip_api.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef WRAPPER_SRC_PUBLIC_FINCLIP_API_H_ -#define WRAPPER_SRC_PUBLIC_FINCLIP_API_H_ - -#include "finclip_api_const.h" - -#ifdef __cplusplus -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct IKnown IKnown; -typedef struct IResultSet IResultSet; -typedef struct IEvent IEvent; -typedef struct IFinPacker IFinPacker; -typedef struct FinclipParams FinclipParams; -typedef struct IFinConfigPacker IFinConfigPacker; -typedef struct IPackerFactory IPackerFactory; -typedef struct FinclipCallback FinclipCallback; -typedef void (*FinClipSDKCallback)(IEvent*); - -/** - * @brief SDK初始化 - */ -DLL_EXPORT int FINSTDMETHODCALLTYPE -finclip_initialize(IFinConfigPacker* configpacker); - -/** - * @brief 获取配置工厂 - */ -DLL_EXPORT IPackerFactory* FINSTDMETHODCALLTYPE finclip_get_packer_factory(); - -/** - * @brief 启动 - */ -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_start_applet(const char* appstore, - const char* appid); -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_start_applet_params( - const char* appstore, const char* appid, void* params); -/** - * @brief 关闭所有小程序 - */ -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_close_all_applet(); - -/** - * @brief 根据appid关闭小程序 - */ -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_close_applet(const char* appid); - -/** - * @brief 设置小程序窗口位置 - * - */ -DLL_EXPORT void FINSTDMETHODCALLTYPE finclip_set_position(const char* appid, - int left, int top, - int width, - int height); - -/** - * @brief - */ -DLL_EXPORT IFinConfigPacker* FINSTDMETHODCALLTYPE -finclip_packer_factory_get_config_packer(IPackerFactory* factory); - -/** - * @brief 新建配置 - */ -DLL_EXPORT FinclipParams* FINSTDMETHODCALLTYPE -finclip_config_packer_new_config(IFinConfigPacker* packer); - -/** - * @brief 获取配置, 如果获取失败, 则返回NULL - */ -DLL_EXPORT FinclipParams* FINSTDMETHODCALLTYPE -finclip_config_packer_get_config(IFinConfigPacker* packer, char* appstore); - -/** - * @brief 增加配置 - */ -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_config_packer_add_config( - IFinConfigPacker* packer, FinclipParams* config); - -/** - * @brief 注册自定义api, 供小程序或h5调用 - * @param packer - * @param type 类型, 区分h5与小程序 - * @param apis api名称 - * @param handle 处理函数 - * @param input 自定义参数, 透传给handle - */ -DLL_EXPORT void FINSTDMETHODCALLTYPE -finclip_register_api(IFinConfigPacker* packer, FinClipApiType type, - const char* apis, FinclipApiHandle handle, void* input); - -/** - * @brief 创建启动参数 - */ -DLL_EXPORT FinclipParams* FINSTDMETHODCALLTYPE finclip_create_params(); - -/** - * @brief 销毁启动参数 - */ -DLL_EXPORT void FINSTDMETHODCALLTYPE -finclip_destory_params(FinclipParams* params); - -/** - * @brief 设置启动参数 - */ -DLL_EXPORT void FINSTDMETHODCALLTYPE finclip_params_set(FinclipParams* params, - const char* key, - const char* value); -/** - * @brief 根据key删除启动启动参数 - */ -DLL_EXPORT void FINSTDMETHODCALLTYPE finclip_params_del(FinclipParams* params, - const char* key); - -#ifdef _WIN32 -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_embed_applet(const char* appstore, - const char* appid, - HWND container); -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_start_applet_embed( - const char* appstore, const char* appid, void* params, HWND container); -#endif - -/** - * @brief 调用h5中的自定义api, 小程序不支持自定义api - */ -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_invoke_api( - FinClipApiType type, const char* app_id, const char* api_name, - const char* params, FinclipApiCallback callback, void* input); - -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_batch_app_info( - const char* app_id, const char* req_list, FinclipApiCallback callback); - -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_search_app( - const char* app_id, const char* search_text, FinclipApiCallback callback); - -/** - * @brief 回调函数设置返回值 - */ -DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_callback_res(const char* app_id, - int callback_id, - void* result); -#ifdef __cplusplus -} -#endif - -#endif /* WRAPPER_SRC_PUBLIC_FINCLIP_API_H_ */ diff --git a/src/finclip_api_const.h b/src/finclip_api_const.h deleted file mode 100644 index 9f4c37a..0000000 --- a/src/finclip_api_const.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef WRAPPER_SRC_PUBLIC_FINCLIP_API_CONST_H_ -#define WRAPPER_SRC_PUBLIC_FINCLIP_API_CONST_H_ - -#define FIN_SID const char* -#define FIN_OK 0 -#define FIN_FAIL 1 - -#ifdef _WIN32 -#include -#define FINCLIP_WINDOW_HANDLE HWND -#elif defined __linux__ -#include -#define FINCLIP_WINDOW_HANDLE GtkWindow* -#elif defined __APPLE__ -typedef struct objc_object* FINCLIP_WINDOW_HANDLE; -#endif - -#ifdef _WIN32 -#ifndef FINSTDMETHODCALLTYPE -#define FINSTDMETHODCALLTYPE __stdcall -#define DLL_EXPORT _declspec(dllexport) -#endif -#else -#define FINSTDMETHODCALLTYPE -#define DLL_EXPORT -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -// Config: 小程序框架的配置信息 -#define FINCLIP_CONFIG_APPSTORE "appstore" -// appkey, secret, domain 从管理后台获取, 必填 -#define FINCLIP_CONFIG_APPKEY "appkey" -#define FINCLIP_CONFIG_SECRET "secret" -#define FINCLIP_CONFIG_DOMAIN "domain" -// windows: finclip.exe位置, 默认为 ./finclip, 即当前目录下的finclip文件夹 -// macos: finclip.app的位置, 默认为 -#define FINCLIP_CONFIG_EXE_PATH "exe_path" - -// Params: 每个小程序独立设置, 0: 独立模式, 1: 嵌入模式 -// 注意, 嵌入模式目前仅支持windows, 且必须调用finclip_embed_applet, 完成嵌入. -#define FINCLIP_UI_CONFIG_WINDOW_TYPE "window_type" -// 是否展示loading动画, 1: 展示, 0: 不展示 -#define FINCLIP_UI_CONFIG_SHOW_LOADING "show_loading" -// 标题栏更多菜单设置, hidden: 隐藏, normal: 显示 -#define FINCLIP_UI_CONFIG_TITLE_BAR_MORE_BUTTON "title_bar_more_button" -// 初始窗口高度 -#define FINCLIP_UI_CONFIG_WINDOW_HEIGHT "window_height" -// 初始窗口宽度 -#define FINCLIP_UI_CONFIG_WINDOW_WIDTH "window_width" - -// 小程序首屏路径 -#define FINCLIP_PARAMS_PAGE_PATH "page_path" -// 传给小程序的启动参数 -#define FINCLIP_PARAMS_START_PARAMS "start_params" - -/** - * @brief 启动机制设置 - * kAsync: 异步启动 - * kBaseLibrarySync: 基础库同步加载 - * kAppletSync: 小程序同步加载 - */ -enum StartFlags { - kAsync = 0, - kBaseLibrarySync = 1 << 0, - kAppletSync = 1 << 1, -}; - -/** - * @brief 自定义API类型,分别用于小程序和jssdk - * - */ -typedef enum { kApplet, kWebView } FinClipApiType; -/** - * @brief 调用h5方法后的返回值回调 - * - */ -typedef void (*FinclipApiCallback)(const char* res, void* input); - -/** - * @brief 自定义api - * - */ -typedef void (*FinclipApiHandle)(const char* event, const char* param, - void* input, int callbackid); - -#ifdef __cplusplus -} -#endif -#endif /* WRAPPER_SRC_PUBLIC_FINCLIP_API_CONST_H_ */