-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflip_social.h
328 lines (290 loc) · 17.5 KB
/
flip_social.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#ifndef FLIP_SOCIAL_H
#define FLIP_SOCIAL_H
#include <easy_flipper/easy_flipper.h>
#include <dialogs/dialogs.h>
#include <storage/storage.h>
#include <flipper_http/flipper_http.h>
#include <input/input.h>
#include <flip_social_icons.h>
#include <font/font.h>
#define TAG "FlipSocial"
#define VERSION_TAG TAG " v1.0.3"
#define MAX_PRE_SAVED_MESSAGES 20 // Maximum number of pre-saved messages
#define MAX_MESSAGE_LENGTH 100 // Maximum length of a message in the feed
#define MAX_EXPLORE_USERS 50 // Maximum number of users to explore
#define MAX_USER_LENGTH 32 // Maximum length of a username
#define MAX_FRIENDS 50 // Maximum number of friends
#define MAX_FEED_ITEMS 20 // Maximum number of feed items
#define MAX_LINE_LENGTH 27
#define MAX_MESSAGE_USERS 40 // Maximum number of users to display in the submenu
#define MAX_MESSAGES 20 // Maximum number of meesages between each user
#define SETTINGS_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/settings.bin"
#define PRE_SAVED_MESSAGES_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/pre_saved_messages.txt"
// Define the submenu items for our Hello World application
typedef enum
{
FlipSocialSubmenuLoggedOutIndexLogin, // click to go to the login screen
FlipSocialSubmenuLoggedOutIndexRegister, // click to go to the register screen
//
FlipSocialSubmenuLoggedOutIndexAbout, // click to go to the about screen
FlipSocialSubmenuLoggedOutIndexWifiSettings, // click to go to the wifi settings screen
FlipSocialSubmenuLoggedInIndexUserSettings, // click to go to the user settings screen
//
FlipSocialSubmenuLoggedInIndexAbout, // click to go to the about screen
FlipSocialSubmenuLoggedInIndexWifiSettings, // click to go to the wifi settings screen
//
FlipSocialSubmenuLoggedInIndexProfile, // click to go to the profile screen
FlipSocialSubmenuExploreIndex, // click to go to the explore
FlipSocialSubmenuLoggedInIndexFeed, // click to go to the feed screen
FlipSocialSubmenuLoggedInIndexMessages, // click to go to the messages screen
FlipSocialSubmenuLoggedInIndexCompose, // click to go to the compose screen
FlipSocialSubmenuLoggedInIndexSettings, // click to go to the settings screen
FlipSocialSubmenuLoggedInSignOutButton, // click to sign out
//
FlipSocialSubmenuLoggedInIndexMessagesNewMessage, // click to add a new message
//
FlipSocialSubmenuComposeIndexAddPreSave, // click to add a pre-saved message
FlipSocialSubemnuComposeIndexStartIndex = 100, // starting index for the first pre saved message
//
FlipSocialSubmenuExploreIndexStartIndex = 200, // starting index for the users to explore
//
FlipSocialSubmenuLoggedInIndexFriendsStart = 400, // starting index for the friends
//
FlipSocialSubmenuLoggedInIndexMessagesUsersStart = 600, // starting index for the messages
//
FlipSocialSubmenuLoggedInIndexMessagesUserChoicesIndexStart = 800, // click to select a user to message
} FlipSocialSubmenuIndex;
// Define the ScriptPlaylist structure
typedef struct
{
char messages[MAX_PRE_SAVED_MESSAGES][MAX_MESSAGE_LENGTH];
size_t count;
size_t index;
} PreSavedPlaylist;
// Define a FlipSocialFeed individual item
typedef struct
{
char username[MAX_USER_LENGTH];
char message[MAX_MESSAGE_LENGTH];
char date_created[MAX_LINE_LENGTH];
bool is_flipped;
int id;
int flips;
} FlipSocialFeedItem;
typedef struct
{
int ids[MAX_FEED_ITEMS];
size_t count;
size_t index;
int series_index;
} FlipSocialFeedMini;
typedef struct
{
char usernames[MAX_EXPLORE_USERS][MAX_USER_LENGTH];
int count;
int index;
} FlipSocialModel;
typedef struct
{
char usernames[MAX_MESSAGE_USERS][MAX_USER_LENGTH];
int count;
int index;
} FlipSocialModel2;
typedef struct
{
char usernames[MAX_MESSAGES][MAX_USER_LENGTH];
char messages[MAX_MESSAGES][MAX_MESSAGE_LENGTH];
int count;
int index;
} FlipSocialMessage;
// Define views for our Hello World application
typedef enum
{
FlipSocialViewLoggedOutSubmenu, // The menu if the user is not logged in
FlipSocialViewLoggedOutLogin, // The login screen
FlipSocialViewLoggedOutRegister, // The register screen
FlipSocialViewLoggedOutAbout, // The about screen
FlipSocialViewLoggedOutWifiSettings, // The wifi settings screen
//
FlipSocialViewLoggedOutLoginUsernameInput, // Text input screen for username input on login screen
FlipSocialViewLoggedOutLoginPasswordInput, // Text input screen for password input on login screen
FlipSocialViewLoggedOutRegisterUsernameInput, // Text input screen for username input on register screen
FlipSocialViewLoggedOutRegisterPasswordInput, // Text input screen for password input on register screen
FlipSocialViewLoggedOutRegisterPassword2Input, // Text input screen for password 2 input on register screen
FlipSocialViewLoggedOutWifiSettingsSSIDInput, // Text input screen for SSID input on wifi screen
FlipSocialViewLoggedOutWifiSettingsPasswordInput, // Text input screen for Password input on wifi screen
FlipSocialViewLoggedOutProcessLogin, // The screen displayed after clicking login
FlipSocialViewLoggedOutProcessRegister, // The screen displayed after clicking register
//
FlipSocialViewLoggedInSubmenu, // The menu if the user is logged in
FlipSocialViewLoggedInProfile, // The profile screen
FlipSocialViewLoggedInFeed, // The feed screen
FlipSocialViewLoggedInCompose, // The compose screen
FlipSocialViewLoggedInSettings, // The settings screen
//
FlipSocialViewLoggedInChangeBioInput, // Text input screen for bio input on profile screen
FlipSocialViewLoggedInChangePasswordInput, // Text input screen for password input on change password screen
FlipSocialViewLoggedInComposeAddPreSaveInput, // Text input screen for add text input on compose screen
//
FlipSocialViewLoggedInMessagesNewMessageInput, // Text input screen for new message input on messages screen
FlipSocialViewLoggedInMessagesNewMessageUserChoicesInput, // Text input screen for new message input on messages screen
FlipSocialViewLoggedInMessagesUserChoices, // the view after clicking [New Message] - select a user to message, then direct to input view
FlipSocialViewLoggedInExploreInput, // Text input screen for explore input on explore screen
FlipSocialViewLoggedInMessageUsersInput,
//
FlipSocialViewLoggedInSettingsAbout, // The about screen
FlipSocialViewLoggedInSettingsWifi, // The wifi settings screen
FlipSocialViewLoggedInSettingsUser, // The user settings screen
FlipSocialViewLoggedInWifiSettingsSSIDInput, // Text input screen for SSID input on wifi screen
FlipSocialViewLoggedInWifiSettingsPasswordInput, // Text input screen for Password input on wifi screen
//
FlipSocialViewLoggedInSignOut, // The view after clicking the sign out button
//
FlipSocialViewLoggedInExploreSubmenu, // The view after clicking the explore button
FlipSocialViewLoggedInFriendsSubmenu, // The view after clicking the friends button on the profile screen
FlipSocialViewLoggedInMessagesSubmenu, // The view after clicking the messages button on the profile screen
//
FlipSocialViewLoading, // The loading screen
//
FlipSocialViewWidgetResult, // The text box that displays the random fact
FlipSocialViewLoader, // The loader screen retrieves data from the internet
//
FlipSocialViewExploreDialog, // The dialog for the explore screen
FlipSocialViewFriendsDialog, // The dialog for the friends screen
FlipSocialViewMessagesDialog, // The dialog for the messages screen
FlipSocialViewComposeDialog, // The dialog for the compose screen
//
FlipSocialViewTextInput, // The text input screen
FlipSocialViewVariableItemList,
//
FlipSocialViewSubmenu,
} FlipSocialView;
// Define the application structure
typedef struct
{
View *view_loader;
Widget *widget_result;
//
ViewDispatcher *view_dispatcher; // Switches between our views
Submenu *submenu_logged_out; // The application submenu (logged out)
Submenu *submenu_logged_in; // The application submenu (logged in)
//
Submenu *submenu;
//
Widget *widget_logged_out_about; // The about screen (logged out)
Widget *widget_logged_in_about; // The about screen (logged in)
VariableItemList *variable_item_list; // The main menu
UART_TextInput *text_input; // The text input
VariableItem *variable_item_logged_out_wifi_settings_ssid; // Reference to the ssid configuration item
VariableItem *variable_item_logged_out_wifi_settings_password; // Reference to the password configuration item
VariableItem *variable_item_logged_out_login_username; // Reference to the username configuration item
VariableItem *variable_item_logged_out_login_password; // Reference to the password configuration item
VariableItem *variable_item_logged_out_login_button; // Reference to the login button configuration item
VariableItem *variable_item_logged_out_register_username; // Reference to the username configuration item
VariableItem *variable_item_logged_out_register_password; // Reference to the password configuration item
VariableItem *variable_item_logged_out_register_password_2; // Reference to the password 2 configuration item
VariableItem *variable_item_logged_out_register_button; // Reference to the register button configuration item
//
VariableItem *variable_item_logged_in_profile_username; // Reference to the username configuration item
VariableItem *variable_item_logged_in_profile_change_password; // Reference to the change password configuration item
VariableItem *variable_item_logged_in_profile_change_bio; // Reference to the change bio configuration item
//
VariableItem *variable_item_logged_in_settings_about; // Reference to the about configuration item
VariableItem *variable_item_logged_in_settings_wifi; // Reference to the wifi settings configuration item
VariableItem *variable_item_logged_in_settings_user; // Reference to the user settings configuration item
VariableItem *variable_item_logged_in_user_settings_feed_type; // Reference to the feed type configuration item
VariableItem *variable_item_logged_in_user_settings_notifications; // Reference to the notifications configuration item
VariableItem *variable_item_logged_in_wifi_settings_ssid; // Reference to the ssid configuration item
VariableItem *variable_item_logged_in_wifi_settings_password; // Reference to the password configuration item
//
VariableItem *variable_item_logged_in_profile_friends; // Reference to the friends configuration item
//
PreSavedPlaylist pre_saved_messages; // Pre-saved messages for the feed screen
char *is_logged_in; // Store the login status
uint32_t is_logged_in_size; // Size of the login status buffer
char *login_username_logged_in; // Store the entered login username
char *login_username_logged_in_temp_buffer; // Temporary buffer for login username text input
uint32_t login_username_logged_in_temp_buffer_size; // Size of the login username temporary buffer
char *change_bio_logged_in; // Store the entered bio
char *change_bio_logged_in_temp_buffer; // Temporary buffer for bio text input
uint32_t change_bio_logged_in_temp_buffer_size; // Size of the bio temporary buffer
//
char *wifi_ssid_logged_out; // Store the entered wifi ssid
char *wifi_ssid_logged_out_temp_buffer; // Temporary buffer for wifi ssid text input
uint32_t wifi_ssid_logged_out_temp_buffer_size; // Size of the wifi ssid temporary buffer
char *wifi_password_logged_out; // Store the entered wifi password
char *wifi_password_logged_out_temp_buffer; // Temporary buffer for wifi_password text input
uint32_t wifi_password_logged_out_temp_buffer_size; // Size of the wifi_password temporary buffer
char *login_username_logged_out; // Store the entered login username
char *login_username_logged_out_temp_buffer; // Temporary buffer for login username text input
uint32_t login_username_logged_out_temp_buffer_size; // Size of the login username temporary buffer
char *login_password_logged_out; // Store the entered login password
char *login_password_logged_out_temp_buffer; // Temporary buffer for login password text input
uint32_t login_password_logged_out_temp_buffer_size; // Size of the login password temporary buffer
char *register_username_logged_out; // Store the entered register username
char *register_username_logged_out_temp_buffer; // Temporary buffer for register username text input
uint32_t register_username_logged_out_temp_buffer_size; // Size of the register username temporary buffer
char *register_password_logged_out; // Store the entered register password
char *register_password_logged_out_temp_buffer; // Temporary buffer for register password text input
uint32_t register_password_logged_out_temp_buffer_size; // Size of the register password temporary buffer
char *register_password_2_logged_out; // Store the entered register password 2
char *register_password_2_logged_out_temp_buffer; // Temporary buffer for register password 2 text input
uint32_t register_password_2_logged_out_temp_buffer_size; // Size of the register password 2 temporary buffer
//
char *change_password_logged_in; // Store the entered change password
char *change_password_logged_in_temp_buffer; // Temporary buffer for change password text input
uint32_t change_password_logged_in_temp_buffer_size; // Size of the change password temporary buffer
char *compose_pre_save_logged_in; // Store the entered add text
char *compose_pre_save_logged_in_temp_buffer; // Temporary buffer for add text text input
uint32_t compose_pre_save_logged_in_temp_buffer_size; // Size of the add text temporary buffer
char *wifi_ssid_logged_in; // Store the entered wifi ssid
char *wifi_ssid_logged_in_temp_buffer; // Temporary buffer for wifi ssid text input
uint32_t wifi_ssid_logged_in_temp_buffer_size; // Size of the wifi ssid temporary buffer
char *wifi_password_logged_in; // Store the entered wifi password
char *wifi_password_logged_in_temp_buffer; // Temporary buffer for wifi_password text input
uint32_t wifi_password_logged_in_temp_buffer_size; // Size of the wifi_password temporary buffer
//
char *messages_new_message_logged_in; // Store the entered new message
char *messages_new_message_logged_in_temp_buffer; // Temporary buffer for new message text input
uint32_t messages_new_message_logged_in_temp_buffer_size; // Size of the new message temporary buffer
char *message_user_choice_logged_in; // Store the entered message to send to the selected user
char *message_user_choice_logged_in_temp_buffer; // Temporary buffer for message to send to the selected user
uint32_t message_user_choice_logged_in_temp_buffer_size; // Size of the message to send to the selected user temporary buffer
//
char *explore_logged_in; // Store the entered explore
char *explore_logged_in_temp_buffer; // Temporary buffer for explore text input
uint32_t explore_logged_in_temp_buffer_size; // Size of the explore temporary buffer
char *message_users_logged_in; // Store the entered message users
char *message_users_logged_in_temp_buffer; // Temporary buffer for message users text input
uint32_t message_users_logged_in_temp_buffer_size; // Size of the message users temporary buffer
DialogEx *dialog_explore;
DialogEx *dialog_friends;
DialogEx *dialog_messages;
DialogEx *dialog_compose;
View *view_feed;
char *explore_user_bio; // Store the bio of the selected user
} FlipSocialApp;
void flip_social_app_free(FlipSocialApp *app);
extern FlipSocialModel *flip_social_friends; // Store the friends
extern FlipSocialModel2 *flip_social_message_users; // Store the users that have sent messages to the logged in user
extern FlipSocialModel *flip_social_explore; // Store the users to explore
extern FlipSocialMessage *flip_social_messages; // Store the messages between the logged in user and the selected user
extern FlipSocialFeedMini *flip_feed_info; // Store the feed info
extern FlipSocialFeedItem *flip_feed_item; // Store a feed item
extern FlipSocialApp *app_instance;
extern bool flip_social_sent_login_request;
extern bool flip_social_sent_register_request;
extern bool flip_social_login_success;
extern bool flip_social_register_success;
extern bool flip_social_dialog_shown;
extern bool flip_social_dialog_stop;
extern bool flip_social_send_message;
extern char *selected_message;
extern char auth_headers[256];
//
extern char *flip_social_feed_type[];
extern uint8_t flip_social_feed_type_index;
//
extern char *flip_social_notification_type[];
extern uint8_t flip_social_notification_type_index;
#endif