Changeset 951aefd
- Timestamp:
- 2015-04-12T15:27:31Z (10 years ago)
- Branches:
- master
- Children:
- 2fe8297
- Parents:
- 5fbf815
- Location:
- protocols/msn
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/gw.c
r5fbf815 r951aefd 15 15 static gboolean msn_gw_poll_timeout(gpointer data, gint source, b_input_condition cond); 16 16 17 struct msn_gw *msn_gw_new(struct msn_data *md)17 struct msn_gw *msn_gw_new(struct im_connection *ic) 18 18 { 19 19 struct msn_gw *gw = g_new0(struct msn_gw, 1); … … 22 22 gw->ssl = (GATEWAY_PORT == 443); 23 23 gw->poll_timeout = -1; 24 gw->data = md; 24 gw->ic = ic; 25 gw->md = ic->proto_data; 25 26 gw->in = g_byte_array_new(); 26 27 gw->out = g_byte_array_new(); … … 38 39 g_free(gw->last_host); 39 40 g_free(gw); 41 } 42 43 static struct msn_gw *msn_gw_from_ic(struct im_connection *ic) 44 { 45 if (g_slist_find(msn_connections, ic) == NULL) { 46 return NULL; 47 } else { 48 struct msn_data *md = ic->proto_data; 49 return md->gw; 50 } 40 51 } 41 52 … … 66 77 void msn_gw_callback(struct http_request *req) 67 78 { 79 struct msn_gw *gw; 68 80 char *value; 69 struct msn_gw *gw = req->data; 81 82 if (!(gw = msn_gw_from_ic(req->data))) { 83 return; 84 } 70 85 71 86 gw->waiting = FALSE; 72 87 gw->polling = FALSE; 73 74 if (!gw->open) {75 /* the user tried to logout while the request was pending76 * see msn_ns_close() */77 msn_gw_free(gw);78 return;79 }80 88 81 89 if (getenv("BITLBEE_DEBUG")) { … … 85 93 86 94 if (req->status_code != 200) { 87 gw->callback(gw-> data, -1, B_EV_IO_READ);95 gw->callback(gw->md, -1, B_EV_IO_READ); 88 96 return; 89 97 } … … 91 99 if ((value = get_rfc822_header(req->reply_headers, "X-MSN-Messenger", 0))) { 92 100 if (!msn_gw_parse_session_header(gw, value)) { 93 gw->callback(gw-> data, -1, B_EV_IO_READ);101 gw->callback(gw->md, -1, B_EV_IO_READ); 94 102 g_free(value); 95 103 return; … … 105 113 if (req->body_size) { 106 114 g_byte_array_append(gw->in, (const guint8 *) req->reply_body, req->body_size); 107 gw->callback(gw-> data, -1, B_EV_IO_READ);115 gw->callback(gw->md, -1, B_EV_IO_READ); 108 116 } 109 117 … … 111 119 b_event_remove(gw->poll_timeout); 112 120 } 113 gw->poll_timeout = b_timeout_add(500, msn_gw_poll_timeout, gw );121 gw->poll_timeout = b_timeout_add(500, msn_gw_poll_timeout, gw->ic); 114 122 115 123 } … … 136 144 gw->session_id ? : "", args ? : "", gw->last_host, bodylen, body ? : ""); 137 145 138 http_dorequest(gw->last_host, gw->port, gw->ssl, request, msn_gw_callback, gw );146 http_dorequest(gw->last_host, gw->port, gw->ssl, request, msn_gw_callback, gw->ic); 139 147 gw->open = TRUE; 140 148 gw->waiting = TRUE; … … 151 159 static gboolean msn_gw_poll_timeout(gpointer data, gint source, b_input_condition cond) 152 160 { 153 struct msn_gw *gw = data; 161 struct msn_gw *gw; 162 163 if (!(gw = msn_gw_from_ic(data))) { 164 return FALSE; 165 } 166 154 167 gw->poll_timeout = -1; 155 168 if (!gw->waiting) { -
protocols/msn/msn.h
r5fbf815 r951aefd 137 137 138 138 b_event_handler callback; 139 gpointer data; 139 140 struct im_connection *ic; 141 struct msn_data *md; 140 142 141 143 gboolean open; … … 265 267 266 268 /* gw.c */ 267 struct msn_gw *msn_gw_new(struct msn_data *md);269 struct msn_gw *msn_gw_new(struct im_connection *ic); 268 270 void msn_gw_free(struct msn_gw *gw); 269 271 void msn_gw_open(struct msn_gw *gw); -
protocols/msn/ns.c
r5fbf815 r951aefd 90 90 91 91 if (md->is_http) { 92 md->gw = msn_gw_new( md);92 md->gw = msn_gw_new(ic); 93 93 md->gw->callback = msn_ns_callback; 94 94 msn_ns_connected(md, -1, B_EV_IO_READ); … … 148 148 { 149 149 if (md->gw) { 150 if (md->gw->waiting) { 151 /* mark it as closed, let the request callback clean it */ 152 md->gw->open = FALSE; 153 } else { 154 msn_gw_free(md->gw); 155 } 150 msn_gw_free(md->gw); 156 151 } 157 152 if (md->fd >= 0) {
Note: See TracChangeset
for help on using the changeset viewer.