# HG changeset patch # User Mark Doliner # Date 1110089666 0 # Node ID 61930cadca7cb770b10d9cc7f619db753c6e1372 # Parent 3f7508b1531f44d089c68648f45acff11772ff8b [gaim-migrate @ 12190] sf patch #1108846, from Richard Laager This patch allows one to create protocol plugin options which are masked. This is useful for storing passwords, etc. This patch implements functions similar to the masking functions for general plugin preferences. I'm submitting this for inclusion in Gaim because I've written a plugin which hides the NickServ or Q (for QuakeNet) authentication details from the user. It makes IRC feel more like the other protocols in Gaim. I'd like to have the passwords masked in the preferences to match other password fields in Gaim. This is the only change to Gaim I need for my plugin to work. committer: Tailor Script diff -r 3f7508b1531f -r 61930cadca7c src/accountopt.c --- a/src/accountopt.c Sun Mar 06 02:23:03 2005 +0000 +++ b/src/accountopt.c Sun Mar 06 06:14:26 2005 +0000 @@ -169,6 +169,16 @@ } void +gaim_account_option_set_masked(GaimAccountOption *option, gboolean masked) +{ + g_return_if_fail(option != NULL); + g_return_if_fail(option->type == GAIM_PREF_STRING); + + option->masked = masked; +} + + +void gaim_account_option_set_list(GaimAccountOption *option, GList *values) { g_return_if_fail(option != NULL); @@ -249,6 +259,15 @@ return option->default_value.string; } +gboolean +gaim_account_option_get_masked(const GaimAccountOption *option) +{ + g_return_val_if_fail(option != NULL, FALSE); + g_return_val_if_fail(option->type == GAIM_PREF_STRING, FALSE); + + return option->masked; +} + const GList * gaim_account_option_get_list(const GaimAccountOption *option) { diff -r 3f7508b1531f -r 61930cadca7c src/accountopt.h --- a/src/accountopt.h Sun Mar 06 02:23:03 2005 +0000 +++ b/src/accountopt.h Sun Mar 06 06:14:26 2005 +0000 @@ -49,6 +49,8 @@ } default_value; + gboolean masked; + } GaimAccountOption; /** @@ -179,6 +181,15 @@ const char *value); /** + * Sets the masking for an account option. + * + * @param option The account option. + * @param masked The masking. + */ +void +gaim_account_option_set_masked(GaimAccountOption *option, gboolean masked); + +/** * Sets the list values for an account option. * * The list passed will be owned by the account option, and the @@ -258,6 +269,16 @@ const GaimAccountOption *option); /** + * Returns the masking for an account option. + * + * @param option The account option. + * + * @return The masking. + */ +gboolean +gaim_account_option_get_masked(const GaimAccountOption *option); + +/** * Returns the list values for an account option. * * @param option The account option. diff -r 3f7508b1531f -r 61930cadca7c src/gtkaccount.c --- a/src/gtkaccount.c Sun Mar 06 02:23:03 2005 +0000 +++ b/src/gtkaccount.c Sun Mar 06 06:14:26 2005 +0000 @@ -1019,6 +1019,8 @@ } entry = gtk_entry_new(); + if (gaim_account_option_get_masked(option)) + gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); if (str_value != NULL) gtk_entry_set_text(GTK_ENTRY(entry), str_value);