pidgin/pidgin

Remove the ability to register new accounts.

18 months ago, Gary Kramlich
27f355b8b497
Parents c3c64590319f
Children 7842e3231dbb
Remove the ability to register new accounts.

XMPP is the only in-tree protocol with torchat and telegram being the others
that support this. I'm not opposed to bringing this back somehow, but this
current form has to go as it's way too complicated.

Testing Done:
Compiled

Reviewed at https://reviews.imfreedom.org/r/2047/
--- a/finch/gntaccount.c Mon Nov 07 23:28:31 2022 -0600
+++ b/finch/gntaccount.c Mon Nov 07 23:29:57 2022 -0600
@@ -58,7 +58,6 @@
GntWidget *protocols;
GntWidget *remember;
- GntWidget *regserver;
} AccountEditDialog;
/* This is necessary to close an edit-dialog when an account is deleted */
@@ -241,10 +240,7 @@
gnt_box_give_focus_to_child(GNT_BOX(accounts.window), accounts.tree);
}
- if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER, register_user) &&
- gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->regserver))) {
- purple_account_register(account);
- } else if (dialog->account == NULL) {
+ if (dialog->account == NULL) {
/* This is a new account. Set it to the current status. */
/* Xerox from gtkaccount.c :D */
const PurpleSavedStatus *saved_status;
@@ -477,11 +473,6 @@
}
}
g_list_free_full(opts, (GDestroyNotify)purple_account_option_destroy);
-
- /* Show the registration checkbox only in a new account dialog,
- * and when the selected protocol has the support for it. */
- gnt_widget_set_visible(dialog->regserver, account == NULL &&
- PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER, register_user));
}
static void
@@ -628,10 +619,6 @@
gnt_box_add_widget(GNT_BOX(window), dialog->remember);
gnt_box_add_widget(GNT_BOX(window), dialog->require_password);
- /* Register checkbox */
- dialog->regserver = gnt_check_box_new(_("Create this account on the server"));
- gnt_box_add_widget(GNT_BOX(window), dialog->regserver);
-
gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE));
/* The advanced box */
--- a/libpurple/account.c Mon Nov 07 23:28:31 2022 -0600
+++ b/libpurple/account.c Mon Nov 07 23:29:57 2022 -0600
@@ -91,9 +91,6 @@
PurplePresence *presence; /* Presence. */
- PurpleAccountRegistrationCb registration_cb;
- void *registration_cb_user_data;
-
PurpleConnectionErrorInfo *current_error; /* Errors */
PurpleNotification *error_notification;
} PurpleAccountPrivate;
@@ -105,13 +102,6 @@
} PurpleAccountSetting;
-typedef struct
-{
- PurpleAccount *account;
- GCallback cb;
- gpointer data;
-} PurpleCallbackBundle;
-
/* GObject Property enums */
enum
{
@@ -179,101 +169,6 @@
}
static void
-purple_account_register_got_password_cb(GObject *obj, GAsyncResult *res,
- gpointer data)
-{
- PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
- PurpleAccount *account = PURPLE_ACCOUNT(data);
- GError *error = NULL;
- gchar *password = NULL;
-
- password = purple_credential_manager_read_password_finish(manager, res,
- &error);
- if(error != NULL) {
- /* If we failed to read a password, just log it, as it could not be
- * stored yet, in which case we will just prompt the user later in the
- * connection process.
- */
- purple_debug_warning("account", "failed to read password: %s",
- error->message);
- g_clear_error(&error);
- }
-
- purple_account_real_connect(account, password);
-
- g_free(password);
-}
-
-void
-purple_account_register(PurpleAccount *account)
-{
- PurpleCredentialManager *manager = NULL;
-
- g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-
- purple_debug_info("account", "Registering account %s\n",
- purple_account_get_username(account));
-
- manager = purple_credential_manager_get_default();
- purple_credential_manager_read_password_async(manager, account, NULL,
- purple_account_register_got_password_cb,
- account);
-}
-
-static void
-purple_account_unregister_got_password_cb(GObject *obj, GAsyncResult *res,
- gpointer data)
-{
- PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
- PurpleCallbackBundle *cbb = data;
- PurpleAccountUnregistrationCb cb;
- GError *error = NULL;
- gchar *password = NULL;
-
- cb = (PurpleAccountUnregistrationCb)cbb->cb;
-
- password = purple_credential_manager_read_password_finish(manager, res,
- &error);
-
- if(error != NULL) {
- purple_debug_warning("account", "failed to read password: %s",
- error->message);
-
- g_error_free(error);
- }
-
- _purple_connection_new_unregister(cbb->account, password, cb, cbb->data);
-
- g_free(password);
- g_free(cbb);
-}
-
-struct register_completed_closure
-{
- PurpleAccount *account;
- gboolean succeeded;
-};
-
-static gboolean
-purple_account_register_completed_cb(gpointer data)
-{
- PurpleAccount *account = NULL;
- struct register_completed_closure *closure = data;
-
- account = closure->account;
-
- if (account->registration_cb) {
- (account->registration_cb)(closure->account, closure->succeeded,
- account->registration_cb_user_data);
- }
-
- g_object_unref(closure->account);
- g_free(closure);
-
- return FALSE;
-}
-
-static void
request_password_write_cb(GObject *obj, GAsyncResult *res, gpointer data) {
PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
PurpleAccount *account = PURPLE_ACCOUNT(data);
@@ -1158,52 +1053,6 @@
}
void
-purple_account_set_register_callback(PurpleAccount *account, PurpleAccountRegistrationCb cb, void *user_data)
-{
- g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-
- account->registration_cb = cb;
- account->registration_cb_user_data = user_data;
-}
-
-void
-purple_account_register_completed(PurpleAccount *account, gboolean succeeded)
-{
- struct register_completed_closure *closure;
-
- g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-
- closure = g_new0(struct register_completed_closure, 1);
- closure->account = g_object_ref(account);
- closure->succeeded = succeeded;
-
- g_timeout_add(0, purple_account_register_completed_cb, closure);
-}
-
-void
-purple_account_unregister(PurpleAccount *account,
- PurpleAccountUnregistrationCb cb, gpointer user_data)
-{
- PurpleCallbackBundle *cbb;
- PurpleCredentialManager *manager = NULL;
-
- g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-
- purple_debug_info("account", "Unregistering account %s\n",
- purple_account_get_username(account));
-
- cbb = g_new0(PurpleCallbackBundle, 1);
- cbb->account = account;
- cbb->cb = G_CALLBACK(cb);
- cbb->data = user_data;
-
- manager = purple_credential_manager_get_default();
- purple_credential_manager_read_password_async(manager, account, NULL,
- purple_account_unregister_got_password_cb,
- cbb);
-}
-
-void
purple_account_disconnect(PurpleAccount *account)
{
GError *error = NULL;
--- a/libpurple/account.h Mon Nov 07 23:28:31 2022 -0600
+++ b/libpurple/account.h Mon Nov 07 23:29:57 2022 -0600
@@ -34,8 +34,6 @@
typedef struct _PurpleAccount PurpleAccount;
typedef gboolean (*PurpleFilterAccountFunc)(PurpleAccount *account);
-typedef void (*PurpleAccountRegistrationCb)(PurpleAccount *account, gboolean succeeded, void *user_data);
-typedef void (*PurpleAccountUnregistrationCb)(PurpleAccount *account, gboolean succeeded, void *user_data);
#include "buddy.h"
#include "connection.h"
@@ -137,47 +135,6 @@
void purple_account_connect(PurpleAccount *account);
/**
- * purple_account_set_register_callback:
- * @account: The account for which this callback should be used
- * @cb: (scope call): The callback
- * @user_data: The user data passed to the callback
- *
- * Sets the callback for successful registration.
- */
-void purple_account_set_register_callback(PurpleAccount *account, PurpleAccountRegistrationCb cb, void *user_data);
-
-/**
- * purple_account_register:
- * @account: The account to register.
- *
- * Registers an account.
- */
-void purple_account_register(PurpleAccount *account);
-
-/**
- * purple_account_register_completed:
- * @account: The account being registered.
- * @succeeded: Was the account registration successful?
- *
- * Registration of the account was completed.
- * Calls the registration call-back set with purple_account_set_register_callback().
- *
- * Since: 3.0.0
- */
-void purple_account_register_completed(PurpleAccount *account, gboolean succeeded);
-
-/**
- * purple_account_unregister:
- * @account: The account to unregister.
- * @cb: (scope call): Optional callback to be called when unregistration is
- * complete
- * @user_data: user data to pass to the callback
- *
- * Unregisters an account (deleting it from the server).
- */
-void purple_account_unregister(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data);
-
-/**
* purple_account_disconnect:
* @account: The account to disconnect from.
*
--- a/libpurple/connection.c Mon Nov 07 23:28:31 2022 -0600
+++ b/libpurple/connection.c Mon Nov 07 23:29:57 2022 -0600
@@ -921,61 +921,6 @@
g_object_class_install_properties(obj_class, PROP_LAST, properties);
}
-void
-_purple_connection_new_unregister(PurpleAccount *account, const char *password,
- PurpleAccountUnregistrationCb cb,
- gpointer user_data)
-{
- PurpleConnection *gc;
- PurpleProtocol *protocol;
-
- g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-
- protocol = purple_account_get_protocol(account);
-
- if(protocol == NULL) {
- gchar *message;
-
- message = g_strdup_printf(_("Missing protocol for %s"),
- purple_account_get_username(account));
- purple_notify_error(NULL, _("Unregistration Error"), message,
- NULL, purple_request_cpar_from_account(account));
- g_free(message);
- return;
- }
-
- if(!purple_account_is_disconnected(account)) {
- purple_protocol_server_unregister_user(PURPLE_PROTOCOL_SERVER(protocol),
- account, cb, user_data);
- return;
- }
-
- if(((password == NULL) || (*password == '\0')) &&
- !(purple_protocol_get_options(protocol) & OPT_PROTO_NO_PASSWORD) &&
- !(purple_protocol_get_options(protocol) & OPT_PROTO_PASSWORD_OPTIONAL))
- {
- purple_debug_error("connection", "Cannot connect to account %s "
- "without a password.",
- purple_account_get_username(account));
-
- return;
- }
-
- gc = g_object_new(
- PURPLE_TYPE_CONNECTION,
- "protocol", protocol,
- "account", account,
- "password", password,
- NULL);
-
- g_return_if_fail(gc != NULL);
-
- purple_debug_info("connection", "Unregistering. gc = %p", gc);
-
- purple_protocol_server_unregister_user(PURPLE_PROTOCOL_SERVER(protocol),
- account, cb, user_data);
-}
-
gboolean
purple_connection_connect(PurpleConnection *connection, GError **error) {
PurpleConnectionClass *klass = NULL;
--- a/libpurple/protocols/jabber/auth.c Mon Nov 07 23:28:31 2022 -0600
+++ b/libpurple/protocols/jabber/auth.c Mon Nov 07 23:29:57 2022 -0600
@@ -173,11 +173,6 @@
JabberSaslState state;
char *msg = NULL;
- if(js->registration) {
- jabber_register_start(js);
- return;
- }
-
mechs = purple_xmlnode_get_child(packet, "mechanisms");
if(!mechs) {
purple_connection_error(js->gc,
@@ -390,11 +385,6 @@
return;
}
- if (js->registration) {
- jabber_register_start(js);
- return;
- }
-
/*
* IQ Auth doesn't have support for resource binding, so we need to pick a
* default resource so it will work properly. jabberd14 throws an error and
--- a/libpurple/protocols/jabber/iq.c Mon Nov 07 23:28:31 2022 -0600
+++ b/libpurple/protocols/jabber/iq.c Mon Nov 07 23:29:57 2022 -0600
@@ -545,8 +545,6 @@
jabber_iq_register_handler("query", NS_DISCO_ITEMS, jabber_disco_items_parse);
jabber_iq_register_handler("query", NS_LAST_ACTIVITY, jabber_iq_last_parse);
jabber_iq_register_handler("query", NS_OOB_IQ_DATA, jabber_oob_parse);
- jabber_iq_register_handler("query", "jabber:iq:register",
- jabber_register_parse);
jabber_iq_register_handler("query", "jabber:iq:roster",
jabber_roster_parse);
jabber_iq_register_handler("query", "jabber:iq:version",
--- a/libpurple/protocols/jabber/jabber.c Mon Nov 07 23:28:31 2022 -0600
+++ b/libpurple/protocols/jabber/jabber.c Mon Nov 07 23:29:57 2022 -0600
@@ -77,7 +77,6 @@
static gint plugin_ref = 0;
-static void jabber_unregister_account_cb(JabberStream *js);
static void jabber_send_raw(PurpleProtocolServer *protocol_server, JabberStream *js, const gchar *data, gint len);
static void jabber_remove_feature(const gchar *namespace);
static gboolean jabber_initiate_media(PurpleProtocolMedia *media, PurpleAccount *account, const char *who, PurpleMediaSessionType type);
@@ -109,8 +108,6 @@
{
if (type == JABBER_IQ_RESULT) {
jabber_disco_items_server(js);
- if(js->unregistration)
- jabber_unregister_account_cb(js);
} else {
purple_connection_error(js->gc,
PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
@@ -270,9 +267,7 @@
return;
}
- if(js->registration) {
- jabber_register_start(js);
- } else if(purple_xmlnode_get_child(packet, "mechanisms")) {
+ if(purple_xmlnode_get_child(packet, "mechanisms")) {
jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING);
jabber_auth_start(js, packet);
} else if(purple_xmlnode_get_child(packet, "bind")) {
@@ -1041,486 +1036,6 @@
jabber_stream_connect(js);
}
-
-static gboolean
-conn_close_cb(gpointer data)
-{
- JabberStream *js = data;
- PurpleAccount *account = purple_connection_get_account(js->gc);
-
- jabber_parser_free(js);
-
- purple_account_disconnect(account);
-
- js->conn_close_timeout = 0;
-
- return FALSE;
-}
-
-static void
-jabber_connection_schedule_close(JabberStream *js)
-{
- js->conn_close_timeout = g_timeout_add(0, conn_close_cb, js);
-}
-
-static void
-jabber_registration_result_cb(JabberStream *js, const char *from,
- JabberIqType type, const char *id,
- PurpleXmlNode *packet, gpointer data)
-{
- PurpleAccount *account = purple_connection_get_account(js->gc);
- char *buf;
- char *to = data;
-
- if (type == JABBER_IQ_RESULT) {
- if(js->registration) {
- buf = g_strdup_printf(_("Registration of %s@%s successful"),
- js->user->node, js->user->domain);
- purple_account_register_completed(account, TRUE);
- } else {
- g_return_if_fail(to != NULL);
- buf = g_strdup_printf(_("Registration to %s successful"),
- to);
- }
- purple_notify_info(NULL, _("Registration Successful"),
- _("Registration Successful"), buf,
- purple_request_cpar_from_connection(js->gc));
- g_free(buf);
- } else {
- char *msg = jabber_parse_error(js, packet, NULL);
-
- if(!msg)
- msg = g_strdup(_("Unknown Error"));
-
- purple_notify_error(NULL, _("Registration Failed"),
- _("Registration Failed"), msg,
- purple_request_cpar_from_connection(js->gc));
- g_free(msg);
- purple_account_register_completed(account, FALSE);
- }
- g_free(to);
- if(js->registration)
- jabber_connection_schedule_close(js);
-}
-
-static void
-jabber_unregistration_result_cb(JabberStream *js, const char *from,
- JabberIqType type, const char *id,
- PurpleXmlNode *packet, gpointer data)
-{
- char *buf;
- char *to = data;
-
- /* This function is never called for unregistering our XMPP account from
- * the server, so there should always be a 'to' address. */
- g_return_if_fail(to != NULL);
-
- if (type == JABBER_IQ_RESULT) {
- buf = g_strdup_printf(_("Registration from %s successfully removed"),
- to);
- purple_notify_info(NULL, _("Unregistration Successful"),
- _("Unregistration Successful"), buf,
- purple_request_cpar_from_connection(js->gc));
- g_free(buf);
- } else {
- char *msg = jabber_parse_error(js, packet, NULL);
-
- if(!msg)
- msg = g_strdup(_("Unknown Error"));
-
- purple_notify_error(NULL, _("Unregistration Failed"),
- _("Unregistration Failed"), msg,
- purple_request_cpar_from_connection(js->gc));
- g_free(msg);
- }
- g_free(to);
-}
-
-static void
-jabber_register_cb(PurpleKeyValuePair *cbdata, PurpleRequestFields *fields)
-{
- JabberStream *js = cbdata->value;
- GList *groups, *flds;
- PurpleXmlNode *query, *y;
- JabberIq *iq;
-
- iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
- query = purple_xmlnode_get_child(iq->node, "query");
- if (cbdata->key) {
- purple_xmlnode_set_attrib(iq->node, "to", cbdata->key);
- }
-
- for(groups = purple_request_fields_get_groups(fields); groups;
- groups = groups->next) {
- for(flds = purple_request_field_group_get_fields(groups->data);
- flds; flds = flds->next) {
- PurpleRequestField *field = flds->data;
- const char *id = purple_request_field_get_id(field);
- if(purple_strequal(id,"unregister")) {
- gboolean value = purple_request_field_bool_get_value(field);
- if(value) {
- /* unregister from service. this doesn't include any of the fields, so remove them from the stanza by recreating it
- (there's no "remove child" function for PurpleXmlNode) */
- jabber_iq_free(iq);
- iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
- query = purple_xmlnode_get_child(iq->node, "query");
- if (cbdata->key) {
- purple_xmlnode_set_attrib(iq->node, "to", cbdata->key);
- }
- purple_xmlnode_new_child(query, "remove");
-
- jabber_iq_set_callback(iq, jabber_unregistration_result_cb, g_strdup(cbdata->key));
-
- jabber_iq_send(iq);
- purple_key_value_pair_free(cbdata);
- return;
- }
- } else {
- const char *ids[] = {"username", "password", "name", "email", "nick", "first",
- "last", "address", "city", "state", "zip", "phone", "url", "date",
- NULL};
- const char *value = purple_request_field_string_get_value(field);
- int i;
- for (i = 0; ids[i]; i++) {
- if (purple_strequal(id, ids[i]))
- break;
- }
-
- if (!ids[i])
- continue;
- y = purple_xmlnode_new_child(query, ids[i]);
- purple_xmlnode_insert_data(y, value, -1);
- if(js->registration && purple_strequal(id, "username")) {
- g_free(js->user->node);
- js->user->node = g_strdup(value);
- }
- if(js->registration && purple_strequal(id, "password")) {
- PurpleCredentialManager *manager = NULL;
- PurpleAccount *account = NULL;
-
- account = purple_connection_get_account(js->gc);
- manager = purple_credential_manager_get_default();
-
- purple_credential_manager_write_password_async(manager,
- account,
- value, NULL,
- NULL, NULL);
- }
- }
- }
- }
-
- if(js->registration) {
- char *username = g_strdup_printf("%s@%s%s%s", js->user->node, js->user->domain,
- js->user->resource ? "/" : "",
- js->user->resource ? js->user->resource : "");
- purple_account_set_username(purple_connection_get_account(js->gc), username);
- g_free(username);
- }
-
- jabber_iq_set_callback(iq, jabber_registration_result_cb, g_strdup(cbdata->key));
-
- jabber_iq_send(iq);
- purple_key_value_pair_free(cbdata);
-}
-
-static void
-jabber_register_cancel_cb(PurpleKeyValuePair *cbdata, PurpleRequestFields *fields)
-{
- JabberStream *js = cbdata->value;
- PurpleAccount *account = purple_connection_get_account(js->gc);
- if(account && js->registration) {
- purple_account_register_completed(account, FALSE);
- jabber_connection_schedule_close(js);
- }
- purple_key_value_pair_free(cbdata);
-}
-
-static void jabber_register_x_data_cb(JabberStream *js, PurpleXmlNode *result, gpointer data)
-{
- PurpleXmlNode *query;
- JabberIq *iq;
- char *to = data;
-
- iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
- query = purple_xmlnode_get_child(iq->node, "query");
- if (to)
- purple_xmlnode_set_attrib(iq->node,"to",to);
-
- purple_xmlnode_insert_child(query, result);
-
- jabber_iq_set_callback(iq, jabber_registration_result_cb, to);
- jabber_iq_send(iq);
-}
-
-static const struct {
- const char *name;
- const char *label;
-} registration_fields[] = {
- { "email", N_("Email") },
- { "nick", N_("Nickname") },
- { "first", N_("First name") },
- { "last", N_("Last name") },
- { "address", N_("Address") },
- { "city", N_("City") },
- { "state", N_("State") },
- { "zip", N_("Postal code") },
- { "phone", N_("Phone") },
- { "url", N_("URL") },
- { "date", N_("Date") },
- { NULL, NULL }
-};
-
-void jabber_register_parse(JabberStream *js, const char *from, JabberIqType type,
- const char *id, PurpleXmlNode *query)
-{
- PurpleAccount *account = purple_connection_get_account(js->gc);
- PurpleRequestFields *fields;
- PurpleRequestFieldGroup *group;
- PurpleRequestField *field;
- PurpleXmlNode *x, *y, *node;
- char *instructions;
- PurpleKeyValuePair *cbdata;
- gboolean registered = FALSE;
- int i;
-
- if (type != JABBER_IQ_RESULT)
- return;
-
- if(js->registration) {
- /* get rid of the login thingy */
- purple_connection_set_state(js->gc, PURPLE_CONNECTION_STATE_CONNECTED);
- }
-
- if(purple_xmlnode_get_child(query, "registered")) {
- registered = TRUE;
-
- if(js->registration) {
- purple_notify_error(NULL, _("Already Registered"),
- _("Already Registered"), NULL,
- purple_request_cpar_from_connection(js->gc));
- purple_account_register_completed(account, FALSE);
- jabber_connection_schedule_close(js);
- return;
- }
- }
-
- if((x = purple_xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) {
- jabber_x_data_request(js, x, jabber_register_x_data_cb, g_strdup(from));
- return;
-
- } else if((x = purple_xmlnode_get_child_with_namespace(query, "x", NS_OOB_X_DATA))) {
- PurpleXmlNode *url;
-
- if((url = purple_xmlnode_get_child(x, "url"))) {
- char *href;
- if((href = purple_xmlnode_get_data(url))) {
- purple_notify_uri(NULL, href);
- g_free(href);
-
- if(js->registration) {
- /* succeeded, but we have no login info */
- purple_account_register_completed(account, TRUE);
- purple_connection_error(js->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
- _("Registration completed successfully. Please reconnect to continue."));
- jabber_connection_schedule_close(js);
- }
- return;
- }
- }
- }
-
- /* as a last resort, use the old jabber:iq:register syntax */
-
- fields = purple_request_fields_new();
- group = purple_request_field_group_new(NULL);
- purple_request_fields_add_group(fields, group);
-
- if((node = purple_xmlnode_get_child(query, "username"))) {
- char *data = purple_xmlnode_get_data(node);
- if(js->registration)
- field = purple_request_field_string_new("username", _("Username"), data ? data : js->user->node, FALSE);
- else
- field = purple_request_field_string_new("username", _("Username"), data, FALSE);
-
- purple_request_field_group_add_field(group, field);
- g_free(data);
- }
- if((node = purple_xmlnode_get_child(query, "password"))) {
- if(js->registration)
- field = purple_request_field_string_new("password", _("Password"),
- purple_connection_get_password(js->gc), FALSE);
- else {
- char *data = purple_xmlnode_get_data(node);
- field = purple_request_field_string_new("password", _("Password"), data, FALSE);
- g_free(data);
- }
-
- purple_request_field_string_set_masked(field, TRUE);
- purple_request_field_group_add_field(group, field);
- }
-
- if((node = purple_xmlnode_get_child(query, "name"))) {
- if(js->registration)
- field = purple_request_field_string_new("name", _("Name"),
- purple_account_get_private_alias(purple_connection_get_account(js->gc)), FALSE);
- else {
- char *data = purple_xmlnode_get_data(node);
- field = purple_request_field_string_new("name", _("Name"), data, FALSE);
- g_free(data);
- }
- purple_request_field_group_add_field(group, field);
- }
-
- for (i = 0; registration_fields[i].name != NULL; ++i) {
- if ((node = purple_xmlnode_get_child(query, registration_fields[i].name))) {
- char *data = purple_xmlnode_get_data(node);
- field = purple_request_field_string_new(registration_fields[i].name,
- _(registration_fields[i].label),
- data, FALSE);
- purple_request_field_group_add_field(group, field);
- g_free(data);
- }
- }
-
- if(registered) {
- field = purple_request_field_bool_new("unregister", _("Unregister"), FALSE);
- purple_request_field_group_add_field(group, field);
- }
-
- if((y = purple_xmlnode_get_child(query, "instructions")))
- instructions = purple_xmlnode_get_data(y);
- else if(registered)
- instructions = g_strdup(_("Please fill out the information below "
- "to change your account registration."));
- else
- instructions = g_strdup(_("Please fill out the information below "
- "to register your new account."));
-
- cbdata = purple_key_value_pair_new(from, js);
-
- if(js->registration)
- purple_request_fields(js->gc, _("Register New XMPP Account"),
- _("Register New XMPP Account"), instructions, fields,
- _("Register"), G_CALLBACK(jabber_register_cb),
- _("Cancel"), G_CALLBACK(jabber_register_cancel_cb),
- purple_request_cpar_from_connection(js->gc),
- cbdata);
- else {
- char *title;
- g_return_if_fail(from != NULL);
- title = registered ? g_strdup_printf(_("Change Account Registration at %s"), from)
- :g_strdup_printf(_("Register New Account at %s"), from);
- purple_request_fields(js->gc, title, title, instructions,
- fields, (registered ? _("Change Registration") :
- _("Register")), G_CALLBACK(jabber_register_cb),
- _("Cancel"), G_CALLBACK(jabber_register_cancel_cb),
- purple_request_cpar_from_connection(js->gc), cbdata);
- g_free(title);
- }
-
- g_free(instructions);
-}
-
-void jabber_register_start(JabberStream *js)
-{
- JabberIq *iq;
-
- iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register");
- jabber_iq_send(iq);
-}
-
-static void
-jabber_register_account(PurpleProtocolServer *protocol_server,
- PurpleAccount *account)
-{
- JabberStream *js;
-
- js = jabber_stream_new(account);
- if (js == NULL)
- return;
-
- js->registration = TRUE;
- jabber_stream_connect(js);
-}
-
-static void
-jabber_unregister_account_iq_cb(JabberStream *js, const char *from,
- JabberIqType type, const char *id,
- PurpleXmlNode *packet, gpointer data)
-{
- PurpleAccount *account = purple_connection_get_account(js->gc);
-
- if (type == JABBER_IQ_ERROR) {
- char *msg = jabber_parse_error(js, packet, NULL);
-
- purple_notify_error(js->gc, _("Error unregistering account"),
- _("Error unregistering account"), msg,
- purple_request_cpar_from_connection(js->gc));
- g_free(msg);
- if(js->unregistration_cb)
- js->unregistration_cb(account, FALSE, js->unregistration_user_data);
- } else {
- purple_notify_info(js->gc, _("Account successfully "
- "unregistered"), _("Account successfully unregistered"),
- NULL, purple_request_cpar_from_connection(js->gc));
- if(js->unregistration_cb)
- js->unregistration_cb(account, TRUE, js->unregistration_user_data);
- }
-}
-
-static void jabber_unregister_account_cb(JabberStream *js) {
- JabberIq *iq;
- PurpleXmlNode *query;
-
- g_return_if_fail(js->unregistration);
-
- iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
-
- query = purple_xmlnode_get_child_with_namespace(iq->node, "query", "jabber:iq:register");
-
- purple_xmlnode_new_child(query, "remove");
- purple_xmlnode_set_attrib(iq->node, "to", js->user->domain);
-
- jabber_iq_set_callback(iq, jabber_unregister_account_iq_cb, NULL);
- jabber_iq_send(iq);
-}
-
-static void
-jabber_unregister_account(PurpleProtocolServer *protocol_server,
- PurpleAccount *account,
- PurpleAccountUnregistrationCb cb, gpointer user_data)
-{
- PurpleConnection *gc = purple_account_get_connection(account);
- JabberStream *js;
-
- if (purple_connection_get_state(gc) != PURPLE_CONNECTION_STATE_CONNECTED) {
- if (purple_connection_get_state(gc) != PURPLE_CONNECTION_STATE_CONNECTING) {
- jabber_login(PURPLE_PROTOCOL(protocol_server), account);
- }
-
- js = purple_connection_get_protocol_data(gc);
- js->unregistration = TRUE;
- js->unregistration_cb = cb;
- js->unregistration_user_data = user_data;
-
- return;
- }
-
- js = purple_connection_get_protocol_data(gc);
-
- if (js->unregistration) {
- purple_debug_error("jabber", "Unregistration in process; ignoring duplicate request.\n");
- return;
- }
-
- js->unregistration = TRUE;
- js->unregistration_cb = cb;
- js->unregistration_user_data = user_data;
-
- jabber_unregister_account_cb(js);
-}
-
/* TODO: As Will pointed out in IRC, after being notified by the core to
* shutdown, we should async. wait for the server to send us the stream
* termination before destroying everything. That seems like it would require
@@ -3961,8 +3476,6 @@
static void
jabber_protocol_server_iface_init(PurpleProtocolServerInterface *server_iface)
{
- server_iface->register_user = jabber_register_account;
- server_iface->unregister_user = jabber_unregister_account;
server_iface->set_info = jabber_set_info;
server_iface->get_info = jabber_buddy_get_info;
server_iface->set_status = jabber_set_status;
--- a/libpurple/protocols/jabber/jabber.h Mon Nov 07 23:28:31 2022 -0600
+++ b/libpurple/protocols/jabber/jabber.h Mon Nov 07 23:29:57 2022 -0600
@@ -179,8 +179,6 @@
GInputStream *input;
PurpleQueuedOutputStream *output;
- gboolean registration;
-
char *initial_avatar_hash;
char *avatar_hash;
GSList *pending_avatar_requests;
@@ -206,10 +204,6 @@
gchar *sasl_password;
- gboolean unregistration;
- PurpleAccountUnregistrationCb unregistration_cb;
- void *unregistration_user_data;
-
gboolean vcard_fetched;
/* Entity Capabilities hash */
@@ -297,10 +291,6 @@
void jabber_stream_set_state(JabberStream *js, JabberStreamState state);
-void jabber_register_parse(JabberStream *js, const char *from,
- JabberIqType type, const char *id, PurpleXmlNode *query);
-void jabber_register_start(JabberStream *js);
-
char *jabber_get_next_id(JabberStream *js);
/** Parse an error into a human-readable string and optionally a disconnect
--- a/libpurple/purpleprivate.h Mon Nov 07 23:28:31 2022 -0600
+++ b/libpurple/purpleprivate.h Mon Nov 07 23:29:57 2022 -0600
@@ -83,21 +83,6 @@
_purple_buddy_icons_blist_loaded_cb(void);
/**
- * _purple_connection_new_unregister:
- * @account: The account to unregister
- * @password: The password to use.
- * @cb: Optional callback to be called when unregistration is complete
- * @user_data: user data to pass to the callback
- *
- * Tries to unregister the account on the server. If the account is not
- * connected, also creates a new connection.
- *
- * Note: This function should only be called by purple_account_unregister()
- * in account.c.
- */
-void _purple_connection_new_unregister(PurpleAccount *account, const char *password,
- PurpleAccountUnregistrationCb cb, void *user_data);
-/**
* _purple_connection_wants_to_die:
* @gc: The connection to check
*
--- a/libpurple/purpleprotocolserver.c Mon Nov 07 23:28:31 2022 -0600
+++ b/libpurple/purpleprotocolserver.c Mon Nov 07 23:29:57 2022 -0600
@@ -36,38 +36,6 @@
* Public API
*****************************************************************************/
void
-purple_protocol_server_register_user(PurpleProtocolServer *protocol_server,
- PurpleAccount *account)
-{
- PurpleProtocolServerInterface *iface = NULL;
-
- g_return_if_fail(PURPLE_IS_PROTOCOL_SERVER(protocol_server));
- g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-
- iface = PURPLE_PROTOCOL_SERVER_GET_IFACE(protocol_server);
- if(iface != NULL && iface->register_user != NULL) {
- iface->register_user(protocol_server, account);
- }
-}
-
-void
-purple_protocol_server_unregister_user(PurpleProtocolServer *protocol_server,
- PurpleAccount *account,
- PurpleAccountUnregistrationCb cb,
- gpointer data)
-{
- PurpleProtocolServerInterface *iface = NULL;
-
- g_return_if_fail(PURPLE_IS_PROTOCOL_SERVER(protocol_server));
- g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-
- iface = PURPLE_PROTOCOL_SERVER_GET_IFACE(protocol_server);
- if(iface != NULL && iface->unregister_user != NULL) {
- iface->unregister_user(protocol_server, account, cb, data);
- }
-}
-
-void
purple_protocol_server_set_info(PurpleProtocolServer *protocol_server,
PurpleConnection *connection,
const gchar *info)
--- a/libpurple/purpleprotocolserver.h Mon Nov 07 23:28:31 2022 -0600
+++ b/libpurple/purpleprotocolserver.h Mon Nov 07 23:29:57 2022 -0600
@@ -54,10 +54,6 @@
/**
* PurpleProtocolServerInterface:
- * @register_user: Register a new user.
- * @unregister_user: Remove the user from the server. The account can either be
- * connected or disconnected. After the removal is finished,
- * the connection will stay open and has to be closed!
* @set_info: Sets the user's profile.
* @get_info: Should arrange for purple_notify_userinfo() to be called with the
* requested user's profile.
@@ -93,9 +89,6 @@
GTypeInterface parent;
/*< public >*/
- void (*register_user)(PurpleProtocolServer *protocol_server, PurpleAccount *account);
- void (*unregister_user)(PurpleProtocolServer *protocol_server, PurpleAccount *account, PurpleAccountUnregistrationCb cb, gpointer data);
-
void (*set_info)(PurpleProtocolServer *protocol_server, PurpleConnection *connection, const gchar *info);
void (*get_info)(PurpleProtocolServer *protocol_server, PurpleConnection *connection, const gchar *who);
@@ -129,32 +122,6 @@
};
/**
- * purple_protocol_server_register_user:
- * @protocol_server: The #PurpleProtocolServer instance.
- * @account: The #PurpleAccount to register.
- *
- * Tell @protocol_server to register the new account described by @account.
- *
- * Since: 3.0.0
- */
-void purple_protocol_server_register_user(PurpleProtocolServer *protocol_server, PurpleAccount *account);
-
-/**
- * purple_protocol_server_unregister_user:
- * @protocol_server: The #PurpleProtocolServer instance.
- * @account: The #PurpleAccount instance.
- * @cb: (scope call): A PurpleAccountUnregistrationCb function.
- * @data: User data to pass to @cb.
- *
- * Unregisters @account with @protocol_server. The account can either be
- * connected or disconnected. After the removal is finished, the connection
- * will stay open and has to be closed.
- *
- * Since: 3.0.0
- */
-void purple_protocol_server_unregister_user(PurpleProtocolServer *protocol_server, PurpleAccount *account, PurpleAccountUnregistrationCb cb, gpointer data);
-
-/**
* purple_protocol_server_set_info:
* @protocol_server: The #PurpleProtocolServer instance.
* @connection: The #PurpleConnection instance.