Mercurial > pidgin.yaz
diff src/status.c @ 13373:1ca4a579eb57
[gaim-migrate @ 15746]
Parts of sf patch #1438833, from Sadrul Habib Chowdhury
"This patch enables removing message-text from a status.
Currently when you have some status with a message, and
you remove the message from the statusbox-entry, the
new status with no message is not used (reported in a
number of bugs, like #1431289, #1431801)."
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 02 Mar 2006 04:51:09 +0000 |
parents | 3e3d54d5be19 |
children | c358be635301 |
line wrap: on
line diff
--- a/src/status.c Thu Mar 02 02:12:43 2006 +0000 +++ b/src/status.c Thu Mar 02 04:51:09 2006 +0000 @@ -747,7 +747,9 @@ const GList *attrs) { gboolean changed = FALSE; - const gchar *id; + const GList *l; + GList *specified_attr_ids = NULL; + GaimStatusType *status_type; g_return_if_fail(status != NULL); @@ -767,26 +769,30 @@ status->active = active; /* Set any attributes */ - while (attrs) + l = attrs; + while (l != NULL) { + const gchar *id; GaimValue *value; - id = attrs->data; - attrs = attrs->next; + id = l->data; + l = l->next; value = gaim_status_get_attr_value(status, id); if (value == NULL) { gaim_debug_warning("status", "The attribute \"%s\" on the status \"%s\" is " "not supported.\n", id, status->type->name); /* Skip over the data and move on to the next attribute */ - attrs = attrs->next; + l = l->next; continue; } + specified_attr_ids = g_list_prepend(specified_attr_ids, (gpointer)id); + if (value->type == GAIM_TYPE_STRING) { - const gchar *string_data = attrs->data; - attrs = attrs->next; + const gchar *string_data = l->data; + l = l->next; if (((string_data == NULL) && (value->data.string_data == NULL)) || ((string_data != NULL) && (value->data.string_data != NULL) && !strcmp(string_data, value->data.string_data))) @@ -798,8 +804,8 @@ } else if (value->type == GAIM_TYPE_INT) { - int int_data = GPOINTER_TO_INT(attrs->data); - attrs = attrs->next; + int int_data = GPOINTER_TO_INT(l->data); + l = l->next; if (int_data == value->data.int_data) continue; gaim_status_set_attr_int(status, id, int_data); @@ -807,20 +813,48 @@ } else if (value->type == GAIM_TYPE_BOOLEAN) { - gboolean boolean_data = GPOINTER_TO_INT(attrs->data); - attrs = attrs->next; + gboolean boolean_data = GPOINTER_TO_INT(l->data); + l = l->next; if (boolean_data == value->data.boolean_data) continue; - gaim_status_set_attr_int(status, id, boolean_data); + gaim_status_set_attr_boolean(status, id, boolean_data); changed = TRUE; } else { /* We don't know what the data is--skip over it */ - attrs = attrs->next; + l = l->next; } } + /* Reset any unspecified attributes to their default value */ + status_type = gaim_status_get_type(status); + l = gaim_status_type_get_attrs(status_type); + while (l != NULL) + { + GaimStatusAttr *attr; + + attr = l->data; + if (!g_list_find_custom(specified_attr_ids, attr->id, (GCompareFunc)strcmp)) + { + GaimValue *default_value; + default_value = gaim_status_attr_get_value(attr); + if (default_value->type == GAIM_TYPE_STRING) + gaim_status_set_attr_string(status, attr->id, + gaim_value_get_string(default_value)); + else if (default_value->type == GAIM_TYPE_INT) + gaim_status_set_attr_int(status, attr->id, + gaim_value_get_int(default_value)); + else if (default_value->type == GAIM_TYPE_BOOLEAN) + gaim_status_set_attr_boolean(status, attr->id, + gaim_value_get_boolean(default_value)); + changed = TRUE; + } + + l = l->next; + } + g_list_free(specified_attr_ids); + if (!changed) return; status_has_changed(status); @@ -889,7 +923,6 @@ "this!\n", id, gaim_status_type_get_name(gaim_status_get_type(status))); return; - } g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_STRING);