├── vendor ├── mac │ └── .gitignore ├── win │ └── .gitignore └── linux │ └── .gitignore ├── examples ├── qt │ ├── .gitignore │ ├── README.md │ ├── src │ │ └── main.cc │ └── CMakeLists.txt ├── win32 │ ├── .gitignore │ ├── finclip_cpp.cpp │ ├── finclip_cpp.vcxproj.filters │ ├── finclip_cpp.sln │ └── finclip_cpp.vcxproj ├── qmake │ ├── .gitignore │ ├── demo │ │ ├── main.cpp │ │ ├── finclip-qt-demo.h │ │ ├── .gitignore │ │ ├── demo.pro │ │ └── finclip-qt-demo.cpp │ └── README.md ├── csharp │ └── WpfApp │ │ ├── WpfApp │ │ ├── .gitignore │ │ ├── WpfApp.csproj │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── MainWindow.xaml │ │ ├── AssemblyInfo.cs │ │ └── MainWindow.xaml.cs │ │ └── WpfApp.sln ├── pyqt │ ├── README.md │ └── main.py ├── rust │ ├── .gitignore │ ├── start.sh │ ├── build_mac.sh │ ├── build.rs │ ├── Cargo.toml │ ├── Cargo.lock │ └── src │ │ ├── finclip.rs │ │ └── main.rs ├── electron │ ├── src │ │ ├── mainPreload.js │ │ ├── mainScript.js │ │ ├── main.js │ │ └── finclip.js │ ├── package.json │ ├── README.md │ └── view │ │ └── index.html ├── README.md └── gtk │ ├── CMakeLists.txt │ └── main.c ├── doc ├── images │ ├── 450.gif │ └── demo_readme2.png └── integration.md ├── .github └── workflows │ ├── issue.yml │ └── pull_request.yml ├── README.md └── .gitignore /vendor/mac/.gitignore: -------------------------------------------------------------------------------- 1 | */ -------------------------------------------------------------------------------- /vendor/win/.gitignore: -------------------------------------------------------------------------------- 1 | */ -------------------------------------------------------------------------------- /examples/qt/.gitignore: -------------------------------------------------------------------------------- 1 | build/ -------------------------------------------------------------------------------- /examples/win32/.gitignore: -------------------------------------------------------------------------------- 1 | x64 -------------------------------------------------------------------------------- /vendor/linux/.gitignore: -------------------------------------------------------------------------------- 1 | */ -------------------------------------------------------------------------------- /examples/qmake/.gitignore: -------------------------------------------------------------------------------- 1 | build-demo* -------------------------------------------------------------------------------- /examples/csharp/WpfApp/WpfApp/.gitignore: -------------------------------------------------------------------------------- 1 | Properties/ -------------------------------------------------------------------------------- /examples/pyqt/README.md: -------------------------------------------------------------------------------- 1 | # 下载base包 2 | 3 | 4 | # 下载python包 5 | 6 | # demo接受 -------------------------------------------------------------------------------- /examples/rust/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | config.json 3 | libFinClipSDKWrapper.so -------------------------------------------------------------------------------- /examples/rust/start.sh: -------------------------------------------------------------------------------- 1 | DIR=`cd $(dirname $0); pwd -P` 2 | cd $DIR 3 | ./target/debug/rustdemo -------------------------------------------------------------------------------- /doc/images/450.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finogeeks/finclip-desktop-demo/HEAD/doc/images/450.gif -------------------------------------------------------------------------------- /doc/images/demo_readme2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finogeeks/finclip-desktop-demo/HEAD/doc/images/demo_readme2.png -------------------------------------------------------------------------------- /examples/rust/build_mac.sh: -------------------------------------------------------------------------------- 1 | DIR=`cd $(dirname $0); pwd -P` 2 | cd $DIR 3 | cargo build 4 | install_name_tool -add_rpath ${DIR} target/debug/rustdemo -------------------------------------------------------------------------------- /examples/rust/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("cargo:rustc-link-lib=dylib=FinClipSDKWrapper"); 3 | println!("cargo:rustc-link-search=native=/path/to/libFinClipSDKWrapper.so"); 4 | // println!("cargo:rustc-link-search=native=."); 5 | } 6 | -------------------------------------------------------------------------------- /examples/qmake/demo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "finclip-qt-demo.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | 9 | FinclipQtDemo w; 10 | w.show(); 11 | return a.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /examples/csharp/WpfApp/WpfApp/WpfApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | netcoreapp3.1 6 | true 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/qmake/README.md: -------------------------------------------------------------------------------- 1 | # 通用步骤与功能介绍 2 | 3 | 快速开始前请先阅读以下文档 4 | 5 | [Finclip桌面版Demo集成指引与功能介绍](https://github.com/finogeeks/finclip-desktop-demo/tree/master/examples/README.md) 6 | 7 | 8 | # 快速开始 9 | 10 | 1. 使用qt creator打开 demo文件夹 11 | 2. 点击运行, 即可打开 12 | 13 | 14 | # 注意事项 15 | 16 | 1. 下载路径请不要有中文, 否则会有奇怪的问题 17 | 2. 集成时将finclip存放至独立的位置, 避免dll冲突 -------------------------------------------------------------------------------- /examples/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustdemo" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | anyhow = "1.0" 10 | serde = { version = "1.0.80", features = ["derive"] } 11 | serde_derive = "^1.0.59" 12 | serde_json = "1.0.0" -------------------------------------------------------------------------------- /examples/electron/src/mainPreload.js: -------------------------------------------------------------------------------- 1 | const { contextBridge, ipcRenderer } = require('electron'); 2 | 3 | contextBridge.exposeInMainWorld( 4 | 'finclip', 5 | { 6 | open: (payload) => ipcRenderer.send('OPEN_FINCLIP_WINDOW', payload), 7 | embed: (payload) => ipcRenderer.send('EMBED_FINCLIP_WINDOW', payload), 8 | close: () => ipcRenderer.send('CLOSE_FINCLIP_WINDOW'), 9 | } 10 | ) -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # 集成步骤 2 | 3 | ## 第一步: 📦 下载依赖 4 | 5 | 选择对应的release包, 并解压至指定位置 6 | ``` 7 | 以win x64为例: 8 | [下载finclip二进制包](https://www.finclip.com/downloads/)到`vendor`的对应目录下,如`vendor/win/x64`并解压 9 | ``` 10 | 11 | 12 | # 基本功能介绍 13 | 14 | 此处展示各种语言集成finclip的demo, 每个demo应完整的包含以下功能: 15 | 16 | - 启动finclip 17 | - 启动参数的设置 18 | - 启动回调 19 | - 设置窗口位置 20 | - 自定义api 21 | - 宿主 -> 小程序 22 | - 宿主 -> h5 23 | - h5 -> 宿主 -------------------------------------------------------------------------------- /examples/csharp/WpfApp/WpfApp/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/qmake/demo/finclip-qt-demo.h: -------------------------------------------------------------------------------- 1 | #ifndef FINCLIPQTDEMO_H 2 | #define FINCLIPQTDEMO_H 3 | 4 | #include 5 | #include "finclip_api.h" 6 | 7 | class FinclipQtDemo : public QMainWindow 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | FinclipQtDemo(QWidget *parent = nullptr); 13 | ~FinclipQtDemo(); 14 | private: 15 | void resizeEvent(QResizeEvent* event); 16 | }; 17 | #endif // FINCLIPQTDEMO_H 18 | -------------------------------------------------------------------------------- /examples/csharp/WpfApp/WpfApp/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WpfApp 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/electron/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "finclip-electron-demo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "./src/main.js", 6 | "scripts": { 7 | "start": "npx electron ./src/main.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "electron": "^22.3.27", 14 | "koffi": "^2.14.1" 15 | } 16 | } -------------------------------------------------------------------------------- /.github/workflows/issue.yml: -------------------------------------------------------------------------------- 1 | name: Notify 2 | on: 3 | issues: 4 | types: [opened] 5 | issue_comment: 6 | types: [created] 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Notify 13 | run: curl --location --request POST 'https://api.finogeeks.club/api/v1/finstore/webhooks/61b331d79b3dad0001f72fa2/postreceive?nonce=jhd2QyrArsc' --header "Content-Type:application/json" --data-raw '{"msg":"仓库 ${{github.repository}} 有新的 issue"}' 14 | -------------------------------------------------------------------------------- /.github/workflows/pull_request.yml: -------------------------------------------------------------------------------- 1 | name: Notify 2 | on: 3 | pull_request: 4 | branches: [ master ] 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - name: Notify 11 | run: curl --location --request POST 'https://api.finogeeks.club/api/v1/finstore/webhooks/61b331d79b3dad0001f72fa2/postreceive?nonce=jhd2QyrArsc' --header "Content-Type:application/json" --data-raw '{"msg":"仓库 ${{github.repository}} 有新的 PR ${{ github.event.pull_request._links.html.href }}"}' 12 | -------------------------------------------------------------------------------- /examples/csharp/WpfApp/WpfApp/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/csharp/WpfApp/WpfApp/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /doc/integration.md: -------------------------------------------------------------------------------- 1 | # Finclip SDK的总体架构 2 | ```mermaid 3 | flowchart LR 4 | electron --> npm 5 | C++ --> cpp 6 | pyqt ---> pip 7 | subgraph 应用 8 | pyqt 9 | electron 10 | C++ 11 | end 12 | pip --> cpp 13 | npm --> cpp 14 | subgraph SDK 15 | npm 16 | pip 17 | cpp(c api) 18 | end 19 | SDK <--> 小程序进程 20 | 21 | subgraph 小程序进程 22 | end 23 | ``` 24 | 25 | 如上图所示, Finclip SDK 的核心由 C++ 实现, 对外提供 C api, 对于部分语言, 我们根据实际情况提供了额外的库, 如 pyqt, electron 等. 26 | 对于无法直接调用C api的语言, 也可以使用dlopen等手段集成 27 | 28 | # 集成步骤 29 | 30 | 1. 下载release包, 参考demo, 解压至相应的目录 31 | 2. 根据实际情况下载语言库和头文件, 参考demo, 解压至相应的目录 32 | 3. 根据demo和实际情况, 完成集成 33 | 34 | # demo位置 35 | 36 | 参见首页表格 37 | 38 | https://github.com/finogeeks/finclip-desktop-demo -------------------------------------------------------------------------------- /examples/electron/src/mainScript.js: -------------------------------------------------------------------------------- 1 | window.openFinClipWindow = () => { 2 | const domain = document.getElementById('domain').value; 3 | const appkey = document.getElementById('appkey').value; 4 | const appid = document.getElementById('appid').value; 5 | const secret = document.getElementById('secret').value; 6 | finclip.open({ 7 | domain, appkey, appid, secret, 8 | }); 9 | }; 10 | 11 | window.openEmbedFinClipWindow = () => { 12 | const domain = document.getElementById('domain').value; 13 | const appkey = document.getElementById('appkey').value; 14 | const appid = document.getElementById('appid').value; 15 | const secret = document.getElementById('secret').value; 16 | finclip.embed({ 17 | domain, appkey, appid, secret, 18 | }); 19 | }; 20 | 21 | window.closeFinClipWindow = () => { 22 | finclip.close(); 23 | }; 24 | -------------------------------------------------------------------------------- /examples/win32/finclip_cpp.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "finclip_api.h" 3 | #include "finclip_api_const.h" 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | const string appkey = ""; 10 | const string secret = ""; 11 | const string domain = ""; 12 | const string appid = ""; 13 | const string exe_path = ""; 14 | const string app_store = "1"; 15 | 16 | std::cout << "Hello FinClip!\n"; 17 | 18 | FinclipParams *config = finclip_create_params(); 19 | finclip_params_set(config, FINCLIP_CONFIG_APPKEY, appkey.c_str()); 20 | finclip_params_set(config, FINCLIP_CONFIG_SECRET, secret.c_str()); 21 | finclip_params_set(config, FINCLIP_CONFIG_DOMAIN, domain.c_str()); 22 | finclip_params_set(config, FINCLIP_CONFIG_EXE_PATH, exe_path.c_str()); 23 | 24 | finclip_init_with_config(app_store.c_str(), config); 25 | finclip_start_applet(app_store.c_str(), appid.c_str()); 26 | 27 | std::cin.get(); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /examples/gtk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_COMPILER gcc) 2 | project(FinClipGTK C) 3 | 4 | # Use the package PkgConfig to detect GTK+ headers/library files 5 | find_package(PkgConfig REQUIRED) 6 | pkg_check_modules(GTK REQUIRED gtk+-3.0) 7 | 8 | set(FINCLIP_GTK_DEMO "FinClipGTK") 9 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<$:>) 10 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<$:>) 11 | 12 | # Add other flags to the compiler 13 | add_definitions(${GTK_CFLAGS_OTHER}) 14 | add_executable(${FINCLIP_GTK_DEMO} main.c) 15 | target_include_directories(${FINCLIP_GTK_DEMO} PRIVATE ${GTK_INCLUDE_DIRS}) 16 | target_include_directories(${FINCLIP_GTK_DEMO} PRIVATE FinClipSDKWrapper) 17 | add_dependencies(${FINCLIP_GTK_DEMO} FinClipSDKWrapper) 18 | target_link_libraries(${FINCLIP_GTK_DEMO} FinClipSDKWrapper ${GTK_LIBRARIES}) 19 | 20 | set(OUTPUT_FILE FinClipGTK) 21 | copy_files("${FINCLIP_GTK_DEMO}" "${OUTPUT_FILE}" "${CMAKE_BINARY_DIR}" "${CMAKE_BINARY_DIR}/core/$") 22 | -------------------------------------------------------------------------------- /examples/win32/finclip_cpp.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/qmake/demo/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /examples/electron/README.md: -------------------------------------------------------------------------------- 1 | # finclip-electron-demo 2 | 3 | ## 通用步骤与功能介绍 4 | 5 | 快速开始前请先阅读以下链接 6 | 7 | [Finclip桌面版Demo集成指引与功能介绍](https://github.com/finogeeks/finclip-desktop-demo/tree/master/examples/README.md) 8 | 9 | ## 快速开始 10 | 11 | ``` 12 | npm i 13 | npm run start 14 | ``` 15 | 16 | ## 调用finclip api 17 | 18 | 1. 引入finclip依赖包 19 | 20 | 注意,只能在electron的主进程使用 21 | 22 | ``` 23 | const finclip = require('finclip'); 24 | ``` 25 | 26 | 2. 设置启动参数 27 | 28 | ``` 29 | finclip.setDomain('xxx'); 30 | finclip.setAppkey('xxx'); 31 | finclip.setAppid('xxx'); 32 | finclip.setSecret('xxx'); 33 | ``` 34 | 35 | 3. 打开finclip窗口 36 | 37 | finclipPath为finclip.exe所在位置,需转换成绝对路径 38 | ``` 39 | finclip.start({ 40 | handle: 0, 41 | finclipPath, 42 | }); 43 | ``` 44 | 45 | 4. 关闭finclip窗口 46 | 47 | ``` 48 | finclip.close(); 49 | ``` 50 | 51 | 5. 设置finclip窗口的位置和大小 52 | 53 | ``` 54 | finclip.setPosition({ width: 800, height: 800, left: 0, top: 0 }); 55 | ``` 56 | 57 | ## 修改finclip依赖包 58 | 59 | 如果默认的finclip包无法满足需求,可以在此项目的`src/npm`下修改并编译,需要先配置C++环境 -------------------------------------------------------------------------------- /examples/qmake/demo/demo.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++11 6 | 7 | # You can make your code fail to compile if it uses deprecated APIs. 8 | # In order to do so, uncomment the following line. 9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 10 | 11 | SOURCES += \ 12 | main.cpp \ 13 | finclip-qt-demo.cpp 14 | 15 | HEADERS += \ 16 | finclip-qt-demo.h 17 | 18 | # Default rules for deployment. 19 | qnx: target.path = /tmp/$${TARGET}/bin 20 | else: unix:!android: target.path = /opt/$${TARGET}/bin 21 | !isEmpty(target.path): INSTALLS += target 22 | 23 | win32 { 24 | contains(QMAKE_TARGET.arch, x86_64) { 25 | message("x86_64 build") 26 | ## Windows x64 (64bit) specific build here 27 | LIBS += "../../../vendor/win/x64/FinClipSDKWrapper.lib" 28 | INCLUDEPATH += "../../../vendor/win/x64" 29 | QMAKE_POST_LINK=xcopy ../../../vendor/win/x64 . /E 30 | } else { 31 | message("x86 build") 32 | ## Windows x86 (32bit) specific build here 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /examples/csharp/WpfApp/WpfApp.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32901.215 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfApp", "WpfApp\WpfApp.csproj", "{B3B7E57C-2CD0-4000-AC40-93FDDDF86CC5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B3B7E57C-2CD0-4000-AC40-93FDDDF86CC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {B3B7E57C-2CD0-4000-AC40-93FDDDF86CC5}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {B3B7E57C-2CD0-4000-AC40-93FDDDF86CC5}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {B3B7E57C-2CD0-4000-AC40-93FDDDF86CC5}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {AA2E9BFB-BA0A-4228-ABA5-8ED86B80DDDA} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /examples/qmake/demo/finclip-qt-demo.cpp: -------------------------------------------------------------------------------- 1 | #include "finclip-qt-demo.h" 2 | #include 3 | 4 | std::string appid = ""; 5 | FinclipQtDemo::FinclipQtDemo(QWidget *parent) 6 | : QMainWindow(parent) 7 | { 8 | this->show(); 9 | std::string appkey = ""; 10 | std::string secret = ""; 11 | std::string domain = ""; 12 | 13 | std::string app_store = "1"; 14 | 15 | FinclipParams *config = finclip_create_params(); 16 | finclip_params_set(config, FINCLIP_CONFIG_APPSTORE, "1"); 17 | finclip_params_set(config, FINCLIP_CONFIG_APPKEY, appkey.c_str()); 18 | finclip_params_set(config, FINCLIP_CONFIG_SECRET, secret.c_str()); 19 | finclip_params_set(config, FINCLIP_CONFIG_DOMAIN, domain.c_str()); 20 | finclip_init_with_config(app_store, config); 21 | 22 | auto* params = finclip_create_params(); 23 | finclip_params_set(params, "window_type", "1"); 24 | finclip_start_applet_embed(app_store.c_str(), appid.c_str(),params, (HWND)this->effectiveWinId()); 25 | } 26 | 27 | void FinclipQtDemo::resizeEvent(QResizeEvent* event) 28 | { 29 | QMainWindow::resizeEvent(event); 30 | 31 | finclip_set_position(appid.c_str(), 0, 0, event->size().height(),event->size().width() ); 32 | 33 | } 34 | 35 | FinclipQtDemo::~FinclipQtDemo() 36 | { 37 | } 38 | 39 | -------------------------------------------------------------------------------- /examples/electron/view/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 启动参数 9 |
10 |
11 |
appkey
12 | 13 |
14 |
15 |
secret
16 | 17 |
18 |
19 |
domain
20 | 21 |
22 |
23 |
appid
24 | 25 |
26 | 27 |
28 |
29 | 30 | 31 | 32 |
33 | 34 | 35 | 56 | 57 | -------------------------------------------------------------------------------- /examples/qt/README.md: -------------------------------------------------------------------------------- 1 | # FinClipQtDemo is a cross-platform C++ project based on CMake. 2 | 3 | # 总体思路介绍 4 | 1. 在编译机搭建好环境后, 首先下载 FinClip DeskTop SDK并解压后. 解压路径就是CMakeLists.txt中的FINCLIP_SDK_PATH 5 | 2. 不同系统编译所依赖的文件略有差异 6 | - windows 需要 头文件, .dll, .lib 7 | - Linux / Mac 需要 头文件, .so 8 | 3. 创建一个 cmake library, finclip_wrapper, 不同系统分别设置相关属性, CMakeLists.txt 中包含了编译通过的最少属性 9 | 10 | # demo 使用方法 11 | 12 | ## 1. 下载 FinClip DeskTop SDK 13 | 14 | [下载finclip二进制包](https://www.finclip.com/downloads/)到`vendor`的对应目录下,如`vendor/win/x86_64`并解压 15 | 16 | 17 | ## 2. 生成cmake 构建目录 18 | 19 | 下面以 mac 为例 20 | 需要注意指定目标架构 PROJECT_ARCH 21 | 22 | - windows支持: x86_64, x86 23 | - linux支持: x86_64, arm64 24 | - mac支持: x86_64, arm64 25 | 26 | 具体以 CMakeLists.txt 为准 27 | ```shell 28 | mkdir build 29 | cd build 30 | # 生成 x86_64 位的build 31 | cmake .. -DPROJECT_ARCH=x86_64 32 | ``` 33 | 34 | ## 3. 填写参数 35 | 36 | 准备好[从管理后台获取的参数](https://www.finclip.com/mop/document/introduce/functionDescription/application-management.html#_1-%E5%8A%9F%E8%83%BD%E4%BB%8B%E7%BB%8D) 37 | 38 | ```C 39 | // 修改main.cc中的以下变量: 40 | const string appkey = ""; 41 | const string secret = ""; 42 | const string domain = ""; 43 | const string appid = ""; 44 | ``` 45 | 46 | 设置exe_path 47 | ```C 48 | // windows 49 | const string exe_path = "path/to/FinClip.exe"; 50 | 51 | // Linux 52 | const string exe_path = "path/to/FinClip"; 53 | 54 | // Macos 55 | const string exe_path = "path/to/FinClip.app"; 56 | ``` 57 | 58 | ## 4. 编译项目并启动 59 | 60 | 下面以 mac 为例 61 | 62 | ```shell 63 | cd build 64 | make 65 | ./FinClipQtDemo 66 | ``` -------------------------------------------------------------------------------- /examples/win32/finclip_cpp.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32825.248 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "finclip_cpp", "finclip_cpp.vcxproj", "{61D67564-438E-4D8D-8A8F-0DC63C6E470C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {61D67564-438E-4D8D-8A8F-0DC63C6E470C}.Debug|x64.ActiveCfg = Debug|x64 17 | {61D67564-438E-4D8D-8A8F-0DC63C6E470C}.Debug|x64.Build.0 = Debug|x64 18 | {61D67564-438E-4D8D-8A8F-0DC63C6E470C}.Debug|x86.ActiveCfg = Debug|Win32 19 | {61D67564-438E-4D8D-8A8F-0DC63C6E470C}.Debug|x86.Build.0 = Debug|Win32 20 | {61D67564-438E-4D8D-8A8F-0DC63C6E470C}.Release|x64.ActiveCfg = Release|x64 21 | {61D67564-438E-4D8D-8A8F-0DC63C6E470C}.Release|x64.Build.0 = Release|x64 22 | {61D67564-438E-4D8D-8A8F-0DC63C6E470C}.Release|x86.ActiveCfg = Release|Win32 23 | {61D67564-438E-4D8D-8A8F-0DC63C6E470C}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {ED8A0396-6E77-40AA-B40B-B4A579333645} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /examples/csharp/WpfApp/WpfApp/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.DirectoryServices.ActiveDirectory; 4 | using System.Linq; 5 | using System.Net.Sockets; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | using System.Windows.Data; 12 | using System.Windows.Documents; 13 | using System.Windows.Input; 14 | using System.Windows.Media; 15 | using System.Windows.Media.Imaging; 16 | using System.Windows.Navigation; 17 | using System.Windows.Shapes; 18 | 19 | namespace WpfApp 20 | { 21 | 22 | /// 23 | /// Interaction logic for MainWindow.xaml 24 | /// 25 | public partial class MainWindow : Window 26 | { 27 | [DllImport("FinClipSDKWrapper.dll", SetLastError = true)] 28 | public static extern IntPtr finclip_create_params(); 29 | [DllImport("FinClipSDKWrapper.dll", SetLastError = true)] 30 | public static extern Boolean finclip_params_set(IntPtr p, [MarshalAs(UnmanagedType.LPUTF8Str)] string a, [MarshalAs(UnmanagedType.LPUTF8Str)] string b); 31 | [DllImport("FinClipSDKWrapper.dll", SetLastError = true)] 32 | public static extern Int32 finclip_init_with_config([MarshalAs(UnmanagedType.LPUTF8Str)] string a, IntPtr config); 33 | [DllImport("FinClipSDKWrapper.dll", SetLastError = true)] 34 | public static extern Int32 finclip_start_applet([MarshalAs(UnmanagedType.LPUTF8Str)] string app_store, [MarshalAs(UnmanagedType.LPUTF8Str)] string appid); 35 | private string DOMAIN = ""; 36 | private string APP_KEY = ""; 37 | private string SECRET = ""; 38 | private string APPID = ""; 39 | private string appstore = "test"; 40 | 41 | private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) 42 | { 43 | int res = finclip_start_applet(appstore, APPID); 44 | } 45 | public MainWindow() 46 | { 47 | IntPtr config = finclip_create_params(); 48 | finclip_params_set(config, "appkey", APP_KEY); 49 | finclip_params_set(config, "secret", SECRET); 50 | finclip_params_set(config, "domain", DOMAIN); 51 | // 下载sdk后, 将working dir 设置到FinClipSDKWrapper.dll所在的文件夹 52 | // 这样相对路径才可以生效, 如果有所改动, 请自行调整参数 53 | finclip_params_set(config, "exe_path", "finclip/FinClip.exe"); 54 | 55 | finclip_init_with_config(appstore, config); 56 | InitializeComponent(); 57 | Loaded += OnLoaded; 58 | this.Title = "FinClip Desktop Demo"; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /examples/rust/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "anyhow" 7 | version = "1.0.58" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" 10 | 11 | [[package]] 12 | name = "itoa" 13 | version = "1.0.2" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" 16 | 17 | [[package]] 18 | name = "proc-macro2" 19 | version = "1.0.40" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" 22 | dependencies = [ 23 | "unicode-ident", 24 | ] 25 | 26 | [[package]] 27 | name = "quote" 28 | version = "1.0.20" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" 31 | dependencies = [ 32 | "proc-macro2", 33 | ] 34 | 35 | [[package]] 36 | name = "rustdemo" 37 | version = "0.1.0" 38 | dependencies = [ 39 | "anyhow", 40 | "serde", 41 | "serde_derive", 42 | "serde_json", 43 | ] 44 | 45 | [[package]] 46 | name = "ryu" 47 | version = "1.0.10" 48 | source = "registry+https://github.com/rust-lang/crates.io-index" 49 | checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" 50 | 51 | [[package]] 52 | name = "serde" 53 | version = "1.0.138" 54 | source = "registry+https://github.com/rust-lang/crates.io-index" 55 | checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47" 56 | dependencies = [ 57 | "serde_derive", 58 | ] 59 | 60 | [[package]] 61 | name = "serde_derive" 62 | version = "1.0.138" 63 | source = "registry+https://github.com/rust-lang/crates.io-index" 64 | checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c" 65 | dependencies = [ 66 | "proc-macro2", 67 | "quote", 68 | "syn", 69 | ] 70 | 71 | [[package]] 72 | name = "serde_json" 73 | version = "1.0.82" 74 | source = "registry+https://github.com/rust-lang/crates.io-index" 75 | checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" 76 | dependencies = [ 77 | "itoa", 78 | "ryu", 79 | "serde", 80 | ] 81 | 82 | [[package]] 83 | name = "syn" 84 | version = "1.0.98" 85 | source = "registry+https://github.com/rust-lang/crates.io-index" 86 | checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" 87 | dependencies = [ 88 | "proc-macro2", 89 | "quote", 90 | "unicode-ident", 91 | ] 92 | 93 | [[package]] 94 | name = "unicode-ident" 95 | version = "1.0.1" 96 | source = "registry+https://github.com/rust-lang/crates.io-index" 97 | checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" 98 | -------------------------------------------------------------------------------- /examples/qt/src/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "finclip_api.h" 11 | #include "finclip_api_const.h" 12 | 13 | using namespace std; 14 | #define CHECK_RESULT(func) \ 15 | do { \ 16 | int result = func; \ 17 | if (result == 0) { \ 18 | std::cout << "Result is 0" << std::endl; \ 19 | } else { \ 20 | std::cout << "Result is not 0" << std::endl; \ 21 | } \ 22 | } while (0) 23 | #define ASSERT_RESULT(result) \ 24 | do { \ 25 | if (result != 0) std::cout << "Result is " << result << std::endl; \ 26 | assert(result == 0); \ 27 | } while (0) 28 | void fc_lifecycle_close(enum LifecycleType type, const char* appid, 29 | void* input) { 30 | _Exit(0); 31 | } 32 | void fc_lifecycle_crash(enum LifecycleType type, const char* appid, 33 | void* input) { 34 | _Exit(0); 35 | } 36 | 37 | void example_api(const char* event, const char* param, void* input, 38 | int callbackid, const char* appid) { 39 | auto* params = finclip_create_params(); 40 | // YOUR CODE HERE 41 | finclip_callback_success(callbackid, params); 42 | finclip_destory_params(params); 43 | } 44 | 45 | int main(int argc, char* argv[]) { 46 | const QApplication app(argc, argv); 47 | const string appkey = ""; 48 | const string secret = ""; 49 | const string domain = ""; 50 | const string appid = ""; 51 | const string exe_path = ""; 52 | const string app_store = "1"; 53 | 54 | FinclipParams* config = finclip_create_params(); 55 | ASSERT_RESULT( 56 | finclip_params_set(config, FINCLIP_CONFIG_APPSTORE, app_store.c_str())); 57 | ASSERT_RESULT( 58 | finclip_params_set(config, FINCLIP_CONFIG_APPKEY, appkey.c_str())); 59 | ASSERT_RESULT( 60 | finclip_params_set(config, FINCLIP_CONFIG_SECRET, secret.c_str())); 61 | ASSERT_RESULT( 62 | finclip_params_set(config, FINCLIP_CONFIG_DOMAIN, domain.c_str())); 63 | ASSERT_RESULT( 64 | finclip_params_set(config, FINCLIP_CONFIG_EXE_PATH, exe_path.c_str())); 65 | ASSERT_RESULT(finclip_register_lifecycle(appid.c_str(), kLifecycleClosed, 66 | fc_lifecycle_close, nullptr)); 67 | ASSERT_RESULT(finclip_register_lifecycle(appid.c_str(), kLifecycleCrashed, 68 | fc_lifecycle_crash, nullptr)); 69 | finclip_register_api_v2(kApplet, "example_api", example_api, nullptr); 70 | finclip_register_api_v2(kWebView, "example_api1", example_api, nullptr); 71 | auto* params = finclip_create_params(); 72 | ASSERT_RESULT(finclip_init_with_config(app_store.c_str(), config)); 73 | 74 | ASSERT_RESULT( 75 | finclip_start_applet_params(app_store.c_str(), appid.data(), params)); 76 | 77 | app.exec(); 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /examples/qt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | project(FinClipQtDemo) 3 | 4 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 5 | 6 | set(CMAKE_CXX_STANDARD 17) 7 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_EXTENSIONS OFF) 9 | 10 | set(FINCLIP_QTDEMO_TARGET "FinClipQtDemo") 11 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") 12 | 13 | if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") 14 | # 在arm下编译x86的包需要特殊处理 15 | if(PROJECT_ARCH STREQUAL "x86_64") 16 | set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE INTERNAL "" FORCE) 17 | endif() 18 | endif() 19 | 20 | set(FINCLIP_QTDEMO_SRCS src/main.cc) 21 | 22 | add_executable(${FINCLIP_QTDEMO_TARGET} ${FINCLIP_QTDEMO_SRCS}) 23 | 24 | if(NOT DEFINED PROJECT_ARCH) 25 | set(PROJECT_ARCH ${CMAKE_SYSTEM_PROCESSOR}) 26 | endif() 27 | 28 | add_library( finclip_wrapper SHARED IMPORTED ) 29 | 30 | if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") 31 | if(PROJECT_ARCH STREQUAL "x86_64") 32 | set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/win/x86_64") 33 | set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/FinClipSDKWrapper.dll") 34 | set_target_properties(finclip_wrapper PROPERTIES IMPORTED_IMPLIB "${FINCLIP_SDK_PATH}/FinClipSDKWrapper.lib") 35 | set(Qt5_DIR "C:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5") 36 | elseif(PROJECT_ARCH STREQUAL "x86") 37 | set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/win/x86") 38 | set(Qt5_DIR "C:/Qt/5.15.2/msvc2019/lib/cmake/Qt5") 39 | else() 40 | 41 | endif() 42 | set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/FinClipSDKWrapper.dll") 43 | set_target_properties(finclip_wrapper PROPERTIES IMPORTED_IMPLIB "${FINCLIP_SDK_PATH}/FinClipSDKWrapper.lib") 44 | add_custom_command(TARGET ${FINCLIP_QTDEMO_TARGET} POST_BUILD # Adds a post-build event to MyTest 45 | COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..." 46 | "${FINCLIP_SDK_PATH}/FinClipSDKWrapper.dll" # <--this is in-file 47 | $) # <--this is out-file path 48 | elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 49 | if(PROJECT_ARCH STREQUAL "x86_64") 50 | set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/linux/x86_64") 51 | set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/libFinClipSDKWrapper.so") 52 | else() 53 | # arm64 54 | set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/linux/arm64") 55 | set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/libFinClipSDKWrapper.so") 56 | endif() 57 | elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") 58 | if(PROJECT_ARCH STREQUAL "x86_64") 59 | # intel 60 | set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/mac/intel") 61 | set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/libFinClipSDKWrapper.so") 62 | else() 63 | # arm64 64 | set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/mac/arm64") 65 | set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/libFinClipSDKWrapper.so") 66 | endif() 67 | else() 68 | message("Operating System: Unknown") 69 | endif() 70 | find_package( 71 | Qt5 72 | COMPONENTS Widgets Gui 73 | REQUIRED) 74 | target_include_directories(${FINCLIP_QTDEMO_TARGET} PRIVATE "${FINCLIP_SDK_PATH}") 75 | 76 | message(STATUS "cmake configuration is ${CMAKE_SYSTEM_NAME} ${PROJECT_ARCH} ${FINCLIP_SDK_PATH} ${Qt5_DIR}") 77 | 78 | # 79 | # include_directories(../vendor/json) 80 | 81 | target_link_libraries( 82 | ${FINCLIP_QTDEMO_TARGET} 83 | finclip_wrapper 84 | Qt5::Widgets 85 | Qt5::Gui 86 | ) 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /examples/pyqt/main.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import (QApplication, QComboBox, QDialog, 2 | QDialogButtonBox, QFormLayout, QGridLayout, QGroupBox, QHBoxLayout, 3 | QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QSpinBox, QTextEdit, 4 | QVBoxLayout) 5 | import finclip 6 | import sys 7 | import json 8 | 9 | 10 | class PythonCallback(finclip.Callback): 11 | 12 | # Define Python class 'constructor' 13 | def __init__(self): 14 | # Call C++ base class constructor 15 | finclip.Callback.__init__(self) 16 | 17 | def Run(self, event, param): 18 | print(event) 19 | print(param) 20 | return "{}" 21 | 22 | 23 | appid = "60e3c059949a5300014d0c07" 24 | 25 | callback = PythonCallback().__disown__() 26 | 27 | 28 | def start_finclip(): 29 | factory = finclip.finclip_get_packer_factory() 30 | packer = finclip.finclip_packer_factory_get_config_packer(factory) 31 | config = finclip.finclip_config_packer_new_config(packer) 32 | finclip.finclip_config_set_app_store(config, 1) 33 | finclip.finclip_config_set_app_key(config, 34 | "") 35 | finclip.finclip_config_set_secret(config, "") 36 | finclip.finclip_config_set_domain( 37 | config, "") 38 | if sys.platform == 'win32': 39 | finclip.finclip_config_set_value( 40 | config, finclip.FINCLIP_CONFIG_EXE_PATH, "") 41 | finclip.finclip_config_packer_add_config(packer, config) 42 | # callback.thisown = 0 43 | finclip.finclip_register_callback_cpp( 44 | packer, finclip.kApplet, "test", callback) 45 | finclip.finclip_register_callback_cpp( 46 | packer, finclip.kWebView, "test_webapi", PythonCallback().__disown__()) 47 | finclip.finclip_initialize(packer) 48 | finclip.finclip_start_applet(1, appid) 49 | print("---------------------------------" + str(callback.thisown)) 50 | 51 | 52 | x = { 53 | "name": "John", 54 | "age": 30, 55 | "city": "New York" 56 | } 57 | 58 | 59 | def send_webapi(): 60 | print(123) 61 | finclip.finclip_invoke_api_cpp( 62 | finclip.kWebView, appid, "test", json.dumps(x), PythonCallback().__disown__()) 63 | 64 | 65 | class Dialog(QDialog): 66 | NumGridRows = 3 67 | NumButtons = 4 68 | 69 | def __init__(self): 70 | super(Dialog, self).__init__() 71 | self.createFormGroupBox() 72 | 73 | buttonBox = QDialogButtonBox( 74 | QDialogButtonBox.Ok | QDialogButtonBox.Cancel) 75 | buttonBox.accepted.connect(self.accept) 76 | buttonBox.rejected.connect(self.reject) 77 | 78 | mainLayout = QVBoxLayout() 79 | mainLayout.addWidget(self.formGroupBox) 80 | # mainLayout.addWidget(buttonBox) 81 | self.setLayout(mainLayout) 82 | 83 | self.setWindowTitle("Form Layout - pythonspot.com") 84 | 85 | def createFormGroupBox(self): 86 | startBtn = QPushButton(self) 87 | startBtn.setText("start finclip") 88 | startBtn.clicked.connect(start_finclip) 89 | webapiBtn = QPushButton(self) 90 | webapiBtn.setText("invoke webapi") 91 | webapiBtn.clicked.connect(send_webapi) 92 | self.formGroupBox = QGroupBox("Form layout") 93 | layout = QFormLayout() 94 | layout.addRow(QLabel("Name:"), QLineEdit()) 95 | layout.addRow(QLabel("Country:"), QComboBox()) 96 | layout.addRow(QLabel("Age:"), QSpinBox()) 97 | layout.addWidget(startBtn) 98 | layout.addWidget(webapiBtn) 99 | self.formGroupBox.setLayout(layout) 100 | 101 | 102 | if __name__ == '__main__': 103 | app = QApplication(sys.argv) 104 | dialog = Dialog() 105 | sys.exit(dialog.exec_()) 106 | -------------------------------------------------------------------------------- /examples/rust/src/finclip.rs: -------------------------------------------------------------------------------- 1 | use std::os::raw::{c_char, c_int, c_void}; 2 | 3 | #[repr(C)] 4 | pub struct IPackerFactory; 5 | 6 | #[repr(C)] 7 | pub struct FinclipParams; 8 | 9 | #[repr(C)] 10 | pub struct IFinConfigPacker; 11 | 12 | pub type ApiHandler = extern "C" fn(*const c_char, *const c_char, *mut c_void, *mut c_void); 13 | pub type ApiCallback = extern "C" fn(*const c_char, *mut c_void); 14 | 15 | #[allow(improper_ctypes)] 16 | #[link(name = "FinClipSDKWrapper")] 17 | extern "C" { 18 | #[allow(dead_code)] 19 | pub fn finclip_get_packer_factory() -> *mut IPackerFactory; 20 | 21 | #[allow(dead_code)] 22 | pub fn finclip_packer_factory_get_config_packer( 23 | factory: *mut IPackerFactory, 24 | ) -> *mut IFinConfigPacker; 25 | 26 | #[allow(dead_code)] 27 | pub fn finclip_initialize(configpacker: *mut IFinConfigPacker) -> c_int; 28 | 29 | #[allow(dead_code)] 30 | pub fn finclip_create_params() -> *mut FinclipParams; 31 | 32 | #[allow(dead_code)] 33 | pub fn finclip_destory_params(params: *mut FinclipParams); 34 | 35 | #[allow(dead_code)] 36 | pub fn finclip_params_set(params: *mut FinclipParams, key: *const c_char, value: *const c_char); 37 | 38 | #[allow(dead_code)] 39 | pub fn finclip_params_del(params: *mut FinclipParams, key: *const c_char); 40 | 41 | #[allow(dead_code)] 42 | pub fn finclip_config_packer_add_config( 43 | packer: *mut IFinConfigPacker, 44 | config: *mut FinclipParams, 45 | ) -> c_int; 46 | 47 | #[allow(dead_code)] 48 | pub fn finclip_config_packer_new_config(packer: *mut IFinConfigPacker) -> *mut FinclipParams; 49 | 50 | #[allow(dead_code)] 51 | pub fn finclip_config_packer_get_config( 52 | packer: *mut IFinConfigPacker, 53 | appstore: *const c_char, 54 | ) -> *mut FinclipParams; 55 | 56 | #[allow(dead_code)] 57 | pub fn finclip_set_position( 58 | appid: *const c_char, 59 | left: c_int, 60 | top: c_int, 61 | width: c_int, 62 | height: c_int, 63 | ); 64 | 65 | #[allow(dead_code)] 66 | pub fn finclip_start_applet(appstore: *const c_char, appid: *const c_char) -> c_int; 67 | 68 | #[allow(dead_code)] 69 | pub fn finclip_register_api( 70 | packer: *mut IFinConfigPacker, 71 | typ: c_int, 72 | apis: *const c_char, 73 | handle: ApiHandler, 74 | input: *mut c_void, 75 | ); 76 | 77 | #[allow(dead_code)] 78 | pub fn finclip_invoke_api( 79 | typ: c_int, 80 | app_id: *const c_char, 81 | api_name: *const c_char, 82 | params: *const c_char, 83 | callback: ApiCallback, 84 | input: *mut c_void, 85 | ) -> c_int; 86 | 87 | #[allow(dead_code)] 88 | pub fn finclip_close_applet(appid: *const c_char) -> c_int; 89 | 90 | #[allow(dead_code)] 91 | pub fn finclip_close_all_applet() -> c_int; 92 | 93 | #[allow(dead_code)] 94 | pub fn finclip_batch_app_info( 95 | appid: *const c_char, 96 | req_list: *const c_char, 97 | callback: ApiCallback, 98 | input: *mut c_void, 99 | ) -> c_int; 100 | 101 | #[allow(dead_code)] 102 | pub fn finclip_search_app( 103 | appid: *const c_char, 104 | search_text: *const c_char, 105 | callback: ApiCallback, 106 | input: *mut c_void, 107 | ) -> c_int; 108 | 109 | #[allow(dead_code)] 110 | pub fn finclip_callback_res( 111 | appid: *const c_char, 112 | callback_id: c_int, 113 | result: *mut c_void, 114 | ) -> c_int; 115 | 116 | #[allow(dead_code)] 117 | pub fn finclip_is_applet_open(appid: *const c_char) -> bool; 118 | } 119 | 120 | #[allow(dead_code)] 121 | pub enum FinClipApiType { 122 | Applet = 0, 123 | WebView = 1, 124 | } 125 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 |

