Mercurial > pidgin
comparison libpurple/protocols/myspace/myspace.c @ 17950:2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
instead of purple_notify_formatted().
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sun, 15 Jul 2007 23:46:12 +0000 |
parents | c23122e0af91 |
children | c0758f8dff33 |
comparison
equal
deleted
inserted
replaced
17949:81a1f0c60a8d | 17950:2bf10f37fa37 |
---|---|
1737 { | 1737 { |
1738 GHashTable *body; | 1738 GHashTable *body; |
1739 gchar *body_str; | 1739 gchar *body_str; |
1740 GString *notification; | 1740 GString *notification; |
1741 guint old_inbox_status; | 1741 guint old_inbox_status; |
1742 guint i; | 1742 guint i, n; |
1743 const gchar *froms[5], *tos[5], *urls[5], *subjects[5]; | |
1743 | 1744 |
1744 /* Three parallel arrays for each new inbox message type. */ | 1745 /* Three parallel arrays for each new inbox message type. */ |
1745 static const gchar *inbox_keys[] = | 1746 static const gchar *inbox_keys[] = |
1746 { | 1747 { |
1747 "Mail", | 1748 "Mail", |
1790 | 1791 |
1791 notification = g_string_new(""); | 1792 notification = g_string_new(""); |
1792 | 1793 |
1793 old_inbox_status = session->inbox_status; | 1794 old_inbox_status = session->inbox_status; |
1794 | 1795 |
1796 n = 0; | |
1797 | |
1795 for (i = 0; i < sizeof(inbox_keys) / sizeof(inbox_keys[0]); ++i) | 1798 for (i = 0; i < sizeof(inbox_keys) / sizeof(inbox_keys[0]); ++i) |
1796 { | 1799 { |
1797 const gchar *key; | 1800 const gchar *key; |
1798 guint bit; | 1801 guint bit; |
1799 | 1802 |
1804 { | 1807 { |
1805 /* Notify only on when _changes_ from no mail -> has mail | 1808 /* Notify only on when _changes_ from no mail -> has mail |
1806 * (edge triggered) */ | 1809 * (edge triggered) */ |
1807 if (!(session->inbox_status & bit)) | 1810 if (!(session->inbox_status & bit)) |
1808 { | 1811 { |
1809 gchar *str; | 1812 purple_debug_info("msim", "msim_check_inbox_cb: got %s, at %d\n", |
1810 | 1813 key, n); |
1811 str = g_strdup_printf( | 1814 |
1812 "<p><a href=\"%s\">%s</a><br>\n", | 1815 subjects[n] = inbox_text[i]; |
1813 inbox_urls[i], inbox_text[i]); | 1816 froms[n] = _("MySpace"); |
1814 | 1817 tos[n] = session->username; |
1815 g_string_append(notification, str); | 1818 /* TODO: append token, web challenge, so automatically logs in. |
1816 | 1819 * Would also need to free strings because they won't be static |
1817 g_free(str); | 1820 */ |
1821 urls[n] = inbox_urls[i]; | |
1822 | |
1823 ++n; | |
1818 } else { | 1824 } else { |
1819 purple_debug_info("msim", | 1825 purple_debug_info("msim", |
1820 "msim_check_inbox_cb: already notified of %s\n", | 1826 "msim_check_inbox_cb: already notified of %s\n", |
1821 key); | 1827 key); |
1822 /* TODO: some kind of non-intrusitive notification? */ | |
1823 } | 1828 } |
1824 | 1829 |
1825 session->inbox_status |= bit; | 1830 session->inbox_status |= bit; |
1826 } | 1831 } |
1827 } | 1832 } |
1828 | 1833 |
1829 if (notification->len) | 1834 if (n) |
1830 { | 1835 { |
1831 purple_debug_info("msim", | 1836 purple_debug_info("msim", |
1832 "msim_check_inbox_cb: notifying %s\n", notification->str); | 1837 "msim_check_inbox_cb: notifying of %d\n", n); |
1833 | 1838 |
1834 purple_notify_formatted(session->account, | 1839 /* TODO: free strings with callback _if_ change to dynamic (w/ token) */ |
1835 _("New Inbox Messages"), _("New Inbox Messages"), NULL, | 1840 purple_notify_emails(session->account, |
1836 notification->str, | 1841 n, TRUE, subjects, froms, tos, urls, NULL, NULL); |
1837 NULL, NULL); | |
1838 | 1842 |
1839 } | 1843 } |
1840 | 1844 |
1841 g_hash_table_destroy(body); | 1845 g_hash_table_destroy(body); |
1842 } | 1846 } |