changeset 18037:e3e42a99070e

jabber can contain @ symbols and / in the resource, so we have to look for the split characters from the beginning of the username I'm not particularly happy with the name 'reverse' for this, but I'm not feeling creative enough at the moment to come up with something better. If someone comes up with something better before 2.1.0, feel free to change it.
author Nathan Walp <nwalp@pidgin.im>
date Mon, 04 Jun 2007 04:37:07 +0000
parents ee9f7ee0be66
children 4cda1949878c
files finch/gntaccount.c libpurple/accountopt.c libpurple/accountopt.h libpurple/protocols/jabber/libxmpp.c pidgin/gtkaccount.c
diffstat 5 files changed, 49 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntaccount.c	Sun Jun 03 23:11:57 2007 +0000
+++ b/finch/gntaccount.c	Mon Jun 04 04:37:07 2007 +0000
@@ -280,7 +280,11 @@
 
 		if (dialog->account)
 		{
-			s = strrchr(username, purple_account_user_split_get_separator(split));
+			if(purple_account_user_split_get_reverse(split))
+				s = strrchr(username, purple_account_user_split_get_separator(split));
+			else
+				s = strchr(username, purple_account_user_split_get_separator(split));
+
 			if (s != NULL)
 			{
 				*s = '\0';
--- a/libpurple/accountopt.c	Sun Jun 03 23:11:57 2007 +0000
+++ b/libpurple/accountopt.c	Mon Jun 04 04:37:07 2007 +0000
@@ -308,6 +308,7 @@
 	split->text = g_strdup(text);
 	split->field_sep = sep;
 	split->default_value = g_strdup(default_value);
+	split->reverse = TRUE;
 
 	return split;
 }
@@ -345,3 +346,19 @@
 
 	return split->field_sep;
 }
+
+gboolean
+purple_account_user_split_get_reverse(const PurpleAccountUserSplit *split)
+{
+	g_return_val_if_fail(split != NULL, FALSE);
+
+	return split->reverse;
+}
+
+void
+purple_account_user_split_set_reverse(PurpleAccountUserSplit *split, gboolean reverse)
+{
+	g_return_if_fail(split != NULL);
+
+	split->reverse = reverse;
+}
--- a/libpurple/accountopt.h	Sun Jun 03 23:11:57 2007 +0000
+++ b/libpurple/accountopt.h	Mon Jun 04 04:37:07 2007 +0000
@@ -64,6 +64,9 @@
 	char *text;             /**< The text that will appear to the user. */
 	char *default_value;    /**< The default value.                     */
 	char  field_sep;        /**< The field separator.                   */
+	gboolean reverse;       /**< TRUE if the separator should be found
+							  starting a the end of the string, FALSE
+							  otherwise                                 */
 
 } PurpleAccountUserSplit;
 
@@ -353,6 +356,23 @@
  */
 char purple_account_user_split_get_separator(const PurpleAccountUserSplit *split);
 
+/**
+ * Returns the 'reverse' value for an account split.
+ *
+ * @param split The account username split.
+ *
+ * @return The 'reverse' value.
+ */
+gboolean purple_account_user_split_get_reverse(const PurpleAccountUserSplit *split);
+
+/**
+ * Sets the 'reverse' value for an account split.
+ *
+ * @param split   The account username split.
+ * @param reverse The 'reverse' value
+ */
+void purple_account_user_split_set_reverse(PurpleAccountUserSplit *split, gboolean reverse);
+
 /*@}*/
 
 #ifdef __cplusplus
--- a/libpurple/protocols/jabber/libxmpp.c	Sun Jun 03 23:11:57 2007 +0000
+++ b/libpurple/protocols/jabber/libxmpp.c	Mon Jun 04 04:37:07 2007 +0000
@@ -195,9 +195,11 @@
 
 	/* Translators: 'domain' is used here in the context of Internet domains, e.g. pidgin.im */
         split = purple_account_user_split_new(_("Domain"), NULL, '@');
+		purple_account_user_split_set_reverse(split, FALSE);
         prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
 
         split = purple_account_user_split_new(_("Resource"), "Home", '/');
+		purple_account_user_split_set_reverse(split, FALSE);
         prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
 
         option = purple_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE);
--- a/pidgin/gtkaccount.c	Sun Jun 03 23:11:57 2007 +0000
+++ b/pidgin/gtkaccount.c	Mon Jun 04 04:37:07 2007 +0000
@@ -483,7 +483,11 @@
 		char *c;
 
 		if (dialog->account != NULL) {
-			c = strrchr(username,
+			if(purple_account_user_split_get_reverse(split))
+				c = strrchr(username,
+						purple_account_user_split_get_separator(split));
+			else
+				c = strchr(username,
 						purple_account_user_split_get_separator(split));
 
 			if (c != NULL) {