-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flutter native on Linux started for ayfStarter
- Loading branch information
1 parent
9ae2784
commit 3887106
Showing
9 changed files
with
352 additions
and
17 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
File renamed without changes.
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
91 changes: 91 additions & 0 deletions
91
sources/sub-projects/ayfstarter/flutter/ayf_starter_corepack/linux/ayfcorepack_plugin.cc
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,91 @@ | ||
#include "ayf-sdk-local-headers.h" | ||
|
||
#include "include/ayfcorepack/ayfcorepack_plugin.h" | ||
|
||
#include <flutter_linux/flutter_linux.h> | ||
#include <gtk/gtk.h> | ||
#include <sys/utsname.h> | ||
|
||
#include <cstring> | ||
|
||
#define AYFCOREPACK_PLUGIN(obj) \ | ||
(G_TYPE_CHECK_INSTANCE_CAST((obj), ayfcorepack_plugin_get_type(), \ | ||
AyfcorepackPlugin)) | ||
|
||
struct _AyfcorepackPlugin { | ||
GObject parent_instance; | ||
}; | ||
|
||
G_DEFINE_TYPE(AyfcorepackPlugin, ayfcorepack_plugin, g_object_get_type()) | ||
|
||
// Called when a method call is received from Flutter. | ||
static void ayfcorepack_plugin_handle_method_call( | ||
AyfcorepackPlugin* self, | ||
FlMethodCall* method_call) { | ||
g_autoptr(FlMethodResponse) response = nullptr; | ||
|
||
const gchar* method = fl_method_call_get_name(method_call); | ||
|
||
if (strcmp(method, "getPlatformVersion") == 0) { | ||
struct utsname uname_data = {}; | ||
uname(&uname_data); | ||
g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version); | ||
g_autoptr(FlValue) result = fl_value_new_string(version); | ||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); | ||
} | ||
else if (strcmp(method, "getEntryPoints") == 0) | ||
{ | ||
g_autoptr(FlValue) mapReturn = fl_value_new_map(); | ||
//flutter::EncodableMap retMap; | ||
|
||
fl_value_set(mapReturn, fl_value_new_string("loadedModule"), | ||
fl_value_new_string("123"));//ayfcorepack::AyfcorepackPlugin::fileNameModule.c_str())); | ||
// retMap[flutter::EncodableValue("loadedModule")] = flutter::EncodableValue(ayfcorepack::AyfcorepackPlugin::fileNameModule); | ||
|
||
fl_value_set(mapReturn, fl_value_new_string("moduleEntryAddress"), fl_value_new_int((intptr_t)flutter_config_open)); | ||
//retMap[flutter::EncodableValue("moduleEntryAddress")] = flutter::EncodableValue((intptr_t)flutter_config_open); | ||
|
||
fl_value_set(mapReturn, fl_value_new_string("moduleEntrySymbol"), fl_value_new_string("flutter_config_open")); | ||
// retMap[flutter::EncodableValue("moduleEntrySymbol")] = flutter::EncodableValue("flutter_config_open"); | ||
|
||
//result->Success(retMap); | ||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(mapReturn)); | ||
} | ||
else { | ||
response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); | ||
} | ||
|
||
fl_method_call_respond(method_call, response, nullptr); | ||
} | ||
|
||
static void ayfcorepack_plugin_dispose(GObject* object) { | ||
G_OBJECT_CLASS(ayfcorepack_plugin_parent_class)->dispose(object); | ||
} | ||
|
||
static void ayfcorepack_plugin_class_init(AyfcorepackPluginClass* klass) { | ||
G_OBJECT_CLASS(klass)->dispose = ayfcorepack_plugin_dispose; | ||
} | ||
|
||
static void ayfcorepack_plugin_init(AyfcorepackPlugin* self) {} | ||
|
||
static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, | ||
gpointer user_data) { | ||
AyfcorepackPlugin* plugin = AYFCOREPACK_PLUGIN(user_data); | ||
ayfcorepack_plugin_handle_method_call(plugin, method_call); | ||
} | ||
|
||
void ayfcorepack_plugin_register_with_registrar(FlPluginRegistrar* registrar) { | ||
AyfcorepackPlugin* plugin = AYFCOREPACK_PLUGIN( | ||
g_object_new(ayfcorepack_plugin_get_type(), nullptr)); | ||
|
||
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); | ||
g_autoptr(FlMethodChannel) channel = | ||
fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar), | ||
"ayfcorepack", | ||
FL_METHOD_CODEC(codec)); | ||
fl_method_channel_set_method_call_handler(channel, method_call_cb, | ||
g_object_ref(plugin), | ||
g_object_unref); | ||
|
||
g_object_unref(plugin); | ||
} |
26 changes: 26 additions & 0 deletions
26
...ts/ayfstarter/flutter/ayf_starter_corepack/linux/include/ayfcorepack/ayfcorepack_plugin.h
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,26 @@ | ||
#ifndef FLUTTER_PLUGIN_AYFCOREPACK_PLUGIN_H_ | ||
#define FLUTTER_PLUGIN_AYFCOREPACK_PLUGIN_H_ | ||
|
||
#include <flutter_linux/flutter_linux.h> | ||
|
||
G_BEGIN_DECLS | ||
|
||
#ifdef FLUTTER_PLUGIN_IMPL | ||
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default"))) | ||
#else | ||
#define FLUTTER_PLUGIN_EXPORT | ||
#endif | ||
|
||
typedef struct _AyfcorepackPlugin AyfcorepackPlugin; | ||
typedef struct { | ||
GObjectClass parent_class; | ||
} AyfcorepackPluginClass; | ||
|
||
FLUTTER_PLUGIN_EXPORT GType ayfcorepack_plugin_get_type(); | ||
|
||
FLUTTER_PLUGIN_EXPORT void ayfcorepack_plugin_register_with_registrar( | ||
FlPluginRegistrar* registrar); | ||
|
||
G_END_DECLS | ||
|
||
#endif // FLUTTER_PLUGIN_AYFCOREPACK_PLUGIN_H_ |
5 changes: 5 additions & 0 deletions
5
sources/sub-projects/ayfstarter/flutter/create_plugin_linux.txt
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,5 @@ | ||
1) Renamed folder "ayf_starter_corpack" to "ayfcorepack". | ||
2) Ran "flutter create --template=plugin --platforms=linux" | ||
3) Copied file "CMakeLists.txt" from "templates" to "linux" | ||
4) Renamed "ayfcorepack" to "ayf_starter_corpack" | ||
|
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
Oops, something went wrong.