comparison src/proxy.c @ 2300:d2686f757d6e

[gaim-migrate @ 2310] neat things. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 17 Sep 2001 21:30:47 +0000
parents 0844f0bdf119
children 7973a8348d8b
comparison
equal deleted inserted replaced
2299:b5b7dece5249 2300:d2686f757d6e
56 gint inpa; 56 gint inpa;
57 }; 57 };
58 58
59 typedef struct _GaimIOClosure { 59 typedef struct _GaimIOClosure {
60 GaimInputFunction function; 60 GaimInputFunction function;
61 guint result;
61 gpointer data; 62 gpointer data;
62 } GaimIOClosure; 63 } GaimIOClosure;
63 64
64 static void gaim_io_destroy(gpointer data) 65 static void gaim_io_destroy(gpointer data)
65 { 66 {
74 if (condition & GAIM_READ_COND) 75 if (condition & GAIM_READ_COND)
75 gaim_cond |= GAIM_INPUT_READ; 76 gaim_cond |= GAIM_INPUT_READ;
76 if (condition & GAIM_READ_COND) 77 if (condition & GAIM_READ_COND)
77 gaim_cond |= GAIM_INPUT_WRITE; 78 gaim_cond |= GAIM_INPUT_WRITE;
78 79
80 debug_printf("CLOSURE: callback for %d, fd is %d\n",
81 closure->result, g_io_channel_unix_get_fd(source));
82
79 closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond); 83 closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond);
80 84
81 return TRUE; 85 return TRUE;
82 } 86 }
83 87
84 gint gaim_input_add(gint source, GaimInputCondition condition, 88 gint gaim_input_add(gint source, GaimInputCondition condition,
85 GaimInputFunction function, gpointer data) 89 GaimInputFunction function, gpointer data)
86 { 90 {
87 guint result;
88 GaimIOClosure *closure = g_new0(GaimIOClosure, 1); 91 GaimIOClosure *closure = g_new0(GaimIOClosure, 1);
89 GIOChannel *channel; 92 GIOChannel *channel;
90 GIOCondition cond = 0; 93 GIOCondition cond = 0;
91 94
92 closure->function = function; 95 closure->function = function;
96 cond |= GAIM_READ_COND; 99 cond |= GAIM_READ_COND;
97 if (condition & GAIM_INPUT_WRITE) 100 if (condition & GAIM_INPUT_WRITE)
98 cond |= GAIM_WRITE_COND; 101 cond |= GAIM_WRITE_COND;
99 102
100 channel = g_io_channel_unix_new(source); 103 channel = g_io_channel_unix_new(source);
101 result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, 104 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
102 gaim_io_invoke, closure, gaim_io_destroy); 105 gaim_io_invoke, closure, gaim_io_destroy);
106
107 debug_printf("CLOSURE: adding input watcher %d for fd %d\n", closure->result, source);
108
103 g_io_channel_unref(channel); 109 g_io_channel_unref(channel);
104 return result; 110 return closure->result;
105 } 111 }
106 112
107 void gaim_input_remove(gint tag) 113 void gaim_input_remove(gint tag)
108 { 114 {
115 debug_printf("CLOSURE: removing input watcher %d\n", tag);
109 g_source_remove(tag); 116 g_source_remove(tag);
110 } 117 }
111 118
112 static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) 119 static void no_one_calls(gpointer data, gint source, GaimInputCondition cond)
113 { 120 {