Mercurial > pidgin
comparison src/protocols/jabber/jabber.c @ 9954:a9fb4493ae22
[gaim-migrate @ 10851]
a combination of the hacking i've been doing on jabber, and the patch datallah just sent me
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 05 Sep 2004 17:10:39 +0000 |
parents | f8e395a054e2 |
children | 1cad29047886 |
comparison
equal
deleted
inserted
replaced
9953:d908907d9441 | 9954:a9fb4493ae22 |
---|---|
740 | 740 |
741 static void jabber_close(GaimConnection *gc) | 741 static void jabber_close(GaimConnection *gc) |
742 { | 742 { |
743 JabberStream *js = gc->proto_data; | 743 JabberStream *js = gc->proto_data; |
744 | 744 |
745 jabber_presence_send(gc, "unavailable", _("Logged out")); | 745 jabber_presence_send(gc, NULL); /* XXX: FIXME: EEK! */ |
746 jabber_send_raw(js, "</stream:stream>", -1); | 746 jabber_send_raw(js, "</stream:stream>", -1); |
747 | 747 |
748 if(js->gsc) { | 748 if(js->gsc) { |
749 gaim_ssl_close(js->gsc); | 749 gaim_ssl_close(js->gsc); |
750 } else if (js->fd > 0) { | 750 } else if (js->fd > 0) { |
774 g_free(js); | 774 g_free(js); |
775 } | 775 } |
776 | 776 |
777 void jabber_stream_set_state(JabberStream *js, JabberStreamState state) | 777 void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
778 { | 778 { |
779 GaimPresence *gpresence; | |
780 GaimStatus *status; | |
781 | |
779 js->state = state; | 782 js->state = state; |
780 switch(state) { | 783 switch(state) { |
781 case JABBER_STREAM_OFFLINE: | 784 case JABBER_STREAM_OFFLINE: |
782 break; | 785 break; |
783 case JABBER_STREAM_CONNECTING: | 786 case JABBER_STREAM_CONNECTING: |
805 jabber_stream_init(js); | 808 jabber_stream_init(js); |
806 break; | 809 break; |
807 case JABBER_STREAM_CONNECTED: | 810 case JABBER_STREAM_CONNECTED: |
808 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | 811 gaim_connection_set_state(js->gc, GAIM_CONNECTED); |
809 jabber_roster_request(js); | 812 jabber_roster_request(js); |
810 jabber_presence_send(js->gc, js->gc->away_state, js->gc->away); | 813 gpresence = gaim_account_get_presence(js->gc->account); |
814 status = gaim_presence_get_active_status(gpresence); | |
815 jabber_presence_send(js->gc, status); | |
811 jabber_disco_items_server(js); | 816 jabber_disco_items_server(js); |
812 serv_finish_login(js->gc); | 817 serv_finish_login(js->gc); |
813 break; | 818 break; |
814 } | 819 } |
815 } | 820 } |
830 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) | 835 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
831 { | 836 { |
832 return "jabber"; | 837 return "jabber"; |
833 } | 838 } |
834 | 839 |
835 static void jabber_list_emblems(GaimBuddy *b, char **se, char **sw, | 840 static void jabber_list_emblems(GaimBuddy *b, const char **se, const char **sw, |
836 char **nw, char **ne) | 841 const char **nw, const char **ne) |
837 { | 842 { |
838 JabberStream *js; | 843 JabberStream *js; |
839 JabberBuddy *jb; | 844 JabberBuddy *jb; |
840 | 845 |
841 if(!b->account->gc) | 846 if(!b->account->gc) |
851 !(jb->subscription & JABBER_SUB_TO))) | 856 !(jb->subscription & JABBER_SUB_TO))) |
852 *se = "notauthorized"; | 857 *se = "notauthorized"; |
853 else | 858 else |
854 *se = "offline"; | 859 *se = "offline"; |
855 } else { | 860 } else { |
856 switch (b->uc) { | 861 GaimStatusType *status_type = gaim_status_get_type(gaim_presence_get_active_status(gaim_buddy_get_presence(b))); |
857 case JABBER_STATE_AWAY: | 862 |
858 *se = "away"; | 863 if(gaim_status_type_get_primitive(status_type) > GAIM_STATUS_ONLINE) { |
859 break; | 864 *se = gaim_status_type_get_id(status_type); |
860 case JABBER_STATE_CHAT: | 865 if(!strcmp(*se, "xa")) |
861 *se = "chat"; | |
862 break; | |
863 case JABBER_STATE_XA: | |
864 *se = "extendedaway"; | 866 *se = "extendedaway"; |
865 break; | |
866 case JABBER_STATE_DND: | |
867 *se = "dnd"; | |
868 break; | |
869 case JABBER_STATE_ERROR: | |
870 *se = "error"; | |
871 break; | |
872 } | 867 } |
873 } | 868 } |
874 } | 869 } |
875 | 870 |
876 static char *jabber_status_text(GaimBuddy *b) | 871 static char *jabber_status_text(GaimBuddy *b) |
884 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | 879 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { |
885 ret = g_strdup(jb->error_msg); | 880 ret = g_strdup(jb->error_msg); |
886 } else { | 881 } else { |
887 char *stripped; | 882 char *stripped; |
888 | 883 |
889 stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)); | 884 if(!(stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { |
890 | 885 GaimStatus *status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); |
891 if(!stripped && b->uc & UC_UNAVAILABLE) | 886 |
892 stripped = g_strdup(jabber_get_state_string(b->uc)); | 887 if(!gaim_status_is_available(status)) |
888 stripped = g_strdup(gaim_status_get_name(status)); | |
889 } | |
893 | 890 |
894 if(stripped) { | 891 if(stripped) { |
895 ret = g_markup_escape_text(stripped, -1); | 892 ret = g_markup_escape_text(stripped, -1); |
896 g_free(stripped); | 893 g_free(stripped); |
897 } | 894 } |
935 g_free(stripped); | 932 g_free(stripped); |
936 } | 933 } |
937 | 934 |
938 g_string_append_printf(ret, "\n<b>%s:</b> %s%s%s", | 935 g_string_append_printf(ret, "\n<b>%s:</b> %s%s%s", |
939 _("Status"), | 936 _("Status"), |
940 jabber_get_state_string(jbr->state), | 937 jabber_buddy_state_get_name(jbr->state), |
941 text ? ": " : "", | 938 text ? ": " : "", |
942 text ? text : ""); | 939 text ? text : ""); |
943 if(text) | 940 if(text) |
944 g_free(text); | 941 g_free(text); |
945 } else if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | 942 } else if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { |
949 } | 946 } |
950 | 947 |
951 return g_string_free(ret, FALSE); | 948 return g_string_free(ret, FALSE); |
952 } | 949 } |
953 | 950 |
954 static GList *jabber_away_states(GaimConnection *gc) | 951 static GList *jabber_status_types(GaimAccount *account) |
955 { | 952 { |
956 JabberStream *js = gc->proto_data; | 953 GaimStatusType *type; |
957 GList *m = NULL; | 954 GList *types = NULL; |
958 | 955 |
959 m = g_list_append(m, _("Online")); | 956 type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE, "offline", _("Offline"), TRUE, FALSE, FALSE, "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); |
960 m = g_list_append(m, _("Chatty")); | 957 types = g_list_append(types, type); |
961 m = g_list_append(m, _("Away")); | 958 |
962 m = g_list_append(m, _("Extended Away")); | 959 type = gaim_status_type_new_with_attrs(GAIM_STATUS_ONLINE, "online", _("Online"), TRUE, TRUE, FALSE, "priority", _("Priority"), gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); |
963 m = g_list_append(m, _("Do Not Disturb")); | 960 types = g_list_append(types, type); |
961 | |
962 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, "chat", _("Chatty"), TRUE, TRUE, FALSE, "priority", _("Priority"), gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); | |
963 types = g_list_append(types, type); | |
964 | |
965 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, "away", _("Away"), TRUE, TRUE, FALSE, "priority", _("Priority"), gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); | |
966 types = g_list_append(types, type); | |
967 | |
968 type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, "xa", _("Extended Away"), TRUE, TRUE, FALSE, "priority", _("Priority"), gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); | |
969 types = g_list_append(types, type); | |
970 | |
971 type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, "dnd", _("Do Not Disturb"), TRUE, TRUE, FALSE, "priority", _("Priority"), gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); | |
972 types = g_list_append(types, type); | |
973 | |
974 /* | |
964 if(js->protocol_version == JABBER_PROTO_0_9) | 975 if(js->protocol_version == JABBER_PROTO_0_9) |
965 m = g_list_append(m, _("Invisible")); | 976 m = g_list_append(m, _("Invisible")); |
966 m = g_list_append(m, GAIM_AWAY_CUSTOM); | 977 */ |
967 | 978 |
968 return m; | 979 return types; |
969 } | 980 } |
970 | 981 |
971 static void | 982 static void |
972 jabber_password_change_result_cb(JabberStream *js, xmlnode *packet, | 983 jabber_password_change_result_cb(JabberStream *js, xmlnode *packet, |
973 gpointer data) | 984 gpointer data) |
1486 NO_BUDDY_ICONS, /* icon_spec */ | 1497 NO_BUDDY_ICONS, /* icon_spec */ |
1487 jabber_list_icon, /* list_icon */ | 1498 jabber_list_icon, /* list_icon */ |
1488 jabber_list_emblems, /* list_emblems */ | 1499 jabber_list_emblems, /* list_emblems */ |
1489 jabber_status_text, /* status_text */ | 1500 jabber_status_text, /* status_text */ |
1490 jabber_tooltip_text, /* tooltip_text */ | 1501 jabber_tooltip_text, /* tooltip_text */ |
1491 jabber_away_states, /* away_states */ | 1502 jabber_status_types, /* status_types */ |
1492 jabber_blist_node_menu, /* blist_node_menu */ | 1503 jabber_blist_node_menu, /* blist_node_menu */ |
1493 jabber_chat_info, /* chat_info */ | 1504 jabber_chat_info, /* chat_info */ |
1494 jabber_chat_info_defaults, /* chat_info_defaults */ | 1505 jabber_chat_info_defaults, /* chat_info_defaults */ |
1495 jabber_login, /* login */ | 1506 jabber_login, /* login */ |
1496 jabber_close, /* close */ | 1507 jabber_close, /* close */ |
1497 jabber_message_send_im, /* send_im */ | 1508 jabber_message_send_im, /* send_im */ |
1498 jabber_set_info, /* set_info */ | 1509 jabber_set_info, /* set_info */ |
1499 jabber_send_typing, /* send_typing */ | 1510 jabber_send_typing, /* send_typing */ |
1500 jabber_buddy_get_info, /* get_info */ | 1511 jabber_buddy_get_info, /* get_info */ |
1501 jabber_presence_send, /* set_away */ | 1512 NULL, /* set_away */ |
1502 jabber_idle_set, /* set_idle */ | 1513 jabber_idle_set, /* set_idle */ |
1503 NULL, /* change_passwd */ | 1514 NULL, /* change_passwd */ |
1504 jabber_roster_add_buddy, /* add_buddy */ | 1515 jabber_roster_add_buddy, /* add_buddy */ |
1505 NULL, /* add_buddies */ | 1516 NULL, /* add_buddies */ |
1506 jabber_roster_remove_buddy, /* remove_buddy */ | 1517 jabber_roster_remove_buddy, /* remove_buddy */ |