Changeset 5ebff60 for protocols/jabber/jabber.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/jabber/jabber.h
raf359b4 r5ebff60 33 33 extern GSList *jabber_connections; 34 34 35 typedef enum 36 { 35 typedef enum { 37 36 JFLAG_STREAM_STARTED = 1, /* Set when we detected the beginning of the stream 38 37 and want to do auth. */ … … 40 39 JFLAG_STREAM_RESTART = 4, /* Set when we want to restart the stream (after 41 40 SASL or TLS). */ 42 JFLAG_WANT_SESSION = 8, 41 JFLAG_WANT_SESSION = 8, /* Set if the server wants a <session/> tag 43 42 before we continue. */ 44 43 JFLAG_WANT_BIND = 16, /* ... for <bind> tag. */ … … 53 52 } jabber_flags_t; 54 53 55 typedef enum 56 { 54 typedef enum { 57 55 JBFLAG_PROBED_XEP85 = 1, /* Set this when we sent our probe packet to make 58 56 sure it gets sent only once. */ … … 68 66 69 67 /* Stores a streamhost's (a.k.a. proxy) data */ 70 typedef struct 71 { 68 typedef struct { 72 69 char *jid; 73 70 char *host; … … 75 72 } jabber_streamhost_t; 76 73 77 typedef enum 78 { 74 typedef enum { 79 75 JCFLAG_MESSAGE_SENT = 1, /* Set this after sending the first message, so 80 76 we can detect echoes/backlogs. */ 81 77 } jabber_chat_flags_t; 82 78 83 struct jabber_data 84 { 79 struct jabber_data { 85 80 struct im_connection *ic; 86 81 87 82 int fd; 88 83 void *ssl; … … 90 85 int tx_len; 91 86 int r_inpa, w_inpa; 92 87 93 88 struct xt_parser *xt; 94 89 jabber_flags_t flags; 95 96 char *username; 97 char *server; 98 char *me; 90 91 char *username; /* USERNAME@server */ 92 char *server; /* username@SERVER -=> server/domain, not hostname */ 93 char *me; /* bare jid */ 99 94 char *internal_jid; 100 95 101 96 const struct oauth2_service *oauth2_service; 102 97 char *oauth2_access_token; 103 98 104 99 /* After changing one of these two (or the priority setting), call 105 100 presence_send_update() to inform the server about the changes. */ 106 101 const struct jabber_away_state *away_state; 107 102 char *away_message; 108 103 109 104 md5_state_t cached_id_prefix; 110 105 GHashTable *node_cache; … … 116 111 }; 117 112 118 struct jabber_away_state 119 { 113 struct jabber_away_state { 120 114 char code[5]; 121 115 char *full_name; 122 116 }; 123 117 124 typedef xt_status (*jabber_cache_event) ( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 125 126 struct jabber_cache_entry 127 { 118 typedef xt_status (*jabber_cache_event) (struct im_connection *ic, struct xt_node *node, struct xt_node *orig); 119 120 struct jabber_cache_entry { 128 121 time_t saved_at; 129 122 struct xt_node *node; … … 138 131 refer to a real session and should only be used for operations that 139 132 support incomplete JIDs. */ 140 struct jabber_buddy 141 { 133 struct jabber_buddy { 142 134 char *bare_jid; 143 135 char *full_jid; 144 136 char *resource; 145 137 146 138 char *ext_jid; /* The JID to use in BitlBee. The real JID if possible, */ 147 139 /* otherwise something similar to the conference JID. */ 148 140 149 141 int priority; 150 142 struct jabber_away_state *away_state; 151 143 char *away_message; 152 144 GSList *features; 153 145 154 146 time_t last_msg; 155 147 jabber_buddy_flags_t flags; 156 148 157 149 struct jabber_buddy *next; 158 150 }; 159 151 160 struct jabber_chat 161 { 152 struct jabber_chat { 162 153 int flags; 163 154 char *name; … … 167 158 }; 168 159 169 struct jabber_transfer 170 { 160 struct jabber_transfer { 171 161 /* bitlbee's handle for this transfer */ 172 162 file_transfer_t *ft; … … 246 236 247 237 /* jabber.c */ 248 void jabber_connect( struct im_connection *ic);238 void jabber_connect(struct im_connection *ic); 249 239 250 240 /* iq.c */ 251 xt_status jabber_pkt_iq( struct xt_node *node, gpointer data);252 int jabber_init_iq_auth( struct im_connection *ic);253 xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig);254 int jabber_get_roster( struct im_connection *ic);255 int jabber_get_vcard( struct im_connection *ic, char *bare_jid);256 int jabber_add_to_roster( struct im_connection *ic, const char *handle, const char *name, const char *group);257 int jabber_remove_from_roster( struct im_connection *ic, char *handle);258 xt_status jabber_iq_query_features( struct im_connection *ic, char *bare_jid);259 xt_status jabber_iq_query_server( struct im_connection *ic, char *jid, char *xmlns);260 void jabber_iq_version_send( struct im_connection *ic, struct jabber_buddy *bud, void *data);241 xt_status jabber_pkt_iq(struct xt_node *node, gpointer data); 242 int jabber_init_iq_auth(struct im_connection *ic); 243 xt_status jabber_pkt_bind_sess(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); 244 int jabber_get_roster(struct im_connection *ic); 245 int jabber_get_vcard(struct im_connection *ic, char *bare_jid); 246 int jabber_add_to_roster(struct im_connection *ic, const char *handle, const char *name, const char *group); 247 int jabber_remove_from_roster(struct im_connection *ic, char *handle); 248 xt_status jabber_iq_query_features(struct im_connection *ic, char *bare_jid); 249 xt_status jabber_iq_query_server(struct im_connection *ic, char *jid, char *xmlns); 250 void jabber_iq_version_send(struct im_connection *ic, struct jabber_buddy *bud, void *data); 261 251 262 252 /* si.c */ 263 int jabber_si_handle_request( struct im_connection *ic, struct xt_node *node, struct xt_node *sinode);264 void jabber_si_transfer_request( struct im_connection *ic, file_transfer_t *ft, char *who);265 void jabber_si_free_transfer( 253 int jabber_si_handle_request(struct im_connection *ic, struct xt_node *node, struct xt_node *sinode); 254 void jabber_si_transfer_request(struct im_connection *ic, file_transfer_t *ft, char *who); 255 void jabber_si_free_transfer(file_transfer_t *ft); 266 256 267 257 /* s5bytestream.c */ 268 int jabber_bs_recv_request( 269 gboolean jabber_bs_send_start( struct jabber_transfer *tf);270 gboolean jabber_bs_send_write( file_transfer_t *ft, char *buffer, unsigned int len);258 int jabber_bs_recv_request(struct im_connection *ic, struct xt_node *node, struct xt_node *qnode); 259 gboolean jabber_bs_send_start(struct jabber_transfer *tf); 260 gboolean jabber_bs_send_write(file_transfer_t *ft, char *buffer, unsigned int len); 271 261 272 262 /* message.c */ 273 xt_status jabber_pkt_message( struct xt_node *node, gpointer data);263 xt_status jabber_pkt_message(struct xt_node *node, gpointer data); 274 264 275 265 /* presence.c */ 276 xt_status jabber_pkt_presence( struct xt_node *node, gpointer data);277 int presence_send_update( struct im_connection *ic);278 int presence_send_request( struct im_connection *ic, char *handle, char *request);266 xt_status jabber_pkt_presence(struct xt_node *node, gpointer data); 267 int presence_send_update(struct im_connection *ic); 268 int presence_send_request(struct im_connection *ic, char *handle, char *request); 279 269 280 270 /* jabber_util.c */ 281 char *set_eval_priority( set_t *set, char *value ); 282 char *set_eval_tls( set_t *set, char *value ); 283 struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_node *children ); 284 struct xt_node *jabber_make_error_packet( struct xt_node *orig, char *err_cond, char *err_type, char *err_code ); 285 void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_cache_event func ); 286 struct xt_node *jabber_cache_get( struct im_connection *ic, char *id ); 287 void jabber_cache_entry_free( gpointer entry ); 288 void jabber_cache_clean( struct im_connection *ic ); 289 xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node ); 290 const struct jabber_away_state *jabber_away_state_by_code( char *code ); 291 const struct jabber_away_state *jabber_away_state_by_name( char *name ); 292 void jabber_buddy_ask( struct im_connection *ic, char *handle ); 293 int jabber_compare_jid( const char *jid1, const char *jid2 ); 294 char *jabber_normalize( const char *orig ); 295 296 typedef enum 297 { 298 GET_BUDDY_CREAT = 1, /* Try to create it, if necessary. */ 299 GET_BUDDY_EXACT = 2, /* Get an exact match (only makes sense with bare JIDs). */ 300 GET_BUDDY_FIRST = 4, /* No selection, simply get the first resource for this JID. */ 301 GET_BUDDY_BARE = 8, /* Get the bare version of the JID (possibly inexistent). */ 302 GET_BUDDY_BARE_OK = 16, /* Allow returning a bare JID if that seems better. */ 271 char *set_eval_priority(set_t *set, char *value); 272 char *set_eval_tls(set_t *set, char *value); 273 struct xt_node *jabber_make_packet(char *name, char *type, char *to, struct xt_node *children); 274 struct xt_node *jabber_make_error_packet(struct xt_node *orig, char *err_cond, char *err_type, char *err_code); 275 void jabber_cache_add(struct im_connection *ic, struct xt_node *node, jabber_cache_event func); 276 struct xt_node *jabber_cache_get(struct im_connection *ic, char *id); 277 void jabber_cache_entry_free(gpointer entry); 278 void jabber_cache_clean(struct im_connection *ic); 279 xt_status jabber_cache_handle_packet(struct im_connection *ic, struct xt_node *node); 280 const struct jabber_away_state *jabber_away_state_by_code(char *code); 281 const struct jabber_away_state *jabber_away_state_by_name(char *name); 282 void jabber_buddy_ask(struct im_connection *ic, char *handle); 283 int jabber_compare_jid(const char *jid1, const char *jid2); 284 char *jabber_normalize(const char *orig); 285 286 typedef enum { 287 GET_BUDDY_CREAT = 1, /* Try to create it, if necessary. */ 288 GET_BUDDY_EXACT = 2, /* Get an exact match (only makes sense with bare JIDs). */ 289 GET_BUDDY_FIRST = 4, /* No selection, simply get the first resource for this JID. */ 290 GET_BUDDY_BARE = 8, /* Get the bare version of the JID (possibly inexistent). */ 291 GET_BUDDY_BARE_OK = 16, /* Allow returning a bare JID if that seems better. */ 303 292 } get_buddy_flags_t; 304 293 305 struct jabber_error 306 { 294 struct jabber_error { 307 295 char *code, *text, *type; 308 296 }; 309 297 310 struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid);311 struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid, get_buddy_flags_t flags);312 struct jabber_buddy *jabber_buddy_by_ext_jid( struct im_connection *ic, char *jid, get_buddy_flags_t flags);313 int jabber_buddy_remove( struct im_connection *ic, char *full_jid);314 int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid);315 void jabber_buddy_remove_all( struct im_connection *ic);316 time_t jabber_get_timestamp( struct xt_node *xt);317 struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns);318 void jabber_error_free( struct jabber_error *err);319 gboolean jabber_set_me( struct im_connection *ic, const char *me);298 struct jabber_buddy *jabber_buddy_add(struct im_connection *ic, char *full_jid); 299 struct jabber_buddy *jabber_buddy_by_jid(struct im_connection *ic, char *jid, get_buddy_flags_t flags); 300 struct jabber_buddy *jabber_buddy_by_ext_jid(struct im_connection *ic, char *jid, get_buddy_flags_t flags); 301 int jabber_buddy_remove(struct im_connection *ic, char *full_jid); 302 int jabber_buddy_remove_bare(struct im_connection *ic, char *bare_jid); 303 void jabber_buddy_remove_all(struct im_connection *ic); 304 time_t jabber_get_timestamp(struct xt_node *xt); 305 struct jabber_error *jabber_error_parse(struct xt_node *node, char *xmlns); 306 void jabber_error_free(struct jabber_error *err); 307 gboolean jabber_set_me(struct im_connection *ic, const char *me); 320 308 321 309 extern const struct jabber_away_state jabber_away_state_list[]; 322 310 323 311 /* io.c */ 324 int jabber_write_packet( struct im_connection *ic, struct xt_node *node);325 int jabber_write( struct im_connection *ic, char *buf, int len);326 gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond);327 gboolean jabber_connected_ssl( gpointer data, int returncode, void *source, b_input_condition cond);328 gboolean jabber_start_stream( struct im_connection *ic);329 void jabber_end_stream( struct im_connection *ic);312 int jabber_write_packet(struct im_connection *ic, struct xt_node *node); 313 int jabber_write(struct im_connection *ic, char *buf, int len); 314 gboolean jabber_connected_plain(gpointer data, gint source, b_input_condition cond); 315 gboolean jabber_connected_ssl(gpointer data, int returncode, void *source, b_input_condition cond); 316 gboolean jabber_start_stream(struct im_connection *ic); 317 void jabber_end_stream(struct im_connection *ic); 330 318 331 319 /* sasl.c */ 332 xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data);333 xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data);334 xt_status sasl_pkt_result( struct xt_node *node, gpointer data);335 gboolean sasl_supported( struct im_connection *ic);336 void sasl_oauth2_init( struct im_connection *ic);337 int sasl_oauth2_get_refresh_token( struct im_connection *ic, const char *msg);338 int sasl_oauth2_refresh( struct im_connection *ic, const char *refresh_token);320 xt_status sasl_pkt_mechanisms(struct xt_node *node, gpointer data); 321 xt_status sasl_pkt_challenge(struct xt_node *node, gpointer data); 322 xt_status sasl_pkt_result(struct xt_node *node, gpointer data); 323 gboolean sasl_supported(struct im_connection *ic); 324 void sasl_oauth2_init(struct im_connection *ic); 325 int sasl_oauth2_get_refresh_token(struct im_connection *ic, const char *msg); 326 int sasl_oauth2_refresh(struct im_connection *ic, const char *refresh_token); 339 327 340 328 extern const struct oauth2_service oauth2_service_google; … … 342 330 343 331 /* conference.c */ 344 struct groupchat *jabber_chat_join( struct im_connection *ic, const char *room, const char *nick, const char *password);345 struct groupchat *jabber_chat_with( struct im_connection *ic, char *who);346 struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name);347 void jabber_chat_free( struct groupchat *c);348 int jabber_chat_msg( struct groupchat *ic, char *message, int flags);349 int jabber_chat_topic( struct groupchat *c, char *topic);350 int jabber_chat_leave( struct groupchat *c, const char *reason);351 void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node);352 void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node);353 void jabber_chat_invite( struct groupchat *c, char *who, char *message);332 struct groupchat *jabber_chat_join(struct im_connection *ic, const char *room, const char *nick, const char *password); 333 struct groupchat *jabber_chat_with(struct im_connection *ic, char *who); 334 struct groupchat *jabber_chat_by_jid(struct im_connection *ic, const char *name); 335 void jabber_chat_free(struct groupchat *c); 336 int jabber_chat_msg(struct groupchat *ic, char *message, int flags); 337 int jabber_chat_topic(struct groupchat *c, char *topic); 338 int jabber_chat_leave(struct groupchat *c, const char *reason); 339 void jabber_chat_pkt_presence(struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node); 340 void jabber_chat_pkt_message(struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node); 341 void jabber_chat_invite(struct groupchat *c, char *who, char *message); 354 342 355 343 #endif
Note: See TracChangeset
for help on using the changeset viewer.