removed keeweb launching

This commit is contained in:
antelle 2021-04-13 22:59:39 +02:00
parent 5cc146481b
commit 99d0fa30ed
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 0 additions and 47 deletions

View File

@ -11,17 +11,6 @@
// https://developer.chrome.com/docs/apps/nativeMessaging/#native-messaging-host-protocol
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging#app_side
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
#define APP_EXECUTABLE_FILE_NAME "KeeWeb.exe"
#elif __APPLE__
#define APP_EXECUTABLE_FILE_NAME "KeeWeb"
#else
#define APP_EXECUTABLE_FILE_NAME "keeweb"
#endif
constexpr auto kKeeWebLaunchArg = "--browser-extension";
constexpr auto kLaunchKeeWebIfNotRunning = false;
constexpr auto kSockName = "keeweb-browser.sock";
constexpr std::array kAllowedOrigins = {
@ -37,9 +26,6 @@ constexpr std::array kAllowedOrigins = {
std::string_view("chrome-extension://pdffhmdngciaglkoonimfcmckehcpafo/"),
};
constexpr uint32_t kMaxKeeWebConnectAttempts = 10;
constexpr uint32_t kKeeWebConnectRetryTimeoutMillis = 500;
struct State {
uv_stream_t *tty_in = nullptr;
uv_stream_t *tty_out = nullptr;
@ -190,17 +176,6 @@ void keeweb_pipe_read_cb(uv_stream_t *, ssize_t nread, const uv_buf_t *buf) {
}
}
void keeweb_connect_timer_cb(uv_timer_t *timer) {
delete timer;
connect_keeweb_pipe();
}
void set_keeweb_connect_timer() {
auto timer_req = new uv_timer_t();
uv_timer_init(uv_default_loop(), timer_req);
uv_timer_start(timer_req, keeweb_connect_timer_cb, kKeeWebConnectRetryTimeoutMillis, 0);
}
void keeweb_pipe_connect_cb(uv_connect_t *req, int status) {
auto pipe = req->handle;
delete req;
@ -209,28 +184,6 @@ void keeweb_pipe_connect_cb(uv_connect_t *req, int status) {
state.keeweb_pipe = pipe;
uv_read_start(pipe, alloc_buf, keeweb_pipe_read_cb);
process_keeweb_queue();
} else if (state.keeweb_launched) {
if (state.keeweb_connect_attempts >= kMaxKeeWebConnectAttempts) {
std::cerr << "Cannot connect to KeeWeb: timeout" << std::endl;
quit_on_error();
} else {
set_keeweb_connect_timer();
}
} else if (kLaunchKeeWebIfNotRunning) {
auto child_req = new uv_process_t();
const char *args[2]{kKeeWebLaunchArg, nullptr};
uv_process_options_t options{.file = APP_EXECUTABLE_FILE_NAME,
.args = const_cast<char **>(args),
.flags = UV_PROCESS_DETACHED};
auto spawn_error = uv_spawn(uv_default_loop(), child_req, &options);
if (spawn_error) {
std::cerr << "Cannot spawn KeeWeb: " << uv_err_name(spawn_error) << std::endl;
quit_on_error();
} else {
uv_unref(reinterpret_cast<uv_handle_t *>(&child_req));
state.keeweb_launched = true;
set_keeweb_connect_timer();
}
} else {
std::cerr << "Cannot connect to KeeWeb: " << uv_err_name(status) << std::endl;
quit_on_error();