1788 void scr_update_chat_status(int forceupdate) |
1788 void scr_update_chat_status(int forceupdate) |
1789 { |
1789 { |
1790 unsigned short btype, isgrp, ismuc, isspe; |
1790 unsigned short btype, isgrp, ismuc, isspe; |
1791 const char *btypetext = "Unknown"; |
1791 const char *btypetext = "Unknown"; |
1792 const char *fullname; |
1792 const char *fullname; |
|
1793 char *fullnameres = NULL; |
|
1794 const char *activeres; |
1793 const char *msg = NULL; |
1795 const char *msg = NULL; |
1794 char status; |
1796 char status; |
1795 char *buf, *buf_locale; |
1797 char *buf, *buf_locale; |
1796 |
1798 |
1797 // Usually we need to update the bottom status line too, |
1799 // Usually we need to update the bottom status line too, |
1854 return; |
1856 return; |
1855 } |
1857 } |
1856 |
1858 |
1857 status = '?'; |
1859 status = '?'; |
1858 |
1860 |
|
1861 activeres = buddy_getactiveresource(BUDDATA(current_buddy)); |
|
1862 |
1859 if (ismuc) { |
1863 if (ismuc) { |
1860 if (buddy_getinsideroom(BUDDATA(current_buddy))) |
1864 if (buddy_getinsideroom(BUDDATA(current_buddy))) |
1861 status = 'C'; |
1865 status = 'C'; |
1862 else |
1866 else |
1863 status = 'x'; |
1867 status = 'x'; |
1864 } else if (xmpp_getstatus() != offline) { |
1868 } else if (xmpp_getstatus() != offline) { |
1865 enum imstatus budstate; |
1869 enum imstatus budstate; |
1866 budstate = buddy_getstatus(BUDDATA(current_buddy), NULL); |
1870 budstate = buddy_getstatus(BUDDATA(current_buddy), activeres); |
1867 if (budstate < imstatus_size) |
1871 if (budstate < imstatus_size) |
1868 status = imstatus2char[budstate]; |
1872 status = imstatus2char[budstate]; |
1869 } |
1873 } |
1870 |
1874 |
1871 // No status message for MUC rooms |
1875 // No status message for MUC rooms |
1872 if (!ismuc) { |
1876 if (!ismuc) { |
1873 GSList *resources, *p_res, *p_next_res; |
1877 if (activeres) { |
1874 resources = buddy_getresources(BUDDATA(current_buddy)); |
1878 fullnameres = g_strdup_printf("%s/%s", fullname, activeres); |
1875 |
1879 fullname = fullnameres; |
1876 for (p_res = resources ; p_res ; p_res = p_next_res) { |
1880 msg = buddy_getstatusmsg(BUDDATA(current_buddy), activeres); |
1877 p_next_res = g_slist_next(p_res); |
1881 } else { |
1878 // Store the status message of the latest resource (highest priority) |
1882 GSList *resources, *p_res, *p_next_res; |
1879 if (!p_next_res) |
1883 resources = buddy_getresources(BUDDATA(current_buddy)); |
1880 msg = buddy_getstatusmsg(BUDDATA(current_buddy), p_res->data); |
1884 |
1881 g_free(p_res->data); |
1885 for (p_res = resources ; p_res ; p_res = p_next_res) { |
1882 } |
1886 p_next_res = g_slist_next(p_res); |
1883 g_slist_free(resources); |
1887 // Store the status message of the latest resource (highest priority) |
|
1888 if (!p_next_res) |
|
1889 msg = buddy_getstatusmsg(BUDDATA(current_buddy), p_res->data); |
|
1890 g_free(p_res->data); |
|
1891 } |
|
1892 g_slist_free(resources); |
|
1893 } |
1884 } else { |
1894 } else { |
1885 msg = buddy_gettopic(BUDDATA(current_buddy)); |
1895 msg = buddy_gettopic(BUDDATA(current_buddy)); |
1886 } |
1896 } |
1887 |
1897 |
1888 if (msg) |
1898 if (msg) |
1890 else |
1900 else |
1891 buf = g_strdup_printf("[%c] %s: %s", status, btypetext, fullname); |
1901 buf = g_strdup_printf("[%c] %s: %s", status, btypetext, fullname); |
1892 replace_nl_with_dots(buf); |
1902 replace_nl_with_dots(buf); |
1893 buf_locale = from_utf8(buf); |
1903 buf_locale = from_utf8(buf); |
1894 mvwprintw(chatstatusWnd, 0, 1, "%s", buf_locale); |
1904 mvwprintw(chatstatusWnd, 0, 1, "%s", buf_locale); |
|
1905 g_free(fullnameres); |
1895 g_free(buf_locale); |
1906 g_free(buf_locale); |
1896 g_free(buf); |
1907 g_free(buf); |
1897 |
1908 |
1898 // Display chatstates of the contact, if available. |
1909 // Display chatstates of the contact, if available. |
1899 if (btype & ROSTER_TYPE_USER) { |
1910 if (btype & ROSTER_TYPE_USER) { |
1900 char eventchar = 0; |
1911 char eventchar = 0; |
1901 guint event; |
1912 guint event; |
1902 |
1913 |
1903 // We do not specify the resource here, so one of the resources with the |
1914 // We specify active resource here, so when there is none then the resource |
1904 // highest priority will be used. |
1915 // with the highest priority will be used. |
1905 event = buddy_resource_getevents(BUDDATA(current_buddy), NULL); |
1916 event = buddy_resource_getevents(BUDDATA(current_buddy), activeres); |
1906 |
1917 |
1907 if (event == ROSTER_EVENT_ACTIVE) |
1918 if (event == ROSTER_EVENT_ACTIVE) |
1908 eventchar = 'A'; |
1919 eventchar = 'A'; |
1909 else if (event == ROSTER_EVENT_COMPOSING) |
1920 else if (event == ROSTER_EVENT_COMPOSING) |
1910 eventchar = 'C'; |
1921 eventchar = 'C'; |
2701 |
2712 |
2702 // Delete the current hbuf |
2713 // Delete the current hbuf |
2703 hbuf_free(&win_entry->bd->hbuf); |
2714 hbuf_free(&win_entry->bd->hbuf); |
2704 |
2715 |
2705 if (*p_closebuf) { |
2716 if (*p_closebuf) { |
|
2717 GSList *roster_elt; |
2706 retval = TRUE; |
2718 retval = TRUE; |
|
2719 roster_elt = roster_find(key, jidsearch, |
|
2720 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT); |
|
2721 if (roster_elt) |
|
2722 buddy_setactiveresource(roster_elt->data, NULL); |
2707 } else { |
2723 } else { |
2708 win_entry->bd->cleared = FALSE; |
2724 win_entry->bd->cleared = FALSE; |
2709 win_entry->bd->top = NULL; |
2725 win_entry->bd->top = NULL; |
2710 } |
2726 } |
2711 return retval; |
2727 return retval; |
2747 if(buffer_purge((gpointer)cjid, win_entry, p_closebuf)) |
2763 if(buffer_purge((gpointer)cjid, win_entry, p_closebuf)) |
2748 g_hash_table_remove(winbufhash, cjid); |
2764 g_hash_table_remove(winbufhash, cjid); |
2749 roster_msg_setflag(cjid, FALSE, FALSE); |
2765 roster_msg_setflag(cjid, FALSE, FALSE); |
2750 g_free(p_closebuf); |
2766 g_free(p_closebuf); |
2751 if (closebuf && !hold_chatmode) { |
2767 if (closebuf && !hold_chatmode) { |
2752 //buddy_setactiveresource(bud, resource); |
|
2753 scr_set_chatmode(FALSE); |
2768 scr_set_chatmode(FALSE); |
2754 currentWindow = NULL; |
2769 currentWindow = NULL; |
2755 } |
2770 } |
2756 } else { |
2771 } else { |
2757 // (Special buffer) |
2772 // (Special buffer) |