6 | 7 |

8 | FinClip Desktop DEMO
9 |

10 |

11 | 桌面版小程序 DEMO 12 |

13 | 14 |

15 | 👉 https://www.finclip.com/ 👈 16 |

17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | 32 |

33 | 34 |

35 | 36 | [官方网站](https://www.finclip.com/) | [示例小程序](https://www.finclip.com/#/market) | [开发文档](https://www.finclip.com/mop/document/) | [部署指南](https://www.finclip.com/mop/document/introduce/quickStart/cloud-server-deployment-guide.html) | [SDK 集成指南](https://www.finclip.com/mop/document/introduce/quickStart/intergration-guide.html) | [API 列表](https://www.finclip.com/mop/document/develop/api/overview.html) | [组件列表](https://www.finclip.com/mop/document/develop/component/overview.html) | [隐私承诺](https://www.finclip.com/mop/document/operate/safety.html) 37 | 38 |
39 | 40 | ----- 41 | ## 🤔 FinClip 是什么? 42 | 43 | 有没有**想过**,开发好的微信小程序能放在自己的 APP 里直接运行,只需要开发一次小程序,就能在不同的应用中打开它,是不是很不可思议? 44 | 45 | 有没有**试过**,在自己的 APP 中引入一个 SDK ,应用中不仅可以打开小程序,还能自定义小程序接口,修改小程序样式,是不是觉得更不可思议? 46 | 47 | 这就是 FinClip ,就是有这么多不可思议! 48 | 49 | ## 🖥 FinClip SDK 是什么? 50 | 开发者可以使用 FinClip SDK 在宿主 APP 中快速实现小程序的能力。一般会用于以下场景: 51 | - 宿主 APP 构建自己的应用生态,既可以面向广泛开发者,也可以定向部分开发者; 52 | - 宿主 APP 通过小程序方式对模块进行解耦,让不同模块的开发团队独立发版,灵活更新; 53 | - 宿主 APP 中部分功能使用 FinClip 小程序实现,降低开发成本,并且提升发布效率; 54 | 55 | 此外,SDK 还需要配合基础库一并使用,通过基础库提供的小程序生命周期钩子、API函数,页面 DOM创建、渲染以及事件传递等能力为用户提供更加良好的体验。 56 | 57 | ## 🤩 效果预览 58 | 59 | **本项目是 FinClip 小程序在 Win32 环境下的 DEMO 演示,您可以按照下方流程测试,验证 FinClip 小程序在 Windows 环境下的实际效果。** 60 | 61 | 先看一下运行效果~ 62 | 63 |

64 | 65 | 66 | 67 |

68 | 69 | > 我们已经提供了 DEMO 资源,您可以下载运行,以便获取对应的效果。如果您有相关商业化使用需求,也请与我们联系。 70 | 71 | ## 桌面版 SDK 支持进展 72 | 73 | 目前已支持客户使用 C, C++, C#, python, delphi, electron 集成 FinClip 桌面版 SDK, 并在 Windows / Macos / Ubuntu / UOS 中验证 74 | 75 | ## DEMO 运行与 SDK 集成说明 76 | 77 | ### 第一步: 下载对应的 base 包 78 | 根据你的系统和架构, 下载对应的 FinClip-SDK; 79 | 80 | 假如你是 Windows 32 位, 则下载 `finclip-sdk-win-x86-x.y.z.zip` , 并解压至 `vendor/win/x86` 目录下; 81 | 82 | ### 第二步: 下载语言 SDK 83 | 84 | - 对于 Python,JavaScript 编写的应用程序,我们提供了对应语言的库; 85 | - 对于 C/C++ 编写的应用程序则可以直接调用,无须集成额外支持库; 86 | 87 | ### 第三步: 运行 88 | 89 | 查看文档,在准备好相应的文件后,即可运行 FinClip DEMO; 90 | 91 | ## 查看集成文档 92 | 93 | 在demo文档中, 我们也描述了在该语言环境下, 如何集成FinClip SDK 94 | ## 🔗 常用链接 95 | 以下内容是您在 FinClip 进行开发与体验时,常见的问题与指引信息 96 | 97 | - [FinClip 官网](https://www.finclip.com/#/home) 98 | - [示例小程序](https://www.finclip.com/#/market) 99 | - [文档中心](https://www.finclip.com/mop/document/) 100 | - [SDK 部署指南](https://www.finclip.com/mop/document/introduce/quickStart/intergration-guide.html) 101 | - [小程序代码结构](https://www.finclip.com/mop/document/develop/guide/structure.html) 102 | - [iOS 集成指引](https://www.finclip.com/mop/document/runtime-sdk/ios/ios-integrate.html) 103 | - [Android 集成指引](https://www.finclip.com/mop/document/runtime-sdk/android/android-integrate.html) 104 | - [Flutter 集成指引](https://www.finclip.com/mop/document/runtime-sdk/flutter/flutter-integrate.html) 105 | 106 | ## ☎️ 联系我们 107 | 微信扫描下面二维码,关注官方公众号 **「凡泰极客」**,获取更多精彩内容。
108 | 109 | 110 | 微信扫描下面二维码,加入官方微信交流群,获取更多精彩内容。
111 | 112 | -------------------------------------------------------------------------------- /examples/electron/src/main.js: -------------------------------------------------------------------------------- 1 | const { app, BrowserWindow, ipcMain } = require("electron"); 2 | const os = require("os"); 3 | const path = require("path"); 4 | const finclip = require("./finclip"); 5 | 6 | let mainWindow = null; 7 | const appstore = "1"; 8 | 9 | const sdkState = { 10 | isInitialized: false, 11 | lastConfig: null, 12 | paths: { 13 | exe: "", 14 | dll: "", 15 | }, 16 | }; 17 | 18 | function setupPaths() { 19 | const platform = os.platform(); 20 | const vendorBase = path.resolve(__dirname, "../../../vendor"); 21 | 22 | if (platform === "win32") { 23 | sdkState.paths.exe = path.join( 24 | vendorBase, 25 | "win", 26 | "x64", 27 | "FinClip", 28 | "FinClip.exe" 29 | ); 30 | sdkState.paths.dll = path.join( 31 | vendorBase, 32 | "win", 33 | "x64", 34 | "FinClipSDKWrapper.dll" 35 | ); 36 | } else if (platform === "darwin") { 37 | sdkState.paths.exe = path.join(vendorBase, "mac", "x64", "FinClip.app"); 38 | sdkState.paths.dll = path.join( 39 | vendorBase, 40 | "mac", 41 | "x64", 42 | "libFinClipSDKWrapper.so" 43 | ); 44 | } else if (platform === "linux") { 45 | sdkState.paths.exe = path.join(vendorBase, "linux", "arm64", "FinClip"); 46 | sdkState.paths.dll = path.join( 47 | vendorBase, 48 | "linux", 49 | "arm64", 50 | "libFinClipSDKWrapper.so" 51 | ); 52 | process.env["LD_LIBRARY_PATH"] = path.join( 53 | vendorBase, 54 | "linux", 55 | "arm64", 56 | "lib" 57 | ); 58 | } 59 | } 60 | 61 | setupPaths(); 62 | finclip.load_library(sdkState.paths.dll); 63 | 64 | const createMainWindow = () => { 65 | mainWindow = new BrowserWindow({ 66 | width: 800, 67 | height: 600, 68 | autoHideMenuBar: true, 69 | webPreferences: { 70 | preload: path.join(__dirname, "mainPreload.js"), 71 | }, 72 | }); 73 | mainWindow.loadFile("../view/index.html"); 74 | }; 75 | 76 | const createParams = (arg) => { 77 | const { domain, appkey, secret } = arg; 78 | const params = finclip.finclip_create_params(); 79 | finclip.finclip_params_set(params, "preload_process_number", "0"); 80 | finclip.finclip_params_set(params, "appkey", appkey); 81 | finclip.finclip_params_set(params, "secret", secret); 82 | finclip.finclip_params_set(params, "domain", domain); 83 | finclip.finclip_params_set(params, "development_framework", "electron"); 84 | finclip.finclip_params_set(params, "exe_path", sdkState.paths.exe); 85 | return params; 86 | }; 87 | 88 | const onSdkFirstInit = () => { 89 | console.log("FinClip SDK Initializing for the first time."); 90 | // 自定义 api 91 | finclip.finclip_register_api_v2( 92 | 0, 93 | "test", 94 | async (name, params, data, id, appId) => {} 95 | ); 96 | // 代理方法注册一次即可 97 | const proxyHandler = (appid, proxy_name, inputPtr, callbackId, params) => {}; 98 | finclip.finclip_register_proxy("more_custom_menu", proxyHandler, ""); 99 | }; 100 | 101 | const initializeFinClipSDK = (arg) => { 102 | const { domain, appkey, secret } = arg; 103 | const params = createParams(arg); 104 | const newConfigSig = JSON.stringify({ domain, appkey, secret }); 105 | const oldConfigSig = JSON.stringify(sdkState.lastConfig); 106 | 107 | if (!sdkState.isInitialized || newConfigSig !== oldConfigSig) { 108 | if (!sdkState.isInitialized) { 109 | onSdkFirstInit(); 110 | } 111 | finclip.finclip_init_with_config(appstore, params); 112 | sdkState.isInitialized = true; 113 | sdkState.lastConfig = { domain, appkey, secret }; 114 | } 115 | return params; 116 | }; 117 | 118 | const openFinClipWindow = (arg) => { 119 | const { appid } = arg; 120 | 121 | initializeFinClipSDK(arg); 122 | 123 | finclip.finclip_register_lifecycle(appid, 2, () => {}, ""); 124 | 125 | finclip.finclip_start_applet(appstore, appid); 126 | }; 127 | 128 | const embedFinClipWindow = (arg) => { 129 | if (os.platform() !== "win32") return; 130 | if (!mainWindow) return; 131 | 132 | const { appid } = arg; 133 | 134 | const params = initializeFinClipSDK(arg); 135 | 136 | finclip.finclip_register_lifecycle(appid, 2, () => {}, ""); 137 | 138 | const handleBuffer = mainWindow.getNativeWindowHandle(); 139 | const hwnd = 140 | os.endianness() === "LE" 141 | ? handleBuffer.readInt32LE() 142 | : handleBuffer.readInt32BE(); 143 | finclip.finclip_start_applet_embed(appstore, appid, params, hwnd); 144 | }; 145 | 146 | const closeFinClipWindow = (arg) => { 147 | const { appid } = arg; 148 | finclip.finclip_close_applet(appid); 149 | }; 150 | 151 | ipcMain.on("EMBED_FINCLIP_WINDOW", (event, arg) => { 152 | embedFinClipWindow(arg); 153 | }); 154 | 155 | ipcMain.on("OPEN_FINCLIP_WINDOW", (event, arg) => { 156 | openFinClipWindow(arg); 157 | }); 158 | 159 | ipcMain.on("CLOSE_FINCLIP_WINDOW", (event, arg) => { 160 | closeFinClipWindow(arg); 161 | }); 162 | 163 | app.whenReady().then(() => { 164 | createMainWindow(); 165 | }); 166 | -------------------------------------------------------------------------------- /examples/rust/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate anyhow; 2 | extern crate serde; 3 | extern crate serde_json; 4 | 5 | mod finclip; 6 | 7 | use anyhow::Result; 8 | use finclip::*; 9 | use std::collections::HashMap; 10 | use std::ffi::{CStr, CString, NulError}; 11 | use std::fmt::{Display, self}; 12 | use std::os::raw::{c_char, c_void}; 13 | use std::thread; 14 | use std::time::Duration; 15 | 16 | pub fn str_to_cstr(k: &str) -> Result { 17 | let v = CString::new(k.as_bytes())?; 18 | Ok(v) 19 | } 20 | 21 | #[derive(Debug)] 22 | pub struct AppParams { 23 | pub appstore: String, 24 | pub appkey: String, 25 | pub secret: String, 26 | pub domain: String, 27 | pub appid: String, 28 | pub exe_path: String, 29 | pub show_loading: String, 30 | pub params: HashMap, 31 | } 32 | 33 | impl Display for AppParams { 34 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 35 | write!( 36 | f, 37 | "AppParams({}, {}, {}, {}, {}, {}, {})", 38 | self.appstore, 39 | self.appid, 40 | self.appkey, 41 | self.secret, 42 | self.domain, 43 | self.show_loading, 44 | self.exe_path 45 | ) 46 | } 47 | } 48 | 49 | extern "C" fn web_api_handler( 50 | res: *const c_char, 51 | _res: *const c_char, 52 | input: *mut c_void, 53 | _input: *mut c_void, 54 | ) { 55 | unsafe { 56 | let appid = { 57 | let data = &*(input as *mut AppParams); 58 | data.appid.clone() 59 | }; 60 | println!( 61 | ">> web_api_callback {} {}", 62 | CStr::from_ptr(res).to_str().unwrap(), 63 | appid, 64 | ); 65 | //finclip_callback_res(appid, callback_id, result); 66 | } 67 | } 68 | 69 | fn start_normal(cfg: &AppParams) -> Result<()> { 70 | unsafe { 71 | let factory = finclip_get_packer_factory(); 72 | let packer = finclip_packer_factory_get_config_packer(factory); 73 | println!("get config packer."); 74 | let cfg_ptr = &cfg as *const _ as *mut c_void; 75 | finclip_register_api( 76 | packer, 77 | FinClipApiType::Applet as i32, 78 | str_to_cstr("openapi_search")?.as_ptr(), 79 | web_api_handler, 80 | cfg_ptr, 81 | ); 82 | let res = finclip_initialize(packer); 83 | println!("initialize packer. result: {}", res); 84 | let config = finclip_create_params(); 85 | println!("create params."); 86 | for k in &cfg.params { 87 | finclip_params_set( 88 | config, 89 | str_to_cstr(k.0.as_str())?.as_ptr(), 90 | str_to_cstr(k.1.as_str())?.as_ptr(), 91 | ); 92 | } 93 | finclip_params_set( 94 | config, 95 | str_to_cstr("appstore")?.as_ptr(), 96 | str_to_cstr(cfg.appstore.as_str())?.as_ptr(), 97 | ); 98 | finclip_params_set( 99 | config, 100 | str_to_cstr("appkey")?.as_ptr(), 101 | str_to_cstr(cfg.appkey.as_str())?.as_ptr(), 102 | ); 103 | finclip_params_set( 104 | config, 105 | str_to_cstr("secret")?.as_ptr(), 106 | str_to_cstr(cfg.secret.as_str())?.as_ptr(), 107 | ); 108 | finclip_params_set( 109 | config, 110 | str_to_cstr("domain")?.as_ptr(), 111 | str_to_cstr(cfg.domain.as_str())?.as_ptr(), 112 | ); 113 | finclip_params_set( 114 | config, 115 | str_to_cstr("app_id")?.as_ptr(), 116 | str_to_cstr(cfg.appid.as_str())?.as_ptr(), 117 | ); 118 | if !cfg.exe_path.is_empty() { 119 | finclip_params_set( 120 | config, 121 | str_to_cstr("exe_path")?.as_ptr(), 122 | str_to_cstr(cfg.exe_path.as_str())?.as_ptr(), 123 | ); 124 | } 125 | finclip_params_set( 126 | config, 127 | str_to_cstr("show_loading")?.as_ptr(), 128 | str_to_cstr(cfg.show_loading.as_str())?.as_ptr(), 129 | ); 130 | println!("set params finished."); 131 | let res = finclip_config_packer_add_config(packer, config); 132 | println!("add config. result: {}", res); 133 | let res = finclip_start_applet( 134 | str_to_cstr(cfg.appstore.as_str())?.as_ptr(), 135 | str_to_cstr(cfg.appid.as_str())?.as_ptr(), 136 | ); 137 | println!("start applet. result: {}", res); 138 | Ok(()) 139 | } 140 | } 141 | 142 | fn main() -> Result<()> { 143 | let appid = "6152b5dbfcfb4e0001448e6e"; 144 | start_normal(&AppParams { 145 | appstore: "1".to_string(), 146 | appkey: "22LyZEib0gLTQdU3MUauAfJ/xujwNfM6OvvEqQyH4igA".to_string(), 147 | secret: "703b9026be3d6bc5".to_string(), 148 | domain: "https://finclip-testing.finogeeks.club".to_string(), 149 | appid: appid.to_string(), 150 | exe_path: "/Users/sylar/Projects/finclipsdk-desktop/build/core/Debug/FinClip.app" 151 | .to_string(), 152 | show_loading: "0".to_string(), 153 | params: HashMap::new(), 154 | })?; 155 | loop { 156 | thread::sleep(Duration::from_secs(1)); 157 | unsafe { 158 | if !finclip_is_applet_open(str_to_cstr(appid)?.as_ptr()) { 159 | break; 160 | } 161 | } 162 | } 163 | Ok(()) 164 | } 165 | -------------------------------------------------------------------------------- /examples/win32/finclip_cpp.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {61d67564-438e-4d8d-8a8f-0dc63c6e470c} 25 | finclip_cpp 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | $(ProjectDir)..\..\vendor\win\x64;$(IncludePath) 75 | $(ProjectDir)..\..\vendor\win\x64;$(LibraryPath) 76 | 77 | 78 | 79 | Level3 80 | true 81 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 82 | true 83 | 84 | 85 | Console 86 | true 87 | 88 | 89 | 90 | 91 | Level3 92 | true 93 | true 94 | true 95 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 96 | true 97 | 98 | 99 | Console 100 | true 101 | true 102 | true 103 | 104 | 105 | 106 | 107 | Level3 108 | true 109 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 110 | true 111 | $(ProjectDir)..\..\vendor\win\x64;%(AdditionalIncludeDirectories) 112 | 113 | 114 | Console 115 | true 116 | FinClipSDKWrapper.lib;%(AdditionalDependencies) 117 | 118 | 119 | 120 | 121 | Level3 122 | true 123 | true 124 | true 125 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 126 | true 127 | 128 | 129 | Console 130 | true 131 | true 132 | true 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /examples/gtk/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Demo GTK+ Application that illustrates data entry. 3 | * 4 | * M. Horauer 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "../../wrapper/src/public/finclip_wrapper.h" 11 | 12 | typedef struct { 13 | GtkWidget *dateDate; 14 | GtkWidget *idNbr; 15 | GtkWidget *emailAddr; 16 | GtkWidget *gnameEntry; 17 | GtkWidget *fnameEntry; 18 | GtkWidget *streetEntry; 19 | GtkWidget *cityEntry; 20 | GtkWidget *zipEntry; 21 | GtkWidget *phoneEntry; 22 | GtkWidget *byearSpin; 23 | GtkWidget *bmonthSpin; 24 | GtkWidget *bdaySpin; 25 | } diaWidgets; 26 | 27 | typedef struct { 28 | GtkApplication *app; 29 | GtkWidget *window; 30 | GtkWidget *img; 31 | diaWidgets *d; 32 | } appWidgets; 33 | 34 | /***************************************************************** PROTOTYPES */ 35 | static void activate(GtkApplication *app, gpointer user_data); 36 | static void cancel_callback(GtkWidget *widget, gpointer user_data); 37 | static void clear_callback(GtkWidget *widget, gpointer user_data); 38 | static void add_callback(GtkWidget *widget, gpointer user_data); 39 | static gint get_next_id(void); 40 | static gint get_next_id(void) { return 12; } 41 | 42 | /************************************************************ Cancel Callback */ 43 | static void cancel_callback(GtkWidget *widget, gpointer user_data) {} 44 | 45 | /************************************************************* Clear Callback */ 46 | static void clear_callback(GtkWidget *widget, gpointer user_data) { 47 | finclip_close_all_applet(); 48 | } 49 | 50 | /*************************************************************** Add Callback */ 51 | static void add_callback(GtkWidget *widget, gpointer user_data) { 52 | IPackerFactory *factory = finclip_get_packer_factory(); 53 | IFinConfigPacker *packer = finclip_packer_factory_get_config_packer(factory); 54 | IFinConfig *config = finclip_config_packer_new_config(packer); 55 | finclip_config_set_app_store(config, 1); 56 | finclip_config_set_app_key(config, ""); 57 | finclip_config_set_secret(config, ""); 58 | finclip_config_set_domain(config, ""); 59 | finclip_config_packer_add_config(packer, config); 60 | finclip_initialize(packer); 61 | finclip_start_applet(NULL, 1, "", "", NULL, "", NULL); 62 | } 63 | 64 | /********************************************************* nameentry_callback */ 65 | static void nameentry_callback(GtkWidget *widget, gpointer user_data) { 66 | gint study_prog_nr = 54; 67 | gchar *org = "uni"; 68 | gchar *cnt = "net"; 69 | gchar *gname; 70 | gchar *fname; 71 | gchar email[256]; 72 | gchar dateStamp[256]; 73 | gchar *year; 74 | gchar id[256] = ""; 75 | appWidgets *a = (appWidgets *)user_data; 76 | 77 | /* construct the eMail address */ 78 | gname = (gchar *)gtk_entry_get_text(GTK_ENTRY(a->d->gnameEntry)); 79 | fname = (gchar *)gtk_entry_get_text(GTK_ENTRY(a->d->fnameEntry)); 80 | /* we update the fields on the top only when we got a family name */ 81 | if ((g_strcmp0(gname, "") != 0) && (g_strcmp0(fname, "") != 0)) { 82 | g_sprintf(email, "%s.%s@%s.%s", gname, fname, org, cnt); 83 | gtk_label_set_label(GTK_LABEL(a->d->emailAddr), email); 84 | /* update date info when Family Name was entered */ 85 | gtk_label_set_label(GTK_LABEL(a->d->dateDate), dateStamp); 86 | /* construct matrnum when Family Name was entered */ 87 | year = g_strndup(dateStamp, 4); 88 | g_snprintf(id, 10, "%s%d%03d", year, study_prog_nr, get_next_id()); 89 | gtk_label_set_label(GTK_LABEL(a->d->idNbr), id); 90 | } 91 | } 92 | 93 | /***************************************************************** ADD WINDOW */ 94 | static void activate(GtkApplication *app, gpointer user_data) { 95 | GtkWidget *box; 96 | GtkWidget *ebox; 97 | GtkWidget *grid; 98 | GtkWidget *date_label; 99 | GtkWidget *id_label; 100 | GtkWidget *email_label; 101 | GtkWidget *gname_label; 102 | GtkWidget *fname_label; 103 | GtkWidget *street_label; 104 | GtkWidget *city_label; 105 | GtkWidget *zip_label; 106 | GtkWidget *phone_label; 107 | GtkWidget *birth_label; 108 | GtkWidget *c_button; 109 | GtkWidget *l_button; 110 | GtkWidget *a_button; 111 | appWidgets *a = (appWidgets *)user_data; 112 | 113 | /* create a window with title, default size,and icons */ 114 | a->window = gtk_application_window_new(a->app); 115 | gtk_window_set_application(GTK_WINDOW(a->window), GTK_APPLICATION(a->app)); 116 | gtk_window_set_title(GTK_WINDOW(a->window), "Student Management Toolbox"); 117 | gtk_window_set_default_size(GTK_WINDOW(a->window), 400, 300); 118 | gtk_window_set_resizable(GTK_WINDOW(a->window), FALSE); 119 | 120 | box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); 121 | gtk_container_add(GTK_CONTAINER(a->window), GTK_WIDGET(box)); 122 | gtk_container_set_border_width(GTK_CONTAINER(a->window), 10); 123 | 124 | /* grid: image and labels */ 125 | grid = gtk_grid_new(); 126 | gtk_grid_set_column_spacing(GTK_GRID(grid), 5); 127 | gtk_grid_set_row_spacing(GTK_GRID(grid), 5); 128 | gtk_widget_set_size_request(GTK_WIDGET(grid), 400, 90); 129 | gtk_widget_set_valign(GTK_WIDGET(grid), GTK_ALIGN_CENTER); 130 | gtk_widget_set_halign(GTK_WIDGET(grid), GTK_ALIGN_CENTER); 131 | gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(grid), TRUE, TRUE, 0); 132 | 133 | gname_label = gtk_widget_new(GTK_TYPE_LABEL, "label", "Appid", "xalign", 1.0, 134 | "yalign", 0.5, NULL); 135 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(gname_label), 0, 3, 1, 1); 136 | a->d->gnameEntry = gtk_entry_new(); 137 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(a->d->gnameEntry), 1, 3, 1, 1); 138 | 139 | street_label = gtk_widget_new(GTK_TYPE_LABEL, "label", "secret:", "xalign", 140 | 1.0, "yalign", 0.5, NULL); 141 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(street_label), 0, 4, 1, 1); 142 | a->d->streetEntry = gtk_entry_new(); 143 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(a->d->streetEntry), 1, 4, 1, 1); 144 | 145 | zip_label = gtk_widget_new(GTK_TYPE_LABEL, "label", "key:", "xalign", 1.0, 146 | "yalign", 0.5, NULL); 147 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(zip_label), 0, 5, 1, 1); 148 | a->d->zipEntry = gtk_entry_new(); 149 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(a->d->zipEntry), 1, 5, 1, 1); 150 | 151 | phone_label = gtk_widget_new(GTK_TYPE_LABEL, "label", "domain:", "xalign", 152 | 1.0, "yalign", 0.5, NULL); 153 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(phone_label), 2, 5, 1, 1); 154 | a->d->phoneEntry = gtk_entry_new(); 155 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(a->d->phoneEntry), 3, 5, 1, 1); 156 | 157 | /* lowerbox: buttons */ 158 | c_button = gtk_button_new_with_mnemonic("_Cancel"); 159 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(c_button), 1, 7, 1, 1); 160 | g_signal_connect(G_OBJECT(c_button), "clicked", G_CALLBACK(cancel_callback), 161 | (gpointer)a); 162 | l_button = gtk_button_new_with_mnemonic("C_lear"); 163 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(l_button), 2, 7, 1, 1); 164 | g_signal_connect(G_OBJECT(l_button), "clicked", G_CALLBACK(clear_callback), 165 | (gpointer)a); 166 | a_button = gtk_button_new_with_mnemonic("_Add"); 167 | gtk_grid_attach(GTK_GRID(grid), GTK_WIDGET(a_button), 3, 7, 1, 1); 168 | g_signal_connect(G_OBJECT(a_button), "clicked", G_CALLBACK(add_callback), 169 | (gpointer)a); 170 | 171 | gtk_widget_show_all(GTK_WIDGET(a->window)); 172 | } 173 | 174 | /*********************************************************************** main */ 175 | int main(int argc, char **argv) { 176 | int status; 177 | appWidgets *a = g_malloc(sizeof(appWidgets)); 178 | a->d = g_malloc(sizeof(diaWidgets)); 179 | 180 | a->app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE); 181 | g_signal_connect(G_OBJECT(a->app), "activate", G_CALLBACK(activate), 182 | (gpointer)a); 183 | status = g_application_run(G_APPLICATION(a->app), argc, argv); 184 | g_object_unref(a->app); 185 | 186 | g_free(a->d); 187 | g_free(a); 188 | return status; 189 | } 190 | /** EOF */ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | /dist 8 | /build 9 | .DS_Store 10 | *.rsuser 11 | *.suo 12 | *.user 13 | *.userosscache 14 | *.sln.docstates 15 | 16 | # User-specific files (MonoDevelop/Xamarin Studio) 17 | *.userprefs 18 | 19 | # Mono auto generated files 20 | mono_crash.* 21 | 22 | # Build results 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | [Ll]ogs/ 28 | 29 | # Visual Studio 2015/2017 cache/options directory 30 | .vs/ 31 | # Uncomment if you have tasks that create the project's static files in wwwroot 32 | #wwwroot/ 33 | 34 | # Visual Studio 2017 auto generated files 35 | Generated\ Files/ 36 | 37 | # MSTest test Results 38 | [Tt]est[Rr]esult*/ 39 | [Bb]uild[Ll]og.* 40 | 41 | # NUnit 42 | *.VisualState.xml 43 | TestResult.xml 44 | nunit-*.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # ASP.NET Scaffolding 60 | ScaffoldingReadMe.txt 61 | 62 | # StyleCop 63 | StyleCopReport.xml 64 | 65 | # Files built by Visual Studio 66 | *_i.c 67 | *_p.c 68 | *_h.h 69 | *.ilk 70 | *.meta 71 | *.obj 72 | *.iobj 73 | *.pch 74 | *.pdb 75 | *.ipdb 76 | *.pgc 77 | *.pgd 78 | *.rsp 79 | *.sbr 80 | *.tlb 81 | *.tli 82 | #*.tlh 83 | *.tmp 84 | *.tmp_proj 85 | *_wpftmp.csproj 86 | *.log 87 | *.vspscc 88 | *.vssscc 89 | .builds 90 | *.pidb 91 | *.svclog 92 | *.scc 93 | 94 | # Chutzpah Test files 95 | _Chutzpah* 96 | 97 | # Visual C++ cache files 98 | ipch/ 99 | *.aps 100 | *.ncb 101 | *.opendb 102 | *.opensdf 103 | *.sdf 104 | *.cachefile 105 | *.VC.db 106 | *.VC.VC.opendb 107 | 108 | # Visual Studio profiler 109 | *.psess 110 | *.vsp 111 | *.vspx 112 | *.sap 113 | 114 | # Visual Studio Trace Files 115 | *.e2e 116 | 117 | # TFS 2012 Local Workspace 118 | $tf/ 119 | 120 | # Guidance Automation Toolkit 121 | *.gpState 122 | 123 | # ReSharper is a .NET coding add-in 124 | _ReSharper*/ 125 | *.[Rr]e[Ss]harper 126 | *.DotSettings.user 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Coverlet is a free, cross platform Code Coverage Tool 139 | coverage*.json 140 | coverage*.xml 141 | coverage*.info 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | 355 | # Fody - auto-generated XML schema 356 | FodyWeavers.xsd 357 | /FinClipSDK/res/返回标注切图.zip 358 | .vscode/ -------------------------------------------------------------------------------- /examples/electron/src/finclip.js: -------------------------------------------------------------------------------- 1 | const koffi = require("koffi"); 2 | const os = require("os"); 3 | 4 | const finclip = {}; 5 | const _lifecycleCallbackCache = new Map(); 6 | const proxyCallbackCache = new Map(); 7 | 8 | let lib; 9 | 10 | const loadLibrary = (libraryPath) => { 11 | lib = koffi.load(libraryPath); 12 | koffi.pointer("POINT", koffi.opaque()); 13 | const lifecycleCallback = koffi.proto("lifecycleCallback", "void", [ 14 | "int", 15 | "string", 16 | "void*", 17 | ]); 18 | const customApiCallback = koffi.proto("customApiCallback", "void", [ 19 | "string", 20 | "string", 21 | "string", 22 | "int", 23 | ]); 24 | const proxyCallback = koffi.proto("proxyCallback", "void", [ 25 | "string", 26 | "string", 27 | "void*", 28 | "int", 29 | "string", 30 | ]); 31 | const invokeApiCallback = koffi.proto("invokeApiCallback", "void", [ 32 | "string", 33 | "void*", 34 | ]); 35 | const customApiCallbackV2 = koffi.proto("customApiCallbackV2", "void", [ 36 | "string", 37 | "string", 38 | "string", 39 | "int", 40 | "string", 41 | ]); 42 | 43 | finclip.finclip_create_params = lib.func( 44 | "finclip_create_params", 45 | "POINT", 46 | [] 47 | ); 48 | finclip.finclip_destory_params = lib.func("finclip_destory_params", "int", [ 49 | "POINT", 50 | ]); 51 | finclip.finclip_params_set = lib.func("finclip_params_set", "int", [ 52 | "POINT", 53 | "string", 54 | "string", 55 | ]); 56 | finclip.finclip_params_set_object = lib.func( 57 | "finclip_params_set_object", 58 | "int", 59 | ["POINT", "string", "string"] 60 | ); 61 | finclip.finclip_init_with_config = lib.func( 62 | "finclip_init_with_config", 63 | "int", 64 | ["string", "POINT"] 65 | ); 66 | finclip.finclip_start_applet = lib.func("finclip_start_applet", "int", [ 67 | "string", 68 | "string", 69 | ]); 70 | finclip.finclip_close_applet = lib.func("finclip_close_applet", "int", [ 71 | "string", 72 | ]); 73 | finclip.finclip_close_all_applet = lib.func( 74 | "finclip_close_all_applet", 75 | "int", 76 | [] 77 | ); 78 | finclip.finclip_set_position = lib.func("finclip_set_position", "int", [ 79 | "string", 80 | "int", 81 | "int", 82 | "int", 83 | "int", 84 | ]); 85 | finclip.finclip_show_applet = lib.func("finclip_show_applet", "int", [ 86 | "string", 87 | ]); 88 | finclip.finclip_callback_success = lib.func( 89 | "finclip_callback_success", 90 | "int", 91 | ["int", "POINT"] 92 | ); 93 | finclip.finclip_callback_failure = lib.func( 94 | "finclip_callback_failure", 95 | "int", 96 | ["int", "POINT"] 97 | ); 98 | finclip.finclip_start_applet_qrcode = lib.func( 99 | "finclip_start_applet_qrcode", 100 | "int", 101 | ["string", "string", "string"] 102 | ); 103 | finclip.finclip_params_set_int = lib.func("finclip_params_set_int", "int", [ 104 | "POINT", 105 | "string", 106 | "int", 107 | ]); 108 | 109 | if (os.platform() === "win32") { 110 | finclip.finclip_start_applet_embed = lib.func( 111 | "finclip_start_applet_embed", 112 | "int", 113 | ["string", "string", "POINT", "int"] 114 | ); 115 | } 116 | 117 | finclip.finclip_register_lifecycle = (appid, type, fn, data) => { 118 | if (!_lifecycleCallbackCache.has(appid)) { 119 | _lifecycleCallbackCache.set(appid, new Map()); 120 | } 121 | const appCallbacks = _lifecycleCallbackCache.get(appid); 122 | if (appCallbacks.has(type)) { 123 | const oldCallbackPointer = appCallbacks.get(type); 124 | console.log( 125 | `Replacing existing lifecycle callback for appid=${appid}, type=${type}.` 126 | ); 127 | try { 128 | koffi.unregister(oldCallbackPointer); 129 | } catch (e) { 130 | console.error("Koffi: Failed to unregister previous callback.", e); 131 | } 132 | } 133 | 134 | const newCallbackPointer = koffi.register( 135 | fn, 136 | koffi.pointer(lifecycleCallback) 137 | ); 138 | 139 | appCallbacks.set(type, newCallbackPointer); 140 | 141 | const finclip_register_lifecycle_c = lib.func( 142 | "finclip_register_lifecycle", 143 | "int", 144 | ["string", "int", koffi.pointer(lifecycleCallback), "void*"] 145 | ); 146 | return finclip_register_lifecycle_c(appid, type, newCallbackPointer, data); 147 | }; 148 | finclip.finclip_unregister_lifecycle = (appid) => { 149 | const appCallbacks = _lifecycleCallbackCache.get(appid); 150 | if (appCallbacks) { 151 | console.log( 152 | `Unregistering all lifecycle callbacks for appid=${appid}...` 153 | ); 154 | for (const [type, callbackPointer] of appCallbacks.entries()) { 155 | try { 156 | koffi.unregister(callbackPointer); 157 | } catch (e) { 158 | console.error( 159 | `Koffi: Failed to unregister callback for appid=${appid}, type=${type}.`, 160 | e 161 | ); 162 | } 163 | } 164 | _lifecycleCallbackCache.delete(appid); 165 | } 166 | }; 167 | finclip.finclip_register_api = (type, name, fn, data) => { 168 | const callback = koffi.register(fn, koffi.pointer(customApiCallback)); 169 | const finclip_register_api = lib.func("finclip_register_api", "int", [ 170 | "int", 171 | "string", 172 | koffi.pointer(customApiCallback), 173 | "string", 174 | ]); 175 | return finclip_register_api(type, name, callback, data); 176 | }; 177 | 178 | finclip.finclip_register_api_v2 = (type, name, fn, data) => { 179 | const callback = koffi.register(fn, koffi.pointer(customApiCallbackV2)); 180 | const finclip_register_api_v2 = lib.func("finclip_register_api_v2", "int", [ 181 | "int", 182 | "string", 183 | koffi.pointer(customApiCallbackV2), 184 | "string", 185 | ]); 186 | return finclip_register_api_v2(type, name, callback, data); 187 | }; 188 | 189 | finclip.finclip_register_proxy = (name, fn, data) => { 190 | if (proxyCallbackCache.has(name)) { 191 | const oldCallback = proxyCallbackCache.get(name); 192 | koffi.unregister(oldCallback); 193 | console.warn( 194 | `finclip: Re-registering proxy for "${name}". The old one has been released.` 195 | ); 196 | } 197 | 198 | const callback = koffi.register(fn, koffi.pointer(proxyCallback)); 199 | proxyCallbackCache.set(name, callback); 200 | const finclip_register_proxy_native = lib.func( 201 | "finclip_register_proxy", 202 | "int", 203 | ["string", koffi.pointer(proxyCallback), "string"] 204 | ); 205 | 206 | return finclip_register_proxy_native(name, callback, data); 207 | }; 208 | 209 | finclip.finclip_invoke_api = (type, appid, api_name, params, fn, data) => { 210 | if (typeof fn !== "function") { 211 | const finclip_invoke_api_no_cb = lib.func("finclip_invoke_api", "int", [ 212 | "int", 213 | "string", 214 | "string", 215 | "string", 216 | koffi.pointer(invokeApiCallback), 217 | "void*", 218 | ]); 219 | return finclip_invoke_api_no_cb( 220 | type, 221 | appid, 222 | api_name, 223 | params, 224 | null, 225 | data 226 | ); 227 | } 228 | 229 | let callbackPointer; 230 | 231 | const wrapperCallback = (...args) => { 232 | try { 233 | koffi.unregister(callbackPointer); 234 | } catch (e) { 235 | console.error("Koffi: Failed to unregister callback.", e); 236 | } 237 | fn(...args); 238 | }; 239 | 240 | callbackPointer = koffi.register( 241 | wrapperCallback, 242 | koffi.pointer(invokeApiCallback) 243 | ); 244 | 245 | const finclip_invoke_api = lib.func("finclip_invoke_api", "int", [ 246 | "int", 247 | "string", 248 | "string", 249 | "string", 250 | koffi.pointer(invokeApiCallback), 251 | "void*", 252 | ]); 253 | return finclip_invoke_api( 254 | type, 255 | appid, 256 | api_name, 257 | params, 258 | callbackPointer, 259 | data 260 | ); 261 | }; 262 | 263 | finclip.finclip_call_applet_event = (appid, event, params, fn, data) => { 264 | if (typeof fn !== "function") { 265 | const finclip_call_applet_event_no_cb = lib.func( 266 | "finclip_call_applet_event", 267 | "int", 268 | [ 269 | "string", 270 | "string", 271 | "string", 272 | koffi.pointer(invokeApiCallback), 273 | "void*", 274 | ] 275 | ); 276 | return finclip_call_applet_event_no_cb(appid, event, params, null, data); 277 | } 278 | 279 | let callbackPointer; 280 | 281 | const wrapperCallback = (...args) => { 282 | try { 283 | koffi.unregister(callbackPointer); 284 | } catch (e) { 285 | console.error("Koffi: Failed to unregister callback.", e); 286 | } 287 | fn(...args); 288 | }; 289 | 290 | callbackPointer = koffi.register( 291 | wrapperCallback, 292 | koffi.pointer(invokeApiCallback) 293 | ); 294 | 295 | const finclip_call_applet_event = lib.func( 296 | "finclip_call_applet_event", 297 | "int", 298 | ["string", "string", "string", koffi.pointer(invokeApiCallback), "void*"] 299 | ); 300 | return finclip_call_applet_event( 301 | appid, 302 | event, 303 | params, 304 | callbackPointer, 305 | data 306 | ); 307 | }; 308 | finclip.finclip_start_applet_params = lib.func( 309 | "finclip_start_applet_params", 310 | "int", 311 | ["string", "string", "POINT"] 312 | ); 313 | finclip.finclip_show_applet_v2 = lib.func("finclip_show_applet_v2", "int", [ 314 | "string", 315 | "int", 316 | ]); 317 | }; 318 | 319 | finclip.load_library = loadLibrary; 320 | 321 | module.exports = finclip; 322 | --------------------------------------------------------------------------------