Mercurial > pidgin.yaz
comparison src/status.c @ 10197:7369bf2bf593
[gaim-migrate @ 11314]
More status fixes. Oscar kind of works... you can set yourself away,
invisible and available, but you can't choose the message for away,
can't choose an available message, and invisible only seems to work
the first time.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 17 Nov 2004 01:32:06 +0000 |
parents | 760e690a5f30 |
children | f086269582b1 |
comparison
equal
deleted
inserted
replaced
10196:760e690a5f30 | 10197:7369bf2bf593 |
---|---|
267 | 267 |
268 status_type->primary_attr_id = (id == NULL ? NULL : g_strdup(id)); | 268 status_type->primary_attr_id = (id == NULL ? NULL : g_strdup(id)); |
269 } | 269 } |
270 | 270 |
271 void | 271 void |
272 gaim_status_type_add_attr(GaimStatusType *status_type, const char *id,\ | 272 gaim_status_type_add_attr(GaimStatusType *status_type, const char *id, |
273 const char *name, GaimValue *value) | 273 const char *name, GaimValue *value) |
274 { | 274 { |
275 GaimStatusAttr *attr; | 275 GaimStatusAttr *attr; |
276 | 276 |
277 g_return_if_fail(status_type != NULL); | 277 g_return_if_fail(status_type != NULL); |
513 GaimStatusAttr *attr = (GaimStatusAttr *)l->data; | 513 GaimStatusAttr *attr = (GaimStatusAttr *)l->data; |
514 GaimValue *value = gaim_status_attr_get_value_type(attr); | 514 GaimValue *value = gaim_status_attr_get_value_type(attr); |
515 GaimValue *new_value = gaim_value_dup(value); | 515 GaimValue *new_value = gaim_value_dup(value); |
516 | 516 |
517 g_hash_table_insert(status->attr_values, | 517 g_hash_table_insert(status->attr_values, |
518 g_strdup(gaim_status_attr_get_id(attr)), new_value); | 518 g_strdup(gaim_status_attr_get_id(attr)), |
519 new_value); | |
519 } | 520 } |
520 | 521 |
521 return status; | 522 return status; |
522 } | 523 } |
523 | 524 |
691 void | 692 void |
692 gaim_status_set_attr_boolean(GaimStatus *status, const char *id, | 693 gaim_status_set_attr_boolean(GaimStatus *status, const char *id, |
693 gboolean value) | 694 gboolean value) |
694 { | 695 { |
695 GaimStatusType *status_type; | 696 GaimStatusType *status_type; |
696 GaimStatusAttr *attr; | |
697 GaimValue *attr_value; | 697 GaimValue *attr_value; |
698 | 698 |
699 g_return_if_fail(status != NULL); | 699 g_return_if_fail(status != NULL); |
700 g_return_if_fail(id != NULL); | 700 g_return_if_fail(id != NULL); |
701 | 701 |
702 status_type = gaim_status_get_type(status); | 702 status_type = gaim_status_get_type(status); |
703 | 703 |
704 /* Make sure this attribute exists. */ | 704 /* Make sure this attribute exists and is the correct type. */ |
705 attr = gaim_status_type_get_attr(status_type, id); | 705 attr_value = gaim_status_get_attr_value(status, id); |
706 g_return_if_fail(attr != NULL); | 706 g_return_if_fail(attr_value != NULL); |
707 | |
708 attr_value = gaim_status_attr_get_value_type(attr); | |
709 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_BOOLEAN); | 707 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_BOOLEAN); |
710 | 708 |
711 gaim_value_set_boolean(attr_value, value); | 709 gaim_value_set_boolean(attr_value, value); |
712 } | 710 } |
713 | 711 |
714 void | 712 void |
715 gaim_status_set_attr_int(GaimStatus *status, const char *id, int value) | 713 gaim_status_set_attr_int(GaimStatus *status, const char *id, int value) |
716 { | 714 { |
717 GaimStatusType *status_type; | 715 GaimStatusType *status_type; |
718 GaimStatusAttr *attr; | |
719 GaimValue *attr_value; | 716 GaimValue *attr_value; |
720 | 717 |
721 g_return_if_fail(status != NULL); | 718 g_return_if_fail(status != NULL); |
722 g_return_if_fail(id != NULL); | 719 g_return_if_fail(id != NULL); |
723 | 720 |
724 status_type = gaim_status_get_type(status); | 721 status_type = gaim_status_get_type(status); |
725 | 722 |
726 /* Make sure this attribute exists. */ | 723 /* Make sure this attribute exists and is the correct type. */ |
727 attr = gaim_status_type_get_attr(status_type, id); | 724 attr_value = gaim_status_get_attr_value(status, id); |
728 g_return_if_fail(attr != NULL); | 725 g_return_if_fail(attr_value != NULL); |
729 | |
730 attr_value = gaim_status_attr_get_value_type(attr); | |
731 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_INT); | 726 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_INT); |
732 | 727 |
733 gaim_value_set_int(attr_value, value); | 728 gaim_value_set_int(attr_value, value); |
734 } | 729 } |
735 | 730 |
736 void | 731 void |
737 gaim_status_set_attr_string(GaimStatus *status, const char *id, | 732 gaim_status_set_attr_string(GaimStatus *status, const char *id, |
738 const char *value) | 733 const char *value) |
739 { | 734 { |
740 GaimStatusType *status_type; | 735 GaimStatusType *status_type; |
741 GaimStatusAttr *attr; | |
742 GaimValue *attr_value; | 736 GaimValue *attr_value; |
743 | 737 |
744 g_return_if_fail(status != NULL); | 738 g_return_if_fail(status != NULL); |
745 g_return_if_fail(id != NULL); | 739 g_return_if_fail(id != NULL); |
746 | 740 |
747 status_type = gaim_status_get_type(status); | 741 status_type = gaim_status_get_type(status); |
748 | 742 |
749 /* Make sure this attribute exists. */ | 743 /* Make sure this attribute exists and is the correct type. */ |
750 attr = gaim_status_type_get_attr(status_type, id); | |
751 g_return_if_fail(attr != NULL); | |
752 | |
753 attr_value = gaim_status_get_attr_value(status, id); | 744 attr_value = gaim_status_get_attr_value(status, id); |
745 g_return_if_fail(attr_value != NULL); | |
754 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_STRING); | 746 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_STRING); |
755 | 747 |
756 gaim_value_set_string(attr_value, value); | 748 gaim_value_set_string(attr_value, value); |
757 } | 749 } |
758 | 750 |
831 | 823 |
832 return (primitive != GAIM_STATUS_UNSET && | 824 return (primitive != GAIM_STATUS_UNSET && |
833 primitive != GAIM_STATUS_OFFLINE); | 825 primitive != GAIM_STATUS_OFFLINE); |
834 } | 826 } |
835 | 827 |
836 /* | |
837 * What's the difference between | |
838 * gaim_status_get_attr_value(GaimStatus *status, const char *id) | |
839 * gaim_status_attr_get_value_type(GaimStatusAttr *attr) | |
840 * and I think there was another similar one... | |
841 */ | |
842 GaimValue * | 828 GaimValue * |
843 gaim_status_get_attr_value(const GaimStatus *status, const char *id) | 829 gaim_status_get_attr_value(const GaimStatus *status, const char *id) |
844 { | 830 { |
845 GaimStatusType *status_type; | 831 GaimStatusType *status_type; |
846 GaimStatusAttr *attr; | 832 GaimStatusAttr *attr; |
866 g_return_val_if_fail(id != NULL, FALSE); | 852 g_return_val_if_fail(id != NULL, FALSE); |
867 | 853 |
868 if ((value = gaim_status_get_attr_value(status, id)) == NULL) | 854 if ((value = gaim_status_get_attr_value(status, id)) == NULL) |
869 return FALSE; | 855 return FALSE; |
870 | 856 |
871 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_STRING, FALSE); | 857 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_BOOLEAN, FALSE); |
872 | 858 |
873 return gaim_value_get_boolean(value); | 859 return gaim_value_get_boolean(value); |
874 } | 860 } |
875 | 861 |
876 int | 862 int |