flip_store_e.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef FLIP_STORE_E_H
  2. #define FLIP_STORE_E_H
  3. #include <flipper_http.h>
  4. #include <easy_flipper.h>
  5. #include <furi.h>
  6. #include <furi_hal.h>
  7. #include <gui/gui.h>
  8. #include <gui/view.h>
  9. #include <gui/modules/submenu.h>
  10. #include <gui/view_dispatcher.h>
  11. #include <notification/notification.h>
  12. #include <dialogs/dialogs.h>
  13. #include <jsmn.h>
  14. #define TAG "FlipStore"
  15. // define the list of categories
  16. char* categories[] = {
  17. "Bluetooth",
  18. "Games",
  19. "GPIO",
  20. "Infrared",
  21. "iButton",
  22. "Media",
  23. "NFC",
  24. "RFID",
  25. "Sub-GHz",
  26. "Tools",
  27. "USB",
  28. };
  29. // Define the submenu items for our FlipStore application
  30. typedef enum {
  31. FlipStoreSubmenuIndexMain, // Click to start downloading the selected app
  32. FlipStoreSubmenuIndexAbout,
  33. FlipStoreSubmenuIndexSettings,
  34. FlipStoreSubmenuIndexAppList,
  35. //
  36. FlipStoreSubmenuIndexAppListBluetooth,
  37. FlipStoreSubmenuIndexAppListGames,
  38. FlipStoreSubmenuIndexAppListGPIO,
  39. FlipStoreSubmenuIndexAppListInfrared,
  40. FlipStoreSubmenuIndexAppListiButton,
  41. FlipStoreSubmenuIndexAppListMedia,
  42. FlipStoreSubmenuIndexAppListNFC,
  43. FlipStoreSubmenuIndexAppListRFID,
  44. FlipStoreSubmenuIndexAppListSubGHz,
  45. FlipStoreSubmenuIndexAppListTools,
  46. FlipStoreSubmenuIndexAppListUSB,
  47. //
  48. FlipStoreSubmenuIndexStartAppList
  49. } FlipStoreSubmenuIndex;
  50. // Define a single view for our FlipStore application
  51. typedef enum {
  52. FlipStoreViewMain, // The main screen
  53. FlipStoreViewSubmenu, // The submenu
  54. FlipStoreViewAbout, // The about screen
  55. FlipStoreViewSettings, // The settings screen
  56. FlipStoreViewTextInputSSID, // The text input screen for SSID
  57. FlipStoreViewTextInputPass, // The text input screen for password
  58. //
  59. FlipStoreViewPopup, // The popup screen
  60. //
  61. FlipStoreViewAppList, // The app list screen
  62. FlipStoreViewAppInfo, // The app info screen (widget) of the selected app
  63. FlipStoreViewAppDownload, // The app download screen (widget) of the selected app
  64. FlipStoreViewAppDelete, // The app delete screen (DialogEx) of the selected app
  65. //
  66. FlipStoreViewAppListBluetooth, // the app list screen for Bluetooth
  67. FlipStoreViewAppListGames, // the app list screen for Games
  68. FlipStoreViewAppListGPIO, // the app list screen for GPIO
  69. FlipStoreViewAppListInfrared, // the app list screen for Infrared
  70. FlipStoreViewAppListiButton, // the app list screen for iButton
  71. FlipStoreViewAppListMedia, // the app list screen for Media
  72. FlipStoreViewAppListNFC, // the app list screen for NFC
  73. FlipStoreViewAppListRFID, // the app list screen for RFID
  74. FlipStoreViewAppListSubGHz, // the app list screen for Sub-GHz
  75. FlipStoreViewAppListTools, // the app list screen for Tools
  76. FlipStoreViewAppListUSB, // the app list screen for USB
  77. } FlipStoreView;
  78. // Each screen will have its own view
  79. typedef struct {
  80. ViewDispatcher* view_dispatcher; // Switches between our views
  81. View* view_main; // The main screen for downloading apps
  82. View* view_app_info; // The app info screen (view) of the selected app
  83. Submenu* submenu; // The submenu (main)
  84. //
  85. Submenu* submenu_app_list; // The submenu (app list) for the selected category
  86. //
  87. Submenu* submenu_app_list_bluetooth; // The submenu (app list) for Bluetooth
  88. Submenu* submenu_app_list_games; // The submenu (app list) for Games
  89. Submenu* submenu_app_list_gpio; // The submenu (app list) for GPIO
  90. Submenu* submenu_app_list_infrared; // The submenu (app list) for Infrared
  91. Submenu* submenu_app_list_ibutton; // The submenu (app list) for iButton
  92. Submenu* submenu_app_list_media; // The submenu (app list) for Media
  93. Submenu* submenu_app_list_nfc; // The submenu (app list) for NFC
  94. Submenu* submenu_app_list_rfid; // The submenu (app list) for RFID
  95. Submenu* submenu_app_list_subghz; // The submenu (app list) for Sub-GHz
  96. Submenu* submenu_app_list_tools; // The submenu (app list) for Tools
  97. Submenu* submenu_app_list_usb; // The submenu (app list) for USB
  98. //
  99. Widget* widget; // The widget
  100. Popup* popup; // The popup
  101. DialogEx* dialog_delete; // The dialog for deleting an app
  102. VariableItemList* variable_item_list; // The variable item list (settngs)
  103. VariableItem* variable_item_ssid; // The variable item
  104. VariableItem* variable_item_pass; // The variable item
  105. TextInput* uart_text_input_ssid; // The text input
  106. TextInput* uart_text_input_pass; // The text input
  107. char* uart_text_input_buffer_ssid; // Buffer for the text input
  108. char* uart_text_input_temp_buffer_ssid; // Temporary buffer for the text input
  109. uint32_t uart_text_input_buffer_size_ssid; // Size of the text input buffer
  110. char* uart_text_input_buffer_pass; // Buffer for the text input
  111. char* uart_text_input_temp_buffer_pass; // Temporary buffer for the text input
  112. uint32_t uart_text_input_buffer_size_pass; // Size of the text input buffer
  113. } FlipStoreApp;
  114. // include strndup (otherwise NULL pointer dereference)
  115. char* strndup(const char* s, size_t n) {
  116. char* result;
  117. size_t len = strlen(s);
  118. if(n < len) len = n;
  119. result = (char*)malloc(len + 1);
  120. if(!result) return NULL;
  121. result[len] = '\0';
  122. return (char*)memcpy(result, s, len);
  123. }
  124. static void callback_submenu_choices(void* context, uint32_t index);
  125. #endif // FLIP_STORE_E_H