2022-07-04 16:09:46 +03:00
|
|
|
#include "../ibutton_i.h"
|
|
|
|
|
|
|
|
void ibutton_scene_rpc_on_enter(void* context) {
|
|
|
|
iButton* ibutton = context;
|
2022-07-25 17:16:45 +03:00
|
|
|
Popup* popup = ibutton->popup;
|
2022-07-04 16:09:46 +03:00
|
|
|
|
2022-07-25 17:16:45 +03:00
|
|
|
popup_set_header(popup, "iButton", 82, 28, AlignCenter, AlignBottom);
|
|
|
|
popup_set_text(popup, "RPC mode", 82, 32, AlignCenter, AlignTop);
|
2022-07-04 16:09:46 +03:00
|
|
|
|
2022-07-25 17:16:45 +03:00
|
|
|
popup_set_icon(popup, 2, 14, &I_iButtonKey_49x44);
|
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
|
2022-07-04 16:09:46 +03:00
|
|
|
|
|
|
|
notification_message(ibutton->notifications, &sequence_display_backlight_on);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ibutton_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
iButton* ibutton = context;
|
2022-07-25 17:16:45 +03:00
|
|
|
Popup* popup = ibutton->popup;
|
2022-07-04 16:09:46 +03:00
|
|
|
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
consumed = true;
|
2023-03-02 16:23:33 +03:00
|
|
|
|
2022-07-25 17:16:45 +03:00
|
|
|
if(event.event == iButtonCustomEventRpcLoad) {
|
2022-08-02 15:54:12 +03:00
|
|
|
bool result = false;
|
2023-03-02 16:23:33 +03:00
|
|
|
const char* file_path = rpc_system_app_get_data(ibutton->rpc);
|
|
|
|
|
|
|
|
if(file_path && (furi_string_empty(ibutton->file_path))) {
|
|
|
|
furi_string_set(ibutton->file_path, file_path);
|
|
|
|
|
|
|
|
if(ibutton_load_key(ibutton)) {
|
|
|
|
popup_set_text(popup, ibutton->key_name, 82, 32, AlignCenter, AlignTop);
|
|
|
|
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
|
2022-07-25 17:16:45 +03:00
|
|
|
|
2022-08-02 15:54:12 +03:00
|
|
|
ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateStart);
|
2023-03-02 16:23:33 +03:00
|
|
|
ibutton_worker_emulate_start(ibutton->worker, ibutton->key);
|
2022-07-25 17:16:45 +03:00
|
|
|
|
2022-08-02 15:54:12 +03:00
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
2023-03-02 16:23:33 +03:00
|
|
|
|
|
|
|
rpc_system_app_confirm(ibutton->rpc, RpcAppEventLoadFile, result);
|
|
|
|
|
2022-07-25 17:16:45 +03:00
|
|
|
} else if(event.event == iButtonCustomEventRpcExit) {
|
2023-03-02 16:23:33 +03:00
|
|
|
rpc_system_app_confirm(ibutton->rpc, RpcAppEventAppExit, true);
|
2022-08-11 18:37:23 +03:00
|
|
|
scene_manager_stop(ibutton->scene_manager);
|
2022-08-02 15:54:12 +03:00
|
|
|
view_dispatcher_stop(ibutton->view_dispatcher);
|
2023-03-02 16:23:33 +03:00
|
|
|
|
2022-08-02 15:54:12 +03:00
|
|
|
} else if(event.event == iButtonCustomEventRpcSessionClose) {
|
2022-08-11 18:37:23 +03:00
|
|
|
scene_manager_stop(ibutton->scene_manager);
|
2022-07-04 16:09:46 +03:00
|
|
|
view_dispatcher_stop(ibutton->view_dispatcher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ibutton_scene_rpc_on_exit(void* context) {
|
|
|
|
iButton* ibutton = context;
|
2022-07-25 17:16:45 +03:00
|
|
|
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);
|
2022-07-04 16:09:46 +03:00
|
|
|
}
|