| 70 |
70 |
| 71 /* IO error, please disconnect */ |
71 /* IO error, please disconnect */ |
| 72 IceSetShutdownNegotiation(conninfo->connection, False); |
72 IceSetShutdownNegotiation(conninfo->connection, False); |
| 73 IceCloseConnection(conninfo->connection); |
73 IceCloseConnection(conninfo->connection); |
| 74 |
74 |
| 75 purple_debug(PURPLE_DEBUG_INFO, NULL, "done.\n"); |
75 if (purple_debug_is_verbose()) { |
| |
76 purple_debug_misc("Session Management", |
| |
77 "Connection closed."); |
| |
78 } |
| 76 |
79 |
| 77 /* cancel the handler */ |
80 /* cancel the handler */ |
| 78 purple_input_remove(conninfo->input_id); |
81 purple_input_remove(conninfo->input_id); |
| 79 } |
82 } |
| 80 } |
83 } |
| 82 static void ice_connection_watch(IceConn connection, IcePointer client_data, |
85 static void ice_connection_watch(IceConn connection, IcePointer client_data, |
| 83 Bool opening, IcePointer *watch_data) { |
86 Bool opening, IcePointer *watch_data) { |
| 84 struct ice_connection_info *conninfo = NULL; |
87 struct ice_connection_info *conninfo = NULL; |
| 85 |
88 |
| 86 if (opening) { |
89 if (opening) { |
| 87 purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
90 purple_debug_misc("Session Management", |
| 88 "Handling new ICE connection... \n"); |
91 "Handling new ICE connection..."); |
| 89 |
92 |
| 90 /* ensure ICE connection is not passed to child processes */ |
93 /* ensure ICE connection is not passed to child processes */ |
| 91 fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC); |
94 fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC); |
| 92 |
95 |
| 93 conninfo = g_new(struct ice_connection_info, 1); |
96 conninfo = g_new(struct ice_connection_info, 1); |
| 105 conninfo = (struct ice_connection_info*) *watch_data; |
108 conninfo = (struct ice_connection_info*) *watch_data; |
| 106 purple_input_remove(conninfo->input_id); |
109 purple_input_remove(conninfo->input_id); |
| 107 g_free(conninfo); |
110 g_free(conninfo); |
| 108 } |
111 } |
| 109 |
112 |
| 110 purple_debug(PURPLE_DEBUG_INFO, NULL, "done.\n"); |
113 if (purple_debug_is_verbose()) { |
| |
114 purple_debug_misc("Session Management", |
| |
115 "ICE connection handled."); |
| |
116 } |
| 111 } |
117 } |
| 112 |
118 |
| 113 /* We call any handler installed before (or after) ice_init but |
119 /* We call any handler installed before (or after) ice_init but |
| 114 * avoid calling the default libICE handler which does an exit(). |
120 * avoid calling the default libICE handler which does an exit(). |
| 115 * |
121 * |
| 122 "Handling ICE IO error... "); |
128 "Handling ICE IO error... "); |
| 123 |
129 |
| 124 if (ice_installed_io_error_handler) |
130 if (ice_installed_io_error_handler) |
| 125 (*ice_installed_io_error_handler)(connection); |
131 (*ice_installed_io_error_handler)(connection); |
| 126 |
132 |
| 127 purple_debug(PURPLE_DEBUG_INFO, NULL, "done.\n"); |
133 if (purple_debug_is_verbose()) { |
| |
134 purple_debug_misc("Session Management", |
| |
135 "ICE IO error handled."); |
| |
136 } |
| 128 } |
137 } |
| 129 |
138 |
| 130 static void ice_init(void) { |
139 static void ice_init(void) { |
| 131 IceIOErrorHandler default_handler; |
140 IceIOErrorHandler default_handler; |
| 132 |
141 |
| 136 if (ice_installed_io_error_handler == default_handler) |
145 if (ice_installed_io_error_handler == default_handler) |
| 137 ice_installed_io_error_handler = NULL; |
146 ice_installed_io_error_handler = NULL; |
| 138 |
147 |
| 139 IceAddConnectionWatch(ice_connection_watch, NULL); |
148 IceAddConnectionWatch(ice_connection_watch, NULL); |
| 140 |
149 |
| 141 purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
150 if (purple_debug_is_verbose()) { |
| 142 "ICE initialized.\n"); |
151 purple_debug_misc("Session Management", "ICE initialized."); |
| |
152 } |
| 143 } |
153 } |
| 144 |
154 |
| 145 /* my magic utility function */ |
155 /* my magic utility function */ |
| 146 |
156 |
| 147 static gchar **session_make_command(gchar *client_id, gchar *config_dir) { |
157 static gchar **session_make_command(gchar *client_id, gchar *config_dir) { |