Mercurial > ~mikael > mcabber > hg
diff mcabber/mcabber/screen.c @ 2013:8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
author | Hermitifier |
---|---|
date | Thu, 01 Mar 2012 15:10:41 +0100 |
parents | 2039ea6bd7a5 |
children | db8ec238cd2c |
line wrap: on
line diff
--- a/mcabber/mcabber/screen.c Thu Mar 01 14:46:49 2012 +0100 +++ b/mcabber/mcabber/screen.c Thu Mar 01 15:10:41 2012 +0100 @@ -1790,6 +1790,8 @@ unsigned short btype, isgrp, ismuc, isspe; const char *btypetext = "Unknown"; const char *fullname; + char *fullnameres = NULL; + const char *activeres; const char *msg = NULL; char status; char *buf, *buf_locale; @@ -1856,6 +1858,8 @@ status = '?'; + activeres = buddy_getactiveresource(BUDDATA(current_buddy)); + if (ismuc) { if (buddy_getinsideroom(BUDDATA(current_buddy))) status = 'C'; @@ -1863,24 +1867,30 @@ status = 'x'; } else if (xmpp_getstatus() != offline) { enum imstatus budstate; - budstate = buddy_getstatus(BUDDATA(current_buddy), NULL); + budstate = buddy_getstatus(BUDDATA(current_buddy), activeres); if (budstate < imstatus_size) status = imstatus2char[budstate]; } // No status message for MUC rooms if (!ismuc) { - GSList *resources, *p_res, *p_next_res; - resources = buddy_getresources(BUDDATA(current_buddy)); - - for (p_res = resources ; p_res ; p_res = p_next_res) { - p_next_res = g_slist_next(p_res); - // Store the status message of the latest resource (highest priority) - if (!p_next_res) - msg = buddy_getstatusmsg(BUDDATA(current_buddy), p_res->data); - g_free(p_res->data); + if (activeres) { + fullnameres = g_strdup_printf("%s/%s", fullname, activeres); + fullname = fullnameres; + msg = buddy_getstatusmsg(BUDDATA(current_buddy), activeres); + } else { + GSList *resources, *p_res, *p_next_res; + resources = buddy_getresources(BUDDATA(current_buddy)); + + for (p_res = resources ; p_res ; p_res = p_next_res) { + p_next_res = g_slist_next(p_res); + // Store the status message of the latest resource (highest priority) + if (!p_next_res) + msg = buddy_getstatusmsg(BUDDATA(current_buddy), p_res->data); + g_free(p_res->data); + } + g_slist_free(resources); } - g_slist_free(resources); } else { msg = buddy_gettopic(BUDDATA(current_buddy)); } @@ -1892,6 +1902,7 @@ replace_nl_with_dots(buf); buf_locale = from_utf8(buf); mvwprintw(chatstatusWnd, 0, 1, "%s", buf_locale); + g_free(fullnameres); g_free(buf_locale); g_free(buf); @@ -1900,9 +1911,9 @@ char eventchar = 0; guint event; - // We do not specify the resource here, so one of the resources with the - // highest priority will be used. - event = buddy_resource_getevents(BUDDATA(current_buddy), NULL); + // We specify active resource here, so when there is none then the resource + // with the highest priority will be used. + event = buddy_resource_getevents(BUDDATA(current_buddy), activeres); if (event == ROSTER_EVENT_ACTIVE) eventchar = 'A'; @@ -2703,7 +2714,12 @@ hbuf_free(&win_entry->bd->hbuf); if (*p_closebuf) { + GSList *roster_elt; retval = TRUE; + roster_elt = roster_find(key, jidsearch, + ROSTER_TYPE_USER|ROSTER_TYPE_AGENT); + if (roster_elt) + buddy_setactiveresource(roster_elt->data, NULL); } else { win_entry->bd->cleared = FALSE; win_entry->bd->top = NULL; @@ -2749,7 +2765,6 @@ roster_msg_setflag(cjid, FALSE, FALSE); g_free(p_closebuf); if (closebuf && !hold_chatmode) { - //buddy_setactiveresource(bud, resource); scr_set_chatmode(FALSE); currentWindow = NULL; }