Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/buddy.c @ 29449:73e4c14921e4
jabber: Move those functions to jutil.[ch]
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Mon, 15 Feb 2010 05:35:56 +0000 |
parents | f2949cd7db0a |
children | af4bb8ccc7f5 |
comparison
equal
deleted
inserted
replaced
29448:f2949cd7db0a | 29449:73e4c14921e4 |
---|---|
1906 } else { | 1906 } else { |
1907 return NULL; | 1907 return NULL; |
1908 } | 1908 } |
1909 } | 1909 } |
1910 | 1910 |
1911 static const struct { | |
1912 const char *status_id; /* link to core */ | |
1913 const char *show; /* The show child's cdata in a presence stanza */ | |
1914 const char *readable; /* readable representation */ | |
1915 JabberBuddyState state; | |
1916 } jabber_statuses[] = { | |
1917 { "offline", NULL, N_("Offline"), JABBER_BUDDY_STATE_UNAVAILABLE }, | |
1918 { "available", NULL, N_("Available"), JABBER_BUDDY_STATE_ONLINE}, | |
1919 { "freeforchat", "chat", N_("Chatty"), JABBER_BUDDY_STATE_CHAT }, | |
1920 { "away", "away", N_("Away"), JABBER_BUDDY_STATE_AWAY }, | |
1921 { "extended_away", "xa", N_("Extended Away"), JABBER_BUDDY_STATE_XA }, | |
1922 { "dnd", "dnd", N_("Do Not Disturb"), JABBER_BUDDY_STATE_DND }, | |
1923 { "error", NULL, N_("Error"), JABBER_BUDDY_STATE_ERROR } | |
1924 }; | |
1925 | |
1926 const char * | |
1927 jabber_buddy_state_get_name(const JabberBuddyState state) | |
1928 { | |
1929 int i; | |
1930 for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) | |
1931 if (jabber_statuses[i].state == state) | |
1932 return _(jabber_statuses[i].readable); | |
1933 | |
1934 return _("Unknown"); | |
1935 } | |
1936 | |
1937 JabberBuddyState | |
1938 jabber_buddy_status_id_get_state(const char *id) | |
1939 { | |
1940 int i; | |
1941 if (!id) | |
1942 return JABBER_BUDDY_STATE_UNKNOWN; | |
1943 | |
1944 for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) | |
1945 if (g_str_equal(id, jabber_statuses[i].status_id)) | |
1946 return jabber_statuses[i].state; | |
1947 | |
1948 return JABBER_BUDDY_STATE_UNKNOWN; | |
1949 } | |
1950 | |
1951 JabberBuddyState jabber_buddy_show_get_state(const char *id) | |
1952 { | |
1953 int i; | |
1954 | |
1955 g_return_val_if_fail(id != NULL, JABBER_BUDDY_STATE_UNKNOWN); | |
1956 | |
1957 for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) | |
1958 if (g_str_equal(id, jabber_statuses[i].show)) | |
1959 return jabber_statuses[i].state; | |
1960 | |
1961 purple_debug_warning("jabber", "Invalid value of presence <show/> " | |
1962 "attribute: %s\n", id); | |
1963 return JABBER_BUDDY_STATE_UNKNOWN; | |
1964 } | |
1965 | |
1966 const char * | |
1967 jabber_buddy_state_get_show(JabberBuddyState state) | |
1968 { | |
1969 int i; | |
1970 for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) | |
1971 if (state == jabber_statuses[i].state) | |
1972 return jabber_statuses[i].show; | |
1973 | |
1974 return NULL; | |
1975 } | |
1976 | |
1977 const char * | |
1978 jabber_buddy_state_get_status_id(JabberBuddyState state) | |
1979 { | |
1980 int i; | |
1981 for (i = 0; i < G_N_ELEMENTS(jabber_statuses); ++i) | |
1982 if (state == jabber_statuses[i].state) | |
1983 return jabber_statuses[i].status_id; | |
1984 | |
1985 return NULL; | |
1986 } | |
1987 | 1911 |
1988 static void user_search_result_add_buddy_cb(PurpleConnection *gc, GList *row, void *user_data) | 1912 static void user_search_result_add_buddy_cb(PurpleConnection *gc, GList *row, void *user_data) |
1989 { | 1913 { |
1990 /* XXX find out the jid */ | 1914 /* XXX find out the jid */ |
1991 purple_blist_request_add_buddy(purple_connection_get_account(gc), | 1915 purple_blist_request_add_buddy(purple_connection_get_account(gc), |