RPC App: state message and GUI update (#1423)
* RPC App: state message and GUI update * Protobuf submodule update Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -118,6 +118,8 @@ static bool ibutton_rpc_command_callback(RpcAppSystemEvent event, const char* ar
|
||||
string_set_str(ibutton->file_path, arg);
|
||||
if(ibutton_load_key_data(ibutton, ibutton->file_path, false)) {
|
||||
ibutton_worker_emulate_start(ibutton->key_worker, ibutton->key);
|
||||
view_dispatcher_send_custom_event(
|
||||
ibutton->view_dispatcher, iButtonCustomEventRpcLoad);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
@@ -162,8 +164,6 @@ iButton* ibutton_alloc() {
|
||||
ibutton->view_dispatcher, ibutton_tick_event_callback, 100);
|
||||
|
||||
ibutton->gui = furi_record_open("gui");
|
||||
view_dispatcher_attach_to_gui(
|
||||
ibutton->view_dispatcher, ibutton->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
ibutton->storage = furi_record_open("storage");
|
||||
ibutton->dialogs = furi_record_open("dialogs");
|
||||
@@ -373,6 +373,7 @@ int32_t ibutton_app(void* p) {
|
||||
ibutton->rpc_ctx = (void*)rpc_ctx;
|
||||
rpc_mode = true;
|
||||
rpc_system_app_set_callback(ibutton->rpc_ctx, ibutton_rpc_command_callback, ibutton);
|
||||
rpc_system_app_send_started(ibutton->rpc_ctx);
|
||||
} else {
|
||||
string_set_str(ibutton->file_path, (const char*)p);
|
||||
if(ibutton_load_key_data(ibutton, ibutton->file_path, true)) {
|
||||
@@ -383,17 +384,24 @@ int32_t ibutton_app(void* p) {
|
||||
}
|
||||
|
||||
if(rpc_mode) {
|
||||
view_dispatcher_attach_to_gui(
|
||||
ibutton->view_dispatcher, ibutton->gui, ViewDispatcherTypeDesktop);
|
||||
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneRpc);
|
||||
} else if(key_loaded) {
|
||||
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneEmulate);
|
||||
} else {
|
||||
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneStart);
|
||||
view_dispatcher_attach_to_gui(
|
||||
ibutton->view_dispatcher, ibutton->gui, ViewDispatcherTypeFullscreen);
|
||||
if(key_loaded) {
|
||||
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneEmulate);
|
||||
} else {
|
||||
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneStart);
|
||||
}
|
||||
}
|
||||
|
||||
view_dispatcher_run(ibutton->view_dispatcher);
|
||||
|
||||
if(ibutton->rpc_ctx) {
|
||||
rpc_system_app_set_callback(ibutton->rpc_ctx, NULL, NULL);
|
||||
rpc_system_app_send_exited(ibutton->rpc_ctx);
|
||||
}
|
||||
ibutton_free(ibutton);
|
||||
return 0;
|
||||
|
@@ -10,5 +10,6 @@ enum iButtonCustomEvent {
|
||||
iButtonCustomEventWorkerEmulated,
|
||||
iButtonCustomEventWorkerRead,
|
||||
|
||||
iButtonCustomEventRpcLoad,
|
||||
iButtonCustomEventRpcExit,
|
||||
};
|
||||
|
@@ -3,12 +3,14 @@
|
||||
|
||||
void ibutton_scene_rpc_on_enter(void* context) {
|
||||
iButton* ibutton = context;
|
||||
Widget* widget = ibutton->widget;
|
||||
Popup* popup = ibutton->popup;
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 0, 128, 28, AlignCenter, AlignCenter, "RPC mode", false);
|
||||
popup_set_header(popup, "iButton", 82, 28, AlignCenter, AlignBottom);
|
||||
popup_set_text(popup, "RPC mode", 82, 32, AlignCenter, AlignTop);
|
||||
|
||||
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
|
||||
popup_set_icon(popup, 2, 14, &I_iButtonKey_49x44);
|
||||
|
||||
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
|
||||
|
||||
notification_message(ibutton->notifications, &sequence_display_backlight_on);
|
||||
}
|
||||
@@ -17,12 +19,31 @@ bool ibutton_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
iButton* ibutton = context;
|
||||
Popup* popup = ibutton->popup;
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
if(event.event == iButtonCustomEventRpcExit) {
|
||||
if(event.event == iButtonCustomEventRpcLoad) {
|
||||
string_t key_name;
|
||||
string_init(key_name);
|
||||
if(string_end_with_str_p(ibutton->file_path, IBUTTON_APP_EXTENSION)) {
|
||||
path_extract_filename(ibutton->file_path, key_name, true);
|
||||
}
|
||||
|
||||
if(!string_empty_p(key_name)) {
|
||||
ibutton_text_store_set(ibutton, "emulating\n%s", string_get_cstr(key_name));
|
||||
} else {
|
||||
ibutton_text_store_set(ibutton, "emulating");
|
||||
}
|
||||
popup_set_text(popup, ibutton->text_store, 82, 32, AlignCenter, AlignTop);
|
||||
|
||||
ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateStart);
|
||||
|
||||
string_clear(key_name);
|
||||
} else if(event.event == iButtonCustomEventRpcExit) {
|
||||
ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop);
|
||||
view_dispatcher_stop(ibutton->view_dispatcher);
|
||||
}
|
||||
}
|
||||
@@ -32,5 +53,11 @@ bool ibutton_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
void ibutton_scene_rpc_on_exit(void* context) {
|
||||
iButton* ibutton = context;
|
||||
widget_reset(ibutton->widget);
|
||||
Popup* popup = ibutton->popup;
|
||||
|
||||
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
|
||||
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 0, NULL);
|
||||
|
||||
ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop);
|
||||
}
|
||||
|
Reference in New Issue
Block a user