Mercurial > pidgin.yaz
changeset 16162:28b52d87392e
This lets you rename entire trees of prefs. This should help with the migration
this has received exactly zero testing, but since I know a couple people
wanted to work on prefs migration soon, I figured I'd commit it.
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Wed, 18 Apr 2007 22:56:12 +0000 |
parents | 2663150c0a9f |
children | 6baa6a71bad1 017405933589 |
files | libpurple/prefs.c |
diffstat | 1 files changed, 47 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/prefs.c Sun Apr 15 20:00:30 2007 +0000 +++ b/libpurple/prefs.c Wed Apr 18 22:56:12 2007 +0000 @@ -1090,30 +1090,30 @@ return ret; } -void -purple_prefs_rename(const char *oldname, const char *newname) +static void +purple_prefs_rename_node(struct purple_pref *oldpref, struct purple_pref *newpref) { - struct purple_pref *oldpref, *newpref; - - oldpref = find_pref(oldname); - - /* it's already been renamed, call off the dogs */ - if(!oldpref) - return; + struct purple_pref *child; + char *oldname, *newname; - if (oldpref->first_child != NULL) /* can't rename parents */ + /* if we're a parent, rename the kids first */ + for(child = oldpref->first_child; child != NULL; child = child->sibling) { - purple_debug_error("prefs", "Unable to rename %s to %s: can't rename parents\n", oldname, newname); - return; - } - - - newpref = find_pref(newname); - - if (newpref == NULL) - { - purple_debug_error("prefs", "Unable to rename %s to %s: new pref not created\n", oldname, newname); - return; + struct purple_pref *newchild; + for(newchild = newpref->first_child; newchild != NULL; newchild = newchild->sibling) + { + if(!strcmp(child->name, newchild->name)) + { + purple_prefs_rename_node(child, newchild); + break; + } + } + if(newchild == NULL) { + /* no rename happened, we weren't able to find the new pref */ + char *tmpname = pref_full_name(child); + gaim_debug_error("prefs", "Unable to find rename pref for %s", tmpname); + g_free(tmpname); + } } if (oldpref->type != newpref->type) @@ -1122,7 +1122,11 @@ return; } + oldname = pref_full_name(oldpref); + newname = pref_full_name(newpref); purple_debug_info("prefs", "Renaming %s to %s\n", oldname, newname); + g_free(oldname); + g_free(newname); switch(oldpref->type) { case PURPLE_PREF_NONE: @@ -1151,6 +1155,28 @@ } void +purple_prefs_rename(const char *oldname, const char *newname) +{ + struct purple_pref *oldpref, *newpref; + + oldpref = find_pref(oldname); + + /* it's already been renamed, call off the dogs */ + if(!oldpref) + return; + + newpref = find_pref(newname); + + if (newpref == NULL) + { + purple_debug_error("prefs", "Unable to rename %s to %s: new pref not created\n", oldname, newname); + return; + } + + purple_prefs_rename_node(oldpref, newpref); +} + +void purple_prefs_rename_boolean_toggle(const char *oldname, const char *newname) { struct purple_pref *oldpref, *newpref;