Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/xmpp.c @ 1693:32c6d81bd1ef
Update status when unexpectedly disconnected from server
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 06 Feb 2010 19:01:06 +0100 |
parents | b2e0083891cc |
children | 44e023ad99ed |
comparison
equal
deleted
inserted
replaced
1692:434b2a32d2a0 | 1693:32c6d81bd1ef |
---|---|
934 // Update display | 934 // Update display |
935 update_roster = TRUE; | 935 update_roster = TRUE; |
936 scr_UpdateBuddyWindow(); | 936 scr_UpdateBuddyWindow(); |
937 | 937 |
938 scr_LogPrint(LPRINT_NORMAL, "Disconnected, reason:%d->'%s'\n", reason, str); | 938 scr_LogPrint(LPRINT_NORMAL, "Disconnected, reason:%d->'%s'\n", reason, str); |
939 xmpp_setstatus(offline, NULL, mystatusmsg, TRUE); | |
939 } | 940 } |
940 | 941 |
941 static void handle_state_events(const char *from, LmMessageNode *node) | 942 static void handle_state_events(const char *from, LmMessageNode *node) |
942 { | 943 { |
943 #if defined XEP0022 || defined XEP0085 | 944 #if defined XEP0022 || defined XEP0085 |
1807 | 1808 |
1808 void xmpp_setstatus(enum imstatus st, const char *recipient, const char *msg, | 1809 void xmpp_setstatus(enum imstatus st, const char *recipient, const char *msg, |
1809 int do_not_sign) | 1810 int do_not_sign) |
1810 { | 1811 { |
1811 LmMessage *m; | 1812 LmMessage *m; |
1813 gboolean isonline; | |
1812 | 1814 |
1813 if (msg) { | 1815 if (msg) { |
1814 // The status message has been specified. We'll use it, unless it is | 1816 // The status message has been specified. We'll use it, unless it is |
1815 // "-" which is a special case (option meaning "no status message"). | 1817 // "-" which is a special case (option meaning "no status message"). |
1816 if (!strcmp(msg, "-")) | 1818 if (!strcmp(msg, "-")) |
1827 else | 1829 else |
1828 msg = ""; | 1830 msg = ""; |
1829 } | 1831 } |
1830 } | 1832 } |
1831 | 1833 |
1834 isonline = xmpp_is_online(); | |
1835 | |
1832 // Only send the packet if we're online. | 1836 // Only send the packet if we're online. |
1833 // (But we want to update internal status even when disconnected, | 1837 // (But we want to update internal status even when disconnected, |
1834 // in order to avoid some problems during network failures) | 1838 // in order to avoid some problems during network failures) |
1835 if (xmpp_is_online()) { | 1839 if (isonline) { |
1836 const char *s_msg = (st != invisible ? msg : NULL); | 1840 const char *s_msg = (st != invisible ? msg : NULL); |
1837 m = lm_message_new_presence(st, recipient, s_msg); | 1841 m = lm_message_new_presence(st, recipient, s_msg); |
1838 insert_entity_capabilities(m->node, st); // Entity Capabilities (XEP-0115) | 1842 insert_entity_capabilities(m->node, st); // Entity Capabilities (XEP-0115) |
1839 #ifdef HAVE_GPGME | 1843 #ifdef HAVE_GPGME |
1840 if (!do_not_sign && gpg_enabled()) { | 1844 if (!do_not_sign && gpg_enabled()) { |
1853 } | 1857 } |
1854 | 1858 |
1855 // If we didn't change our _global_ status, we are done | 1859 // If we didn't change our _global_ status, we are done |
1856 if (recipient) return; | 1860 if (recipient) return; |
1857 | 1861 |
1858 if (xmpp_is_online()) { | 1862 if (isonline) { |
1859 // Send presence to chatrooms | 1863 // Send presence to chatrooms |
1860 if (st != invisible) { | 1864 if (st != invisible) { |
1861 struct T_presence room_presence; | 1865 struct T_presence room_presence; |
1862 room_presence.st = st; | 1866 room_presence.st = st; |
1863 room_presence.msg = msg; | 1867 room_presence.msg = msg; |
1864 foreach_buddy(ROSTER_TYPE_ROOM, &roompresence, &room_presence); | 1868 foreach_buddy(ROSTER_TYPE_ROOM, &roompresence, &room_presence); |
1865 } | 1869 } |
1866 | 1870 } |
1871 | |
1872 if (isonline || !st) { | |
1867 // We'll have to update the roster if we switch to/from offline because | 1873 // We'll have to update the roster if we switch to/from offline because |
1868 // we don't know the presences of buddies when offline... | 1874 // we don't know the presences of buddies when offline... |
1869 if (mystatus == offline || st == offline) | 1875 if (mystatus == offline || st == offline) |
1870 update_roster = TRUE; | 1876 update_roster = TRUE; |
1871 | 1877 |