Mercurial > pidgin.yaz
comparison libpurple/protocols/gg/gg.c @ 23241:636a116113d1
Extract converting a PurpleStatus to GG's format to its own function.
A modified version of part of a patch by Adam "OnO" Strzelecki;
references #5693.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Thu, 29 May 2008 12:15:41 +0000 |
parents | 7981a140d81a |
children | 8522f594157c |
comparison
equal
deleted
inserted
replaced
23240:7981a140d81a | 23241:636a116113d1 |
---|---|
1825 ggp_search_add(info->searches, seq, form); | 1825 ggp_search_add(info->searches, seq, form); |
1826 } | 1826 } |
1827 /* }}} */ | 1827 /* }}} */ |
1828 | 1828 |
1829 /* static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) {{{ */ | 1829 /* static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) {{{ */ |
1830 static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) | 1830 static int ggp_to_gg_status(PurpleStatus *status, char **msg) |
1831 { | 1831 { |
1832 PurpleConnection *gc; | 1832 const char *status_id = purple_status_get_id(status); |
1833 GGPInfo *info; | |
1834 const char *status_id, *msg; | |
1835 int new_status, new_status_descr; | 1833 int new_status, new_status_descr; |
1836 | 1834 const char *new_msg; |
1837 if (!purple_status_is_active(status)) | 1835 |
1838 return; | 1836 g_return_val_if_fail(msg == NULL, 0); |
1839 | 1837 |
1840 gc = purple_account_get_connection(account); | 1838 purple_debug_info("gg", "ggp_to_gg_status: Requested status = %s\n", |
1841 info = gc->proto_data; | |
1842 | |
1843 status_id = purple_status_get_id(status); | |
1844 | |
1845 purple_debug_info("gg", "ggp_set_status: Requested status = %s\n", | |
1846 status_id); | 1839 status_id); |
1847 | 1840 |
1848 if (strcmp(status_id, "available") == 0) { | 1841 if (strcmp(status_id, "available") == 0) { |
1849 new_status = GG_STATUS_AVAIL; | 1842 new_status = GG_STATUS_AVAIL; |
1850 new_status_descr = GG_STATUS_AVAIL_DESCR; | 1843 new_status_descr = GG_STATUS_AVAIL_DESCR; |
1859 new_status_descr = GG_STATUS_NOT_AVAIL_DESCR; | 1852 new_status_descr = GG_STATUS_NOT_AVAIL_DESCR; |
1860 } else { | 1853 } else { |
1861 new_status = GG_STATUS_AVAIL; | 1854 new_status = GG_STATUS_AVAIL; |
1862 new_status_descr = GG_STATUS_AVAIL_DESCR; | 1855 new_status_descr = GG_STATUS_AVAIL_DESCR; |
1863 purple_debug_info("gg", | 1856 purple_debug_info("gg", |
1864 "ggp_set_status: uknown status requested (status_id=%s)\n", | 1857 "ggp_set_status: unknown status requested (status_id=%s)\n", |
1865 status_id); | 1858 status_id); |
1866 } | 1859 } |
1867 | 1860 |
1868 msg = purple_status_get_attr_string(status, "message"); | 1861 new_msg = purple_status_get_attr_string(status, "message"); |
1869 | 1862 |
1870 if (msg == NULL) { | 1863 if(new_msg) { |
1864 char *tmp = purple_markup_strip_html(new_msg); | |
1865 *msg = charset_convert(tmp, "UTF-8", "CP1250"); | |
1866 g_free(tmp); | |
1867 | |
1868 return new_status_descr; | |
1869 } else { | |
1870 *msg = NULL; | |
1871 return new_status; | |
1872 } | |
1873 } | |
1874 /* }}} */ | |
1875 | |
1876 /* static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) {{{ */ | |
1877 static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) | |
1878 { | |
1879 PurpleConnection *gc; | |
1880 GGPInfo *info; | |
1881 int new_status; | |
1882 char *new_msg = NULL; | |
1883 | |
1884 if (!purple_status_is_active(status)) | |
1885 return; | |
1886 | |
1887 gc = purple_account_get_connection(account); | |
1888 info = gc->proto_data; | |
1889 | |
1890 new_status = ggp_to_gg_status(status, &new_msg); | |
1891 | |
1892 if (new_msg == NULL) { | |
1871 gg_change_status(info->session, new_status); | 1893 gg_change_status(info->session, new_status); |
1872 } else { | 1894 } else { |
1873 gchar *tmp, *new_msg; | 1895 gg_change_status_descr(info->session, new_status, new_msg); |
1874 | |
1875 tmp = charset_convert(msg, "UTF-8", "CP1250"); | |
1876 new_msg = purple_markup_strip_html(tmp); | |
1877 g_free(tmp); | |
1878 | |
1879 gg_change_status_descr(info->session, new_status_descr, new_msg); | |
1880 g_free(new_msg); | 1896 g_free(new_msg); |
1881 } | 1897 } |
1882 | 1898 |
1883 ggp_status_fake_to_self(account); | 1899 ggp_status_fake_to_self(account); |
1884 | 1900 |