comparison src/protocols/bonjour/dns_sd.c @ 11678:b37c439dfcc0

[gaim-migrate @ 13964] Modify the Bonjour PRPL to use gc->inpa, gaim_input_add, and to stop watching the mDNS socket when Bonjour is disconnected. This fixes the crash-at-signoff committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 17 Oct 2005 06:11:02 +0000
parents 8004885fabbe
children 92cf092f194e
comparison
equal deleted inserted replaced
11677:8004885fabbe 11678:b37c439dfcc0
279 sw_text_record_fina(dns_data); 279 sw_text_record_fina(dns_data);
280 280
281 return 0; 281 return 0;
282 } 282 }
283 283
284 static gboolean 284 static void
285 _dns_sd_handle_packets(GIOChannel *source, GIOCondition condition, gpointer data) 285 _dns_sd_handle_packets(gpointer data, gint source, GaimInputCondition condition)
286 { 286 {
287 sw_discovery_read_socket(*((sw_discovery*)data)); 287 sw_discovery_read_socket(*((sw_discovery*)data));
288 return TRUE;
289 } 288 }
290 289
291 // End private functions 290 // End private functions
292 291
293 /** 292 /**
336 * for other bonjour peers. 335 * for other bonjour peers.
337 */ 336 */
338 void 337 void
339 bonjour_dns_sd_start(BonjourDnsSd *data) 338 bonjour_dns_sd_start(BonjourDnsSd *data)
340 { 339 {
341 GIOChannel *io_channel; 340 GaimAccount *account;
341 GaimConnection *gc;
342 gint dns_sd_socket; 342 gint dns_sd_socket;
343 sw_discovery_oid session_id; 343 sw_discovery_oid session_id;
344
345 account = data->account;
346 gc = gaim_account_get_connection(account);
344 347
345 // Initilizations of the dns-sd data and session 348 // Initilizations of the dns-sd data and session
346 data->session = malloc(sizeof(sw_discovery)); 349 data->session = malloc(sizeof(sw_discovery));
347 if (sw_discovery_init(data->session) != SW_OKAY) 350 if (sw_discovery_init(data->session) != SW_OKAY)
348 { 351 {
362 } 365 }
363 366
364 // Get the socket that communicates with the mDNS daemon and bind it to a 367 // Get the socket that communicates with the mDNS daemon and bind it to a
365 // callback that will handle the dns_sd packets 368 // callback that will handle the dns_sd packets
366 dns_sd_socket = sw_discovery_socket(*(data->session)); 369 dns_sd_socket = sw_discovery_socket(*(data->session));
367 io_channel = g_io_channel_unix_new(dns_sd_socket); 370 gc->inpa = gaim_input_add(dns_sd_socket, GAIM_INPUT_READ,
368 // Add more for other conditions like when the conn. has been broken 371 _dns_sd_handle_packets, data->session);
369 g_io_add_watch(io_channel, G_IO_IN, _dns_sd_handle_packets, data->session);
370 } 372 }
371 373
372 /** 374 /**
373 * Unregister the "_presence._tcp" service at the mDNS daemon. 375 * Unregister the "_presence._tcp" service at the mDNS daemon.
374 */ 376 */
375 int 377 int
376 bonjour_dns_sd_stop(BonjourDnsSd *data) 378 bonjour_dns_sd_stop(BonjourDnsSd *data)
377 { 379 {
380 GaimAccount *account;
381 GaimConnection *gc;
382
378 sw_discovery_cancel(*(data->session), data->session_id); 383 sw_discovery_cancel(*(data->session), data->session_id);
379 384
385 account = data->account;
386 gc = gaim_account_get_connection(account);
387 gaim_input_remove(gc->inpa);
388
380 return 0; 389 return 0;
381 } 390 }