Changeset b4e96d6 for protocols/msn/gw.c
- Timestamp:
- 2015-03-15T14:41:48Z (10 years ago)
- Children:
- 89e0c94
- Parents:
- c408298
- git-author:
- dequis <dx@…> (14-03-15 12:00:58)
- git-committer:
- dequis <dx@…> (15-03-15 14:41:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/gw.c
rc408298 rb4e96d6 30 30 void msn_gw_free(struct msn_gw *gw) 31 31 { 32 if (gw->poll_timeout != -1) { 33 b_event_remove(gw->poll_timeout); 34 } 32 35 g_byte_array_free(gw->in, TRUE); 33 36 g_byte_array_free(gw->out, TRUE); … … 66 69 struct msn_gw *gw = req->data; 67 70 71 gw->waiting = FALSE; 72 73 if (!gw->open) { 74 /* the user tried to logout while the request was pending 75 * see msn_ns_close() */ 76 msn_gw_free(gw); 77 return; 78 } 79 80 if (getenv("BITLBEE_DEBUG")) { 81 fprintf(stderr, "\n\x1b[90mHTTP:%s\n", req->reply_body); 82 fprintf(stderr, "\n\x1b[97m\n"); 83 } 84 85 if (req->status_code != 200) { 86 gw->callback(gw->data, -1, B_EV_IO_READ); 87 return; 88 } 89 68 90 if ((value = get_rfc822_header(req->reply_headers, "X-MSN-Messenger", 0))) { 69 91 if (!msn_gw_parse_session_header(gw, value)) { 70 /* XXX handle this */ 92 gw->callback(gw->data, -1, B_EV_IO_READ); 93 g_free(value); 94 return; 71 95 } 72 96 g_free(value); … … 78 102 } 79 103 80 /* XXX handle reply */ 104 if (req->body_size) { 105 g_byte_array_append(gw->in, (const guint8 *) req->reply_body, req->body_size); 106 gw->callback(gw->data, -1, B_EV_IO_READ); 107 } 81 108 82 109 if (gw->poll_timeout != -1) { … … 104 131 105 132 http_dorequest(gw->last_host, gw->port, gw->ssl, request, msn_gw_callback, gw); 133 gw->open = TRUE; 106 134 gw->waiting = TRUE; 107 135 … … 113 141 { 114 142 msn_gw_dorequest(gw, "Action=open&Server=NS"); 115 gw->open = TRUE;116 143 } 117 144 … … 125 152 return FALSE; 126 153 } 154 155 ssize_t msn_gw_read(struct msn_gw *gw, char **buf) 156 { 157 size_t bodylen; 158 if (!gw->open) { 159 return 0; 160 } 161 162 bodylen = gw->in->len; 163 g_byte_array_append(gw->in, (guint8 *) "", 1); /* nullnullnull */ 164 *buf = (char *) g_byte_array_free(gw->in, FALSE); 165 gw->in = g_byte_array_new(); 166 return bodylen; 167 } 168 169 void msn_gw_write(struct msn_gw *gw, char *buf, size_t len) 170 { 171 g_byte_array_append(gw->out, (const guint8 *) buf, len); 172 if (!gw->open) { 173 msn_gw_open(gw); 174 } else if (!gw->waiting) { 175 msn_gw_dorequest(gw, NULL); 176 } 177 }
Note: See TracChangeset
for help on using the changeset viewer.