Changeset ecf8fa8 for protocols


Ignore:
Timestamp:
2006-05-09T07:20:05Z (19 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.

Location:
protocols
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/Makefile

    ra0d04d6 recf8fa8  
    1010
    1111# [SH] Program variables
    12 objects = http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT)
     12objects = events_glib.o http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT)
    1313
    1414# [SH] The next two lines should contain the directory name (in $(subdirs))
  • protocols/nogaim.c

    ra0d04d6 recf8fa8  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2004 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2006 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    1313 * from scratch for BitlBee and doesn't contain any code from Gaim anymore
    1414 * (except for the function names).
    15  *
    16  * Copyright 2002-2006 Wilmer van der Gaast <wilmer@gaast.net> and others
    1715 */
    1816
  • 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{
  • protocols/proxy.h

    ra0d04d6 recf8fa8  
    11/*
    2  * gaim
     2 * nogaim
    33 *
    44 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
     
    3636#include <gmodule.h>
    3737
     38#include "events.h"
     39
    3840#define PROXY_NONE 0
    3941#define PROXY_HTTP 1
     
    4749extern char proxypass[128];
    4850
    49 typedef enum {
    50         GAIM_INPUT_READ = 1 << 0,
    51         GAIM_INPUT_WRITE = 1 << 1
    52 } GaimInputCondition;
    53 typedef void (*GaimInputFunction)(gpointer, gint, GaimInputCondition);
    54 
    55 G_MODULE_EXPORT gint gaim_input_add(int, GaimInputCondition, GaimInputFunction, gpointer);
    56 G_MODULE_EXPORT void gaim_input_remove(gint);
    57 
    5851G_MODULE_EXPORT int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data);
    5952
Note: See TracChangeset for help on using the changeset viewer.