comparison pidgin/gtkeventloop.c @ 30909:25e200cb3532

propagate from branch 'im.pidgin.pidgin' (head dca20e09164518b0f7a773edd7e9649f41d8873d) to branch 'im.pidgin.cpw.malu.xmpp.google_refactor' (head 7823c556f2d1bbca43f5ef9f0fea30cabc5d313f)
author Marcus Lundblad <ml@update.uu.se>
date Tue, 31 Aug 2010 18:28:10 +0000
parents 48e15c705add
children
comparison
equal deleted inserted replaced
30908:c44ec533a48c 30909:25e200cb3532
39 guint result; 39 guint result;
40 gpointer data; 40 gpointer data;
41 41
42 } PidginIOClosure; 42 } PidginIOClosure;
43 43
44 static void pidgin_io_destroy(gpointer data)
45 {
46 g_free(data);
47 }
48
49 static gboolean pidgin_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) 44 static gboolean pidgin_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
50 { 45 {
51 PidginIOClosure *closure = data; 46 PidginIOClosure *closure = data;
52 PurpleInputCondition purple_cond = 0; 47 PurpleInputCondition purple_cond = 0;
53 48
55 purple_cond |= PURPLE_INPUT_READ; 50 purple_cond |= PURPLE_INPUT_READ;
56 if (condition & PIDGIN_WRITE_COND) 51 if (condition & PIDGIN_WRITE_COND)
57 purple_cond |= PURPLE_INPUT_WRITE; 52 purple_cond |= PURPLE_INPUT_WRITE;
58 53
59 #if 0 54 #if 0
60 purple_debug(PURPLE_DEBUG_MISC, "gtk_eventloop", 55 purple_debug_misc("gtk_eventloop",
61 "CLOSURE: callback for %d, fd is %d\n", 56 "CLOSURE: callback for %d, fd is %d\n",
62 closure->result, g_io_channel_unix_get_fd(source)); 57 closure->result, g_io_channel_unix_get_fd(source));
63 #endif 58 #endif
64 59
65 #ifdef _WIN32 60 #ifdef _WIN32
66 if(! purple_cond) { 61 if(! purple_cond) {
67 #ifdef DEBUG 62 #ifdef DEBUG
68 purple_debug(PURPLE_DEBUG_MISC, "gtk_eventloop", 63 purple_debug_misc("gtk_eventloop",
69 "CLOSURE received GIOCondition of 0x%x, which does not" 64 "CLOSURE received GIOCondition of 0x%x, which does not"
70 " match 0x%x (READ) or 0x%x (WRITE)\n", 65 " match 0x%x (READ) or 0x%x (WRITE)\n",
71 condition, PIDGIN_READ_COND, PIDGIN_WRITE_COND); 66 condition, PIDGIN_READ_COND, PIDGIN_WRITE_COND);
72 #endif /* DEBUG */ 67 #endif /* DEBUG */
73 68
108 else 103 else
109 #endif 104 #endif
110 channel = g_io_channel_unix_new(fd); 105 channel = g_io_channel_unix_new(fd);
111 106
112 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, 107 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
113 pidgin_io_invoke, closure, pidgin_io_destroy); 108 pidgin_io_invoke, closure, g_free);
114 109
115 #if 0 110 #if 0
116 purple_debug(PURPLE_DEBUG_MISC, "gtk_eventloop", 111 purple_debug_misc("gtk_eventloop",
117 "CLOSURE: adding input watcher %d for fd %d\n", 112 "CLOSURE: adding input watcher %d for fd %d\n",
118 closure->result, fd); 113 closure->result, fd);
119 #endif 114 #endif
120 115
121 g_io_channel_unref(channel); 116 g_io_channel_unref(channel);