flip_store_e.h 5.3 KB

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