Mercurial > pidgin.yaz
comparison 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 |
comparison
equal
deleted
inserted
replaced
13372:fb178093e364 | 13373:1ca4a579eb57 |
---|---|
745 void | 745 void |
746 gaim_status_set_active_with_attrs_list(GaimStatus *status, gboolean active, | 746 gaim_status_set_active_with_attrs_list(GaimStatus *status, gboolean active, |
747 const GList *attrs) | 747 const GList *attrs) |
748 { | 748 { |
749 gboolean changed = FALSE; | 749 gboolean changed = FALSE; |
750 const gchar *id; | 750 const GList *l; |
751 GList *specified_attr_ids = NULL; | |
752 GaimStatusType *status_type; | |
751 | 753 |
752 g_return_if_fail(status != NULL); | 754 g_return_if_fail(status != NULL); |
753 | 755 |
754 if (!active && gaim_status_is_exclusive(status)) | 756 if (!active && gaim_status_is_exclusive(status)) |
755 { | 757 { |
765 } | 767 } |
766 | 768 |
767 status->active = active; | 769 status->active = active; |
768 | 770 |
769 /* Set any attributes */ | 771 /* Set any attributes */ |
770 while (attrs) | 772 l = attrs; |
771 { | 773 while (l != NULL) |
774 { | |
775 const gchar *id; | |
772 GaimValue *value; | 776 GaimValue *value; |
773 | 777 |
774 id = attrs->data; | 778 id = l->data; |
775 attrs = attrs->next; | 779 l = l->next; |
776 value = gaim_status_get_attr_value(status, id); | 780 value = gaim_status_get_attr_value(status, id); |
777 if (value == NULL) | 781 if (value == NULL) |
778 { | 782 { |
779 gaim_debug_warning("status", "The attribute \"%s\" on the status \"%s\" is " | 783 gaim_debug_warning("status", "The attribute \"%s\" on the status \"%s\" is " |
780 "not supported.\n", id, status->type->name); | 784 "not supported.\n", id, status->type->name); |
781 /* Skip over the data and move on to the next attribute */ | 785 /* Skip over the data and move on to the next attribute */ |
782 attrs = attrs->next; | 786 l = l->next; |
783 continue; | 787 continue; |
784 } | 788 } |
785 | 789 |
790 specified_attr_ids = g_list_prepend(specified_attr_ids, (gpointer)id); | |
791 | |
786 if (value->type == GAIM_TYPE_STRING) | 792 if (value->type == GAIM_TYPE_STRING) |
787 { | 793 { |
788 const gchar *string_data = attrs->data; | 794 const gchar *string_data = l->data; |
789 attrs = attrs->next; | 795 l = l->next; |
790 if (((string_data == NULL) && (value->data.string_data == NULL)) || | 796 if (((string_data == NULL) && (value->data.string_data == NULL)) || |
791 ((string_data != NULL) && (value->data.string_data != NULL) && | 797 ((string_data != NULL) && (value->data.string_data != NULL) && |
792 !strcmp(string_data, value->data.string_data))) | 798 !strcmp(string_data, value->data.string_data))) |
793 { | 799 { |
794 continue; | 800 continue; |
796 gaim_status_set_attr_string(status, id, string_data); | 802 gaim_status_set_attr_string(status, id, string_data); |
797 changed = TRUE; | 803 changed = TRUE; |
798 } | 804 } |
799 else if (value->type == GAIM_TYPE_INT) | 805 else if (value->type == GAIM_TYPE_INT) |
800 { | 806 { |
801 int int_data = GPOINTER_TO_INT(attrs->data); | 807 int int_data = GPOINTER_TO_INT(l->data); |
802 attrs = attrs->next; | 808 l = l->next; |
803 if (int_data == value->data.int_data) | 809 if (int_data == value->data.int_data) |
804 continue; | 810 continue; |
805 gaim_status_set_attr_int(status, id, int_data); | 811 gaim_status_set_attr_int(status, id, int_data); |
806 changed = TRUE; | 812 changed = TRUE; |
807 } | 813 } |
808 else if (value->type == GAIM_TYPE_BOOLEAN) | 814 else if (value->type == GAIM_TYPE_BOOLEAN) |
809 { | 815 { |
810 gboolean boolean_data = GPOINTER_TO_INT(attrs->data); | 816 gboolean boolean_data = GPOINTER_TO_INT(l->data); |
811 attrs = attrs->next; | 817 l = l->next; |
812 if (boolean_data == value->data.boolean_data) | 818 if (boolean_data == value->data.boolean_data) |
813 continue; | 819 continue; |
814 gaim_status_set_attr_int(status, id, boolean_data); | 820 gaim_status_set_attr_boolean(status, id, boolean_data); |
815 changed = TRUE; | 821 changed = TRUE; |
816 } | 822 } |
817 else | 823 else |
818 { | 824 { |
819 /* We don't know what the data is--skip over it */ | 825 /* We don't know what the data is--skip over it */ |
820 attrs = attrs->next; | 826 l = l->next; |
821 } | 827 } |
822 } | 828 } |
829 | |
830 /* Reset any unspecified attributes to their default value */ | |
831 status_type = gaim_status_get_type(status); | |
832 l = gaim_status_type_get_attrs(status_type); | |
833 while (l != NULL) | |
834 { | |
835 GaimStatusAttr *attr; | |
836 | |
837 attr = l->data; | |
838 if (!g_list_find_custom(specified_attr_ids, attr->id, (GCompareFunc)strcmp)) | |
839 { | |
840 GaimValue *default_value; | |
841 default_value = gaim_status_attr_get_value(attr); | |
842 if (default_value->type == GAIM_TYPE_STRING) | |
843 gaim_status_set_attr_string(status, attr->id, | |
844 gaim_value_get_string(default_value)); | |
845 else if (default_value->type == GAIM_TYPE_INT) | |
846 gaim_status_set_attr_int(status, attr->id, | |
847 gaim_value_get_int(default_value)); | |
848 else if (default_value->type == GAIM_TYPE_BOOLEAN) | |
849 gaim_status_set_attr_boolean(status, attr->id, | |
850 gaim_value_get_boolean(default_value)); | |
851 changed = TRUE; | |
852 } | |
853 | |
854 l = l->next; | |
855 } | |
856 g_list_free(specified_attr_ids); | |
823 | 857 |
824 if (!changed) | 858 if (!changed) |
825 return; | 859 return; |
826 status_has_changed(status); | 860 status_has_changed(status); |
827 } | 861 } |
887 "Attempted to set status attribute '%s' for " | 921 "Attempted to set status attribute '%s' for " |
888 "status '%s', which is not legal. Fix " | 922 "status '%s', which is not legal. Fix " |
889 "this!\n", id, | 923 "this!\n", id, |
890 gaim_status_type_get_name(gaim_status_get_type(status))); | 924 gaim_status_type_get_name(gaim_status_get_type(status))); |
891 return; | 925 return; |
892 | |
893 } | 926 } |
894 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_STRING); | 927 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_STRING); |
895 | 928 |
896 gaim_value_set_string(attr_value, value); | 929 gaim_value_set_string(attr_value, value); |
897 } | 930 } |