mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-24 12:26:22 +00:00
Improve MUC title behaviour for roster, statusbar, and titlebar
## Abstract Continuation of https://github.com/profanity-im/profanity/pull/1881 Give all MUC title commands a consistent command structure and appearance. - `/roster room use name|jid` and `/roster room show|hide server` are now `/roster room title bookmark|jid|localpart|name` - `/statusbar room room|jid` is now `/statusbar room title bookmark|jid|localpart|name` - `/statusbar show|hide jid` and `/statusbar show|hide name` are now `/titlebar room title bookmark|jid|localpart|name` Fix both bugs mentioned in https://github.com/profanity-im/profanity/pull/1881 ### src/ui/mucwin.c:mucwin_generate_title Called by each command to generate a properly formatted title. It checks for "name" first because "name" is the default preference for each command. The last if-statement sets the title to "localpart" for special cases when the title should be "localpart" instead of the user-defined preference. ## Testing ### Preparation Remove preferences that will interfere with testing. ``` sed -i "/roster.rooms.title=/d" profrc sed -i "/statusbar.room.title=/d" profrc sed -i "/titlebar.muc.title=/d" profrc sed -i "/roster.rooms.use.name=/d" profrc sed -i "/roster.rooms.server=/d" profrc sed -i "/statusbar.room=/d" profrc sed -i "/titlebar.muc.title.jid=/d" profrc sed -i "/titlebar.muc.title.name=/d" profrc sed -i "/roster.rooms.by=/d" profrc ``` ### Command Definitions | Test | Window | | :--- | :--- | | `/help roster` | - /roster room title bookmark\|jid\|localpart\|name<br>- room title bookmark\|jid\|localpart\|name : Display the bookmark name, JID, JID localpart, or room name as the roster title for MUCs.<br>- *No /roster show\|hide server*<br>- *No /roster room use jid\|name* | | `/help statusbar` | - /statusbar room title bookmark\|jid\|localpart\|name<br>- room title bookmark\|jid\|localpart\|name : Display the bookmark name, JID, JID localpart, or room name as the title for MUC tabs.<br>- *No /statusbar room jid\|room* | | `/help titlebar` | - /titlebar room title bookmark\|jid\|localpart\|name<br>- room title bookmark\|jid\|localpart\|name : Display the bookmark name, JID, JID localpart, or room name as the MUC window title.<br>- *No /titlebar show\|hide jid\|name* | ### Autocomplete | Test | Command line | | :--- | :--- | | `/roster room <TAB>` | Autocompletes `title` | | `/roster room title <TAB>` | Autocompletes `bookmark\|jid\|localpart\|name` | | `/statusbar room <TAB>` | Autocompletes `title` | | `/statusbar room title <TAB>` | Autocompletes `bookmark\|jid\|localpart\|name` | | `/titlebar room <TAB>` | Autocompletes `title` | | `/titlebar room title <TAB>` | Autocompletes `bookmark\|jid\|localpart\|name` | | `/roster room <TAB>` | Does not autocomplete `use`, `show`, or `hide` | | `/roster room use <TAB>` | Does not autocomplete `name` | | `/roster room show <TAB>` | Does not autocomplete `server` | | `/roster room hide <TAB>` | Does not autocomplete `server` | | `/statusbar room <TAB>` | Does not autocomplete `jid` or `room` | | `/titlebar show <TAB>` | Does not autocomplete `jid` or `name` | | `/titlebar hide <TAB>` | Does not autocomplete `jid` or `name` | ### Set Preferences | Test | Window | profrc | | :--- | :--- | :--- | | `/roster room title bookmark` | Roster MUCs will display 'bookmark' as their title. | roster.rooms.title=bookmark | | `/roster room title jid` | Roster MUCs will display 'jid' as their title. | roster.rooms.title=jid | | `/roster room title localpart` | Roster MUCs will display 'localpart' as their title. | roster.rooms.title=localpart | | `/roster room title name` | Roster MUCs will display 'name' as their title. | roster.rooms.title=name | | `/roster room title invalid` | Invalid usage, see '/help roster' for details. | | | `/statusbar room title bookmark` | Displaying 'bookmark' as the title for MUC tabs. | statusbar.room.title=bookmark | | `/statusbar room title jid` | Displaying 'jid' as the title for MUC tabs. | statusbar.room.title=jid | | `/statusbar room title localpart` | Displaying 'localpart' as the title for MUC tabs. | statusbar.room.title=localpart | | `/statusbar room title name` | Displaying 'name' as the title for MUC tabs. | statusbar.room.title=name | | `/statusbar room title invalid` | Invalid usage, see '/help statusbar' for details. | | | `/titlebar room title bookmark` | MUC windows will display 'bookmark' as the window title. | titlebar.muc.title=bookmark | | `/titlebar room title jid` | MUC windows will display 'jid' as the window title. | titlebar.muc.title=jid | | `/titlebar room title localpart` | MUC windows will display 'localpart' as the window title. | titlebar.muc.title=localpart | | `/titlebar room title name` | MUC windows will display 'name' as the window title. | titlebar.muc.title=name | | `/titlebar room title invalid` | Invalid usage, see '/help titlebar' for details. | | | `/roster room use jid` | Invalid usage, see '/help roster' for details. | | | `/roster room use name` | Invalid usage, see '/help roster' for details. | | | `/roster room show server` | Invalid usage, see '/help roster' for details. | | | `/roster room hide server` | Invalid usage, see '/help roster' for details. | | | `/statusbar room jid` | Invalid usage, see '/help statusbar' for details. | | | `/statusbar room room` | Invalid usage, see '/help statusbar' for details. | | | `/titlebar show jid` | Invalid usage, see '/help titlebar' for details. | | | `/titlebar hide jid` | Invalid usage, see '/help titlebar' for details. | | | `/titlebar show name` | Invalid usage, see '/help titlebar' for details. | | | `/titlebar hide name` | Invalid usage, see '/help titlebar' for details. | | ### Display Set Preferences | Test | Window | | :--- | :--- | | /prefs ui | - Roster rooms title (/roster) : name<br>- Room tab display (/statusbar) : name<br>- MUC window title (/titlebar) : name | ### Test MUC Window #### Test: without *name* preference, without *room name* field ``` /join muc@dmn.im /room config /field1 "" /form submit /quit ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/join muc@dmn.im` | muc<span/>@dmn.im | muc<span/>@dmn.im | muc<span/>@dmn.im | | `/room config` | | muc<span/>@dmn.im conf | muc<span/>@dmn.im config | | `/field2 edit` | | | muc<span/>@dmn.im config * | | `/msg tst` | tst | muc<span/>@dmn.im/tst | muc<span/>@dmn.im/tst | | `/roster room by service` | muc | | | #### Test: with *name* preference, without *room name* field ``` /roster room title name /statusbar room title name /titlebar room title name /save /quit ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/join muc@dmn.im` | muc<span/>@dmn.im | muc<span/>@dmn.im | muc<span/>@dmn.im | | `/room config` | | muc<span/>@dmn.im conf | muc<span/>@dmn.im config | | `/field2 edit` | | | muc<span/>@dmn.im config * | | `/msg tst` | tst | muc<span/>@dmn.im/tst | muc<span/>@dmn.im/tst | | `/roster room by service` | muc | | | #### Test: without *name* preference, with *room name* field ``` sed -i "/roster.rooms.title=/d" profrc sed -i "/statusbar.room.title=/d" profrc sed -i "/titlebar.muc.title=/d" profrc /join muc@dmn.im /room config /field1 "my_room" /form submit /quit ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/join muc@dmn.im` | my_room | my_room | my_room | | `/room config` | | my_room conf | my_room config | | `/field2 edit` | | | my_room config * | | `/msg tst` | tst | my_room/tst | my_room/tst | | `/roster room by service` | my_room | | | #### Test: with *name* preference, with *room name* field ``` /quit /roster room title name /statusbar room title name /titlebar room title name /save /quit ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/join muc@dmn.im` | my_room | my_room | my_room | | `/room config` | | my_room conf | my_room config | | `/field2 edit` | | | my_room config * | | `/msg tst` | tst | my_room/tst | my_room/tst | | `/roster room by service` | my_room | | | #### Test: with *localpart* preference ``` /quit /roster room title localpart /statusbar room title localpart /titlebar room title localpart /save /quit ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/join muc@dmn.im` | muc | muc | muc | | `/room config` | | muc conf | muc config | | `/field2 edit` | | | muc config * | | `/msg tst` | tst | muc/tst | muc/tst | | `/roster room by service` | muc | | | #### Test: with *bookmark* preference, without *bookmark name* ``` /quit /roster room title bookmark /statusbar room title bookmark /titlebar room title bookmark /save /quit /bookmark add muc@dmn.im ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/bookmark join muc@dmn.im` | muc<span/>@dmn.im | muc<span/>@dmn.im | muc<span/>@dmn.im | | `/room config` | | muc<span/>@dmn.im conf | muc<span/>@dmn.im config | | `/field2 edit` | | | muc<span/>@dmn.im config * | | `/msg tst` | tst | muc<span/>@dmn.im/tst | muc<span/>@dmn.im/tst | | `/roster room by service` | muc | | | #### Test: with *bookmark* preference, with *bookmark name* ``` /quit /bookmark remove muc@dmn.im /bookmark add muc@dmn.im name "my_bookmark" ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/bookmark join muc@dmn.im` | my_bookmark | my_bookmark | my_bookmark | | `/room config` | | my_bookmark conf | my_bookmark config | | `/field2 edit` | | | my_bookmark config * | | `/msg tst` | tst | my_bookmark/tst | my_bookmark/tst | | `/roster room by service` | my_bookmark | | | #### Test: with *jid* preference ``` /quit /roster room title jid /statusbar room title jid /titlebar room title jid /save /quit ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/join muc@dmn.im` | muc<span/>@dmn.im | muc<span/>@dmn.im | muc<span/>@dmn.im | | `/room config` | | muc<span/>@dmn.im conf | muc<span/>@dmn.im config | | `/field2 edit` | | | muc<span/>@dmn.im config * | | `/msg tst` | tst | muc<span/>@dmn.im/tst | muc<span/>@dmn.im/tst | | `/roster room by service` | muc | | | ### Test Contact Chat Window Title #### Test: without contact nick ``` /roster add tst@dmn.im ``` | Test | Titlebar | | :--- | :--- | | `/msg tst@dmn.im` | tst<span/>@dmn.im | #### Test: with contact nick ``` /roster add tst@dmn.im my_tst ``` | Test | Titlebar | | :--- | :--- | | `/msg my_tst` | my_tst <tst<span/>@ike.snikket.chat> | ### Test Preference Upgrade #### Test /roster | Test | profrc | | :--- | :--- | | `sed -i '/\[ui\]/a\roster.rooms.use.name=name' profrc` | Original key removed. | | `sed -i '/\[ui\]/a\roster.rooms.use.name=' profrc` | Original key removed. | | `sed -i '/\[ui\]/a\roster.rooms.server=' profrc` | Original key removed. | | `sed -i '/\[ui\]/a\roster.rooms.use.name=jid' profrc` | Original key removed.<br>roster.rooms.title=jid | | `sed -i '/\[ui\]/a\roster.rooms.use.name=jid' profrc`<br>`sed -i '/\[ui\]/a\roster.rooms.server=false' profrc` | Original keys removed.<br>roster.rooms.title=localpart | | `sed -i '/\[ui\]/a\roster.rooms.use.name=jid' profrc`<br>`sed -i '/\[ui\]/a\roster.rooms.server=true' profrc` | Original keys removed.<br>roster.rooms.title=jid | | `sed -i '/\[ui\]/a\roster.rooms.use.name=jid' profrc`<br>`sed -i '/\[ui\]/a\roster.rooms.server=' profrc` | Original keys removed.<br>roster.rooms.title=jid | | `sed -i '/\[ui\]/a\statusbar.room=' profrc` | Original key removed. | | `sed -i '/\[ui\]/a\statusbar.room=room' profrc` | Original key removed.<br>statusbar.room.title=localpart | | `sed -i '/\[ui\]/a\statusbar.room=jid' profrc` | Original key removed.<br>statusbar.room.title=jid | | `sed -i '/\[ui\]/a\titlebar.muc.title.jid=' profrc` | Original key removed. | | `sed -i '/\[ui\]/a\titlebar.muc.title.name=' profrc` | Original key removed. | | `sed -i '/\[ui\]/a\titlebar.muc.title.jid=true' profrc` | Original key removed. | | `sed -i '/\[ui\]/a\titlebar.muc.title.name=true' profrc` | Original key removed. | | `sed -i '/\[ui\]/a\titlebar.muc.title.jid=false' profrc` | Original key removed. | | `sed -i '/\[ui\]/a\titlebar.muc.title.name=false' profrc` | Original key removed. | | `sed -i '/\[ui\]/a\titlebar.muc.title.jid=true' profrc`<br>`sed -i '/\[ui\]/a\titlebar.muc.title.name=false' profrc` | Original key removed.<br>titlebar.muc.title=jid | | `sed -i '/\[ui\]/a\titlebar.muc.title.jid=false' profrc`<br>`sed -i '/\[ui\]/a\titlebar.muc.title.name=true' profrc` | Original keys removed. | | `sed -i '/\[ui\]/a\titlebar.muc.title.jid=true' profrc`<br>`sed -i '/\[ui\]/a\titlebar.muc.title.name=true' profrc` | Original keys removed. | ### Test Valgrind No memory leaks detected relating to these changes.
This commit is contained in:
@@ -1277,17 +1277,8 @@ cons_titlebar_setting(void)
|
||||
cons_show("Titlebar presence (/titlebar) : OFF");
|
||||
}
|
||||
|
||||
if (prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_NAME)) {
|
||||
cons_show("Titlebar show MUC name (/titlebar) : ON");
|
||||
} else {
|
||||
cons_show("Titlebar show MUC name (/titlebar) : OFF");
|
||||
}
|
||||
|
||||
if (prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_JID)) {
|
||||
cons_show("Titlebar show MUC JID (/titlebar) : ON");
|
||||
} else {
|
||||
cons_show("Titlebar show MUC JID (/titlebar) : OFF");
|
||||
}
|
||||
auto_gchar gchar* titlebar_muc_title = prefs_get_string(PREF_TITLEBAR_MUC_TITLE);
|
||||
cons_show("MUC window title (/titlebar) : %s", titlebar_muc_title);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1630,11 +1621,6 @@ cons_roster_setting(void)
|
||||
cons_show("Roster unread (/roster) : OFF");
|
||||
}
|
||||
|
||||
if (prefs_get_boolean(PREF_ROSTER_ROOMS))
|
||||
cons_show("Roster rooms (/roster) : show");
|
||||
else
|
||||
cons_show("Roster rooms (/roster) : hide");
|
||||
|
||||
auto_gchar gchar* priv = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
if (g_strcmp0(priv, "room") == 0) {
|
||||
cons_show("Roster private (/roster) : room");
|
||||
@@ -1650,8 +1636,8 @@ cons_roster_setting(void)
|
||||
auto_gchar gchar* rooms_by = prefs_get_string(PREF_ROSTER_ROOMS_BY);
|
||||
cons_show("Roster rooms by (/roster) : %s", rooms_by);
|
||||
|
||||
auto_gchar gchar* rooms_use = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME);
|
||||
cons_show("Roster rooms use (/roster) : %s", rooms_use);
|
||||
auto_gchar gchar* rooms_title = prefs_get_string(PREF_ROSTER_ROOMS_TITLE);
|
||||
cons_show("Roster rooms title (/roster) : %s", rooms_title);
|
||||
|
||||
auto_gchar gchar* rooms_order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER);
|
||||
cons_show("Roster rooms order (/roster) : %s", rooms_order);
|
||||
@@ -1949,8 +1935,8 @@ cons_statusbar_setting(void)
|
||||
auto_gchar gchar* pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT);
|
||||
cons_show("Chat tab display (/statusbar) : %s", pref_chat);
|
||||
|
||||
auto_gchar gchar* pref_room = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
cons_show("Room tab display (/statusbar) : %s", pref_room);
|
||||
auto_gchar gchar* pref_room_title = prefs_get_string(PREF_STATUSBAR_ROOM_TITLE);
|
||||
cons_show("Room tab display (/statusbar) : %s", pref_room_title);
|
||||
|
||||
auto_gchar gchar* pref_tabmode = prefs_get_string(PREF_STATUSBAR_TABMODE);
|
||||
cons_show("Tab mode (/statusbar) : %s", pref_tabmode);
|
||||
|
||||
@@ -988,3 +988,48 @@ _mucwin_set_last_message(ProfMucWin* mucwin, const char* const id, const char* c
|
||||
free(mucwin->last_msg_id);
|
||||
mucwin->last_msg_id = strdup(id);
|
||||
}
|
||||
|
||||
gchar*
|
||||
mucwin_generate_title(const gchar* const muc_jid, const preference_t pref)
|
||||
{
|
||||
auto_gchar gchar* pref_val = prefs_get_string(pref);
|
||||
if (g_strcmp0(pref_val, "name") == 0) {
|
||||
const ProfMucWin* mucwin = wins_get_muc(muc_jid);
|
||||
if (mucwin && mucwin->room_name) {
|
||||
return g_strdup(mucwin->room_name);
|
||||
}
|
||||
} else if (g_strcmp0(pref_val, "bookmark") == 0) {
|
||||
const Bookmark* bookmark = bookmark_get_by_jid(muc_jid);
|
||||
if (bookmark && bookmark->name) {
|
||||
return g_strdup(bookmark->name);
|
||||
}
|
||||
}
|
||||
|
||||
auto_gchar gchar* roster_room_by = prefs_get_string(PREF_ROSTER_ROOMS_BY);
|
||||
if (g_strcmp0(pref_val, "localpart") == 0 || (g_strcmp0(roster_room_by, "service") == 0 && pref == PREF_ROSTER_ROOMS_TITLE)) {
|
||||
auto_jid Jid* jid = jid_create(muc_jid);
|
||||
if (jid && jid->localpart) {
|
||||
return g_strdup(jid->localpart);
|
||||
}
|
||||
}
|
||||
|
||||
return g_strdup(muc_jid);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mucwin_set_room_name(const gchar* const muc_jid, const gchar* const new_room_name)
|
||||
{
|
||||
ProfMucWin* mucwin = wins_get_muc(muc_jid);
|
||||
if (!mucwin) {
|
||||
log_error("No window found with this JID: '%s'", muc_jid);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
free(mucwin->room_name);
|
||||
if (new_room_name) {
|
||||
mucwin->room_name = strdup(new_room_name);
|
||||
} else {
|
||||
mucwin->room_name = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -745,35 +745,8 @@ _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin)
|
||||
g_string_append_printf(msg, "(%d) ", mucwin->unread);
|
||||
}
|
||||
|
||||
auto_gchar gchar* use_as_name = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME);
|
||||
auto_gchar gchar* roombypref = prefs_get_string(PREF_ROSTER_ROOMS_BY);
|
||||
|
||||
if (g_strcmp0(roombypref, "service") == 0) {
|
||||
if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) {
|
||||
auto_jid Jid* jidp = jid_create(mucwin->roomjid);
|
||||
g_string_append(msg, jidp->localpart);
|
||||
} else {
|
||||
g_string_append(msg, mucwin->room_name);
|
||||
}
|
||||
} else {
|
||||
gboolean show_server = prefs_get_boolean(PREF_ROSTER_ROOMS_SERVER);
|
||||
|
||||
if (show_server) {
|
||||
if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) {
|
||||
g_string_append(msg, mucwin->roomjid);
|
||||
} else {
|
||||
g_string_append(msg, mucwin->room_name);
|
||||
}
|
||||
} else {
|
||||
auto_jid Jid* jidp = jid_create(mucwin->roomjid);
|
||||
|
||||
if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) {
|
||||
g_string_append(msg, jidp->localpart);
|
||||
} else {
|
||||
g_string_append(msg, mucwin->room_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto_gchar gchar* mucwin_title = mucwin_generate_title(mucwin->roomjid, PREF_ROSTER_ROOMS_TITLE);
|
||||
g_string_append(msg, mucwin_title);
|
||||
|
||||
if ((g_strcmp0(unreadpos, "after") == 0) && mucwin->unread > 0) {
|
||||
g_string_append_printf(msg, " (%d)", mucwin->unread);
|
||||
|
||||
@@ -650,43 +650,15 @@ _display_name(StatusBarTab* tab)
|
||||
fullname = strdup(tab->display_name);
|
||||
}
|
||||
} else if (tab->window_type == WIN_MUC) {
|
||||
auto_gchar gchar* pref = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
if (g_strcmp0("room", pref) == 0) {
|
||||
auto_jid Jid* jidp = jid_create(tab->identifier);
|
||||
char* room = strdup(jidp->localpart);
|
||||
fullname = room;
|
||||
} else {
|
||||
fullname = strdup(tab->identifier);
|
||||
}
|
||||
auto_gchar gchar* mucwin_title = mucwin_generate_title(tab->identifier, PREF_STATUSBAR_ROOM_TITLE);
|
||||
fullname = strdup(mucwin_title);
|
||||
} else if (tab->window_type == WIN_CONFIG) {
|
||||
auto_gchar gchar* pref = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
GString* display_str = g_string_new("");
|
||||
|
||||
if (g_strcmp0("room", pref) == 0) {
|
||||
auto_jid Jid* jidp = jid_create(tab->identifier);
|
||||
g_string_append(display_str, jidp->localpart);
|
||||
} else {
|
||||
g_string_append(display_str, tab->identifier);
|
||||
}
|
||||
|
||||
g_string_append(display_str, " conf");
|
||||
char* result = strdup(display_str->str);
|
||||
g_string_free(display_str, TRUE);
|
||||
fullname = result;
|
||||
auto_gchar gchar* mucwin_title = mucwin_generate_title(tab->identifier, PREF_STATUSBAR_ROOM_TITLE);
|
||||
fullname = g_strconcat(mucwin_title, " conf", NULL);
|
||||
} else if (tab->window_type == WIN_PRIVATE) {
|
||||
auto_gchar gchar* pref = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
if (g_strcmp0("room", pref) == 0) {
|
||||
GString* display_str = g_string_new("");
|
||||
auto_jid Jid* jidp = jid_create(tab->identifier);
|
||||
g_string_append(display_str, jidp->localpart);
|
||||
g_string_append(display_str, "/");
|
||||
g_string_append(display_str, jidp->resourcepart);
|
||||
char* result = strdup(display_str->str);
|
||||
g_string_free(display_str, TRUE);
|
||||
fullname = result;
|
||||
} else {
|
||||
fullname = strdup(tab->identifier);
|
||||
}
|
||||
auto_jid Jid* jid = jid_create(tab->identifier);
|
||||
auto_gchar gchar* mucwin_title = mucwin_generate_title(jid->barejid, PREF_STATUSBAR_ROOM_TITLE);
|
||||
fullname = g_strconcat(mucwin_title, "/", jid->resourcepart, NULL);
|
||||
} else {
|
||||
fullname = strdup("window");
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
|
||||
#include "config/tlscerts.h"
|
||||
#include "config/account.h"
|
||||
#include "config/preferences.h"
|
||||
#include "command/cmd_funcs.h"
|
||||
#include "ui/win_types.h"
|
||||
#include "xmpp/message.h"
|
||||
@@ -199,6 +200,8 @@ void mucwin_set_enctext(ProfMucWin* mucwin, const char* const enctext);
|
||||
void mucwin_unset_enctext(ProfMucWin* mucwin);
|
||||
void mucwin_set_message_char(ProfMucWin* mucwin, const char* const ch);
|
||||
void mucwin_unset_message_char(ProfMucWin* mucwin);
|
||||
gchar* mucwin_generate_title(const gchar* const muc_jid, const preference_t pref);
|
||||
gboolean mucwin_set_room_name(const gchar* const muc_jid, const gchar* const new_room_name);
|
||||
|
||||
// MUC private chat window
|
||||
void privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message);
|
||||
|
||||
@@ -310,64 +310,41 @@ win_get_title(ProfWin* window)
|
||||
}
|
||||
case WIN_CHAT:
|
||||
{
|
||||
ProfChatWin* chatwin = (ProfChatWin*)window;
|
||||
const ProfChatWin* chatwin = (ProfChatWin*)window;
|
||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||
|
||||
gboolean show_titlebar_jid = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_JID);
|
||||
gboolean show_titlebar_name = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_NAME);
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED || !show_titlebar_name) {
|
||||
return g_strdup(chatwin->barejid);
|
||||
}
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
const PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (!contact) {
|
||||
return g_strdup(chatwin->barejid);
|
||||
}
|
||||
const char* name = p_contact_name(contact);
|
||||
if (name == NULL) {
|
||||
if (!name) {
|
||||
return g_strdup(chatwin->barejid);
|
||||
}
|
||||
if (show_titlebar_jid) {
|
||||
return g_strdup_printf("%s <%s>", name, chatwin->barejid);
|
||||
}
|
||||
return g_strdup_printf("%s", name);
|
||||
return g_strconcat(name, " <", chatwin->barejid, ">", NULL);
|
||||
}
|
||||
case WIN_MUC:
|
||||
{
|
||||
ProfMucWin* mucwin = (ProfMucWin*)window;
|
||||
const ProfMucWin* mucwin = (ProfMucWin*)window;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
|
||||
gboolean show_titlebar_jid = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_JID);
|
||||
gboolean show_titlebar_name = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_NAME);
|
||||
|
||||
if (show_titlebar_name && mucwin->room_name) {
|
||||
if (show_titlebar_jid)
|
||||
return g_strdup_printf("%s %s", mucwin->room_name, mucwin->roomjid);
|
||||
else
|
||||
return g_strdup(mucwin->room_name);
|
||||
}
|
||||
if (show_titlebar_jid)
|
||||
return g_strdup(mucwin->roomjid);
|
||||
|
||||
return g_strdup("");
|
||||
return mucwin_generate_title(mucwin->roomjid, PREF_TITLEBAR_MUC_TITLE);
|
||||
}
|
||||
case WIN_CONFIG:
|
||||
{
|
||||
ProfConfWin* confwin = (ProfConfWin*)window;
|
||||
const ProfConfWin* confwin = (ProfConfWin*)window;
|
||||
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
|
||||
GString* title = g_string_new(confwin->roomjid);
|
||||
g_string_append(title, " config");
|
||||
auto_gchar gchar* mucwin_title = mucwin_generate_title(confwin->roomjid, PREF_TITLEBAR_MUC_TITLE);
|
||||
if (confwin->form->modified) {
|
||||
g_string_append(title, " *");
|
||||
return g_strconcat(mucwin_title, " config *", NULL);
|
||||
}
|
||||
return g_string_free(title, FALSE);
|
||||
return g_strconcat(mucwin_title, " config", NULL);
|
||||
}
|
||||
case WIN_PRIVATE:
|
||||
{
|
||||
ProfPrivateWin* privatewin = (ProfPrivateWin*)window;
|
||||
const ProfPrivateWin* privatewin = (ProfPrivateWin*)window;
|
||||
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
||||
return g_strdup(privatewin->fulljid);
|
||||
auto_jid Jid* jid = jid_create(privatewin->fulljid);
|
||||
auto_gchar gchar* mucwin_title = mucwin_generate_title(jid->barejid, PREF_TITLEBAR_MUC_TITLE);
|
||||
return g_strconcat(mucwin_title, "/", jid->resourcepart, NULL);
|
||||
}
|
||||
case WIN_XML:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user