- Timestamp:
- 2015-05-31T02:40:04Z (9 years ago)
- Children:
- 074c9b6
- Parents:
- 2ca933c
- git-author:
- dequis <dx@…> (07-04-15 12:59:51)
- git-committer:
- dequis <dx@…> (31-05-15 02:40:04)
- Location:
- protocols/msn
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/gw.c
r2ca933c r767b2d1 2 2 #include "lib/http_client.h" 3 3 #include "msn.h" 4 5 #define GATEWAY_HOST "geo.gateway.messenger.live.com"6 #define GATEWAY_PORT 4437 4 8 5 #define REQUEST_TEMPLATE \ … … 18 15 { 19 16 struct msn_gw *gw = g_new0(struct msn_gw, 1); 20 gw->last_host = g_strdup( GATEWAY_HOST);21 gw->port = GATEWAY_PORT;22 gw->ssl = ( GATEWAY_PORT == 443);17 gw->last_host = g_strdup(MSN_HTTP_HOST); 18 gw->port = MSN_HTTP_PORT; 19 gw->ssl = (MSN_HTTP_PORT == 443); 23 20 gw->poll_timeout = -1; 24 21 gw->ic = ic; -
protocols/msn/msn.c
r2ca933c r767b2d1 43 43 s->flags |= SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 44 44 45 s = set_add(&acc->set, "port", MSN_NS_PORT, set_eval_int, acc);45 s = set_add(&acc->set, "port", NULL, set_eval_int, acc); 46 46 s->flags |= ACC_SET_OFFLINE_ONLY; 47 47 … … 60 60 struct im_connection *ic = imcb_new(acc); 61 61 struct msn_data *md = g_new0(struct msn_data, 1); 62 char *server = set_getstr(&ic->acc->set, "server"); 62 char *server = set_getstr(&ic->acc->set, "server") ? : MSN_SSL_HOST; 63 int port = set_getint(&ic->acc->set, "port") ? : MSN_SSL_PORT; 63 64 64 65 ic->proto_data = md; 65 66 ic->flags |= OPT_PONGS | OPT_PONGED; 66 67 if (!server) {68 server = "geo.gateway.messenger.live.com";69 }70 67 71 68 if (strchr(acc->user, '@') == NULL) { … … 84 81 85 82 imcb_log(ic, "Connecting"); 86 msn_ns_connect(ic, server, 87 set_getint(&ic->acc->set, "port"));83 84 msn_ns_connect(ic, server, port); 88 85 89 86 if (set_getbool(&acc->set, "mail_notifications") && set_getstr(&acc->set, "mail_notifications_handle")) { -
protocols/msn/msn.h
r2ca933c r767b2d1 32 32 */ 33 33 34 #define MSN_NS_HOST "messenger.hotmail.com" 35 #define MSN_NS_PORT "1863" 34 #define MSN_SSL_HOST "s.gateway.messenger.live.com" 35 #define MSN_SSL_PORT 443 36 37 #define MSN_HTTP_HOST "geo.gateway.messenger.live.com" 38 #define MSN_HTTP_PORT 443 36 39 37 40 /* Some other version. … … 154 157 gboolean is_http; 155 158 struct msn_gw *gw; 159 void *ssl; 156 160 }; 157 161 -
protocols/msn/ns.c
r2ca933c r767b2d1 32 32 #include "soap.h" 33 33 #include "xmltree.h" 34 35 static gboolean msn_ns_connected(gpointer data, gint source, b_input_condition cond); 34 #include "ssl_client.h" 35 36 static gboolean msn_ns_connected(gpointer data, int source, void *scd, b_input_condition cond); 36 37 static gboolean msn_ns_callback(gpointer data, gint source, b_input_condition cond); 37 38 … … 68 69 msn_gw_write(md->gw, out, len); 69 70 } else { 70 st = write(fd, out, len);71 st = ssl_write(md->ssl, out, len); 71 72 } 72 73 … … 92 93 md->gw = msn_gw_new(ic); 93 94 md->gw->callback = msn_ns_callback; 94 msn_ns_connected(md, -1, B_EV_IO_READ);95 msn_ns_connected(md, 0, NULL, B_EV_IO_READ); 95 96 } else { 96 md->fd = proxy_connect(host, port, msn_ns_connected, md); 97 md->ssl = ssl_connect((char *) host, port, TRUE, msn_ns_connected, md); 98 md->fd = md->ssl ? ssl_getfd(md->ssl) : -1; 97 99 if (md->fd < 0) { 98 100 imcb_error(ic, "Could not connect to server"); … … 105 107 } 106 108 107 static gboolean msn_ns_connected(gpointer data, gint source, b_input_condition cond)109 static gboolean msn_ns_connected(gpointer data, int source, void *scd, b_input_condition cond) 108 110 { 109 111 struct msn_data *md = data; 110 112 struct im_connection *ic = md->ic; 111 113 112 if (source == -1 && !md->is_http) { 114 if (!scd && !md->is_http) { 115 md->ssl = NULL; 113 116 imcb_error(ic, "Could not connect to server"); 114 117 imc_logout(ic, TRUE); … … 135 138 } 136 139 137 if (msn_ns_write(ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER)) {140 if (msn_ns_write(ic, -1, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER)) { 138 141 if (!md->is_http) { 139 142 md->inpa = b_input_add(md->fd, B_EV_IO_READ, msn_ns_callback, md); … … 150 153 msn_gw_free(md->gw); 151 154 } 152 if (md->fd >= 0) { 153 closesocket(md->fd); 155 156 if (md->ssl) { 157 ssl_disconnect(md->ssl); 154 158 b_event_remove(md->inpa); 155 159 } 156 160 161 md->ssl = NULL; 157 162 md->fd = md->inpa = -1; 163 158 164 g_free(md->rxq); 159 165 g_free(md->cmd_text); … … 175 181 } else { 176 182 bytes = g_malloc(1024); 177 st = read(md->fd, bytes, 1024);178 } 179 180 if (st <= 0) {183 st = ssl_read(md->ssl, bytes, 1024); 184 } 185 186 if (st == 0 || (st < 0 && (md->is_http || !ssl_sockerr_again(md->ssl)))) { 181 187 imcb_error(ic, "Error while reading from server"); 182 188 imc_logout(ic, TRUE); … … 188 194 189 195 g_free(bytes); 196 197 if (!md->is_http && ssl_pending(md->ssl)) { 198 return msn_ns_callback(data, source, cond); 199 } 190 200 191 201 return msn_handler(md);
Note: See TracChangeset
for help on using the changeset viewer.