Changeset b4e96d6 for protocols/msn/ns.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/ns.c
rc408298 rb4e96d6 60 60 61 61 len = strlen(out); 62 st = write(fd, out, len); 62 63 if (md->is_http) { 64 st = len; 65 msn_gw_write(md->gw, out, len); 66 } else { 67 st = write(fd, out, len); 68 } 69 63 70 g_free(out); 64 71 if (st != len) { … … 79 86 } 80 87 81 handler->fd = proxy_connect(host, port, msn_ns_connected, handler); 82 if (handler->fd < 0) { 83 imcb_error(ic, "Could not connect to server"); 84 imc_logout(ic, TRUE); 85 return FALSE; 88 if (handler->is_http) { 89 handler->gw = msn_gw_new(handler); 90 handler->gw->callback = msn_ns_callback; 91 msn_ns_connected(handler, -1, B_EV_IO_READ); 92 } else { 93 handler->fd = proxy_connect(host, port, msn_ns_connected, handler); 94 if (handler->fd < 0) { 95 imcb_error(ic, "Could not connect to server"); 96 imc_logout(ic, TRUE); 97 return FALSE; 98 } 86 99 } 87 100 … … 95 108 struct im_connection *ic = md->ic; 96 109 97 if (source == -1 ) {110 if (source == -1 && !md->is_http) { 98 111 imcb_error(ic, "Could not connect to server"); 99 112 imc_logout(ic, TRUE); … … 121 134 122 135 if (msn_ns_write(ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER)) { 123 handler->inpa = b_input_add(handler->fd, B_EV_IO_READ, msn_ns_callback, handler); 136 if (!handler->is_http) { 137 handler->inpa = b_input_add(handler->fd, B_EV_IO_READ, msn_ns_callback, handler); 138 } 124 139 imcb_log(ic, "Connected to server, waiting for reply"); 125 140 } … … 130 145 void msn_ns_close(struct msn_data *handler) 131 146 { 147 if (handler->gw) { 148 if (handler->gw->waiting) { 149 /* mark it as closed, let the request callback clean it */ 150 handler->gw->open = FALSE; 151 } else { 152 msn_gw_free(handler->gw); 153 } 154 } 132 155 if (handler->fd >= 0) { 133 156 closesocket(handler->fd); … … 148 171 struct msn_data *handler = data; 149 172 struct im_connection *ic = handler->ic; 150 char bytes[1024];173 char *bytes; 151 174 int st; 152 175 153 st = read(handler->fd, bytes, 1024); 176 if (handler->is_http) { 177 st = msn_gw_read(handler->gw, &bytes); 178 } else { 179 bytes = g_malloc(1024); 180 st = read(handler->fd, bytes, 1024); 181 } 182 154 183 if (st <= 0) { 155 184 imcb_error(ic, "Error while reading from server"); … … 159 188 160 189 msn_queue_feed(handler, bytes, st); 190 191 g_free(bytes); 161 192 162 193 /* Ignore ret == 0, it's already disconnected then. */
Note: See TracChangeset
for help on using the changeset viewer.