comparison libpurple/protocols/bonjour/mdns_common.c @ 17501:c96b085ddf5c

Clean up Bonjour service publishing and improve XEP-0174 compliance.
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 05 Jun 2007 22:13:10 +0000
parents d7b50cac1c7a
children a8aa651f341f
comparison
equal deleted inserted replaced
17500:bca2780f7669 17501:c96b085ddf5c
40 void 40 void
41 bonjour_dns_sd_free(BonjourDnsSd *data) 41 bonjour_dns_sd_free(BonjourDnsSd *data)
42 { 42 {
43 g_free(data->first); 43 g_free(data->first);
44 g_free(data->last); 44 g_free(data->last);
45 g_free(data->email); 45 g_free(data->phsh);
46 g_free(data->status);
47 g_free(data->vc);
48 g_free(data->msg);
46 g_free(data); 49 g_free(data);
47 } 50 }
48 51
49 /** 52 /**
50 * Send a new dns-sd packet updating our status. 53 * Send a new dns-sd packet updating our status.
80 83
81 account = data->account; 84 account = data->account;
82 gc = purple_account_get_connection(account); 85 gc = purple_account_get_connection(account);
83 86
84 /* Initialize the dns-sd data and session */ 87 /* Initialize the dns-sd data and session */
85 88 #ifndef USE_BONJOUR_APPLE
86 #ifndef USE_BONJOUR_APPLE
87 if (sw_discovery_init(&data->session) != SW_OKAY) 89 if (sw_discovery_init(&data->session) != SW_OKAY)
88 { 90 {
89 purple_debug_error("bonjour", "Unable to initialize an mDNS session.\n"); 91 purple_debug_error("bonjour", "Unable to initialize an mDNS session.\n");
90 92
91 /* In Avahi, sw_discovery_init frees data->session but doesn't clear it */ 93 /* In Avahi, sw_discovery_init frees data->session but doesn't clear it */
103 } 105 }
104 106
105 /* Advise the daemon that we are waiting for connections */ 107 /* Advise the daemon that we are waiting for connections */
106 108
107 #ifdef USE_BONJOUR_APPLE 109 #ifdef USE_BONJOUR_APPLE
108 printf("account pointer here is %x\n,", account);
109 if (DNSServiceBrowse(&data->browser, 0, 0, ICHAT_SERVICE, NULL, _mdns_service_browse_callback, account) 110 if (DNSServiceBrowse(&data->browser, 0, 0, ICHAT_SERVICE, NULL, _mdns_service_browse_callback, account)
110 != kDNSServiceErr_NoError) 111 != kDNSServiceErr_NoError)
111 #else /* USE_BONJOUR_HOWL */ 112 #else /* USE_BONJOUR_HOWL */
112 if (sw_discovery_browse(data->session, 0, ICHAT_SERVICE, NULL, _browser_reply, 113 if (sw_discovery_browse(data->session, 0, ICHAT_SERVICE, NULL, _browser_reply,
113 account, &session_id) != SW_OKAY) 114 account, &session_id) != SW_OKAY)
118 } 119 }
119 120
120 /* Get the socket that communicates with the mDNS daemon and bind it to a */ 121 /* Get the socket that communicates with the mDNS daemon and bind it to a */
121 /* callback that will handle the dns_sd packets */ 122 /* callback that will handle the dns_sd packets */
122 123
123 #ifdef USE_BONJOUR_APPLE 124 #ifdef USE_BONJOUR_APPLE
124 dns_sd_socket = DNSServiceRefSockFD(data->browser); 125 dns_sd_socket = DNSServiceRefSockFD(data->browser);
125 opaque_data = data->browser; 126 opaque_data = data->browser;
126 #else /* USE_BONJOUR_HOWL */ 127 #else /* USE_BONJOUR_HOWL */
127 dns_sd_socket = sw_discovery_socket(data->session); 128 dns_sd_socket = sw_discovery_socket(data->session);
128 opaque_data = data->session; 129 opaque_data = data->session;
129 #endif 130 #endif
130 131
131 gc->inpa = purple_input_add(dns_sd_socket, PURPLE_INPUT_READ, 132 gc->inpa = purple_input_add(dns_sd_socket, PURPLE_INPUT_READ,
132 _mdns_handle_event, opaque_data); 133 _mdns_handle_event, opaque_data);
133 134
134 return TRUE; 135 return TRUE;
135 } 136 }
136 137
137 /** 138 /**
142 bonjour_dns_sd_stop(BonjourDnsSd *data) 143 bonjour_dns_sd_stop(BonjourDnsSd *data)
143 { 144 {
144 PurpleAccount *account; 145 PurpleAccount *account;
145 PurpleConnection *gc; 146 PurpleConnection *gc;
146 147
147 #ifdef USE_BONJOUR_APPLE 148 #ifdef USE_BONJOUR_APPLE
148 if (NULL == data->advertisement || NULL == data->browser) 149 if (data->advertisement == NULL || data->browser == NULL)
149 #else /* USE_BONJOUR_HOWL */ 150 #else /* USE_BONJOUR_HOWL */
150 if (data->session == NULL) 151 if (data->session == NULL)
151 #endif 152 #endif
152 return; 153 return;
153 154
154 #ifdef USE_BONJOUR_HOWL 155 #ifdef USE_BONJOUR_HOWL
155 sw_discovery_cancel(data->session, data->session_id); 156 sw_discovery_cancel(data->session, data->session_id);
156 #endif 157 #endif
157 158
158 account = data->account; 159 account = data->account;
159 gc = purple_account_get_connection(account); 160 gc = purple_account_get_connection(account);
160 purple_input_remove(gc->inpa); 161 purple_input_remove(gc->inpa);
161 162
162 #ifdef USE_BONJOUR_APPLE 163 #ifdef USE_BONJOUR_APPLE
163 /* hack: for win32, we need to stop listening to the advertisement pipe too */ 164 /* hack: for win32, we need to stop listening to the advertisement pipe too */
164 purple_input_remove(data->advertisement_fd); 165 purple_input_remove(data->advertisement_fd);
165 166
166 DNSServiceRefDeallocate(data->advertisement); 167 DNSServiceRefDeallocate(data->advertisement);
167 DNSServiceRefDeallocate(data->browser); 168 DNSServiceRefDeallocate(data->browser);