Changeset b4e96d6 for protocols/msn/ns.c


Ignore:
Timestamp:
2015-03-15T14:41:48Z (9 years ago)
Author:
dequis <dx@…>
Children:
89e0c94
Parents:
c408298
git-author:
dequis <dx@…> (14-03-15 12:00:58)
git-committer:
dequis <dx@…> (15-03-15 14:41:48)
Message:

msn: implement the rest of the http gateway support, enable by default

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/ns.c

    rc408298 rb4e96d6  
    6060
    6161        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
    6370        g_free(out);
    6471        if (st != len) {
     
    7986        }
    8087
    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                }
    8699        }
    87100
     
    95108        struct im_connection *ic = md->ic;
    96109
    97         if (source == -1) {
     110        if (source == -1 && !md->is_http) {
    98111                imcb_error(ic, "Could not connect to server");
    99112                imc_logout(ic, TRUE);
     
    121134
    122135        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                }
    124139                imcb_log(ic, "Connected to server, waiting for reply");
    125140        }
     
    130145void msn_ns_close(struct msn_data *handler)
    131146{
     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        }
    132155        if (handler->fd >= 0) {
    133156                closesocket(handler->fd);
     
    148171        struct msn_data *handler = data;
    149172        struct im_connection *ic = handler->ic;
    150         char bytes[1024];
     173        char *bytes;
    151174        int st;
    152175
    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
    154183        if (st <= 0) {
    155184                imcb_error(ic, "Error while reading from server");
     
    159188
    160189        msn_queue_feed(handler, bytes, st);
     190
     191        g_free(bytes);
    161192
    162193        /* Ignore ret == 0, it's already disconnected then. */
Note: See TracChangeset for help on using the changeset viewer.