comparison src/session.c @ 8273:f24172f53650

[gaim-migrate @ 8997] This is Scott Lamb's eventloop abstraction patch. If it breaks things, Scott Lamb will be glad to take the punishment. If it doesn't, it should make integration into other event loops easier. Well, no, not easier, harder actually, but it'll be done more appropriately and less hackily.. er, hacky. Is hackily a word? committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 17 Feb 2004 02:17:48 +0000
parents fa6395637e2c
children 084ed9f7ac19
comparison
equal deleted inserted replaced
8272:9af78e73f0b2 8273:f24172f53650
22 */ 22 */
23 #include "internal.h" 23 #include "internal.h"
24 24
25 #include "core.h" 25 #include "core.h"
26 #include "debug.h" 26 #include "debug.h"
27 #include "eventloop.h"
27 28
28 extern char *opt_rcfile_arg; 29 extern char *opt_rcfile_arg;
29 30
30 #ifdef USE_SM 31 #ifdef USE_SM
31 32
43 static gboolean had_first_save = FALSE; 44 static gboolean had_first_save = FALSE;
44 gboolean session_managed = FALSE; 45 gboolean session_managed = FALSE;
45 46
46 /* ICE belt'n'braces stuff */ 47 /* ICE belt'n'braces stuff */
47 48
48 static gboolean ice_process_messages(GIOChannel *channel, GIOCondition condition, 49 static void ice_process_messages(gpointer data, gint fd,
49 gpointer data) { 50 GaimInputCondition condition) {
50 IceConn connection = (IceConn)data; 51 IceConn connection = (IceConn)data;
51 IceProcessMessagesStatus status; 52 IceProcessMessagesStatus status;
52 53
53 /* please don't block... please! */ 54 /* please don't block... please! */
54 status = IceProcessMessages(connection, NULL, NULL); 55 status = IceProcessMessages(connection, NULL, NULL);
62 IceCloseConnection(connection); 63 IceCloseConnection(connection);
63 64
64 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n"); 65 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n");
65 66
66 /* cancel the handler */ 67 /* cancel the handler */
67 return FALSE; 68 gaim_input_remove(IceConnectionNumber(connection));
68 } 69 }
69
70 /* live to see another day */
71 return TRUE;
72 } 70 }
73 71
74 static void ice_connection_watch(IceConn connection, IcePointer client_data, 72 static void ice_connection_watch(IceConn connection, IcePointer client_data,
75 Bool opening, IcePointer *watch_data) { 73 Bool opening, IcePointer *watch_data) {
76 guint input_id;
77
78 if (opening) { 74 if (opening) {
79 GIOChannel *channel;
80
81 gaim_debug(GAIM_DEBUG_INFO, "Session Management", 75 gaim_debug(GAIM_DEBUG_INFO, "Session Management",
82 "Handling new ICE connection... "); 76 "Handling new ICE connection... ");
83 77
84 /* ensure ICE connection is not passed to child processes */ 78 /* ensure ICE connection is not passed to child processes */
85 fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC); 79 fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC);
86 80
87 /* get glib to watch the connection for us */ 81 /* watch the connection */
88 channel = g_io_channel_unix_new(IceConnectionNumber(connection)); 82 gaim_input_add(IceConnectionNumber(connection), GAIM_INPUT_READ,
89 input_id = g_io_add_watch(channel, G_IO_IN | G_IO_ERR, 83 ice_process_messages, connection);
90 ice_process_messages, connection);
91 g_io_channel_unref(channel);
92
93 /* store the input ID as a pointer for when it closes */
94 *watch_data = (IcePointer)GUINT_TO_POINTER(input_id);
95 } else { 84 } else {
96 gaim_debug(GAIM_DEBUG_INFO, "Session Management", 85 gaim_debug(GAIM_DEBUG_INFO, "Session Management",
97 "Handling closed ICE connection... "); 86 "Handling closed ICE connection... ");
98 87
99 /* get the input ID back and stop watching it */ 88 /* stop watching it */
100 input_id = GPOINTER_TO_UINT((gpointer) *watch_data); 89 gaim_input_remove(IceConnectionNumber(connection));
101 g_source_remove(input_id);
102 } 90 }
103 91
104 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n"); 92 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n");
105 } 93 }
106 94