comparison libpurple/protocols/jabber/buddy.c @ 24120:16734635febf

Start hiding blist.h internals in prpls.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 27 Sep 2008 06:33:42 +0000
parents 1de1494a13e5
children da46097b4722
comparison
equal deleted inserted replaced
24119:d1cfa8c11902 24120:16734635febf
1846 JabberStream *js; 1846 JabberStream *js;
1847 1847
1848 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 1848 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
1849 1849
1850 buddy = (PurpleBuddy *) node; 1850 buddy = (PurpleBuddy *) node;
1851 gc = purple_account_get_connection(buddy->account); 1851 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
1852 js = gc->proto_data; 1852 js = gc->proto_data;
1853 1853
1854 jabber_buddy_set_invisibility(js, buddy->name, TRUE); 1854 jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), TRUE);
1855 } 1855 }
1856 1856
1857 static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data) 1857 static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data)
1858 { 1858 {
1859 PurpleBuddy *buddy; 1859 PurpleBuddy *buddy;
1861 JabberStream *js; 1861 JabberStream *js;
1862 1862
1863 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 1863 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
1864 1864
1865 buddy = (PurpleBuddy *) node; 1865 buddy = (PurpleBuddy *) node;
1866 gc = purple_account_get_connection(buddy->account); 1866 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
1867 js = gc->proto_data; 1867 js = gc->proto_data;
1868 1868
1869 jabber_buddy_set_invisibility(js, buddy->name, FALSE); 1869 jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), FALSE);
1870 } 1870 }
1871 1871
1872 static void jabber_buddy_cancel_presence_notification(PurpleBlistNode *node, 1872 static void jabber_buddy_cancel_presence_notification(PurpleBlistNode *node,
1873 gpointer data) 1873 gpointer data)
1874 { 1874 {
1877 JabberStream *js; 1877 JabberStream *js;
1878 1878
1879 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 1879 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
1880 1880
1881 buddy = (PurpleBuddy *) node; 1881 buddy = (PurpleBuddy *) node;
1882 gc = purple_account_get_connection(buddy->account); 1882 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
1883 js = gc->proto_data; 1883 js = gc->proto_data;
1884 1884
1885 /* I wonder if we should prompt the user before doing this */ 1885 /* I wonder if we should prompt the user before doing this */
1886 jabber_presence_subscription_set(js, buddy->name, "unsubscribed"); 1886 jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "unsubscribed");
1887 } 1887 }
1888 1888
1889 static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data) 1889 static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data)
1890 { 1890 {
1891 PurpleBuddy *buddy; 1891 PurpleBuddy *buddy;
1893 JabberStream *js; 1893 JabberStream *js;
1894 1894
1895 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 1895 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
1896 1896
1897 buddy = (PurpleBuddy *) node; 1897 buddy = (PurpleBuddy *) node;
1898 gc = purple_account_get_connection(buddy->account); 1898 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
1899 js = gc->proto_data; 1899 js = gc->proto_data;
1900 1900
1901 jabber_presence_subscription_set(js, buddy->name, "subscribe"); 1901 jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "subscribe");
1902 } 1902 }
1903 1903
1904 1904
1905 static void jabber_buddy_unsubscribe(PurpleBlistNode *node, gpointer data) 1905 static void jabber_buddy_unsubscribe(PurpleBlistNode *node, gpointer data)
1906 { 1906 {
1909 JabberStream *js; 1909 JabberStream *js;
1910 1910
1911 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 1911 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
1912 1912
1913 buddy = (PurpleBuddy *) node; 1913 buddy = (PurpleBuddy *) node;
1914 gc = purple_account_get_connection(buddy->account); 1914 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
1915 js = gc->proto_data; 1915 js = gc->proto_data;
1916 1916
1917 jabber_presence_subscription_set(js, buddy->name, "unsubscribe"); 1917 jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "unsubscribe");
1918 } 1918 }
1919 1919
1920 static void jabber_buddy_login(PurpleBlistNode *node, gpointer data) { 1920 static void jabber_buddy_login(PurpleBlistNode *node, gpointer data) {
1921 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) { 1921 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
1922 /* simply create a directed presence of the current status */ 1922 /* simply create a directed presence of the current status */
1923 PurpleBuddy *buddy = (PurpleBuddy *) node; 1923 PurpleBuddy *buddy = (PurpleBuddy *) node;
1924 PurpleConnection *gc = purple_account_get_connection(buddy->account); 1924 PurpleAccount *account = purple_buddy_get_account(buddy);
1925 PurpleConnection *gc = purple_account_get_connection(account);
1925 JabberStream *js = gc->proto_data; 1926 JabberStream *js = gc->proto_data;
1926 PurpleAccount *account = purple_connection_get_account(gc);
1927 PurplePresence *gpresence = purple_account_get_presence(account); 1927 PurplePresence *gpresence = purple_account_get_presence(account);
1928 PurpleStatus *status = purple_presence_get_active_status(gpresence); 1928 PurpleStatus *status = purple_presence_get_active_status(gpresence);
1929 xmlnode *presence; 1929 xmlnode *presence;
1930 JabberBuddyState state; 1930 JabberBuddyState state;
1931 char *msg; 1931 char *msg;
1934 purple_status_to_jabber(status, &state, &msg, &priority); 1934 purple_status_to_jabber(status, &state, &msg, &priority);
1935 presence = jabber_presence_create_js(js, state, msg, priority); 1935 presence = jabber_presence_create_js(js, state, msg, priority);
1936 1936
1937 g_free(msg); 1937 g_free(msg);
1938 1938
1939 xmlnode_set_attrib(presence, "to", buddy->name); 1939 xmlnode_set_attrib(presence, "to", purple_buddy_get_name(buddy));
1940 1940
1941 jabber_send(js, presence); 1941 jabber_send(js, presence);
1942 xmlnode_free(presence); 1942 xmlnode_free(presence);
1943 } 1943 }
1944 } 1944 }
1945 1945
1946 static void jabber_buddy_logout(PurpleBlistNode *node, gpointer data) { 1946 static void jabber_buddy_logout(PurpleBlistNode *node, gpointer data) {
1947 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) { 1947 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
1948 /* simply create a directed unavailable presence */ 1948 /* simply create a directed unavailable presence */
1949 PurpleBuddy *buddy = (PurpleBuddy *) node; 1949 PurpleBuddy *buddy = (PurpleBuddy *) node;
1950 JabberStream *js = purple_account_get_connection(buddy->account)->proto_data; 1950 PurpleAccount *account = purple_buddy_get_account(buddy);
1951 JabberStream *js = purple_account_get_connection(account)->proto_data;
1951 xmlnode *presence; 1952 xmlnode *presence;
1952 1953
1953 presence = jabber_presence_create_js(js, JABBER_BUDDY_STATE_UNAVAILABLE, NULL, 0); 1954 presence = jabber_presence_create_js(js, JABBER_BUDDY_STATE_UNAVAILABLE, NULL, 0);
1954 1955
1955 xmlnode_set_attrib(presence, "to", buddy->name); 1956 xmlnode_set_attrib(presence, "to", purple_buddy_get_name(buddy));
1956 1957
1957 jabber_send(js, presence); 1958 jabber_send(js, presence);
1958 xmlnode_free(presence); 1959 xmlnode_free(presence);
1959 } 1960 }
1960 } 1961 }
1961 1962
1962 static GList *jabber_buddy_menu(PurpleBuddy *buddy) 1963 static GList *jabber_buddy_menu(PurpleBuddy *buddy)
1963 { 1964 {
1964 PurpleConnection *gc = purple_account_get_connection(buddy->account); 1965 const char *name = purple_buddy_get_name(buddy);
1966 PurpleAccount *account = purple_buddy_get_account(buddy);
1967 PurpleConnection *gc = purple_account_get_connection(account);
1965 JabberStream *js = gc->proto_data; 1968 JabberStream *js = gc->proto_data;
1966 JabberBuddy *jb = jabber_buddy_find(js, buddy->name, TRUE); 1969 JabberBuddy *jb = jabber_buddy_find(js, name, TRUE);
1967 GList *jbrs; 1970 GList *jbrs;
1968 1971
1969 GList *m = NULL; 1972 GList *m = NULL;
1970 PurpleMenuAction *act; 1973 PurpleMenuAction *act;
1971 1974
2016 * According to stpeter, there is no way to know if a jid on the roster is a gateway without sending a disco#info. 2019 * According to stpeter, there is no way to know if a jid on the roster is a gateway without sending a disco#info.
2017 * However, since the gateway might appear offline to us, we cannot get that information. Therefore, I just assume 2020 * However, since the gateway might appear offline to us, we cannot get that information. Therefore, I just assume
2018 * that gateways on the roster can be identified by having no '@' in their jid. This is a faily safe assumption, since 2021 * that gateways on the roster can be identified by having no '@' in their jid. This is a faily safe assumption, since
2019 * people don't tend to have a server or other service there. 2022 * people don't tend to have a server or other service there.
2020 */ 2023 */
2021 if (g_utf8_strchr(buddy->name, -1, '@') == NULL) { 2024 if (g_utf8_strchr(name, -1, '@') == NULL) {
2022 act = purple_menu_action_new(_("Log In"), 2025 act = purple_menu_action_new(_("Log In"),
2023 PURPLE_CALLBACK(jabber_buddy_login), 2026 PURPLE_CALLBACK(jabber_buddy_login),
2024 NULL, NULL); 2027 NULL, NULL);
2025 m = g_list_append(m, act); 2028 m = g_list_append(m, act);
2026 act = purple_menu_action_new(_("Log Out"), 2029 act = purple_menu_action_new(_("Log Out"),