flip_social_callback.h 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. // flip_social_callback.h
  2. #ifndef FLIP_SOCIAL_CALLBACK_H
  3. #define FLIP_SOCIAL_CALLBACK_H
  4. /**
  5. * @brief Navigation callback to go back to the submenu Logged out.
  6. * @param context The context - unused
  7. * @return next view id (FlipSocialViewLoggedOutSubmenu)
  8. */
  9. static uint32_t flip_social_callback_to_submenu_logged_out(void *context)
  10. {
  11. UNUSED(context);
  12. return FlipSocialViewLoggedOutSubmenu;
  13. }
  14. /**
  15. * @brief Navigation callback to go back to the submenu Logged in.
  16. * @param context The context - unused
  17. * @return next view id (FlipSocialViewLoggedInSubmenu)
  18. */
  19. static uint32_t flip_social_callback_to_submenu_logged_in(void *context)
  20. {
  21. UNUSED(context);
  22. // flip_social_get_feed(); // start the feed request
  23. return FlipSocialViewLoggedInSubmenu;
  24. }
  25. /**
  26. * @brief Navigation callback to bring the user back to the (Logged out) Login screen
  27. * @param context The context - unused
  28. * @return next view id (FlipSocialViewLoggedOutLogin)
  29. */
  30. static uint32_t flip_social_callback_to_login_logged_out(void *context)
  31. {
  32. UNUSED(context);
  33. flip_social_sent_login_request = false;
  34. flip_social_login_success = false;
  35. return FlipSocialViewLoggedOutLogin;
  36. }
  37. /**
  38. * @brief Navigation callback to bring the user back to the (Logged out) Register screen
  39. * @param context The context - unused
  40. * @return next view id (FlipSocialViewLoggedOutRegister)
  41. */
  42. static uint32_t flip_social_callback_to_register_logged_out(void *context)
  43. {
  44. UNUSED(context);
  45. flip_social_sent_register_request = false;
  46. flip_social_register_success = false;
  47. return FlipSocialViewLoggedOutRegister;
  48. }
  49. /**
  50. * @brief Navigation callback to bring the user back to the (Logged out) Wifi Settings screen
  51. * @param context The context - unused
  52. * @return next view id (FlipSocialViewLoggedOutWifiSettings)
  53. */
  54. static uint32_t flip_social_callback_to_wifi_settings_logged_out(void *context)
  55. {
  56. UNUSED(context);
  57. return FlipSocialViewLoggedOutWifiSettings;
  58. }
  59. /**
  60. * @brief Navigation callback to bring the user back to the (Logged in) Wifi Settings screen
  61. * @param context The context - unused
  62. * @return next view id (FlipSocialViewLoggedInSettingsWifi)
  63. */
  64. static uint32_t flip_social_callback_to_wifi_settings_logged_in(void *context)
  65. {
  66. UNUSED(context);
  67. return FlipSocialViewLoggedInSettingsWifi;
  68. }
  69. /**
  70. * @brief Navigation callback to bring the user back to the (Logged in) Settings screen
  71. * @param context The context - unused
  72. * @return next view id (FlipSocialViewLoggedInSettingsWifi)
  73. */
  74. static uint32_t flip_social_callback_to_settings_logged_in(void *context)
  75. {
  76. UNUSED(context);
  77. return FlipSocialViewLoggedInSettings;
  78. }
  79. /**
  80. * @brief Navigation callback to bring the user back to the (Logged in) Compose screen
  81. * @param context The context - unused
  82. * @return next view id (FlipSocialViewLoggedInCompose)
  83. */
  84. static uint32_t flip_social_callback_to_compose_logged_in(void *context)
  85. {
  86. UNUSED(context);
  87. return FlipSocialViewLoggedInCompose;
  88. }
  89. /**
  90. * @brief Navigation callback to bring the user back to the (Logged in) Profile screen
  91. * @param context The context - unused
  92. * @return next view id (FlipSocialViewLoggedInProfile)
  93. */
  94. static uint32_t flip_social_callback_to_profile_logged_in(void *context)
  95. {
  96. UNUSED(context);
  97. return FlipSocialViewLoggedInProfile;
  98. }
  99. /**
  100. * @brief Navigation callback to bring the user back to the Explore submenu
  101. * @param context The context - unused
  102. * @return next view id (FlipSocialViewLoggedInExploreSubmenu)
  103. */
  104. static uint32_t flip_social_callback_to_explore_logged_in(void *context)
  105. {
  106. UNUSED(context);
  107. flip_social_dialog_stop = true;
  108. last_explore_response = "";
  109. flip_social_dialog_shown = false;
  110. app_instance->flip_social_explore.index = 0;
  111. action = ActionNone;
  112. return FlipSocialViewLoggedInExploreSubmenu;
  113. }
  114. /**
  115. * @brief Navigation callback to bring the user back to the Friends submenu
  116. * @param context The context - unused
  117. * @return next view id (FlipSocialViewLoggedInFriendsSubmenu)
  118. */
  119. static uint32_t flip_social_callback_to_friends_logged_in(void *context)
  120. {
  121. UNUSED(context);
  122. flip_social_dialog_stop = true;
  123. last_explore_response = "";
  124. flip_social_dialog_shown = false;
  125. app_instance->flip_social_friends.index = 0;
  126. action = ActionNone;
  127. return FlipSocialViewLoggedInFriendsSubmenu;
  128. }
  129. /**
  130. * @brief Navigation callback to bring the user back to the Messages submenu
  131. * @param context The context - unused
  132. * @return next view id (FlipSocialViewLoggedInMessagesSubmenu)
  133. */
  134. static uint32_t flip_social_callback_to_messages_logged_in(void *context)
  135. {
  136. UNUSED(context);
  137. return FlipSocialViewLoggedInMessagesSubmenu;
  138. }
  139. /**
  140. * @brief Navigation callback to bring the user back to the User Choices screen
  141. * @param context The context - unused
  142. * @return next view id (FlipSocialViewLoggedInMessagesUserChoices)
  143. */
  144. static uint32_t flip_social_callback_to_messages_user_choices(void *context)
  145. {
  146. UNUSED(context);
  147. return FlipSocialViewLoggedInMessagesUserChoices;
  148. }
  149. /**
  150. * @brief Navigation callback for exiting the application
  151. * @param context The context - unused
  152. * @return next view id (VIEW_NONE to exit the app)
  153. */
  154. static uint32_t flip_social_callback_exit_app(void *context)
  155. {
  156. // Exit the application
  157. if (!context)
  158. {
  159. FURI_LOG_E(TAG, "Context is NULL");
  160. return VIEW_NONE;
  161. }
  162. UNUSED(context);
  163. return VIEW_NONE; // Return VIEW_NONE to exit the app
  164. }
  165. /**
  166. * @brief Handle ALL submenu item selections.
  167. * @param context The context - FlipSocialApp object.
  168. * @param index The FlipSocialSubmenuIndex item that was clicked.
  169. * @return void
  170. */
  171. static void flip_social_callback_submenu_choices(void *context, uint32_t index)
  172. {
  173. FlipSocialApp *app = (FlipSocialApp *)context;
  174. if (!app)
  175. {
  176. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  177. return;
  178. }
  179. switch (index)
  180. {
  181. case FlipSocialSubmenuLoggedOutIndexLogin:
  182. flip_social_sent_login_request = false;
  183. flip_social_login_success = false;
  184. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutLogin);
  185. break;
  186. case FlipSocialSubmenuLoggedOutIndexRegister:
  187. flip_social_sent_register_request = false;
  188. flip_social_register_success = false;
  189. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutRegister);
  190. break;
  191. case FlipSocialSubmenuLoggedOutIndexAbout:
  192. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutAbout);
  193. break;
  194. case FlipSocialSubmenuLoggedOutIndexWifiSettings:
  195. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutWifiSettings);
  196. break;
  197. case FlipSocialSubmenuLoggedInIndexProfile:
  198. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInProfile);
  199. break;
  200. case FlipSocialSubmenuLoggedInIndexMessages:
  201. if (flipper_http_process_response_async(flip_social_get_message_users, flip_social_parse_json_message_users))
  202. {
  203. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInMessagesSubmenu);
  204. }
  205. break;
  206. case FlipSocialSubmenuLoggedInIndexMessagesNewMessage:
  207. if (flipper_http_process_response_async(flip_social_get_explore, flip_social_parse_json_message_user_choices))
  208. {
  209. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInMessagesUserChoices);
  210. }
  211. break;
  212. case FlipSocialSubmenuLoggedInIndexFeed:
  213. if (flipper_http_process_response_async(flip_social_get_feed, flip_social_parse_json_feed))
  214. {
  215. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInFeed);
  216. }
  217. break;
  218. case FlipSocialSubmenuExploreIndex:
  219. if (flipper_http_process_response_async(flip_social_get_explore, flip_social_parse_json_explore))
  220. {
  221. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInExploreSubmenu);
  222. }
  223. break;
  224. case FlipSocialSubmenuLoggedInIndexCompose:
  225. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInCompose);
  226. break;
  227. case FlipSocialSubmenuLoggedInIndexSettings:
  228. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInSettings);
  229. break;
  230. case FlipSocialSubmenuLoggedInSignOutButton:
  231. app->is_logged_in = "false";
  232. save_settings(app_instance->wifi_ssid_logged_out, app_instance->wifi_password_logged_out, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
  233. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutSubmenu);
  234. break;
  235. case FlipSocialSubmenuComposeIndexAddPreSave:
  236. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInComposeAddPreSaveInput);
  237. break;
  238. default:
  239. // Handle the pre-saved message selection (has a max of 25 items)
  240. if (index >= FlipSocialSubemnuComposeIndexStartIndex && index < FlipSocialSubemnuComposeIndexStartIndex + MAX_PRE_SAVED_MESSAGES)
  241. {
  242. app->flip_social_feed.index = index - FlipSocialSubemnuComposeIndexStartIndex;
  243. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInProcessCompose);
  244. }
  245. // Handle the explore selection
  246. else if (index >= FlipSocialSubmenuExploreIndexStartIndex && index < FlipSocialSubmenuExploreIndexStartIndex + MAX_EXPLORE_USERS)
  247. {
  248. app->flip_social_explore.index = index - FlipSocialSubmenuExploreIndexStartIndex;
  249. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInExploreProccess);
  250. }
  251. // handle the friends selection
  252. else if (index >= FlipSocialSubmenuLoggedInIndexFriendsStart && index < FlipSocialSubmenuLoggedInIndexFriendsStart + MAX_FRIENDS)
  253. {
  254. app->flip_social_friends.index = index - FlipSocialSubmenuLoggedInIndexFriendsStart;
  255. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInFriendsProcess);
  256. }
  257. // handle the messages selection
  258. else if (index >= FlipSocialSubmenuLoggedInIndexMessagesUsersStart && index < FlipSocialSubmenuLoggedInIndexMessagesUsersStart + MAX_MESSAGE_USERS)
  259. {
  260. app->flip_social_message_users.index = index - FlipSocialSubmenuLoggedInIndexMessagesUsersStart;
  261. if (flipper_http_process_response_async(flip_social_get_messages_with_user, flip_social_parse_json_messages))
  262. {
  263. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInMessagesProcess);
  264. }
  265. }
  266. // handle the messages user choices selection
  267. else if (index >= FlipSocialSubmenuLoggedInIndexMessagesUserChoicesIndexStart && index < FlipSocialSubmenuLoggedInIndexMessagesUserChoicesIndexStart + MAX_EXPLORE_USERS)
  268. {
  269. app->flip_social_explore.index = index - FlipSocialSubmenuLoggedInIndexMessagesUserChoicesIndexStart;
  270. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInMessagesNewMessageUserChoicesInput);
  271. }
  272. else
  273. {
  274. FURI_LOG_E(TAG, "Unknown submenu index");
  275. }
  276. break;
  277. }
  278. }
  279. /**
  280. * @brief Text input callback for when the user finishes entering their SSID on the wifi settings (logged out) screen.
  281. * @param context The context - FlipSocialApp object.
  282. * @return void
  283. */
  284. static void flip_social_logged_out_wifi_settings_ssid_updated(void *context)
  285. {
  286. FlipSocialApp *app = (FlipSocialApp *)context;
  287. if (!app)
  288. {
  289. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  290. return;
  291. }
  292. // Store the entered name
  293. strncpy(app->wifi_ssid_logged_out, app->wifi_ssid_logged_out_temp_buffer, app->wifi_ssid_logged_out_temp_buffer_size);
  294. // Store the entered name in the logged in name field
  295. strncpy(app->wifi_ssid_logged_in, app->wifi_ssid_logged_out_temp_buffer, app->wifi_ssid_logged_out_temp_buffer_size);
  296. strncpy(app->wifi_ssid_logged_in_temp_buffer, app->wifi_ssid_logged_out_temp_buffer, app->wifi_ssid_logged_out_temp_buffer_size);
  297. // Ensure null-termination
  298. app->wifi_ssid_logged_out[app->wifi_ssid_logged_out_temp_buffer_size - 1] = '\0';
  299. // Update the name item text
  300. if (app->variable_item_logged_out_wifi_settings_ssid)
  301. {
  302. variable_item_set_current_value_text(app->variable_item_logged_out_wifi_settings_ssid, app->wifi_ssid_logged_out);
  303. }
  304. // update the wifi settings
  305. if (!flipper_http_save_wifi(app->wifi_ssid_logged_out, app->wifi_password_logged_out))
  306. {
  307. FURI_LOG_E(TAG, "Failed to save wifi settings via UART");
  308. FURI_LOG_E(TAG, "Make sure the Flipper is connected to the Wifi Dev Board");
  309. }
  310. // Save the settings
  311. save_settings(app_instance->wifi_ssid_logged_out, app_instance->wifi_password_logged_out, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
  312. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutWifiSettings);
  313. }
  314. /**
  315. * @brief Text input callback for when the user finishes entering their password on the wifi settings (logged out) screen.
  316. * @param context The context - FlipSocialApp object.
  317. * @return void
  318. */
  319. static void flip_social_logged_out_wifi_settings_password_updated(void *context)
  320. {
  321. FlipSocialApp *app = (FlipSocialApp *)context;
  322. if (!app)
  323. {
  324. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  325. return;
  326. }
  327. // Store the entered WiFi password
  328. strncpy(app->wifi_password_logged_out, app->wifi_password_logged_out_temp_buffer, app->wifi_password_logged_out_temp_buffer_size);
  329. // Store the entered WiFi password in the logged in password field
  330. strncpy(app->wifi_password_logged_in, app->wifi_password_logged_out_temp_buffer, app->wifi_password_logged_out_temp_buffer_size);
  331. strncpy(app->wifi_password_logged_in_temp_buffer, app->wifi_password_logged_out_temp_buffer, app->wifi_password_logged_out_temp_buffer_size);
  332. // Ensure null-termination
  333. app->wifi_password_logged_out[app->wifi_password_logged_out_temp_buffer_size - 1] = '\0';
  334. // Update the password item text
  335. if (app->variable_item_logged_out_wifi_settings_password)
  336. {
  337. variable_item_set_current_value_text(app->variable_item_logged_out_wifi_settings_password, app->wifi_password_logged_out);
  338. }
  339. // update the wifi settings
  340. if (!flipper_http_save_wifi(app->wifi_ssid_logged_out, app->wifi_password_logged_out))
  341. {
  342. FURI_LOG_E(TAG, "Failed to save wifi settings via UART");
  343. FURI_LOG_E(TAG, "Make sure the Flipper is connected to the Wifi Dev Board");
  344. }
  345. // Save the settings
  346. save_settings(app_instance->wifi_ssid_logged_out, app_instance->wifi_password_logged_out, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
  347. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutWifiSettings);
  348. }
  349. /**
  350. * @brief Callback when the user selects a menu item in the wifi settings (logged out) screen.
  351. * @param context The context - FlipSocialApp object.
  352. * @param index The index of the selected item.
  353. * @return void
  354. */
  355. static void flip_social_text_input_logged_out_wifi_settings_item_selected(void *context, uint32_t index)
  356. {
  357. FlipSocialApp *app = (FlipSocialApp *)context;
  358. if (!app)
  359. {
  360. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  361. return;
  362. }
  363. switch (index)
  364. {
  365. case 0: // Input SSID
  366. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutWifiSettingsSSIDInput);
  367. break;
  368. case 1: // Input Password
  369. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutWifiSettingsPasswordInput);
  370. break;
  371. default:
  372. FURI_LOG_E(TAG, "Unknown configuration item index");
  373. break;
  374. }
  375. }
  376. /**
  377. * @brief Text input callback for when the user finishes entering their username on the login (logged out) screen.
  378. * @param context The context - FlipSocialApp object.
  379. * @return void
  380. */
  381. static void flip_social_logged_out_login_username_updated(void *context)
  382. {
  383. FlipSocialApp *app = (FlipSocialApp *)context;
  384. if (!app)
  385. {
  386. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  387. return;
  388. }
  389. // Store the entered name
  390. strncpy(app->login_username_logged_out, app->login_username_logged_out_temp_buffer, app->login_username_logged_out_temp_buffer_size);
  391. // Store the entered name in the logged in username field
  392. strncpy(app->login_username_logged_in, app->login_username_logged_out_temp_buffer, app->login_username_logged_out_temp_buffer_size);
  393. strncpy(app->login_username_logged_in_temp_buffer, app->login_username_logged_out_temp_buffer, app->login_username_logged_out_temp_buffer_size);
  394. // Ensure null-termination
  395. app->login_username_logged_out[app->login_username_logged_out_temp_buffer_size - 1] = '\0';
  396. // Update the name item text
  397. if (app->variable_item_logged_out_login_username)
  398. {
  399. variable_item_set_current_value_text(app->variable_item_logged_out_login_username, app->login_username_logged_out);
  400. }
  401. // Save the settings
  402. save_settings(app_instance->wifi_ssid_logged_out, app_instance->wifi_password_logged_out, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
  403. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutLogin);
  404. }
  405. /**
  406. * @brief Text input callback for when the user finishes entering their password on the login (logged out) screen.
  407. * @param context The context - FlipSocialApp object.
  408. * @return void
  409. */
  410. static void flip_social_logged_out_login_password_updated(void *context)
  411. {
  412. FlipSocialApp *app = (FlipSocialApp *)context;
  413. if (!app)
  414. {
  415. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  416. return;
  417. }
  418. // Store the entered password
  419. strncpy(app->login_password_logged_out, app->login_password_logged_out_temp_buffer, app->login_password_logged_out_temp_buffer_size);
  420. // Store the entered password in the change password field
  421. strncpy(app->change_password_logged_in, app->login_password_logged_out_temp_buffer, app->login_password_logged_out_temp_buffer_size);
  422. strncpy(app->change_password_logged_in_temp_buffer, app->login_password_logged_out_temp_buffer, app->login_password_logged_out_temp_buffer_size);
  423. // Ensure null-termination
  424. app->login_password_logged_out[app->login_password_logged_out_temp_buffer_size - 1] = '\0';
  425. // Update the password item text
  426. if (app->variable_item_logged_out_login_password)
  427. {
  428. // dont show the password on the screen (version 0.2)
  429. // variable_item_set_current_value_text(app->variable_item_logged_out_login_password, app->login_password_logged_out);
  430. }
  431. // Save the settings
  432. save_settings(app_instance->wifi_ssid_logged_out, app_instance->wifi_password_logged_out, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
  433. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutLogin);
  434. }
  435. /**
  436. * @brief Callback when the user selects a menu item in the login (logged out) screen.
  437. * @param context The context - FlipSocialApp object.
  438. * @param index The index of the selected item.
  439. * @return void
  440. */
  441. static void flip_social_text_input_logged_out_login_item_selected(void *context, uint32_t index)
  442. {
  443. FlipSocialApp *app = (FlipSocialApp *)context;
  444. if (!app)
  445. {
  446. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  447. return;
  448. }
  449. switch (index)
  450. {
  451. case 0: // Input Username
  452. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutLoginUsernameInput);
  453. break;
  454. case 1: // Input Password
  455. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutLoginPasswordInput);
  456. break;
  457. case 2: // Login Button
  458. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutProcessLogin);
  459. break;
  460. default:
  461. FURI_LOG_E(TAG, "Unknown configuration item index");
  462. break;
  463. }
  464. }
  465. /**
  466. * @brief Text input callback for when the user finishes entering their username on the register (logged out) screen.
  467. * @param context The context - FlipSocialApp object.
  468. * @return void
  469. */
  470. static void flip_social_logged_out_register_username_updated(void *context)
  471. {
  472. FlipSocialApp *app = (FlipSocialApp *)context;
  473. if (!app)
  474. {
  475. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  476. return;
  477. }
  478. // Store the entered name
  479. strncpy(app->register_username_logged_out, app->register_username_logged_out_temp_buffer, app->register_username_logged_out_temp_buffer_size);
  480. // Ensure null-termination
  481. app->register_username_logged_out[app->register_username_logged_out_temp_buffer_size - 1] = '\0';
  482. // Update the name item text
  483. if (app->variable_item_logged_out_register_username)
  484. {
  485. variable_item_set_current_value_text(app->variable_item_logged_out_register_username, app->register_username_logged_out);
  486. }
  487. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutRegister);
  488. }
  489. /**
  490. * @brief Text input callback for when the user finishes entering their password on the register (logged out) screen.
  491. * @param context The context - FlipSocialApp object.
  492. * @return void
  493. */
  494. static void flip_social_logged_out_register_password_updated(void *context)
  495. {
  496. FlipSocialApp *app = (FlipSocialApp *)context;
  497. if (!app)
  498. {
  499. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  500. return;
  501. }
  502. // Store the entered password
  503. strncpy(app->register_password_logged_out, app->register_password_logged_out_temp_buffer, app->register_password_logged_out_temp_buffer_size);
  504. // Ensure null-termination
  505. app->register_password_logged_out[app->register_password_logged_out_temp_buffer_size - 1] = '\0';
  506. // Update the password item text
  507. if (app->variable_item_logged_out_register_password)
  508. {
  509. variable_item_set_current_value_text(app->variable_item_logged_out_register_password, app->register_password_logged_out);
  510. }
  511. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutRegister);
  512. }
  513. /**
  514. * @brief Text input callback for when the user finishes entering their password 2 on the register (logged out) screen.
  515. * @param context The context - FlipSocialApp object.
  516. * @return void
  517. */
  518. static void flip_social_logged_out_register_password_2_updated(void *context)
  519. {
  520. FlipSocialApp *app = (FlipSocialApp *)context;
  521. if (!app)
  522. {
  523. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  524. return;
  525. }
  526. // Store the entered password
  527. strncpy(app->register_password_2_logged_out, app->register_password_2_logged_out_temp_buffer, app->register_password_2_logged_out_temp_buffer_size);
  528. // Ensure null-termination
  529. app->register_password_2_logged_out[app->register_password_2_logged_out_temp_buffer_size - 1] = '\0';
  530. // Update the password item text
  531. if (app->variable_item_logged_out_register_password_2)
  532. {
  533. variable_item_set_current_value_text(app->variable_item_logged_out_register_password_2, app->register_password_2_logged_out);
  534. }
  535. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutRegister);
  536. }
  537. /**
  538. * @brief Callback when the user selects a menu item in the register (logged out) screen.
  539. * @param context The context - FlipSocialApp object.
  540. * @param index The index of the selected item.
  541. * @return void
  542. */
  543. static void flip_social_text_input_logged_out_register_item_selected(void *context, uint32_t index)
  544. {
  545. FlipSocialApp *app = (FlipSocialApp *)context;
  546. if (!app)
  547. {
  548. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  549. return;
  550. }
  551. switch (index)
  552. {
  553. case 0: // Input Username
  554. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutRegisterUsernameInput);
  555. break;
  556. case 1: // Input Password
  557. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutRegisterPasswordInput);
  558. break;
  559. case 2: // Input Password 2
  560. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutRegisterPassword2Input);
  561. break;
  562. case 3: // Register button
  563. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedOutProcessRegister);
  564. break;
  565. default:
  566. FURI_LOG_E(TAG, "Unknown configuration item index");
  567. break;
  568. }
  569. }
  570. /**
  571. * @brief Text input callback for when the user finishes entering their SSID on the wifi settings (logged in) screen.
  572. * @param context The context - FlipSocialApp object.
  573. * @return void
  574. */
  575. static void flip_social_logged_in_wifi_settings_ssid_updated(void *context)
  576. {
  577. FlipSocialApp *app = (FlipSocialApp *)context;
  578. if (!app)
  579. {
  580. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  581. return;
  582. }
  583. // Store the entered SSID
  584. strncpy(app->wifi_ssid_logged_in, app->wifi_ssid_logged_in_temp_buffer, app->wifi_ssid_logged_in_temp_buffer_size);
  585. // Store the entered SSID in the logged out SSID
  586. strncpy(app->wifi_ssid_logged_out, app->wifi_ssid_logged_in, app->wifi_ssid_logged_in_temp_buffer_size);
  587. strncpy(app->wifi_ssid_logged_out_temp_buffer, app->wifi_ssid_logged_in, app->wifi_ssid_logged_in_temp_buffer_size);
  588. // Ensure null-termination
  589. app->wifi_ssid_logged_in[app->wifi_ssid_logged_in_temp_buffer_size - 1] = '\0';
  590. // Update the name item text
  591. if (app->variable_item_logged_in_wifi_settings_ssid)
  592. {
  593. variable_item_set_current_value_text(app->variable_item_logged_in_wifi_settings_ssid, app->wifi_ssid_logged_in);
  594. }
  595. // Save the settings
  596. save_settings(app_instance->wifi_ssid_logged_in, app_instance->wifi_password_logged_in, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
  597. // update the wifi settings
  598. if (strlen(app->wifi_ssid_logged_in) > 0 && strlen(app->wifi_password_logged_in) > 0)
  599. {
  600. if (!flipper_http_save_wifi(app->wifi_ssid_logged_in, app->wifi_password_logged_in))
  601. {
  602. FURI_LOG_E(TAG, "Failed to save wifi settings via UART");
  603. FURI_LOG_E(TAG, "Make sure the Flipper is connected to the Wifi Dev Board");
  604. }
  605. }
  606. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInSettingsWifi);
  607. }
  608. /**
  609. * @brief Text input callback for when the user finishes entering their password on the wifi settings (logged in) screen.
  610. * @param context The context - FlipSocialApp object.
  611. * @return void
  612. */
  613. static void flip_social_logged_in_wifi_settings_password_updated(void *context)
  614. {
  615. FlipSocialApp *app = (FlipSocialApp *)context;
  616. if (!app)
  617. {
  618. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  619. return;
  620. }
  621. // Store the entered password
  622. strncpy(app->wifi_password_logged_in, app->wifi_password_logged_in_temp_buffer, app->wifi_password_logged_in_temp_buffer_size);
  623. // Store the entered password in the logged out password
  624. strncpy(app->login_password_logged_out, app->wifi_password_logged_in, app->wifi_password_logged_in_temp_buffer_size);
  625. strncpy(app->login_password_logged_out_temp_buffer, app->wifi_password_logged_in, app->wifi_password_logged_in_temp_buffer_size);
  626. // Ensure null-termination
  627. app->wifi_password_logged_in[app->wifi_password_logged_in_temp_buffer_size - 1] = '\0';
  628. // Update the password item text
  629. if (app->variable_item_logged_in_wifi_settings_password)
  630. {
  631. // dont show the password on the screen (version 0.2)
  632. // variable_item_set_current_value_text(app->variable_item_logged_in_wifi_settings_password, app->wifi_password_logged_in);
  633. }
  634. // Save the settings
  635. save_settings(app_instance->wifi_ssid_logged_in, app_instance->wifi_password_logged_in, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
  636. // update the wifi settings
  637. if (strlen(app->wifi_ssid_logged_in) > 0 && strlen(app->wifi_password_logged_in) > 0)
  638. {
  639. if (!flipper_http_save_wifi(app->wifi_ssid_logged_in, app->wifi_password_logged_in))
  640. {
  641. FURI_LOG_E(TAG, "Failed to save wifi settings via UART");
  642. FURI_LOG_E(TAG, "Make sure the Flipper is connected to the Wifi Dev Board");
  643. }
  644. }
  645. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInSettingsWifi);
  646. }
  647. /**
  648. * @brief Callback when the user selects a menu item in the wifi settings (logged in) screen.
  649. * @param context The context - FlipSocialApp object.
  650. * @param index The index of the selected item.
  651. * @return void
  652. */
  653. static void flip_social_text_input_logged_in_wifi_settings_item_selected(void *context, uint32_t index)
  654. {
  655. FlipSocialApp *app = (FlipSocialApp *)context;
  656. if (!app)
  657. {
  658. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  659. return;
  660. }
  661. switch (index)
  662. {
  663. case 0: // Input SSID
  664. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInWifiSettingsSSIDInput);
  665. break;
  666. case 1: // Input Password
  667. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInWifiSettingsPasswordInput);
  668. break;
  669. default:
  670. FURI_LOG_E(TAG, "Unknown configuration item index");
  671. break;
  672. }
  673. }
  674. /**
  675. * @brief Text input callback for when the user finishes entering their message on the compose (logged in) screen for Add Text
  676. * @param context The context - FlipSocialApp object.
  677. * @return void
  678. */
  679. static void flip_social_logged_in_compose_pre_save_updated(void *context)
  680. {
  681. FlipSocialApp *app = (FlipSocialApp *)context;
  682. if (!app)
  683. {
  684. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  685. return;
  686. }
  687. // check if the message is empty or if adding in the message would exceed the MAX_PRE_SAVED_MESSAGES
  688. if (app->compose_pre_save_logged_in_temp_buffer_size == 0 || app->pre_saved_messages.count >= MAX_PRE_SAVED_MESSAGES)
  689. {
  690. FURI_LOG_E(TAG, "Message is empty or would exceed the maximum number of pre-saved messages");
  691. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInCompose);
  692. return;
  693. }
  694. // Store the entered message
  695. strncpy(app->compose_pre_save_logged_in, app->compose_pre_save_logged_in_temp_buffer, app->compose_pre_save_logged_in_temp_buffer_size);
  696. // Ensure null-termination
  697. app->compose_pre_save_logged_in[app->compose_pre_save_logged_in_temp_buffer_size - 1] = '\0';
  698. // add the item to the submenu
  699. submenu_reset(app->submenu_compose);
  700. // loop through the items and add them to the submenu
  701. app->pre_saved_messages.messages[app->pre_saved_messages.count] = app->compose_pre_save_logged_in;
  702. app->pre_saved_messages.count++;
  703. submenu_add_item(app->submenu_compose, "Add Pre-Save", FlipSocialSubmenuComposeIndexAddPreSave, flip_social_callback_submenu_choices, app);
  704. for (uint32_t i = 0; i < app->pre_saved_messages.count; i++)
  705. {
  706. submenu_add_item(app->submenu_compose, app->pre_saved_messages.messages[i], FlipSocialSubemnuComposeIndexStartIndex + i, flip_social_callback_submenu_choices, app);
  707. }
  708. // save playlist
  709. save_playlist(&app->pre_saved_messages);
  710. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInCompose);
  711. }
  712. /**
  713. * @brief Text input callback for when the user finishes entering their message on the profile (logged in) screen for change password
  714. * @param context The context - FlipSocialApp object.
  715. * @return void
  716. */
  717. static void flip_social_logged_in_profile_change_password_updated(void *context)
  718. {
  719. FlipSocialApp *app = (FlipSocialApp *)context;
  720. if (!app)
  721. {
  722. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  723. return;
  724. }
  725. // Correct type: old_pass should be a pointer to a string (char *)
  726. const char *old_password = app->login_password_logged_out;
  727. // Store the entered message
  728. strncpy(app->change_password_logged_in, app->change_password_logged_in_temp_buffer, app->change_password_logged_in_temp_buffer_size);
  729. // store the entered password in the logged out password
  730. strncpy(app->login_password_logged_out, app->change_password_logged_in, app->login_password_logged_out_temp_buffer_size);
  731. strncpy(app->login_password_logged_out_temp_buffer, app->change_password_logged_in, app->login_password_logged_out_temp_buffer_size);
  732. // Ensure null-termination
  733. app->change_password_logged_in[app->change_password_logged_in_temp_buffer_size - 1] = '\0';
  734. // Update the message item text
  735. if (app->variable_item_logged_in_profile_change_password)
  736. {
  737. // dont show the password on the screen (version 0.2)
  738. // variable_item_set_current_value_text(app->variable_item_logged_in_profile_change_password, app->change_password_logged_in);
  739. }
  740. // send post request to change password
  741. char payload[256];
  742. snprintf(payload, sizeof(payload), "{\"username\":\"%s\",\"old_password\":\"%s\",\"new_password\":\"%s\"}", app->login_username_logged_out, old_password, app->change_password_logged_in);
  743. char *headers = jsmn("Content-Type", "application/json");
  744. if (!flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/change-password/", headers, payload))
  745. {
  746. FURI_LOG_E(TAG, "Failed to send post request to change password");
  747. FURI_LOG_E(TAG, "Make sure the Flipper is connected to the Wifi Dev Board");
  748. free(headers);
  749. return;
  750. }
  751. free(headers);
  752. // Save the settings
  753. save_settings(app_instance->wifi_ssid_logged_out, app_instance->wifi_password_logged_out, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
  754. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInProfile);
  755. }
  756. /**
  757. * @brief Callback when a user selects a menu item in the profile (logged in) screen.
  758. * @param context The context - FlipSocialApp object.
  759. * @param index The index of the selected item.
  760. * @return void
  761. */
  762. static void flip_social_text_input_logged_in_profile_item_selected(void *context, uint32_t index)
  763. {
  764. FlipSocialApp *app = (FlipSocialApp *)context;
  765. if (!app)
  766. {
  767. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  768. return;
  769. }
  770. switch (index)
  771. {
  772. case 0: // Change Username
  773. // do nothing since username cannot be changed
  774. break;
  775. case 1: // Change Password
  776. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInChangePasswordInput);
  777. break;
  778. case 2: // Friends
  779. // get friends then switch to the friends screen
  780. if (flip_social_get_friends()) // start the async friends request
  781. {
  782. furi_timer_start(fhttp.get_timeout_timer, TIMEOUT_DURATION_TICKS);
  783. }
  784. while (fhttp.state == RECEIVING && furi_timer_is_running(fhttp.get_timeout_timer) > 0)
  785. {
  786. // Wait for the friends to be received
  787. furi_delay_ms(100);
  788. }
  789. furi_timer_stop(fhttp.get_timeout_timer);
  790. if (!flip_social_parse_json_friends()) // parse the JSON before switching to the friends (synchonous)
  791. {
  792. FURI_LOG_E(TAG, "Failed to parse the JSON friends...");
  793. return; // just return for now, no temporary friends yet
  794. // show a popup message saving wifi is disconnected
  795. }
  796. furi_timer_stop(fhttp.get_timeout_timer);
  797. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInFriendsSubmenu);
  798. break;
  799. default:
  800. FURI_LOG_E(TAG, "Unknown configuration item index");
  801. break;
  802. }
  803. }
  804. /**
  805. * @brief Callback when a user selects a menu item in the settings (logged in) screen.
  806. * @param context The context - FlipSocialApp object.
  807. * @param index The index of the selected item.
  808. * @return void
  809. */
  810. static void flip_social_text_input_logged_in_settings_item_selected(void *context, uint32_t index)
  811. {
  812. FlipSocialApp *app = (FlipSocialApp *)context;
  813. if (!app)
  814. {
  815. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  816. return;
  817. }
  818. switch (index)
  819. {
  820. case 0: // About
  821. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInSettingsAbout);
  822. break;
  823. case 1: // Wifi
  824. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInSettingsWifi);
  825. break;
  826. default:
  827. break;
  828. }
  829. }
  830. /**
  831. * @brief Text input callback for when the user finishes entering their message to send to the selected user choice (user choice messages view)
  832. * @param context The context - FlipSocialApp object.
  833. * @return void
  834. */
  835. static void flip_social_logged_in_messages_user_choice_message_updated(void *context)
  836. {
  837. FlipSocialApp *app = (FlipSocialApp *)context;
  838. if (!app)
  839. {
  840. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  841. return;
  842. }
  843. // check if the message is empty
  844. if (app->message_user_choice_logged_in_temp_buffer_size == 0)
  845. {
  846. FURI_LOG_E(TAG, "Message is empty");
  847. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInMessagesNewMessageUserChoicesInput);
  848. return;
  849. }
  850. // Store the entered message
  851. strncpy(app->message_user_choice_logged_in, app->message_user_choice_logged_in_temp_buffer, app->message_user_choice_logged_in_temp_buffer_size);
  852. // Ensure null-termination
  853. app->message_user_choice_logged_in[app->message_user_choice_logged_in_temp_buffer_size - 1] = '\0';
  854. // send post request to send message
  855. char url[128];
  856. char payload[256];
  857. snprintf(url, sizeof(url), "https://www.flipsocial.net/api/messages/%s/post/", app->login_username_logged_in);
  858. snprintf(payload, sizeof(payload), "{\"receiver\":\"%s\",\"content\":\"%s\"}", app_instance->flip_social_explore.usernames[app_instance->flip_social_explore.index], app->message_user_choice_logged_in);
  859. char *headers = jsmn("Content-Type", "application/json");
  860. if (flipper_http_post_request_with_headers(url, headers, payload)) // start the async request
  861. {
  862. furi_timer_start(fhttp.get_timeout_timer, TIMEOUT_DURATION_TICKS);
  863. fhttp.state = RECEIVING;
  864. free(headers);
  865. }
  866. else
  867. {
  868. FURI_LOG_E(TAG, "Failed to send post request to send message");
  869. FURI_LOG_E(TAG, "Make sure the Flipper is connected to the Wifi Dev Board");
  870. free(headers);
  871. return;
  872. }
  873. while (fhttp.state == RECEIVING && furi_timer_is_running(fhttp.get_timeout_timer) > 0)
  874. {
  875. // Wait for the request to be received
  876. furi_delay_ms(100);
  877. }
  878. furi_timer_stop(fhttp.get_timeout_timer);
  879. // add user to the message list
  880. strncpy(app_instance->flip_social_message_users.usernames[app_instance->flip_social_message_users.count], app_instance->flip_social_explore.usernames[app_instance->flip_social_explore.index], strlen(app_instance->flip_social_explore.usernames[app_instance->flip_social_explore.index]));
  881. app_instance->flip_social_message_users.count++;
  882. // redraw submenu
  883. flip_social_update_messages_submenu();
  884. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInMessagesSubmenu);
  885. }
  886. /**
  887. * @brief Text input callback for when the user finishes entering their message to the selected user (messages view)
  888. * @param context The context - FlipSocialApp object.
  889. * @return void
  890. */
  891. static void flip_social_logged_in_messages_new_message_updated(void *context)
  892. {
  893. FlipSocialApp *app = (FlipSocialApp *)context;
  894. if (!app)
  895. {
  896. FURI_LOG_E(TAG, "FlipSocialApp is NULL");
  897. return;
  898. }
  899. // check if the message is empty
  900. if (app->messages_new_message_logged_in_temp_buffer_size == 0)
  901. {
  902. FURI_LOG_E(TAG, "Message is empty");
  903. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInMessagesNewMessageInput);
  904. return;
  905. }
  906. // Store the entered message
  907. strncpy(app->messages_new_message_logged_in, app->messages_new_message_logged_in_temp_buffer, app->messages_new_message_logged_in_temp_buffer_size);
  908. // Ensure null-termination
  909. app->messages_new_message_logged_in[app->messages_new_message_logged_in_temp_buffer_size - 1] = '\0';
  910. // send post request to send message
  911. char url[128];
  912. char payload[256];
  913. snprintf(url, sizeof(url), "https://www.flipsocial.net/api/messages/%s/post/", app->login_username_logged_in);
  914. snprintf(payload, sizeof(payload), "{\"receiver\":\"%s\",\"content\":\"%s\"}", app_instance->flip_social_message_users.usernames[app_instance->flip_social_message_users.index], app->messages_new_message_logged_in);
  915. char *headers = jsmn("Content-Type", "application/json");
  916. if (flipper_http_post_request_with_headers(url, headers, payload)) // start the async request
  917. {
  918. furi_timer_start(fhttp.get_timeout_timer, TIMEOUT_DURATION_TICKS);
  919. fhttp.state = RECEIVING;
  920. free(headers);
  921. }
  922. else
  923. {
  924. FURI_LOG_E(TAG, "Failed to send post request to send message");
  925. FURI_LOG_E(TAG, "Make sure the Flipper is connected to the Wifi Dev Board");
  926. free(headers);
  927. return;
  928. }
  929. while (fhttp.state == RECEIVING && furi_timer_is_running(fhttp.get_timeout_timer) > 0)
  930. {
  931. // Wait for the request to be received
  932. furi_delay_ms(100);
  933. }
  934. furi_timer_stop(fhttp.get_timeout_timer);
  935. view_dispatcher_switch_to_view(app->view_dispatcher, FlipSocialViewLoggedInMessagesSubmenu);
  936. }
  937. #endif // FLIP_SOCIAL_CALLBACK_H