comparison src/status.c @ 10359:242b5482910e

[gaim-migrate @ 11577] leak & compile warning fixes, and death-to-extra-typing-notification-pixels from Gary. I noticed we were installing core header files twice, so now we don't. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Mon, 13 Dec 2004 14:58:33 +0000
parents 64bc206c7473
children 28135f8c226d
comparison
equal deleted inserted replaced
10358:524674a4f6bb 10359:242b5482910e
1803 static GaimStatusSavedSub * 1803 static GaimStatusSavedSub *
1804 gaim_statuses_read_parse_substatus(xmlnode *substatus) 1804 gaim_statuses_read_parse_substatus(xmlnode *substatus)
1805 { 1805 {
1806 GaimStatusSavedSub *ret; 1806 GaimStatusSavedSub *ret;
1807 xmlnode *node; 1807 xmlnode *node;
1808 const char *tmp; 1808 char *data = NULL;
1809 1809
1810 ret = g_new0(GaimStatusSavedSub, 1); 1810 ret = g_new0(GaimStatusSavedSub, 1);
1811 1811
1812 /* Read the account */ 1812 /* Read the account */
1813 node = xmlnode_get_child(substatus, "account"); 1813 node = xmlnode_get_child(substatus, "account");
1814 if (node != NULL) 1814 if (node != NULL)
1815 { 1815 {
1816 const char *acct_name; 1816 char *acct_name;
1817 const char *protocol; 1817 const char *protocol;
1818 acct_name = xmlnode_get_data(node); 1818 acct_name = xmlnode_get_data(node);
1819 protocol = xmlnode_get_attrib(node, "protocol"); 1819 protocol = xmlnode_get_attrib(node, "protocol");
1820 if ((acct_name != NULL) && (protocol != NULL)) 1820 if ((acct_name != NULL) && (protocol != NULL))
1821 ret->account = gaim_accounts_find(acct_name, protocol); 1821 ret->account = gaim_accounts_find(acct_name, protocol);
1822 g_free(acct_name);
1822 } 1823 }
1823 1824
1824 if (ret->account == NULL) 1825 if (ret->account == NULL)
1825 { 1826 {
1826 g_free(ret); 1827 g_free(ret);
1828 } 1829 }
1829 1830
1830 /* Read the state */ 1831 /* Read the state */
1831 node = xmlnode_get_child(substatus, "state"); 1832 node = xmlnode_get_child(substatus, "state");
1832 if (node != NULL) 1833 if (node != NULL)
1833 tmp = xmlnode_get_data(node); 1834 data = xmlnode_get_data(node);
1834 if (tmp != NULL) 1835 if (data != NULL) {
1835 ret->type = gaim_status_type_find_with_id(ret->account->status_types, 1836 ret->type = gaim_status_type_find_with_id(ret->account->status_types,
1836 tmp); 1837 data);
1838 g_free(data);
1839 data = NULL;
1840 }
1837 1841
1838 /* Read the message */ 1842 /* Read the message */
1839 node = xmlnode_get_child(substatus, "message"); 1843 node = xmlnode_get_child(substatus, "message");
1840 if (node != NULL) 1844 if (node != NULL)
1841 tmp = xmlnode_get_data(node); 1845 data = xmlnode_get_data(node);
1842 if (tmp != NULL) 1846 if (data != NULL)
1843 ret->message = g_strdup(tmp); 1847 ret->message = data;
1844 1848
1845 return ret; 1849 return ret;
1846 } 1850 }
1847 1851
1848 /** 1852 /**
1872 static GaimStatusSaved * 1876 static GaimStatusSaved *
1873 gaim_statuses_read_parse_status(xmlnode *status) 1877 gaim_statuses_read_parse_status(xmlnode *status)
1874 { 1878 {
1875 GaimStatusSaved *ret; 1879 GaimStatusSaved *ret;
1876 xmlnode *node; 1880 xmlnode *node;
1877 const char *tmp; 1881 const char *attrib;
1882 char *data = NULL;
1878 int i; 1883 int i;
1879 1884
1880 ret = g_new0(GaimStatusSaved, 1); 1885 ret = g_new0(GaimStatusSaved, 1);
1881 1886
1882 /* Read the title */ 1887 /* Read the title */
1883 tmp = xmlnode_get_attrib(status, "name"); 1888 attrib = xmlnode_get_attrib(status, "name");
1884 if (tmp == NULL) 1889 if (attrib == NULL)
1885 tmp = "No Title"; 1890 attrib = "No Title";
1886 /* Ensure the title is unique */ 1891 /* Ensure the title is unique */
1887 ret->title = g_strdup(tmp); 1892 ret->title = g_strdup(attrib);
1888 i = 2; 1893 i = 2;
1889 while (gaim_statuses_find_saved(ret->title) != NULL) 1894 while (gaim_statuses_find_saved(ret->title) != NULL)
1890 { 1895 {
1891 g_free(ret->title); 1896 g_free(ret->title);
1892 ret->title = g_strdup_printf("%s %d", tmp, i); 1897 ret->title = g_strdup_printf("%s %d", attrib, i);
1893 i++; 1898 i++;
1894 } 1899 }
1895 1900
1896 /* Read the primitive status type */ 1901 /* Read the primitive status type */
1897 node = xmlnode_get_child(status, "state"); 1902 node = xmlnode_get_child(status, "state");
1898 if (node != NULL) 1903 if (node != NULL)
1899 tmp = xmlnode_get_data(node); 1904 data = xmlnode_get_data(node);
1900 if (tmp != NULL) 1905 if (data != NULL) {
1901 ret->type = gaim_primitive_get_type(tmp); 1906 ret->type = gaim_primitive_get_type(data);
1907 g_free(data);
1908 data = NULL;
1909 }
1902 1910
1903 /* Read the message */ 1911 /* Read the message */
1904 node = xmlnode_get_child(status, "message"); 1912 node = xmlnode_get_child(status, "message");
1905 if (node != NULL) 1913 if (node != NULL)
1906 tmp = xmlnode_get_data(node); 1914 data = xmlnode_get_data(node);
1907 if (tmp != NULL) 1915 if (data != NULL)
1908 ret->message = g_strdup(tmp); 1916 ret->message = data;
1909 1917
1910 /* Read substatuses */ 1918 /* Read substatuses */
1911 for (node = xmlnode_get_child(status, "status"); node != NULL; 1919 for (node = xmlnode_get_child(status, "status"); node != NULL;
1912 node = xmlnode_get_next_twin(node)) 1920 node = xmlnode_get_next_twin(node))
1913 { 1921 {