Changeset 1323e36 for skype/skype.c


Ignore:
Timestamp:
2007-08-19T13:57:32Z (17 years ago)
Author:
VMiklos <vmiklos@…>
Branches:
master
Children:
9fd4241
Parents:
f06e3ac
Message:

basic read functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skype/skype.c

    rf06e3ac r1323e36  
    6565}
    6666
     67static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition cond )
     68{
     69        struct im_connection *ic = data;
     70        struct skype_data *sd = ic->proto_data;
     71        char buf[1024];
     72        int st;
     73
     74        if( sd->fd == -1 )
     75                return FALSE;
     76        st = read( sd->fd, buf, sizeof( buf ) );
     77        if( st > 0 )
     78        {
     79                buf[st] = '\0';
     80                printf("read(): '%s'\n", buf);
     81        }
     82        else if( st == 0 || ( st < 0 && !sockerr_again() ) )
     83        {
     84                closesocket( sd->fd );
     85                sd->fd = -1;
     86
     87                imcb_error( ic, "Error while reading from server" );
     88                imc_logout( ic, TRUE );
     89                return FALSE;
     90        }
     91
     92        /* EAGAIN/etc or a successful read. */
     93        return TRUE;
     94}
     95
    6796static gboolean skype_write_queue( struct im_connection *ic )
    6897{
     
    7099        int st;
    71100
     101        printf("sd->fd: %d\n", sd->fd);
    72102        st = write( sd->fd, sd->txq, sd->tx_len );
    73103
     
    110140gboolean skype_start_stream( struct im_connection *ic )
    111141{
     142        struct skype_data *sd = ic->proto_data;
    112143        char *buf;
    113144        int st;
     145
     146        if( sd->r_inpa <= 0 )
     147                sd->r_inpa = b_input_add( sd->fd, GAIM_INPUT_READ, skype_read_callback, ic );
    114148
    115149        buf = g_strdup_printf("SEARCH FRIENDS");
     
    122156{
    123157        struct im_connection *ic = data;
     158        struct skype_data *sd = ic->proto_data;
    124159
    125160        imcb_connected(ic);
     161        if( sd->fd < 0 )
     162        {
     163                imcb_error( ic, "Could not connect to server" );
     164                imc_logout( ic, TRUE );
     165                return;
     166        }
    126167        //imcb_add_buddy(ic, "vmiklos_dsd@skype.com", NULL);
    127168        //imcb_buddy_status(ic, "vmiklos_dsd@skype.com", OPT_LOGGED_IN, NULL, NULL);
     
    140181        sd->fd = proxy_connect(acc->server, set_getint( &acc->set, "port" ), skype_connected, ic );
    141182        printf("sd->fd: %d\n", sd->fd);
    142         if( sd->fd < 0 )
    143         {
    144                 imcb_error( ic, "Could not connect to server" );
    145                 imc_logout( ic, TRUE );
    146                 return;
    147         }
    148183
    149184        sd->ic = ic;
Note: See TracChangeset for help on using the changeset viewer.