forked from rustdesk/rustdesk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
35 lines (32 loc) · 1012 Bytes
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <dlfcn.h>
#include "my_application.h"
#define RUSTDESK_LIB_PATH "librustdesk.so"
// #define RUSTDESK_LIB_PATH "/usr/lib/rustdesk/librustdesk.so"
typedef bool (*RustDeskCoreMain)();
bool gIsConnectionManager = false;
bool flutter_rustdesk_core_main() {
void* librustdesk = dlopen(RUSTDESK_LIB_PATH, RTLD_LAZY);
if (!librustdesk) {
fprintf(stderr,"load librustdesk.so failed\n");
return true;
}
auto core_main = (RustDeskCoreMain) dlsym(librustdesk,"rustdesk_core_main");
char* error;
if ((error = dlerror()) != nullptr) {
fprintf(stderr, "error finding rustdesk_core_main: %s", error);
return true;
}
return core_main();
}
int main(int argc, char** argv) {
if (!flutter_rustdesk_core_main()) {
return 0;
}
for (int i = 0; i < argc; i++) {
if (strcmp(argv[i], "--cm") == 0) {
gIsConnectionManager = true;
}
}
g_autoptr(MyApplication) app = my_application_new();
return g_application_run(G_APPLICATION(app), argc, argv);
}