Mercurial > pidgin.yaz
comparison src/status.c @ 11249:b4b1be482b4e
[gaim-migrate @ 13418]
sf patch #1235519, from Sadrul Habib Chowdhury
This is a pretty big patch that makes Gaim correctly save and restore
the current status (away/available, away message, available message,
invisible, etc).
The GaimGtkStatusBoxWidget thing I think defaults to "Available"
every time its created, which overrides the setting that was saved
to the XML file. So that still needs to be fixed before this will
really work.
Anyway, mad props to Sadrul for putting up with my requests on this patch
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 13 Aug 2005 05:22:09 +0000 |
parents | 744c0708d11f |
children | bb0d7b719af2 |
comparison
equal
deleted
inserted
replaced
11248:a2eababc78a8 | 11249:b4b1be482b4e |
---|---|
67 { | 67 { |
68 GaimPresenceContext context; | 68 GaimPresenceContext context; |
69 | 69 |
70 gboolean idle; | 70 gboolean idle; |
71 time_t idle_time; | 71 time_t idle_time; |
72 time_t login_time; | 72 time_t login_time; |
73 | 73 |
74 unsigned int warning_level; | 74 unsigned int warning_level; |
75 | 75 |
76 GList *statuses; | 76 GList *statuses; |
77 GHashTable *status_table; | 77 GHashTable *status_table; |
545 | 545 |
546 return attr->name; | 546 return attr->name; |
547 } | 547 } |
548 | 548 |
549 GaimValue * | 549 GaimValue * |
550 gaim_status_attr_get_value_type(const GaimStatusAttr *attr) | 550 gaim_status_attr_get_value(const GaimStatusAttr *attr) |
551 { | 551 { |
552 g_return_val_if_fail(attr != NULL, NULL); | 552 g_return_val_if_fail(attr != NULL, NULL); |
553 | 553 |
554 return attr->value_type; | 554 return attr->value_type; |
555 } | 555 } |
578 (GDestroyNotify)gaim_value_destroy); | 578 (GDestroyNotify)gaim_value_destroy); |
579 | 579 |
580 for (l = gaim_status_type_get_attrs(status_type); l != NULL; l = l->next) | 580 for (l = gaim_status_type_get_attrs(status_type); l != NULL; l = l->next) |
581 { | 581 { |
582 GaimStatusAttr *attr = (GaimStatusAttr *)l->data; | 582 GaimStatusAttr *attr = (GaimStatusAttr *)l->data; |
583 GaimValue *value = gaim_status_attr_get_value_type(attr); | 583 GaimValue *value = gaim_status_attr_get_value(attr); |
584 GaimValue *new_value = gaim_value_dup(value); | 584 GaimValue *new_value = gaim_value_dup(value); |
585 | 585 |
586 g_hash_table_insert(status->attr_values, | 586 g_hash_table_insert(status->attr_values, |
587 g_strdup(gaim_status_attr_get_id(attr)), | 587 g_strdup(gaim_status_attr_get_id(attr)), |
588 new_value); | 588 new_value); |
745 gaim_status_set_active(GaimStatus *status, gboolean active) | 745 gaim_status_set_active(GaimStatus *status, gboolean active) |
746 { | 746 { |
747 gaim_status_set_active_with_attrs(status, active, NULL); | 747 gaim_status_set_active_with_attrs(status, active, NULL); |
748 } | 748 } |
749 | 749 |
750 /* | |
751 * This used to parse the va_list directly, but now it creates a GList | |
752 * and passes it to gaim_status_set_active_with_attrs_list(). That | |
753 * function was created because accounts.c needs to pass a GList of | |
754 * attributes to the status API. | |
755 */ | |
750 void | 756 void |
751 gaim_status_set_active_with_attrs(GaimStatus *status, gboolean active, va_list args) | 757 gaim_status_set_active_with_attrs(GaimStatus *status, gboolean active, va_list args) |
758 { | |
759 GList *attrs = NULL; | |
760 const gchar *id; | |
761 gpointer data; | |
762 | |
763 if (args != NULL) | |
764 { | |
765 while ((id = va_arg(args, const char *)) != NULL) | |
766 { | |
767 attrs = g_list_append(attrs, (char *)id); | |
768 data = va_arg(args, void *); | |
769 attrs = g_list_append(attrs, data); | |
770 } | |
771 } | |
772 gaim_status_set_active_with_attrs_list(status, active, attrs); | |
773 g_list_free(attrs); | |
774 } | |
775 | |
776 void | |
777 gaim_status_set_active_with_attrs_list(GaimStatus *status, gboolean active, | |
778 const GList *attrs) | |
752 { | 779 { |
753 gboolean changed = FALSE; | 780 gboolean changed = FALSE; |
754 const gchar *id; | 781 const gchar *id; |
755 | 782 |
756 g_return_if_fail(status != NULL); | 783 g_return_if_fail(status != NULL); |
769 } | 796 } |
770 | 797 |
771 status->active = active; | 798 status->active = active; |
772 | 799 |
773 /* Set any attributes */ | 800 /* Set any attributes */ |
774 if (args != NULL) | 801 while (attrs) |
775 while ((id = va_arg(args, const char *)) != NULL) | |
776 { | 802 { |
777 GaimValue *value; | 803 GaimValue *value; |
804 | |
805 id = attrs->data; | |
806 attrs = attrs->next; | |
778 value = gaim_status_get_attr_value(status, id); | 807 value = gaim_status_get_attr_value(status, id); |
779 if (value == NULL) | 808 if (value == NULL) |
780 { | 809 { |
781 gaim_debug_warning("status", "The attribute \"%s\" on the status \"%s\" is " | 810 gaim_debug_warning("status", "The attribute \"%s\" on the status \"%s\" is " |
782 "not supported.\n", id, status->type->name); | 811 "not supported.\n", id, status->type->name); |
783 /* Skip over the data and move on to the next attribute */ | 812 /* Skip over the data and move on to the next attribute */ |
784 va_arg(args, void *); | 813 attrs = attrs->next; |
785 continue; | 814 continue; |
786 } | 815 } |
787 | 816 |
788 if (value->type == GAIM_TYPE_STRING) | 817 if (value->type == GAIM_TYPE_STRING) |
789 { | 818 { |
790 const gchar *string_data = va_arg(args, const char *); | 819 const gchar *string_data = attrs->data; |
820 attrs = attrs->next; | |
791 if (((string_data == NULL) && (value->data.string_data == NULL)) || | 821 if (((string_data == NULL) && (value->data.string_data == NULL)) || |
792 ((string_data != NULL) && (value->data.string_data != NULL) && | 822 ((string_data != NULL) && (value->data.string_data != NULL) && |
793 !strcmp(string_data, value->data.string_data))) | 823 !strcmp(string_data, value->data.string_data))) |
794 { | 824 { |
795 continue; | 825 continue; |
797 gaim_status_set_attr_string(status, id, string_data); | 827 gaim_status_set_attr_string(status, id, string_data); |
798 changed = TRUE; | 828 changed = TRUE; |
799 } | 829 } |
800 else if (value->type == GAIM_TYPE_INT) | 830 else if (value->type == GAIM_TYPE_INT) |
801 { | 831 { |
802 int int_data = va_arg(args, int); | 832 int int_data = (int)attrs->data; |
833 attrs = attrs->next; | |
803 if (int_data == value->data.int_data) | 834 if (int_data == value->data.int_data) |
804 continue; | 835 continue; |
805 gaim_status_set_attr_int(status, id, int_data); | 836 gaim_status_set_attr_int(status, id, int_data); |
806 changed = TRUE; | 837 changed = TRUE; |
807 } | 838 } |
808 else if (value->type == GAIM_TYPE_BOOLEAN) | 839 else if (value->type == GAIM_TYPE_BOOLEAN) |
809 { | 840 { |
810 gboolean boolean_data = va_arg(args, gboolean); | 841 gboolean boolean_data = (gboolean)attrs->data; |
842 attrs = attrs->next; | |
811 if (boolean_data == value->data.boolean_data) | 843 if (boolean_data == value->data.boolean_data) |
812 continue; | 844 continue; |
813 gaim_status_set_attr_int(status, id, boolean_data); | 845 gaim_status_set_attr_int(status, id, boolean_data); |
814 changed = TRUE; | 846 changed = TRUE; |
815 } | 847 } |
816 else | 848 else |
817 { | 849 { |
818 /* We don't know what the data is--skip over it */ | 850 /* We don't know what the data is--skip over it */ |
819 va_arg(args, void *); | 851 attrs = attrs->next; |
820 } | 852 } |
821 } | 853 } |
822 | 854 |
823 if (!changed) | 855 if (!changed) |
824 return; | 856 return; |
825 | |
826 status_has_changed(status); | 857 status_has_changed(status); |
827 } | 858 } |
828 | 859 |
829 void | 860 void |
830 gaim_status_set_attr_boolean(GaimStatus *status, const char *id, | 861 gaim_status_set_attr_boolean(GaimStatus *status, const char *id, |