Mercurial > pidgin.yaz
comparison libpurple/dbus-server.c @ 19114:6de2e9ba0930
merge of '2970edca111b3535ae0703e3c866ad1c3b87df94'
and 'a2b508e8680ac3f20965226a5dd83f7e2a3b15bb'
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Sun, 24 Jun 2007 02:56:09 +0000 |
parents | 428a3418bce5 |
children | 44b4e8bd759b |
comparison
equal
deleted
inserted
replaced
19102:7f26e5b98b15 | 19114:6de2e9ba0930 |
---|---|
118 { | 118 { |
119 gint id = GPOINTER_TO_INT(g_hash_table_lookup(map_node_id, node)); | 119 gint id = GPOINTER_TO_INT(g_hash_table_lookup(map_node_id, node)); |
120 if ((id == 0) && (node != NULL)) | 120 if ((id == 0) && (node != NULL)) |
121 { | 121 { |
122 purple_debug_warning("dbus", | 122 purple_debug_warning("dbus", |
123 "Need to register an object with the dbus subsystem.\n"); | 123 "Need to register an object with the dbus subsystem. (If you are not a developer, please ignore this message.)\n"); |
124 return 0; | 124 return 0; |
125 } | 125 } |
126 return id; | 126 return id; |
127 } | 127 } |
128 | 128 |
288 else | 288 else |
289 return ""; | 289 return ""; |
290 } | 290 } |
291 | 291 |
292 dbus_int32_t * | 292 dbus_int32_t * |
293 purple_dbusify_const_GList(const GList *list, dbus_int32_t *len) | 293 purple_dbusify_GList(GList *list, gboolean free_memory, dbus_int32_t *len) |
294 { | 294 { |
295 dbus_int32_t *array; | 295 dbus_int32_t *array; |
296 int i; | 296 int i; |
297 const GList *elem; | 297 GList *elem; |
298 | 298 |
299 /* g_list_length() should really take a const GList */ | 299 *len = g_list_length(list); |
300 *len = g_list_length((GList *)list); | |
301 array = g_new0(dbus_int32_t, *len); | 300 array = g_new0(dbus_int32_t, *len); |
302 for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) | 301 for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) |
303 array[i] = purple_dbus_pointer_to_id(elem->data); | 302 array[i] = purple_dbus_pointer_to_id(elem->data); |
304 | 303 |
304 if (free_memory) | |
305 g_list_free(list); | |
306 | |
305 return array; | 307 return array; |
306 } | 308 } |
307 | 309 |
308 dbus_int32_t * | 310 dbus_int32_t * |
309 purple_dbusify_GList(GList *list, gboolean free_memory, dbus_int32_t *len) | 311 purple_dbusify_GSList(GSList *list, gboolean free_memory, dbus_int32_t *len) |
310 { | |
311 dbus_int32_t *array = purple_dbusify_const_GList(list, len); | |
312 | |
313 if (!free_memory) | |
314 return array; | |
315 | |
316 g_list_free(list); | |
317 return array; | |
318 } | |
319 | |
320 dbus_int32_t * | |
321 purple_dbusify_const_GSList(const GSList *list, dbus_int32_t *len) | |
322 { | 312 { |
323 dbus_int32_t *array; | 313 dbus_int32_t *array; |
324 int i; | 314 int i; |
325 const GSList *elem; | 315 GSList *elem; |
326 | 316 |
327 /* g_slist_length should really take a const GSList */ | 317 *len = g_slist_length(list); |
328 *len = g_slist_length((GSList *)list); | |
329 array = g_new0(dbus_int32_t, *len); | 318 array = g_new0(dbus_int32_t, *len); |
330 for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) | 319 for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) |
331 array[i] = purple_dbus_pointer_to_id(elem->data); | 320 array[i] = purple_dbus_pointer_to_id(elem->data); |
332 | 321 |
322 if (free_memory) | |
323 g_slist_free(list); | |
324 | |
333 return array; | 325 return array; |
334 } | 326 } |
335 | 327 |
336 dbus_int32_t * | |
337 purple_dbusify_GSList(GSList *list, gboolean free_memory, dbus_int32_t *len) | |
338 { | |
339 dbus_int32_t *array = purple_dbusify_const_GSList(list, len); | |
340 | |
341 if (!free_memory) | |
342 return array; | |
343 | |
344 g_slist_free(list); | |
345 return array; | |
346 } | |
347 | |
348 gpointer * | 328 gpointer * |
349 purple_const_GList_to_array(const GList *list, dbus_int32_t *len) | 329 purple_GList_to_array(GList *list, gboolean free_memory, dbus_int32_t *len) |
350 { | 330 { |
351 gpointer *array; | 331 gpointer *array; |
352 int i; | 332 int i; |
353 const GList *elem; | 333 GList *elem; |
354 | 334 |
355 *len = g_list_length((GList *)list); | 335 *len = g_list_length(list); |
356 array = g_new0(gpointer, *len); | 336 array = g_new0(gpointer, *len); |
357 for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) | 337 for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) |
358 array[i] = elem->data; | 338 array[i] = elem->data; |
359 | 339 |
340 if (free_memory) | |
341 g_list_free(list); | |
342 | |
360 return array; | 343 return array; |
361 } | 344 } |
362 | 345 |
363 gpointer * | 346 gpointer * |
364 purple_GList_to_array(GList *list, gboolean free_memory, dbus_int32_t *len) | 347 purple_GSList_to_array(GSList *list, gboolean free_memory, dbus_int32_t *len) |
365 { | |
366 gpointer *array = purple_const_GList_to_array(list, len); | |
367 | |
368 if (!free_memory) | |
369 return array; | |
370 | |
371 g_list_free(list); | |
372 return array; | |
373 } | |
374 | |
375 gpointer * | |
376 purple_const_GSList_to_array(const GSList *list, dbus_int32_t *len) | |
377 { | 348 { |
378 gpointer *array; | 349 gpointer *array; |
379 int i; | 350 int i; |
380 const GSList *elem; | 351 GSList *elem; |
381 | 352 |
382 *len = g_slist_length((GSList *)list); | 353 *len = g_slist_length(list); |
383 array = g_new0(gpointer, *len); | 354 array = g_new0(gpointer, *len); |
384 for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) | 355 for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) |
385 array[i] = elem->data; | 356 array[i] = elem->data; |
386 | 357 |
387 return array; | 358 if (free_memory) |
388 } | 359 g_slist_free(list); |
389 | 360 |
390 gpointer * | |
391 purple_GSList_to_array(GSList *list, gboolean free_memory, dbus_int32_t *len) | |
392 { | |
393 gpointer *array = purple_const_GSList_to_array(list, len); | |
394 | |
395 if (!free_memory) | |
396 return array; | |
397 | |
398 g_slist_free(list); | |
399 return array; | 361 return array; |
400 } | 362 } |
401 | 363 |
402 GHashTable * | 364 GHashTable * |
403 purple_dbus_iter_hash_table(DBusMessageIter *iter, DBusError *error) | 365 purple_dbus_iter_hash_table(DBusMessageIter *iter, DBusError *error) |
796 newname = purple_dbus_convert_signal_name(name); | 758 newname = purple_dbus_convert_signal_name(name); |
797 signal = dbus_message_new_signal(DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, newname); | 759 signal = dbus_message_new_signal(DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, newname); |
798 dbus_message_iter_init_append(signal, &iter); | 760 dbus_message_iter_init_append(signal, &iter); |
799 | 761 |
800 if (purple_dbus_message_append_purple_values(&iter, num_values, values, vargs)) | 762 if (purple_dbus_message_append_purple_values(&iter, num_values, values, vargs)) |
801 purple_debug_warning("dbus", "The signal \"%s\" caused some dbus error.\n", name); | 763 purple_debug_warning("dbus", "The signal \"%s\" caused some dbus error. (If you are not a developer, please ignore this message.)\n", name); |
802 | 764 |
803 dbus_connection_send(purple_dbus_connection, signal, NULL); | 765 dbus_connection_send(purple_dbus_connection, signal, NULL); |
804 | 766 |
805 g_free(newname); | 767 g_free(newname); |
806 dbus_message_unref(signal); | 768 dbus_message_unref(signal); |
833 } | 795 } |
834 | 796 |
835 void | 797 void |
836 purple_dbus_uninit(void) | 798 purple_dbus_uninit(void) |
837 { | 799 { |
838 /* Surely we must do SOME kind of uninitialization? */ | 800 DBusError error; |
839 | 801 if (!purple_dbus_connection) |
802 return; | |
803 | |
804 dbus_error_init(&error); | |
805 dbus_connection_unregister_object_path(purple_dbus_connection, DBUS_PATH_PURPLE); | |
806 dbus_bus_release_name(purple_dbus_connection, DBUS_SERVICE_PURPLE, &error); | |
807 dbus_error_free(&error); | |
808 dbus_connection_unref(purple_dbus_connection); | |
809 purple_dbus_connection = NULL; | |
810 purple_signals_disconnect_by_handle(purple_dbus_get_handle()); | |
840 g_free(init_error); | 811 g_free(init_error); |
841 init_error = NULL; | 812 init_error = NULL; |
842 } | 813 } |
814 |