Mercurial > pidgin
comparison libpurple/protocols/jabber/jutil.c @ 29055:73e4c14921e4
jabber: Move those functions to jutil.[ch]
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Mon, 15 Feb 2010 05:35:56 +0000 |
parents | b676cb5b4595 |
children | 29bafbfca469 |
comparison
equal
deleted
inserted
replaced
29054:f2949cd7db0a | 29055:73e4c14921e4 |
---|---|
649 g_str_equal(jid->resource, js->user->resource))); | 649 g_str_equal(jid->resource, js->user->resource))); |
650 jabber_id_free(jid); | 650 jabber_id_free(jid); |
651 return equal; | 651 return equal; |
652 } | 652 } |
653 | 653 |
654 static const struct { | |
655 const char *status_id; /* link to core */ | |
656 const char *show; /* The show child's cdata in a presence stanza */ | |
657 const char *readable; /* readable representation */ | |
658 JabberBuddyState state; | |
659 } jabber_statuses[] = { | |
660 { "offline", NULL, N_("Offline"), JABBER_BUDDY_STATE_UNAVAILABLE }, | |
661 { "available", NULL, N_("Available"), JABBER_BUDDY_STATE_ONLINE}, | |
662 { "freeforchat", "chat", N_("Chatty"), JABBER_BUDDY_STATE_CHAT }, | |
663 { "away", "away", N_("Away"), JABBER_BUDDY_STATE_AWAY }, | |
664 { "extended_away", "xa", N_("Extended Away"), JABBER_BUDDY_STATE_XA }, | |
665 { "dnd", "dnd", N_("Do Not Disturb"), JABBER_BUDDY_STATE_DND }, | |
666 { "error", NULL, N_("Error"), JABBER_BUDDY_STATE_ERROR } | |
667 }; | |
668 | |
669 const char * | |
670 jabber_buddy_state_get_name(const JabberBuddyState state) | |
671 { | |
672 int i; | |
673 for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) | |
674 if (jabber_statuses[i].state == state) | |
675 return _(jabber_statuses[i].readable); | |
676 | |
677 return _("Unknown"); | |
678 } | |
679 | |
680 JabberBuddyState | |
681 jabber_buddy_status_id_get_state(const char *id) | |
682 { | |
683 int i; | |
684 if (!id) | |
685 return JABBER_BUDDY_STATE_UNKNOWN; | |
686 | |
687 for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) | |
688 if (g_str_equal(id, jabber_statuses[i].status_id)) | |
689 return jabber_statuses[i].state; | |
690 | |
691 return JABBER_BUDDY_STATE_UNKNOWN; | |
692 } | |
693 | |
694 JabberBuddyState jabber_buddy_show_get_state(const char *id) | |
695 { | |
696 int i; | |
697 | |
698 g_return_val_if_fail(id != NULL, JABBER_BUDDY_STATE_UNKNOWN); | |
699 | |
700 for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) | |
701 if (g_str_equal(id, jabber_statuses[i].show)) | |
702 return jabber_statuses[i].state; | |
703 | |
704 purple_debug_warning("jabber", "Invalid value of presence <show/> " | |
705 "attribute: %s\n", id); | |
706 return JABBER_BUDDY_STATE_UNKNOWN; | |
707 } | |
708 | |
709 const char * | |
710 jabber_buddy_state_get_show(JabberBuddyState state) | |
711 { | |
712 int i; | |
713 for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) | |
714 if (state == jabber_statuses[i].state) | |
715 return jabber_statuses[i].show; | |
716 | |
717 return NULL; | |
718 } | |
719 | |
720 const char * | |
721 jabber_buddy_state_get_status_id(JabberBuddyState state) | |
722 { | |
723 int i; | |
724 for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) | |
725 if (state == jabber_statuses[i].state) | |
726 return jabber_statuses[i].status_id; | |
727 | |
728 return NULL; | |
729 } | |
730 | |
654 /* The same as purple_util_get_image_checksum, but guaranteed to remain SHA1 */ | 731 /* The same as purple_util_get_image_checksum, but guaranteed to remain SHA1 */ |
655 char * | 732 char * |
656 jabber_calculate_data_sha1sum(gconstpointer data, size_t len) | 733 jabber_calculate_data_sha1sum(gconstpointer data, size_t len) |
657 { | 734 { |
658 PurpleCipherContext *context; | 735 PurpleCipherContext *context; |