Changeset e046390 for protocols/purple


Ignore:
Timestamp:
2009-10-10T23:25:54Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
c5c18c1
Parents:
0cbef26
Message:

Make purple use BitlBee's event handling API. Since the APIs never really
diverged too much this is fairly transparent. I did rename and redefine
GAIM_INPUT_* variables to really make it work without adding another stupid
layer in between.

One problem left, the new libpurple input API doesn't care about return
values. Fixing that in the next CL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/purple/purple.c

    r0cbef26 re046390  
    6363}
    6464
    65 static void purple_glib_io_destroy(gpointer data)
    66 {
    67         g_free(data);
    68 }
    69 
    70 static gboolean purple_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
    71 {
    72         PurpleGLibIOClosure *closure = data;
    73         PurpleInputCondition purple_cond = 0;
    74 
    75         if (condition & PURPLE_GLIB_READ_COND)
    76                 purple_cond |= PURPLE_INPUT_READ;
    77         if (condition & PURPLE_GLIB_WRITE_COND)
    78                 purple_cond |= PURPLE_INPUT_WRITE;
    79 
    80         closure->function(closure->data, g_io_channel_unix_get_fd(source),
    81                           purple_cond);
    82 
    83         return TRUE;
    84 }
    85 
    86 static guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function,
    87                                                            gpointer data)
    88 {
    89         PurpleGLibIOClosure *closure = g_new0(PurpleGLibIOClosure, 1);
    90         GIOChannel *channel;
    91         GIOCondition cond = 0;
    92 
    93         closure->function = function;
    94         closure->data = data;
    95 
    96         if (condition & PURPLE_INPUT_READ)
    97                 cond |= PURPLE_GLIB_READ_COND;
    98         if (condition & PURPLE_INPUT_WRITE)
    99                 cond |= PURPLE_GLIB_WRITE_COND;
    100 
    101         channel = g_io_channel_unix_new(fd);
    102         closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
    103                                               purple_glib_io_invoke, closure, purple_glib_io_destroy);
    104 
    105         g_io_channel_unref(channel);
    106         return closure->result;
     65static guint prplcb_ev_timeout_add( guint interval, GSourceFunc func, gpointer udata )
     66{
     67        return b_timeout_add( interval, (b_event_handler) func, udata );
     68}
     69
     70static guint prplcb_ev_input_add( int fd, PurpleInputCondition cond, PurpleInputFunction func, gpointer udata )
     71{
     72        return (guint) b_input_add( fd, cond, (b_event_handler) func, udata );
    10773}
    10874
    10975static PurpleEventLoopUiOps glib_eventloops =
    11076{
    111         g_timeout_add,
    112         g_source_remove,
    113         glib_input_add,
    114         g_source_remove,
    115         NULL,
    116 #if GLIB_CHECK_VERSION(2,14,0)
    117         g_timeout_add_seconds,
    118 #else
    119         NULL,
    120 #endif
    121 
    122         /* padding */
    123         NULL,
    124         NULL,
    125         NULL
     77        prplcb_ev_timeout_add,
     78        b_event_remove,
     79        prplcb_ev_input_add,
     80        b_event_remove,
    12681};
    12782
     
    13792        PurpleAccount *pa;
    13893        //PurpleSavedStatus *ps;
    139         GList *i;
     94        //GList *i;
    14095       
    14196        /* For now this is needed in the _connected() handlers if using
     
    343298        NULL,                      /* write_chat           */
    344299        prplcb_conv_im,            /* write_im             */
    345         NULL, //null_write_conv,           /* write_conv           */
     300        NULL,                      /* write_conv           */
    346301        NULL,                      /* chat_add_users       */
    347302        NULL,                      /* chat_rename_user     */
     
    381336{
    382337        GList *prots;
     338       
     339        if( B_EV_IO_READ != PURPLE_INPUT_READ ||
     340            B_EV_IO_WRITE != PURPLE_INPUT_WRITE )
     341        {
     342                /* FIXME FIXME FIXME FIXME FIXME :-) */
     343                exit( 1 );
     344        }
    383345       
    384346        purple_util_set_user_dir("/tmp");
Note: See TracChangeset for help on using the changeset viewer.