pidgin: a9b83251: Allow account registration in a new acco...

sadrul at pidgin.im sadrul at pidgin.im
Wed May 21 01:10:42 EDT 2008


-----------------------------------------------------------------
Revision: a9b83251335ed42daf54164bf8c5120166f0e589
Ancestor: a24b297798c280b186d6d23946a291c6d967485d
Author: sadrul at pidgin.im
Date: 2008-05-21T05:07:25
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a9b83251335ed42daf54164bf8c5120166f0e589

Modified files:
        finch/gntaccount.c

ChangeLog: 

Allow account registration in a new account dialog.

-------------- next part --------------
============================================================
--- finch/gntaccount.c	33a066d8b8ee2b25225c3fc18f8a5e017c34f066
+++ finch/gntaccount.c	ca651f89af911d02c06bdce4ca60a749bea40954
@@ -43,6 +43,7 @@
 #include <notify.h>
 #include <plugin.h>
 #include <request.h>
+#include <savedstatuses.h>
 
 #include "gntaccount.h"
 #include "gntblist.h"
@@ -67,7 +68,7 @@ typedef struct
 	GntWidget *screenname;
 	GntWidget *password;
 	GntWidget *alias;
-	
+
 	GntWidget *splits;
 	GList *split_entries;
 
@@ -76,6 +77,7 @@ typedef struct
 
 	GntWidget *newmail;
 	GntWidget *remember;
+	GntWidget *regserver;
 } AccountEditDialog;
 
 /* This is necessary to close an edit-dialog when an account is deleted */
@@ -125,7 +127,7 @@ save_account_cb(AccountEditDialog *dialo
 				_("Username of an account must be non-empty."));
 		return;
 	}
-	
+
 	username = g_string_new(value);
 
 	if (prplinfo != NULL)
@@ -183,7 +185,7 @@ save_account_cb(AccountEditDialog *dialo
 	if (prplinfo)
 	{
 		GList *iter, *entries;
-		
+
 		for (iter = prplinfo->protocol_options, entries = dialog->prpl_entries;
 				iter && entries; iter = iter->next, entries = entries->next)
 		{
@@ -228,6 +230,20 @@ save_account_cb(AccountEditDialog *dialo
 		gnt_box_give_focus_to_child(GNT_BOX(accounts.window), accounts.tree);
 	}
 
+	if (prplinfo && prplinfo->register_user &&
+			gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->regserver))) {
+		purple_account_register(account);
+	} else if (dialog->account == NULL) {
+		/* This is a new account. Set it to the current status. */
+		/* Xerox from gtkaccount.c :D */
+		const PurpleSavedStatus *saved_status;
+		saved_status = purple_savedstatus_get_current();
+		if (saved_status != NULL) {
+			purple_savedstatus_activate_for_account(saved_status, account);
+			purple_account_set_enabled(account, FINCH_UI, TRUE);
+		}
+	}
+
 	gnt_widget_destroy(dialog->window);
 }
 
@@ -419,6 +435,11 @@ add_protocol_options(AccountEditDialog *
 			}
 		}
 	}
+
+	/* Show the registration checkbox only in a new account dialog,
+	 * and when the selected prpl has the support for it. */
+	gnt_widget_set_visible(dialog->regserver, account == NULL &&
+			prplinfo->register_user != NULL);
 }
 
 static void
@@ -559,6 +580,10 @@ edit_account(PurpleAccount *account)
 	gnt_box_add_widget(GNT_BOX(window), dialog->remember);
 	gnt_box_add_widget(GNT_BOX(window), dialog->newmail);
 
+	/* 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 */


More information about the Commits mailing list