1 #ifndef FLIST_H 2 #define FLIST_H 3 4 #include <stdbool.h> 5 #include <stdint.h> 6 7 typedef struct groupchat GROUPCHAT; 8 typedef struct utox_friend FRIEND; 9 typedef struct utox_friend_request FREQUEST; 10 11 // call to switch to previous or next friend in list 12 void flist_previous_tab(void); 13 void flist_next_tab(void); 14 15 /* switch to first or last shown item in list */ 16 void flist_first_tab(void); 17 void flist_last_tab(void); 18 19 // update the shown list, should be called whenever something relevant to the filters is done 20 // (like changing name, going online, etc.) 21 void flist_update_shown_list(void); 22 23 // set or get current list filter. Updates list afterwards 24 uint8_t flist_get_filter(void); 25 void flist_set_filter(uint8_t filter); 26 27 // set the search string in the list. Disable search by setting it to NULL. Updates list afterwards 28 // warning: list will just remember the pointer, it will assume you won't deallocate the memory, and it 29 // won't deallocate it after setting to NULL. The string should be NULL-terminated. 30 void flist_search(char *str); 31 32 /* non-exhaustive list of panels we to select from, it's probably better to replace this but I don't know with what. */ 33 typedef enum { 34 ITEM_NONE, 35 ITEM_SETTINGS, 36 ITEM_ADD, 37 ITEM_FRIEND, 38 ITEM_FREQUEST, 39 ITEM_GROUP, 40 ITEM_GROUP_CREATE, 41 } ITEM_TYPE; 42 43 typedef struct { 44 ITEM_TYPE type; 45 uint32_t id_number; 46 } ITEM; 47 48 void flist_start(void); 49 void flist_add_friend(FRIEND *f, const char *msg, const int msg_length); 50 void flist_add_friend_accepted(FRIEND *f, FREQUEST *req); 51 void flist_add_group(GROUPCHAT *g); 52 void flist_add_frequest(FREQUEST *f); 53 void flist_delete_sitem(void); 54 void flist_delete_rmouse_item(void); 55 56 void flist_selectchat(int index); 57 void flist_selectaddfriend(void); 58 void flist_reselect_current(void); 59 void flist_selectsettings(void); 60 void flist_selectswap(void); 61 62 void flist_re_scale(void); 63 64 void flist_freeall(void); 65 66 /* New naming patten */ 67 void flist_select_last(void); 68 void flist_dump_contacts(void); 69 void flist_reload_contacts(void); 70 71 FRIEND *flist_get_friend(void); 72 FREQUEST *flist_get_frequest(void); 73 GROUPCHAT *flist_get_groupchat(void); 74 ITEM_TYPE flist_get_type(void); 75 76 bool try_open_tox_uri(const char *str); 77 78 /* UI functions */ 79 void flist_draw(void *n, int x, int y, int width, int height); 80 bool flist_mmove(void *n, int x, int y, int width, int height, int mx, int my, int dx, int dy); 81 bool flist_mdown(void *n); 82 bool flist_mright(void *n); 83 bool flist_mwheel(void *n, int height, double d, bool smooth); 84 bool flist_mup(void *n); 85 bool flist_mleave(void *n); 86 87 #endif 88