void purple_keyring_unregister(PurpleKeyring *keyring) { PurpleKeyring *inuse; PurpleKeyring *fallback; const gchar *keyring_id; g_return_if_fail(keyring != NULL); keyring_id = purple_keyring_get_id(keyring); purple_debug_info("keyring", "Unregistering keyring: %s.\n", keyring_id); purple_signal_emit(purple_keyring_get_handle(), "keyring-unregister", keyring_id, keyring); PURPLE_DBUS_UNREGISTER_POINTER(keyring); inuse = purple_keyring_get_inuse(); fallback = purple_keyring_find_keyring_by_id(PURPLE_DEFAULT_KEYRING); if (inuse == keyring) { if (inuse != fallback) { purple_keyring_set_inuse(fallback, TRUE, NULL, NULL); } else { fallback = NULL; purple_keyring_set_inuse(NULL, TRUE, NULL, NULL); } } purple_keyring_keyrings = g_list_remove(purple_keyring_keyrings, keyring); }
static void purple_xfer_destroy(PurpleXfer *xfer) { PurpleXferUiOps *ui_ops; g_return_if_fail(xfer != NULL); if (purple_debug_is_verbose()) purple_debug_info("xfer", "destroyed %p [%d]\n", xfer, xfer->ref); /* Close the file browser, if it's open */ purple_request_close_with_handle(xfer); if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_STARTED) purple_xfer_cancel_local(xfer); ui_ops = purple_xfer_get_ui_ops(xfer); if (ui_ops != NULL && ui_ops->destroy != NULL) ui_ops->destroy(xfer); g_free(xfer->who); g_free(xfer->filename); g_free(xfer->remote_ip); g_free(xfer->local_filename); g_hash_table_remove(xfers_data, xfer); PURPLE_DBUS_UNREGISTER_POINTER(xfer); xfers = g_list_remove(xfers, xfer); g_free(xfer); }
PurpleBuddyIcon * purple_buddy_icon_unref(PurpleBuddyIcon *icon) { if (icon == NULL) return NULL; g_return_val_if_fail(icon->ref_count > 0, NULL); icon->ref_count--; if (icon->ref_count == 0) { GHashTable *icon_cache = g_hash_table_lookup(account_cache, purple_buddy_icon_get_account(icon)); if (icon_cache != NULL) g_hash_table_remove(icon_cache, purple_buddy_icon_get_username(icon)); g_free(icon->username); g_free(icon->checksum); purple_imgstore_unref(icon->img); PURPLE_DBUS_UNREGISTER_POINTER(icon); g_slice_free(PurpleBuddyIcon, icon); return NULL; } return icon; }
PurpleStoredImage * purple_imgstore_unref(PurpleStoredImage *img) { if (img == NULL) return NULL; g_return_val_if_fail(img->refcount > 0, NULL); img->refcount--; if (img->refcount == 0) { purple_signal_emit(purple_imgstore_get_handle(), "image-deleting", img); if (img->id) g_hash_table_remove(imgstore, &img->id); g_free(img->data); g_free(img->filename); PURPLE_DBUS_UNREGISTER_POINTER(img); g_free(img); img = NULL; } return img; }
static void purple_protocol_finalize(GObject *object) { PurpleProtocol *protocol = PURPLE_PROTOCOL(object); GList *accounts, *l; accounts = purple_accounts_get_all_active(); for (l = accounts; l != NULL; l = l->next) { PurpleAccount *account = PURPLE_ACCOUNT(l->data); if (purple_account_is_disconnected(account)) continue; if (purple_strequal(protocol->id, purple_account_get_protocol_id(account))) purple_account_disconnect(account); } g_list_free(accounts); purple_request_close_with_handle(protocol); purple_notify_close_with_handle(protocol); purple_signals_disconnect_by_handle(protocol); purple_signals_unregister_by_instance(protocol); purple_prefs_disconnect_by_handle(protocol); user_splits_free(protocol); account_options_free(protocol); icon_spec_free(protocol); PURPLE_DBUS_UNREGISTER_POINTER(protocol); parent_class->finalize(object); }
static gboolean plugin_unload(PurplePlugin *plugin) { g_free(hello.text); /* It is necessary to unregister all pointers registered by the module. */ PURPLE_DBUS_UNREGISTER_POINTER(&hello); return TRUE; }
void purple_notify_user_info_entry_destroy(PurpleNotifyUserInfoEntry *user_info_entry) { g_return_if_fail(user_info_entry != NULL); g_free(user_info_entry->label); g_free(user_info_entry->value); PURPLE_DBUS_UNREGISTER_POINTER(user_info_entry); g_free(user_info_entry); }
void purple_notify_user_info_destroy(PurpleNotifyUserInfo *user_info) { GList *l; for (l = user_info->entries.head; l != NULL; l = l->next) { PurpleNotifyUserInfoEntry *user_info_entry = l->data; purple_notify_user_info_entry_destroy(user_info_entry); } g_queue_clear(&user_info->entries); PURPLE_DBUS_UNREGISTER_POINTER(user_info); g_free(user_info); }
static void purple_smiley_finalize(GObject *obj) { PurpleSmiley *smiley = PURPLE_SMILEY(obj); PurpleSmileyPrivate *priv = PURPLE_SMILEY_GET_PRIVATE(smiley); g_free(priv->shortcut); if (priv->image) g_object_unref(priv->image); PURPLE_DBUS_UNREGISTER_POINTER(smiley); G_OBJECT_CLASS(parent_class)->finalize(obj); }
gboolean purple_ciphers_unregister_cipher(PurpleCipher *cipher) { g_return_val_if_fail(cipher, FALSE); g_return_val_if_fail(cipher->ref == 0, FALSE); purple_signal_emit(purple_ciphers_get_handle(), "cipher-removed", cipher); ciphers = g_list_remove(ciphers, cipher); g_free(cipher->name); PURPLE_DBUS_UNREGISTER_POINTER(cipher); g_free(cipher); return TRUE; }
void xmlnode_free(xmlnode *node) { xmlnode *x, *y; g_return_if_fail(node != NULL); /* if we're part of a tree, remove ourselves from the tree first */ if(NULL != node->parent) { if(node->parent->child == node) { node->parent->child = node->next; if (node->parent->lastchild == node) node->parent->lastchild = node->next; } else { xmlnode *prev = node->parent->child; while(prev && prev->next != node) { prev = prev->next; } if(prev) { prev->next = node->next; if (node->parent->lastchild == node) node->parent->lastchild = prev; } } } /* now free our children */ x = node->child; while(x) { y = x->next; xmlnode_free(x); x = y; } /* now dispose of ourselves */ g_free(node->name); g_free(node->data); g_free(node->xmlns); g_free(node->prefix); if(node->namespace_map) g_hash_table_destroy(node->namespace_map); PURPLE_DBUS_UNREGISTER_POINTER(node); g_free(node); }
static void purple_smiley_finalize(GObject *obj) { PurpleSmiley *smiley = PURPLE_SMILEY(obj); if (g_hash_table_lookup(smiley_shortcut_index, smiley->shortcut)) { g_hash_table_remove(smiley_shortcut_index, smiley->shortcut); g_hash_table_remove(smiley_checksum_index, smiley->checksum); } g_free(smiley->shortcut); g_free(smiley->checksum); if (smiley->img) purple_smiley_data_unstore(purple_imgstore_get_filename(smiley->img)); purple_imgstore_unref(smiley->img); PURPLE_DBUS_UNREGISTER_POINTER(smiley); purple_smileys_save(); }
static void purple_smiley_list_finalize(GObject *obj) { PurpleSmileyList *sl = PURPLE_SMILEY_LIST(obj); PurpleSmileyListPrivate *priv = PURPLE_SMILEY_LIST_GET_PRIVATE(sl); GList *it; g_object_unref(priv->trie); g_hash_table_destroy(priv->path_map); g_hash_table_destroy(priv->shortcut_map); for (it = priv->smileys; it; it = g_list_next(it)) { PurpleSmiley *smiley = it->data; g_object_set_data(G_OBJECT(smiley), "purple-smiley-list", NULL); g_object_set_data(G_OBJECT(smiley), "purple-smiley-list-elem", NULL); g_object_unref(smiley); } g_list_free(priv->smileys); PURPLE_DBUS_UNREGISTER_POINTER(sl); G_OBJECT_CLASS(parent_class)->finalize(obj); }
void purple_plugin_destroy(PurplePlugin *plugin) { #ifdef PURPLE_PLUGINS g_return_if_fail(plugin != NULL); if (purple_plugin_is_loaded(plugin)) purple_plugin_unload(plugin); plugins = g_list_remove(plugins, plugin); if (load_queue != NULL) load_queue = g_list_remove(load_queue, plugin); /* true, this may leak a little memory if there is a major version * mismatch, but it's a lot better than trying to free something * we shouldn't, and crashing while trying to load an old plugin */ if(plugin->info == NULL || plugin->info->magic != PURPLE_PLUGIN_MAGIC || plugin->info->major_version != PURPLE_MAJOR_VERSION) { if(plugin->handle) g_module_close(plugin->handle); g_free(plugin->path); g_free(plugin->error); PURPLE_DBUS_UNREGISTER_POINTER(plugin); g_free(plugin); return; } if (plugin->info != NULL) g_list_free(plugin->info->dependencies); if (plugin->native_plugin) { if (plugin->info != NULL && plugin->info->type == PURPLE_PLUGIN_LOADER) { PurplePluginLoaderInfo *loader_info; GList *exts, *l, *next_l; PurplePlugin *p2; loader_info = PURPLE_PLUGIN_LOADER_INFO(plugin); if (loader_info != NULL && loader_info->exts != NULL) { for (exts = PURPLE_PLUGIN_LOADER_INFO(plugin)->exts; exts != NULL; exts = exts->next) { for (l = purple_plugins_get_all(); l != NULL; l = next_l) { next_l = l->next; p2 = l->data; if (p2->path != NULL && has_file_extension(p2->path, exts->data)) { purple_plugin_destroy(p2); } } } g_list_free(loader_info->exts); loader_info->exts = NULL; } plugin_loaders = g_list_remove(plugin_loaders, plugin); } if (plugin->info != NULL && plugin->info->destroy != NULL) plugin->info->destroy(plugin); /* * I find it extremely useful to do this when using valgrind, as * it keeps all the plugins open, meaning that valgrind is able to * resolve symbol names in leak traces from plugins. */ if (!g_getenv("PURPLE_LEAKCHECK_HELP") && !RUNNING_ON_VALGRIND) { if (plugin->handle != NULL) g_module_close(plugin->handle); } } else { PurplePlugin *loader; PurplePluginLoaderInfo *loader_info; loader = find_loader_for_plugin(plugin); if (loader != NULL) { loader_info = PURPLE_PLUGIN_LOADER_INFO(loader); if (loader_info->destroy != NULL) loader_info->destroy(plugin); } } g_free(plugin->path); g_free(plugin->error); PURPLE_DBUS_UNREGISTER_POINTER(plugin); g_free(plugin); #endif /* !PURPLE_PLUGINS */ }
void _purple_connection_destroy(PurpleConnection *gc) { PurpleAccount *account; GSList *buddies; PurplePluginProtocolInfo *prpl_info = NULL; gboolean remove = FALSE; g_return_if_fail(gc != NULL); account = purple_connection_get_account(gc); purple_debug_info("connection", "Disconnecting connection %p\n", gc); if (purple_connection_get_state(gc) != PURPLE_CONNECTING) remove = TRUE; purple_signal_emit(purple_connections_get_handle(), "signing-off", gc); while (gc->buddy_chats) { PurpleConversation *b = gc->buddy_chats->data; gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); purple_conv_chat_left(PURPLE_CONV_CHAT(b)); } update_keepalive(gc, FALSE); purple_proxy_connect_cancel_with_handle(gc); prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info->close) (prpl_info->close)(gc); /* Clear out the proto data that was freed in the prpl close method*/ buddies = purple_find_buddies(account, NULL); while (buddies != NULL) { PurpleBuddy *buddy = buddies->data; purple_buddy_set_protocol_data(buddy, NULL); buddies = g_slist_delete_link(buddies, buddies); } connections = g_list_remove(connections, gc); purple_connection_set_state(gc, PURPLE_DISCONNECTED); if (remove) purple_blist_remove_account(account); purple_signal_emit(purple_connections_get_handle(), "signed-off", gc); purple_account_request_close_with_account(account); purple_request_close_with_handle(gc); purple_notify_close_with_handle(gc); purple_debug_info("connection", "Destroying connection %p\n", gc); purple_account_set_connection(account, NULL); g_free(gc->password); g_free(gc->display_name); if (gc->disconnect_timeout > 0) purple_timeout_remove(gc->disconnect_timeout); PURPLE_DBUS_UNREGISTER_POINTER(gc); g_free(gc); }