Changeset 5ebff60 for protocols/msn/msn.h
- Timestamp:
- 2015-02-20T22:50:54Z (9 years ago)
- Branches:
- master
- Children:
- 0b9daac, 3d45471, 7733b8c
- Parents:
- af359b4
- git-author:
- Indent <please@…> (19-02-15 05:47:20)
- git-committer:
- dequis <dx@…> (20-02-15 22:50:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.h
raf359b4 r5ebff60 1 1 /********************************************************************\ 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * … … 35 35 36 36 #ifdef DEBUG_MSN 37 #define debug( text... ) imcb_log( ic, text);37 #define debug(text ...) imcb_log(ic, text); 38 38 #else 39 #define debug( text...)39 #define debug(text ...) 40 40 #endif 41 41 … … 69 69 70 70 #define MSN_MESSAGE_HEADERS "MIME-Version: 1.0\r\n" \ 71 72 73 74 71 "Content-Type: text/plain; charset=UTF-8\r\n" \ 72 "User-Agent: BitlBee " BITLBEE_VERSION "\r\n" \ 73 "X-MMS-IM-Format: FN=MS%20Shell%20Dlg; EF=; CO=0; CS=0; PF=0\r\n" \ 74 "\r\n" 75 75 76 76 #define MSN_TYPING_HEADERS "MIME-Version: 1.0\r\n" \ 77 78 79 77 "Content-Type: text/x-msmsgscontrol\r\n" \ 78 "TypingUser: %s\r\n" \ 79 "\r\n\r\n" 80 80 81 81 #define MSN_NUDGE_HEADERS "MIME-Version: 1.0\r\n" \ 82 83 84 85 82 "Content-Type: text/x-msnmsgr-datacast\r\n" \ 83 "\r\n" \ 84 "ID: 1\r\n" \ 85 "\r\n" 86 86 87 87 #define MSN_SB_KEEPALIVE_HEADERS "MIME-Version: 1.0\r\n" \ 88 89 88 "Content-Type: text/x-ping\r\n" \ 89 "\r\n\r\n" 90 90 91 91 #define PROFILE_URL "http://members.msn.com/" 92 92 93 typedef enum 94 { 93 typedef enum { 95 94 MSN_GOT_PROFILE = 1, 96 95 MSN_GOT_PROFILE_DN = 2, … … 100 99 } msn_flags_t; 101 100 102 struct msn_handler_data 103 { 101 struct msn_handler_data { 104 102 int fd, inpa; 105 103 int rxlen; 106 104 char *rxq; 107 105 108 106 int msglen; 109 107 char *cmd_text; 110 108 111 109 /* Either ic or sb */ 112 110 gpointer data; 113 114 int (*exec_command) ( struct msn_handler_data *handler, char **cmd, int count ); 115 int (*exec_message) ( struct msn_handler_data *handler, char *msg, int msglen, char **cmd, int count ); 116 }; 117 118 struct msn_data 119 { 111 112 int (*exec_command) (struct msn_handler_data *handler, char **cmd, int count); 113 int (*exec_message) (struct msn_handler_data *handler, char *msg, int msglen, char **cmd, int count); 114 }; 115 116 struct msn_data { 120 117 struct im_connection *ic; 121 118 122 119 struct msn_handler_data ns[1]; 123 120 msn_flags_t flags; 124 121 125 122 int trId; 126 123 char *tokens[4]; 127 124 char *lock_key, *pp_policy; 128 125 char *uuid; 129 126 130 127 GSList *msgq, *grpq, *soapq; 131 128 GSList *switchboards; 132 129 int sb_failures; 133 130 time_t first_sb_failure; 134 131 135 132 const struct msn_away_state *away_state; 136 133 GSList *groups; 137 134 char *profile_rid; 138 135 139 136 /* Mostly used for sending the ADL command; since MSNP13 the client 140 137 is responsible for downloading the contact list and then sending … … 144 141 }; 145 142 146 struct msn_switchboard 147 { 143 struct msn_switchboard { 148 144 struct im_connection *ic; 149 145 150 146 /* The following two are also in the handler. TODO: Clean up. */ 151 147 int fd; … … 153 149 struct msn_handler_data *handler; 154 150 gint keepalive; 155 151 156 152 int trId; 157 153 int ready; 158 154 159 155 int session; 160 156 char *key; 161 157 162 158 GSList *msgq; 163 159 char *who; … … 165 161 }; 166 162 167 struct msn_away_state 168 { 163 struct msn_away_state { 169 164 char code[4]; 170 165 char name[16]; 171 166 }; 172 167 173 struct msn_status_code 174 { 168 struct msn_status_code { 175 169 int number; 176 170 char *text; … … 178 172 }; 179 173 180 struct msn_message 181 { 174 struct msn_message { 182 175 char *who; 183 176 char *text; 184 177 }; 185 178 186 struct msn_groupadd 187 { 179 struct msn_groupadd { 188 180 char *who; 189 181 char *group; 190 182 }; 191 183 192 typedef enum 193 { 184 typedef enum { 194 185 MSN_BUDDY_FL = 1, /* Warning: FL,AL,BL *must* be 1,2,4. */ 195 186 MSN_BUDDY_AL = 2, … … 201 192 } msn_buddy_flags_t; 202 193 203 struct msn_buddy_data 204 { 194 struct msn_buddy_data { 205 195 char *cid; 206 196 msn_buddy_flags_t flags; 207 197 }; 208 198 209 struct msn_group 210 { 199 struct msn_group { 211 200 char *name; 212 201 char *id; … … 216 205 #define STATUS_FATAL 1 217 206 #define STATUS_SB_FATAL 2 218 #define STATUS_SB_IM_SPARE 4/* Make one-to-one conversation switchboard available again, invite failed. */219 #define STATUS_SB_CHAT_SPARE 8/* Same, but also for groupchats (not used yet). */207 #define STATUS_SB_IM_SPARE 4 /* Make one-to-one conversation switchboard available again, invite failed. */ 208 #define STATUS_SB_CHAT_SPARE 8 /* Same, but also for groupchats (not used yet). */ 220 209 221 210 extern int msn_chat_id; … … 232 221 233 222 /* ns.c */ 234 int msn_ns_write( struct im_connection *ic, int fd, const char *fmt, ... ) G_GNUC_PRINTF( 3, 4);235 gboolean msn_ns_connect( struct im_connection *ic, struct msn_handler_data *handler, const char *host, int port);236 void msn_ns_close( struct msn_handler_data *handler);237 void msn_auth_got_passport_token( struct im_connection *ic, const char *token, const char *error);238 void msn_auth_got_contact_list( struct im_connection *ic);239 int msn_ns_finish_login( struct im_connection *ic);240 int msn_ns_sendmessage( struct im_connection *ic, struct bee_user *bu, const char *text);241 void msn_ns_oim_send_queue( struct im_connection *ic, GSList **msgq);223 int msn_ns_write(struct im_connection *ic, int fd, const char *fmt, ...) G_GNUC_PRINTF(3, 4); 224 gboolean msn_ns_connect(struct im_connection *ic, struct msn_handler_data *handler, const char *host, int port); 225 void msn_ns_close(struct msn_handler_data *handler); 226 void msn_auth_got_passport_token(struct im_connection *ic, const char *token, const char *error); 227 void msn_auth_got_contact_list(struct im_connection *ic); 228 int msn_ns_finish_login(struct im_connection *ic); 229 int msn_ns_sendmessage(struct im_connection *ic, struct bee_user *bu, const char *text); 230 void msn_ns_oim_send_queue(struct im_connection *ic, GSList **msgq); 242 231 243 232 /* msn_util.c */ 244 int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname_, const char *group ); 245 int msn_buddy_list_remove( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group ); 246 void msn_buddy_ask( bee_user_t *bu ); 247 char **msn_linesplit( char *line ); 248 int msn_handler( struct msn_handler_data *h ); 249 void msn_msgq_purge( struct im_connection *ic, GSList **list ); 250 char *msn_p11_challenge( char *challenge ); 251 gint msn_domaintree_cmp( gconstpointer a_, gconstpointer b_ ); 252 struct msn_group *msn_group_by_name( struct im_connection *ic, const char *name ); 253 struct msn_group *msn_group_by_id( struct im_connection *ic, const char *id ); 254 int msn_ns_set_display_name( struct im_connection *ic, const char *value ); 255 const char *msn_normalize_handle( const char *handle ); 233 int msn_buddy_list_add(struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname_, 234 const char *group); 235 int msn_buddy_list_remove(struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group); 236 void msn_buddy_ask(bee_user_t *bu); 237 char **msn_linesplit(char *line); 238 int msn_handler(struct msn_handler_data *h); 239 void msn_msgq_purge(struct im_connection *ic, GSList **list); 240 char *msn_p11_challenge(char *challenge); 241 gint msn_domaintree_cmp(gconstpointer a_, gconstpointer b_); 242 struct msn_group *msn_group_by_name(struct im_connection *ic, const char *name); 243 struct msn_group *msn_group_by_id(struct im_connection *ic, const char *id); 244 int msn_ns_set_display_name(struct im_connection *ic, const char *value); 245 const char *msn_normalize_handle(const char *handle); 256 246 257 247 /* tables.c */ 258 const struct msn_away_state *msn_away_state_by_number( int number);259 const struct msn_away_state *msn_away_state_by_code( char *code);260 const struct msn_away_state *msn_away_state_by_name( char *name);261 const struct msn_status_code *msn_status_by_number( int number);248 const struct msn_away_state *msn_away_state_by_number(int number); 249 const struct msn_away_state *msn_away_state_by_code(char *code); 250 const struct msn_away_state *msn_away_state_by_name(char *name); 251 const struct msn_status_code *msn_status_by_number(int number); 262 252 263 253 /* sb.c */ 264 int msn_sb_write( struct msn_switchboard *sb, const char *fmt, ... ) G_GNUC_PRINTF( 2, 3);;265 struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session);266 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, const char *handle);267 struct msn_switchboard *msn_sb_by_chat( struct groupchat *c);268 struct msn_switchboard *msn_sb_spare( struct im_connection *ic);269 int msn_sb_sendmessage( struct msn_switchboard *sb, char *text);270 struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb);271 void msn_sb_destroy( struct msn_switchboard *sb);272 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond);273 int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m);274 void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial);275 void msn_sb_stop_keepalives( struct msn_switchboard *sb);254 int msn_sb_write(struct msn_switchboard *sb, const char *fmt, ...) G_GNUC_PRINTF(2, 3);; 255 struct msn_switchboard *msn_sb_create(struct im_connection *ic, char *host, int port, char *key, int session); 256 struct msn_switchboard *msn_sb_by_handle(struct im_connection *ic, const char *handle); 257 struct msn_switchboard *msn_sb_by_chat(struct groupchat *c); 258 struct msn_switchboard *msn_sb_spare(struct im_connection *ic); 259 int msn_sb_sendmessage(struct msn_switchboard *sb, char *text); 260 struct groupchat *msn_sb_to_chat(struct msn_switchboard *sb); 261 void msn_sb_destroy(struct msn_switchboard *sb); 262 gboolean msn_sb_connected(gpointer data, gint source, b_input_condition cond); 263 int msn_sb_write_msg(struct im_connection *ic, struct msn_message *m); 264 void msn_sb_start_keepalives(struct msn_switchboard *sb, gboolean initial); 265 void msn_sb_stop_keepalives(struct msn_switchboard *sb); 276 266 277 267 #endif //_MSN_H
Note: See TracChangeset
for help on using the changeset viewer.