1 #ifndef _PURPLE_SLACK_H 2 #define _PURPLE_SLACK_H 3 4 #include <string.h> 5 6 #include <account.h> 7 8 #include "glibcompat.h" 9 #include "purple-websocket.h" 10 #include "slack-object.h" 11 12 #define SLACK_PLUGIN_ID "prpl-slack" 13 14 #define MARK_LIST_END ((SlackObject *)1) 15 16 typedef struct _SlackAccount { 17 PurpleAccount *account; 18 PurpleConnection *gc; 19 char *email; 20 char *host; 21 char *api_url; /* e.g., "https://slack.com/api" */ 22 char *token; /* url encoded */ 23 24 short login_step; 25 struct _SlackAPICall *api_calls; /* linked list */ 26 PurpleWebsocket *rtm; 27 guint rtm_id; 28 GHashTable *rtm_call; /* unsigned rtm_id -> SlackRTMCall */ 29 guint ping_timer; 30 31 struct _SlackTeam { 32 char *id; 33 char *name; 34 char *domain; 35 } team; 36 struct _SlackUser *self; 37 38 GHashTable *users; /* slack_object_id user_id -> SlackUser (ref) */ 39 GHashTable *user_names; /* char *user_name -> SlackUser (no ref) */ 40 GHashTable *ims; /* slack_object_id im_id -> SlackUser (no ref) */ 41 42 GHashTable *channels; /* slack_object_id channel_id -> SlackChannel (ref) */ 43 GHashTable *channel_names; /* char *chan_name -> SlackChannel (no ref) */ 44 int cid; 45 GHashTable *channel_cids; /* int purple_chat_id -> SlackChannel (no ref) */ 46 47 PurpleGroup *blist; /* default group for ims/channels */ 48 GHashTable *buddies; /* char *slack_id -> PurpleBListNode */ 49 gboolean roomlist_stop; 50 51 guint mark_timer; 52 SlackObject *mark_list; 53 54 GQueue *avatar_queue; /* Queue for avatar downloads */ 55 56 gboolean away; 57 } SlackAccount; 58 59 void slack_login_step(SlackAccount *sa); 60 GHashTable *slack_chat_info_defaults(PurpleConnection *gc, const char *name); 61 get_slack_account(PurpleAccount * account)62static inline SlackAccount *get_slack_account(PurpleAccount *account) { 63 if (!account || !account->gc || strcmp(account->protocol_id, SLACK_PLUGIN_ID)) 64 return NULL; 65 return account->gc->proto_data; 66 } 67 68 #endif // _PURPLE_SLACK_H 69