Changeset ecf8fa8 for protocols/proxy.c


Ignore:
Timestamp:
2006-05-09T07:20:05Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
67b6766
Parents:
a0d04d6
Message:

Split off event handling related functions (depending on GLib) to events_glib.c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/proxy.c

    ra0d04d6 recf8fa8  
    2121 */
    2222
    23 /* this is a little piece of code to handle proxy connection */
    24 /* it is intended to : 1st handle http proxy, using the CONNECT command
    25  , 2nd provide an easy way to add socks support */
    26 
    2723#define BITLBEE_CORE
    2824#include <stdio.h>
     
    4642#include "proxy.h"
    4743
    48 #define GAIM_READ_COND  (G_IO_IN | G_IO_HUP | G_IO_ERR)
    49 #define GAIM_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
    50 #define GAIM_ERR_COND   (G_IO_HUP | G_IO_ERR | G_IO_NVAL)
    51 
    5244char proxyhost[128] = "";
    5345int proxyport = 0;
     
    6456        gint inpa;
    6557};
    66 
    67 typedef struct _GaimIOClosure {
    68         GaimInputFunction function;
    69         guint result;
    70         gpointer data;
    71 } GaimIOClosure;
    7258
    7359
     
    9076
    9177        return &sin;
    92 }
    93 
    94 static void gaim_io_destroy(gpointer data)
    95 {
    96         g_free(data);
    97 }
    98 
    99 static gboolean gaim_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
    100 {
    101         GaimIOClosure *closure = data;
    102         GaimInputCondition gaim_cond = 0;
    103 
    104         if (condition & GAIM_READ_COND)
    105                 gaim_cond |= GAIM_INPUT_READ;
    106         if (condition & GAIM_WRITE_COND)
    107                 gaim_cond |= GAIM_INPUT_WRITE;
    108 
    109         closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond);
    110 
    111         return TRUE;
    11278}
    11379
     
    542508/* Export functions */
    543509
    544 gint gaim_input_add(gint source, GaimInputCondition condition, GaimInputFunction function, gpointer data)
    545 {
    546         GaimIOClosure *closure = g_new0(GaimIOClosure, 1);
    547         GIOChannel *channel;
    548         GIOCondition cond = 0;
    549        
    550         closure->function = function;
    551         closure->data = data;
    552        
    553         if (condition & GAIM_INPUT_READ)
    554                 cond |= GAIM_READ_COND;
    555         if (condition & GAIM_INPUT_WRITE)
    556                 cond |= GAIM_WRITE_COND;
    557        
    558         channel = g_io_channel_unix_new(source);
    559         closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
    560                                               gaim_io_invoke, closure, gaim_io_destroy);
    561        
    562         g_io_channel_unref(channel);
    563         return closure->result;
    564 }
    565 
    566 void gaim_input_remove(gint tag)
    567 {
    568         if (tag > 0)
    569                 g_source_remove(tag);
    570 }
    571 
    572510int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data)
    573511{
Note: See TracChangeset for help on using the changeset viewer.