This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9bbef8
commit a37df2a
Showing
7 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
#pragma once | ||
|
||
#include "channels/session.h" | ||
|
||
struct _GenesisShellApplication { | ||
GtkApplication parent_instance; | ||
char** dart_entrypoint_arguments; | ||
FlMethodChannel* outputs; | ||
FlMethodChannel* account; | ||
FlMethodChannel* auth; | ||
SessionChannel session; | ||
GtkWindow* win; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include <flutter_linux/flutter_linux.h> | ||
|
||
extern "C" { | ||
#include <libseat.h> | ||
} | ||
|
||
#include "session.h" | ||
#include "../application-priv.h" | ||
|
||
static void handle_enable(struct libseat* backend, void* data) { | ||
(void)backend; | ||
(void)data; | ||
} | ||
|
||
static void handle_disable(struct libseat* backend, void* data) { | ||
(void)data; | ||
libseat_disable_seat(backend); | ||
} | ||
|
||
struct libseat_seat_listener listener = { | ||
.enable_seat = handle_enable, | ||
.disable_seat = handle_disable, | ||
}; | ||
|
||
static void method_call_handler(FlMethodChannel* channel, FlMethodCall* method_call, gpointer user_data) { | ||
SessionChannel* self = (SessionChannel*)user_data; | ||
g_autoptr(FlMethodResponse) response = nullptr; | ||
|
||
if (strcmp(fl_method_call_get_name(method_call), "open") == 0) { | ||
struct libseat* seat = libseat_open_seat(&listener, user_data); | ||
const char* name = libseat_seat_name(seat); | ||
g_hash_table_insert(self->seats, (gpointer)name, (gpointer)seat); | ||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_string(name))); | ||
} else if (strcmp(fl_method_call_get_name(method_call), "close") == 0) { | ||
FlValue* args = fl_method_call_get_args(method_call); | ||
const gchar* name = fl_value_get_string(args); | ||
|
||
if (g_hash_table_contains(self->seats, name)) { | ||
struct libseat* seat = (struct libseat*)g_hash_table_lookup(self->seats, name); | ||
g_hash_table_remove(self->seats, name); | ||
libseat_close_seat(seat); | ||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_bool(true))); | ||
} else { | ||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_bool(false))); | ||
} | ||
} else { | ||
response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); | ||
} | ||
|
||
g_autoptr(GError) error = nullptr; | ||
if (!fl_method_call_respond(method_call, response, &error)) { | ||
g_warning("Failed to send response: %s", error->message); | ||
} | ||
} | ||
|
||
void session_channel_init(SessionChannel* self, FlView* view) { | ||
self->seats = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)libseat_close_seat); | ||
|
||
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); | ||
self->channel = fl_method_channel_new(fl_engine_get_binary_messenger(fl_view_get_engine(view)), "com.expidusos.genesis.shell/session", FL_METHOD_CODEC(codec)); | ||
fl_method_channel_set_method_call_handler(self->channel, method_call_handler, self, nullptr); | ||
} | ||
|
||
void session_channel_deinit(SessionChannel* self) { | ||
g_clear_object(&self->channel); | ||
g_hash_table_unref(self->seats); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include <flutter_linux/flutter_linux.h> | ||
|
||
#include "../application.h" | ||
|
||
typedef struct _SessionChannel { | ||
GHashTable* seats; | ||
FlMethodChannel* channel; | ||
} SessionChannel; | ||
|
||
void session_channel_init(SessionChannel* self, FlView* view); | ||
void session_channel_deinit(SessionChannel* self); |