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); }
void purple_ssl_close(PurpleSslConnection *gsc) { PurpleSslOps *ops; g_return_if_fail(gsc != NULL); purple_request_close_with_handle(gsc); purple_notify_close_with_handle(gsc); ops = purple_ssl_get_ops(); (ops->close)(gsc); if (gsc->connect_data != NULL) purple_proxy_connect_cancel(gsc->connect_data); if (gsc->inpa > 0) purple_input_remove(gsc->inpa); if (gsc->fd >= 0) close(gsc->fd); g_free(gsc->host); g_free(gsc); }
static void update_edit_list(GntWidget *widget, EditStatus *edit) { edits = g_list_remove(edits, edit); purple_notify_close_with_handle(edit); g_hash_table_foreach(edit->hash, (GHFunc)destroy_substatus_win, NULL); g_list_foreach((GList*)gnt_tree_get_rows(GNT_TREE(edit->tree)), free_key, NULL); g_free(edit); }
void pidgin_xfer_dialog_hide(PidginXferDialog *dialog) { g_return_if_fail(dialog != NULL); purple_notify_close_with_handle(dialog); gtk_widget_hide(dialog->window); }
static void purple_request_close_info(PurpleRequestInfo *info) { PurpleRequestUiOps *ops; ops = purple_request_get_ui_ops(); purple_notify_close_with_handle(info->ui_handle); purple_request_close_with_handle(info->ui_handle); if (ops != NULL && ops->close_request != NULL) ops->close_request(info->type, info->ui_handle); g_free(info); }
void AccountCollector::collectNow(PurpleAccount *account, bool remove) { if (account->ui_data == NULL) { Log("AccountCollector","freeing account " << purple_account_get_username(account)); if (remove) g_hash_table_remove(m_accounts, purple_account_get_username(account)); purple_account_set_enabled(account, purple_core_get_ui(), FALSE); purple_notify_close_with_handle(account); purple_request_close_with_handle(account); purple_accounts_remove(account); GSList *buddies = purple_find_buddies(account, NULL); while(buddies) { PurpleBuddy *b = (PurpleBuddy *) buddies->data; purple_blist_remove_buddy(b); buddies = g_slist_delete_link(buddies, buddies); } /* Remove any open conversation for this account */ for (GList *it = purple_get_conversations(); it; ) { PurpleConversation *conv = (PurpleConversation *) it->data; it = it->next; if (purple_conversation_get_account(conv) == account) purple_conversation_destroy(conv); } /* Remove this account's pounces */ // purple_pounce_destroy_all_by_account(account); /* This will cause the deletion of an old buddy icon. */ purple_buddy_icons_set_account_icon(account, NULL, 0); purple_account_destroy(account); // VALGRIND_DO_LEAK_CHECK; } }
gboolean purple_plugin_unload(PurplePlugin *plugin) { #ifdef PURPLE_PLUGINS GList *l; GList *ll; g_return_val_if_fail(plugin != NULL, FALSE); g_return_val_if_fail(purple_plugin_is_loaded(plugin), FALSE); purple_debug_info("plugins", "Unloading plugin %s\n", plugin->info->name); /* Unload all plugins that depend on this plugin. */ for (l = plugin->dependent_plugins; l != NULL; l = ll) { const char * dep_name = (const char *)l->data; PurplePlugin *dep_plugin; /* Store a pointer to the next element in the list. * This is because we'll be modifying this list in the loop. */ ll = l->next; dep_plugin = purple_plugins_find_with_id(dep_name); if (dep_plugin != NULL && purple_plugin_is_loaded(dep_plugin)) { if (!purple_plugin_unload(dep_plugin)) { g_free(plugin->error); plugin->error = g_strdup_printf(_("%s requires %s, but it failed to unload."), _(plugin->info->name), _(dep_plugin->info->name)); return FALSE; } else { #if 0 /* This isn't necessary. This has already been done when unloading dep_plugin. */ plugin->dependent_plugins = g_list_delete_link(plugin->dependent_plugins, l); #endif } } } /* Remove this plugin from each dependency's dependent_plugins list. */ for (l = plugin->info->dependencies; l != NULL; l = l->next) { const char *dep_name = (const char *)l->data; PurplePlugin *dependency; dependency = purple_plugins_find_with_id(dep_name); if (dependency != NULL) dependency->dependent_plugins = g_list_remove(dependency->dependent_plugins, plugin->info->id); else purple_debug_error("plugins", "Unable to remove from dependency list for %s\n", dep_name); } if (plugin->native_plugin) { if (plugin->info->unload && !plugin->info->unload(plugin)) return FALSE; if (plugin->info->type == PURPLE_PLUGIN_PROTOCOL) { PurplePluginProtocolInfo *prpl_info; GList *l; prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); for (l = prpl_info->user_splits; l != NULL; l = l->next) purple_account_user_split_destroy(l->data); for (l = prpl_info->protocol_options; l != NULL; l = l->next) purple_account_option_destroy(l->data); if (prpl_info->user_splits != NULL) { g_list_free(prpl_info->user_splits); prpl_info->user_splits = NULL; } if (prpl_info->protocol_options != NULL) { g_list_free(prpl_info->protocol_options); prpl_info->protocol_options = NULL; } } } else { PurplePlugin *loader; PurplePluginLoaderInfo *loader_info; loader = find_loader_for_plugin(plugin); if (loader == NULL) return FALSE; loader_info = PURPLE_PLUGIN_LOADER_INFO(loader); if (loader_info->unload && !loader_info->unload(plugin)) return FALSE; } /* cancel any pending dialogs the plugin has */ purple_request_close_with_handle(plugin); purple_notify_close_with_handle(plugin); purple_signals_disconnect_by_handle(plugin); purple_plugin_ipc_unregister_all(plugin); loaded_plugins = g_list_remove(loaded_plugins, plugin); if ((plugin->info != NULL) && PURPLE_IS_PROTOCOL_PLUGIN(plugin)) protocol_plugins = g_list_remove(protocol_plugins, plugin); plugins_to_disable = g_list_remove(plugins_to_disable, plugin); plugin->loaded = FALSE; /* We wouldn't be anywhere near here if the plugin wasn't loaded, so * if plugin->error is set at all, it had to be from a previous * unload failure. It's obviously okay now. */ g_free(plugin->error); plugin->error = NULL; purple_signal_emit(purple_plugins_get_handle(), "plugin-unload", plugin); purple_prefs_disconnect_by_handle(plugin); return TRUE; #else return TRUE; #endif /* PURPLE_PLUGINS */ }
static void request_fields_cb(GntWidget *button, PurpleRequestFields *fields) { PurpleRequestFieldsCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); GList *list; /* Update the data of the fields. Pidgin does this differently. Instead of * updating the fields at the end like here, it updates the appropriate field * instantly whenever a change is made. That allows it to make sure the * 'required' fields are entered before the user can hit OK. It's not the case * here, althought it can be done. */ for (list = purple_request_fields_get_groups(fields); list; list = list->next) { PurpleRequestFieldGroup *group = list->data; GList *fields = purple_request_field_group_get_fields(group); for (; fields ; fields = fields->next) { PurpleRequestField *field = fields->data; PurpleRequestFieldType type = purple_request_field_get_type(field); if (type == PURPLE_REQUEST_FIELD_BOOLEAN) { GntWidget *check = FINCH_GET_DATA(field); gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(check)); purple_request_field_bool_set_value(field, value); } else if (type == PURPLE_REQUEST_FIELD_STRING) { GntWidget *entry = FINCH_GET_DATA(field); const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); purple_request_field_string_set_value(field, (text && *text) ? text : NULL); } else if (type == PURPLE_REQUEST_FIELD_INTEGER) { GntWidget *entry = FINCH_GET_DATA(field); const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); int value = (text && *text) ? atoi(text) : 0; purple_request_field_int_set_value(field, value); } else if (type == PURPLE_REQUEST_FIELD_CHOICE) { GntWidget *combo = FINCH_GET_DATA(field); int id; id = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))); purple_request_field_choice_set_value(field, id); } else if (type == PURPLE_REQUEST_FIELD_LIST) { GList *list = NULL; if (purple_request_field_list_get_multi_select(field)) { GList *iter; GntWidget *tree = FINCH_GET_DATA(field); iter = purple_request_field_list_get_items(field); for (; iter; iter = iter->next) { const char *text = iter->data; gpointer key = purple_request_field_list_get_data(field, text); if (gnt_tree_get_choice(GNT_TREE(tree), key)) list = g_list_prepend(list, key); } } else { GntWidget *combo = FINCH_GET_DATA(field); gpointer data = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)); list = g_list_append(list, data); } purple_request_field_list_set_selected(field, list); g_list_free(list); } else if (type == PURPLE_REQUEST_FIELD_ACCOUNT) { GntWidget *combo = FINCH_GET_DATA(field); PurpleAccount *acc = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)); purple_request_field_account_set_value(field, acc); } } } purple_notify_close_with_handle(button); if (!g_object_get_data(G_OBJECT(button), "cancellation-function") && !purple_request_fields_all_required_filled(fields)) { purple_notify_error(button, _("Error"), _("You must fill all the required fields."), _("The required fields are underlined.")); return; } if (callback) callback(data, fields); while (button->parent) button = button->parent; purple_request_close(PURPLE_REQUEST_FIELDS, button); }
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); }