1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05: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:
IsaacM88 2023-10-05 18:16:04 -06:00
parent 0de0594c5a
commit 23c6936398
17 changed files with 232 additions and 283 deletions

View File

@ -182,8 +182,7 @@ static Autocomplete roster_presence_ac;
static Autocomplete roster_char_ac;
static Autocomplete roster_remove_all_ac;
static Autocomplete roster_room_ac;
static Autocomplete roster_room_show_ac;
static Autocomplete roster_room_use_ac;
static Autocomplete roster_room_title_ac;
static Autocomplete roster_room_position_ac;
static Autocomplete roster_room_by_ac;
static Autocomplete roster_room_order_ac;
@ -241,6 +240,8 @@ static Autocomplete ox_log_ac;
#endif
static Autocomplete tls_ac;
static Autocomplete titlebar_ac;
static Autocomplete titlebar_room_ac;
static Autocomplete titlebar_room_title_ac;
static Autocomplete titlebar_show_ac;
static Autocomplete tls_certpath_ac;
static Autocomplete script_ac;
@ -262,6 +263,7 @@ static Autocomplete statusbar_ac;
static Autocomplete statusbar_self_ac;
static Autocomplete statusbar_chat_ac;
static Autocomplete statusbar_room_ac;
static Autocomplete statusbar_room_title_ac;
static Autocomplete statusbar_show_ac;
static Autocomplete statusbar_tabmode_ac;
static Autocomplete clear_ac;
@ -601,20 +603,17 @@ cmd_ac_init(void)
autocomplete_add(roster_room_ac, "order");
autocomplete_add(roster_room_ac, "unread");
autocomplete_add(roster_room_ac, "private");
autocomplete_add(roster_room_ac, "show");
autocomplete_add(roster_room_ac, "hide");
autocomplete_add(roster_room_ac, "use");
roster_room_show_ac = autocomplete_new();
autocomplete_add(roster_room_show_ac, "server");
autocomplete_add(roster_room_ac, "title");
roster_room_by_ac = autocomplete_new();
autocomplete_add(roster_room_by_ac, "service");
autocomplete_add(roster_room_by_ac, "none");
roster_room_use_ac = autocomplete_new();
autocomplete_add(roster_room_use_ac, "jid");
autocomplete_add(roster_room_use_ac, "name");
roster_room_title_ac = autocomplete_new();
autocomplete_add(roster_room_title_ac, "bookmark");
autocomplete_add(roster_room_title_ac, "jid");
autocomplete_add(roster_room_title_ac, "localpart");
autocomplete_add(roster_room_title_ac, "name");
roster_room_order_ac = autocomplete_new();
autocomplete_add(roster_room_order_ac, "name");
@ -941,14 +940,22 @@ cmd_ac_init(void)
autocomplete_add(titlebar_ac, "down");
autocomplete_add(titlebar_ac, "show");
autocomplete_add(titlebar_ac, "hide");
autocomplete_add(titlebar_ac, "room");
titlebar_room_ac = autocomplete_new();
autocomplete_add(titlebar_room_ac, "title");
titlebar_room_title_ac = autocomplete_new();
autocomplete_add(titlebar_room_title_ac, "bookmark");
autocomplete_add(titlebar_room_title_ac, "jid");
autocomplete_add(titlebar_room_title_ac, "localpart");
autocomplete_add(titlebar_room_title_ac, "name");
titlebar_show_ac = autocomplete_new();
autocomplete_add(titlebar_show_ac, "tls");
autocomplete_add(titlebar_show_ac, "encwarn");
autocomplete_add(titlebar_show_ac, "resource");
autocomplete_add(titlebar_show_ac, "presence");
autocomplete_add(titlebar_show_ac, "jid");
autocomplete_add(titlebar_show_ac, "name");
tls_certpath_ac = autocomplete_new();
autocomplete_add(tls_certpath_ac, "set");
@ -1046,8 +1053,13 @@ cmd_ac_init(void)
autocomplete_add(statusbar_chat_ac, "jid");
statusbar_room_ac = autocomplete_new();
autocomplete_add(statusbar_room_ac, "room");
autocomplete_add(statusbar_room_ac, "jid");
autocomplete_add(statusbar_room_ac, "title");
statusbar_room_title_ac = autocomplete_new();
autocomplete_add(statusbar_room_title_ac, "bookmark");
autocomplete_add(statusbar_room_title_ac, "jid");
autocomplete_add(statusbar_room_title_ac, "localpart");
autocomplete_add(statusbar_room_title_ac, "name");
statusbar_show_ac = autocomplete_new();
autocomplete_add(statusbar_show_ac, "name");
@ -1611,8 +1623,7 @@ cmd_ac_reset(ProfWin* window)
autocomplete_reset(roster_count_ac);
autocomplete_reset(roster_order_ac);
autocomplete_reset(roster_room_ac);
autocomplete_reset(roster_room_show_ac);
autocomplete_reset(roster_room_use_ac);
autocomplete_reset(roster_room_title_ac);
autocomplete_reset(roster_room_by_ac);
autocomplete_reset(roster_unread_ac);
autocomplete_reset(roster_room_position_ac);
@ -1672,6 +1683,8 @@ cmd_ac_reset(ProfWin* window)
#endif
autocomplete_reset(tls_ac);
autocomplete_reset(titlebar_ac);
autocomplete_reset(titlebar_room_ac);
autocomplete_reset(titlebar_room_title_ac);
autocomplete_reset(titlebar_show_ac);
autocomplete_reset(tls_certpath_ac);
autocomplete_reset(console_ac);
@ -1687,6 +1700,7 @@ cmd_ac_reset(ProfWin* window)
autocomplete_reset(statusbar_self_ac);
autocomplete_reset(statusbar_chat_ac);
autocomplete_reset(statusbar_room_ac);
autocomplete_reset(statusbar_room_title_ac);
autocomplete_reset(statusbar_show_ac);
autocomplete_reset(statusbar_tabmode_ac);
autocomplete_reset(clear_ac);
@ -1794,8 +1808,7 @@ cmd_ac_uninit(void)
autocomplete_free(roster_count_ac);
autocomplete_free(roster_order_ac);
autocomplete_free(roster_room_ac);
autocomplete_free(roster_room_show_ac);
autocomplete_free(roster_room_use_ac);
autocomplete_free(roster_room_title_ac);
autocomplete_free(roster_room_by_ac);
autocomplete_free(roster_unread_ac);
autocomplete_free(roster_room_position_ac);
@ -1853,6 +1866,8 @@ cmd_ac_uninit(void)
#endif
autocomplete_free(tls_ac);
autocomplete_free(titlebar_ac);
autocomplete_free(titlebar_room_ac);
autocomplete_free(titlebar_room_title_ac);
autocomplete_free(titlebar_show_ac);
autocomplete_free(tls_certpath_ac);
autocomplete_free(script_ac);
@ -1874,6 +1889,7 @@ cmd_ac_uninit(void)
autocomplete_free(statusbar_self_ac);
autocomplete_free(statusbar_chat_ac);
autocomplete_free(statusbar_room_ac);
autocomplete_free(statusbar_room_title_ac);
autocomplete_free(statusbar_show_ac);
autocomplete_free(statusbar_tabmode_ac);
autocomplete_free(clear_ac);
@ -2265,15 +2281,7 @@ _roster_autocomplete(ProfWin* window, const char* const input, gboolean previous
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster room show", roster_room_show_ac, TRUE, previous);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster room hide", roster_room_show_ac, TRUE, previous);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster room use", roster_room_use_ac, TRUE, previous);
result = autocomplete_param_with_ac(input, "/roster room title", roster_room_title_ac, TRUE, previous);
if (result) {
return result;
}
@ -3549,6 +3557,16 @@ _titlebar_autocomplete(ProfWin* window, const char* const input, gboolean previo
{
char* result = NULL;
result = autocomplete_param_with_ac(input, "/titlebar room title", titlebar_room_title_ac, TRUE, previous);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/titlebar room", titlebar_room_ac, TRUE, previous);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/titlebar show", titlebar_show_ac, TRUE, previous);
if (result) {
return result;
@ -4130,6 +4148,11 @@ _statusbar_autocomplete(ProfWin* window, const char* const input, gboolean previ
}
found = autocomplete_param_with_ac(input, "/statusbar room", statusbar_room_ac, TRUE, previous);
if (found) {
return found;
}
found = autocomplete_param_with_ac(input, "/statusbar room title", statusbar_room_title_ac, TRUE, previous);
return found;
}

View File

@ -275,9 +275,7 @@ static const struct cmd_t command_defs[] = {
"/roster room by service|none",
"/roster room order name|unread",
"/roster room unread before|after|off",
"/roster room show server",
"/roster room hide server",
"/roster room use name|jid",
"/roster room title bookmark|jid|localpart|name",
"/roster private room|group|off",
"/roster private char <char>|none",
"/roster header char <char>|none",
@ -349,10 +347,7 @@ static const struct cmd_t command_defs[] = {
{ "room unread before", "Show unread message count before room." },
{ "room unread after", "Show unread message count after room." },
{ "room unread off", "Do not show unread message count for rooms." },
{ "room show server", "Show the conference server with room JIDs." },
{ "room hide server", "Do not show the conference server with room JIDs." },
{ "room use name", "Use the MUC name as room name." },
{ "room use jid", "Use the JID as room name." },
{ "room title bookmark|jid|localpart|name", "Display the bookmark name, JID, JID localpart, or room name as the roster title for MUCs." },
{ "private room", "Show room private chats with the room." },
{ "private group", "Show room private chats as a separate roster group." },
{ "private off", "Do not show room private chats." },
@ -1241,7 +1236,7 @@ static const struct cmd_t command_defs[] = {
{ CMD_PREAMBLE("/titlebar",
parse_args, 1, 2, &cons_titlebar_setting)
parse_args, 1, 3, &cons_titlebar_setting)
CMD_SUBFUNCS(
{ "show", cmd_titlebar_show_hide },
{ "hide", cmd_titlebar_show_hide })
@ -1251,7 +1246,8 @@ static const struct cmd_t command_defs[] = {
CMD_SYN(
"/titlebar up",
"/titlebar down",
"/titlebar show|hide [encwarn|resource|tls]")
"/titlebar show|hide encwarn|resource|tls",
"/titlebar room title bookmark|jid|localpart|name")
CMD_DESC(
"Titlebar settings.")
CMD_ARGS(
@ -1260,12 +1256,12 @@ static const struct cmd_t command_defs[] = {
{ "show tls", "Show or hide TLS indicator in the titlebar." },
{ "show encwarn", "Enable or disable the unencrypted warning message in the titlebar." },
{ "show resource", "Show or hide the current resource in the titlebar." },
{ "show name", "Show the nickname or MUC name in the titlebar." },
{ "show jid", "Show the JID in the titlebar." })
{ "room title bookmark|jid|localpart|name", "Display the bookmark name, JID, JID localpart, or room name as the MUC window title." })
CMD_EXAMPLES(
"/titlebar up",
"/titlebar show tls",
"/titlebar hide encwarn")
"/titlebar hide encwarn",
"/titlebar room title localpart")
},
{ CMD_PREAMBLE("/mainwin",
@ -1284,7 +1280,7 @@ static const struct cmd_t command_defs[] = {
},
{ CMD_PREAMBLE("/statusbar",
parse_args, 1, 2, &cons_statusbar_setting)
parse_args, 1, 3, &cons_statusbar_setting)
CMD_MAINFUNC(cmd_statusbar)
CMD_TAGS(
CMD_TAG_UI)
@ -1296,7 +1292,7 @@ static const struct cmd_t command_defs[] = {
"/statusbar tabmode default|actlist",
"/statusbar self user|barejid|fulljid|off",
"/statusbar chat user|jid",
"/statusbar room room|jid",
"/statusbar room title bookmark|jid|localpart|name",
"/statusbar up",
"/statusbar down")
CMD_DESC(
@ -1311,7 +1307,7 @@ static const struct cmd_t command_defs[] = {
{ "self user|barejid|fulljid", "Show account user name, barejid, fulljid as status bar title." },
{ "self off", "Disable showing self as status bar title." },
{ "chat user|jid", "Show users name, or fulljid. Change needs a redraw/restart to take effect." },
{ "room room|jid", "Show room name, or the fulljid for room tabs." },
{ "room title bookmark|jid|localpart|name", "Display the bookmark name, JID, JID localpart, or room name as the title for MUC tabs." },
{ "up", "Move the status bar up the screen." },
{ "down", "Move the status bar down the screen." })
CMD_EXAMPLES(

View File

@ -2855,49 +2855,17 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
cons_bad_cmd_usage(command);
return TRUE;
}
} else if (g_strcmp0(args[1], "show") == 0) {
if (g_strcmp0(args[2], "server") == 0) {
cons_show("Roster room server enabled.");
prefs_set_boolean(PREF_ROSTER_ROOMS_SERVER, TRUE);
} else if (g_strcmp0(args[1], "title") == 0) {
if (g_strcmp0(args[2], "bookmark") == 0 || g_strcmp0(args[2], "jid") == 0 || g_strcmp0(args[2], "localpart") == 0 || g_strcmp0(args[2], "name") == 0) {
cons_show("Roster MUCs will display '%s' as their title.", args[2]);
prefs_set_string(PREF_ROSTER_ROOMS_TITLE, args[2]);
if (conn_status == JABBER_CONNECTED) {
rosterwin_roster();
}
return TRUE;
} else {
cons_bad_cmd_usage(command);
return TRUE;
}
} else if (g_strcmp0(args[1], "hide") == 0) {
if (g_strcmp0(args[2], "server") == 0) {
cons_show("Roster room server disabled.");
prefs_set_boolean(PREF_ROSTER_ROOMS_SERVER, FALSE);
if (conn_status == JABBER_CONNECTED) {
rosterwin_roster();
}
return TRUE;
} else {
cons_bad_cmd_usage(command);
return TRUE;
}
} else if (g_strcmp0(args[1], "use") == 0) {
if (g_strcmp0(args[2], "jid") == 0) {
cons_show("Roster room display jid as name.");
prefs_set_string(PREF_ROSTER_ROOMS_USE_AS_NAME, "jid");
if (conn_status == JABBER_CONNECTED) {
rosterwin_roster();
}
return TRUE;
} else if (g_strcmp0(args[2], "name") == 0) {
cons_show("Roster room display room name as name.");
prefs_set_string(PREF_ROSTER_ROOMS_USE_AS_NAME, "name");
if (conn_status == JABBER_CONNECTED) {
rosterwin_roster();
}
return TRUE;
} else {
cons_bad_cmd_usage(command);
return TRUE;
}
cons_bad_cmd_usage(command);
return TRUE;
} else {
cons_bad_cmd_usage(command);
return TRUE;
@ -6089,6 +6057,15 @@ cmd_titlebar(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}
if (g_strcmp0(args[0], "room") == 0) {
if (g_strcmp0(args[1], "title") == 0) {
if (g_strcmp0(args[2], "bookmark") == 0 || g_strcmp0(args[2], "jid") == 0 || g_strcmp0(args[2], "localpart") == 0 || g_strcmp0(args[2], "name") == 0) {
cons_show("MUC windows will display '%s' as the window title.", args[2]);
prefs_set_string(PREF_TITLEBAR_MUC_TITLE, args[2]);
return TRUE;
}
}
}
cons_bad_cmd_usage(command);
@ -6113,12 +6090,6 @@ cmd_titlebar_show_hide(ProfWin* window, const char* const command, gchar** args)
} else if (g_strcmp0(args[1], "presence") == 0) {
cons_show("Showing contact presence in titlebar enabled.");
prefs_set_boolean(PREF_PRESENCE, TRUE);
} else if (g_strcmp0(args[1], "jid") == 0) {
cons_show("Showing MUC JID in titlebar as title enabled.");
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_JID, TRUE);
} else if (g_strcmp0(args[1], "name") == 0) {
cons_show("Showing MUC name in titlebar as title enabled.");
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_NAME, TRUE);
} else {
cons_bad_cmd_usage(command);
}
@ -6136,12 +6107,6 @@ cmd_titlebar_show_hide(ProfWin* window, const char* const command, gchar** args)
} else if (g_strcmp0(args[1], "presence") == 0) {
cons_show("Showing contact presence in titlebar disabled.");
prefs_set_boolean(PREF_PRESENCE, FALSE);
} else if (g_strcmp0(args[1], "jid") == 0) {
cons_show("Showing MUC JID in titlebar as title disabled.");
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_JID, FALSE);
} else if (g_strcmp0(args[1], "name") == 0) {
cons_show("Showing MUC name in titlebar as title disabled.");
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_NAME, FALSE);
} else {
cons_bad_cmd_usage(command);
}
@ -6367,17 +6332,13 @@ cmd_statusbar(ProfWin* window, const char* const command, gchar** args)
}
if (g_strcmp0(args[0], "room") == 0) {
if (g_strcmp0(args[1], "jid") == 0) {
prefs_set_string(PREF_STATUSBAR_ROOM, "jid");
cons_show("Using jid for room tabs.");
ui_resize();
return TRUE;
}
if (g_strcmp0(args[1], "room") == 0) {
prefs_set_string(PREF_STATUSBAR_ROOM, "room");
cons_show("Using room name for room tabs.");
ui_resize();
return TRUE;
if (g_strcmp0(args[1], "title") == 0) {
if (g_strcmp0(args[2], "bookmark") == 0 || g_strcmp0(args[2], "jid") == 0 || g_strcmp0(args[2], "localpart") == 0 || g_strcmp0(args[2], "name") == 0) {
prefs_set_string(PREF_STATUSBAR_ROOM_TITLE, args[2]);
cons_show("Displaying '%s' as the title for MUC tabs.", args[2]);
ui_resize();
return TRUE;
}
}
cons_bad_cmd_usage(command);
return TRUE;

View File

@ -144,16 +144,6 @@ _prefs_load(void)
g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar.goodbye", NULL);
}
// after 0.8.1: titlebar use jid|name -> titlebar show|hide jid|name
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.muc.title", NULL)) {
auto_gchar gchar* value = g_key_file_get_string(prefs, PREF_GROUP_UI, "titlebar.muc.title", NULL);
if (g_strcmp0(value, "name") == 0) {
g_key_file_set_boolean(prefs, PREF_GROUP_UI, "titlebar.muc.title.name", TRUE);
} else if (g_strcmp0(value, "jid") == 0) {
g_key_file_set_boolean(prefs, PREF_GROUP_UI, "titlebar.muc.title.jid", TRUE);
}
}
// 0.9.0 introduced /urlopen. It was saved under "logging" section. Now we have a new "executables" section.
if (g_key_file_has_key(prefs, PREF_GROUP_LOGGING, "urlopen.cmd", NULL)) {
auto_gchar gchar* val = g_key_file_get_string(prefs, PREF_GROUP_LOGGING, "urlopen.cmd", NULL);
@ -208,6 +198,50 @@ _prefs_load(void)
g_key_file_remove_key(prefs, PREF_GROUP_PLUGINS, "sourcepath", NULL);
}
// after 0.14.0: "/roster room use name|jid" and "/roster room show|hide server"
// became "/roster room title bookmark|jid|localpart|name".
// The outer-most if-statement is not needed, but it is included for better performance.
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "roster.rooms.use.name", NULL) || g_key_file_has_key(prefs, PREF_GROUP_UI, "roster.rooms.server", NULL)) {
GError* err = NULL;
auto_gchar gchar* pref_use_name = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.use.name", NULL);
if (g_strcmp0(pref_use_name, "jid") == 0) {
const gboolean pref_show_server = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "roster.rooms.server", &err);
if (!pref_show_server && !err) {
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.title", "localpart");
} else {
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.title", "jid");
}
}
g_clear_error(&err);
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.rooms.server", NULL);
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.rooms.use.name", NULL);
}
// after 0.14.0: "/statusbar room room|jid" became "/statusbar room title bookmark|jid|localpart|name"
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "statusbar.room", NULL)) {
auto_gchar gchar* statusbar_room = g_key_file_get_string(prefs, PREF_GROUP_UI, "statusbar.room", NULL);
if (g_strcmp0(statusbar_room, "room") == 0) {
g_key_file_set_string(prefs, PREF_GROUP_UI, "statusbar.room.title", "localpart");
} else if (g_strcmp0(statusbar_room, "jid") == 0) {
g_key_file_set_string(prefs, PREF_GROUP_UI, "statusbar.room.title", "jid");
}
g_key_file_remove_key(prefs, PREF_GROUP_UI, "statusbar.room", NULL);
}
// after 0.14.0: "/statusbar show jid" and "/statusbar show name"
// became "/titlebar room title bookmark|jid|localpart|name"
// The outer-most if-statement is not needed, but it is included for better performance.
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.muc.title.jid", NULL) || g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.muc.title.name", NULL)) {
GError* err = NULL;
const gboolean pref_titlebar_muc_title_jid = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "titlebar.muc.title.jid", NULL);
const gboolean pref_titlebar_muc_title_name = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "titlebar.muc.title.name", &err);
if (pref_titlebar_muc_title_jid && !pref_titlebar_muc_title_name && !err) {
g_key_file_set_string(prefs, PREF_GROUP_UI, "titlebar.muc.title", "jid");
}
g_clear_error(&err);
g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar.muc.title.jid", NULL);
g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar.muc.title.name", NULL);
}
_save_prefs();
boolean_choice_ac = autocomplete_new();
@ -1731,8 +1765,7 @@ _get_group(preference_t pref)
case PREF_ROSTER_ROOMS_BY:
case PREF_ROSTER_ROOMS_ORDER:
case PREF_ROSTER_ROOMS_UNREAD:
case PREF_ROSTER_ROOMS_SERVER:
case PREF_ROSTER_ROOMS_USE_AS_NAME:
case PREF_ROSTER_ROOMS_TITLE:
case PREF_ROSTER_PRIVATE:
case PREF_RESOURCE_TITLE:
case PREF_RESOURCE_MESSAGE:
@ -1751,10 +1784,9 @@ _get_group(preference_t pref)
case PREF_STATUSBAR_SHOW_READ:
case PREF_STATUSBAR_SELF:
case PREF_STATUSBAR_CHAT:
case PREF_STATUSBAR_ROOM:
case PREF_STATUSBAR_ROOM_TITLE:
case PREF_STATUSBAR_TABMODE:
case PREF_TITLEBAR_MUC_TITLE_JID:
case PREF_TITLEBAR_MUC_TITLE_NAME:
case PREF_TITLEBAR_MUC_TITLE:
case PREF_SLASH_GUARD:
case PREF_COMPOSE_EDITOR:
case PREF_OUTGOING_STAMP:
@ -2022,10 +2054,8 @@ _get_key(preference_t pref)
return "roster.rooms.order";
case PREF_ROSTER_ROOMS_UNREAD:
return "roster.rooms.unread";
case PREF_ROSTER_ROOMS_SERVER:
return "roster.rooms.server";
case PREF_ROSTER_ROOMS_USE_AS_NAME:
return "roster.rooms.use.name";
case PREF_ROSTER_ROOMS_TITLE:
return "roster.rooms.title";
case PREF_ROSTER_PRIVATE:
return "roster.private";
case PREF_RESOURCE_TITLE:
@ -2036,10 +2066,8 @@ _get_key(preference_t pref)
return "inpblock.dynamic";
case PREF_ENC_WARN:
return "enc.warn";
case PREF_TITLEBAR_MUC_TITLE_JID:
return "titlebar.muc.title.jid";
case PREF_TITLEBAR_MUC_TITLE_NAME:
return "titlebar.muc.title.name";
case PREF_TITLEBAR_MUC_TITLE:
return "titlebar.muc.title";
case PREF_PGP_LOG:
return "log";
case PREF_PGP_SENDFILE:
@ -2080,8 +2108,8 @@ _get_key(preference_t pref)
return "statusbar.self";
case PREF_STATUSBAR_CHAT:
return "statusbar.chat";
case PREF_STATUSBAR_ROOM:
return "statusbar.room";
case PREF_STATUSBAR_ROOM_TITLE:
return "statusbar.room.title";
case PREF_STATUSBAR_TABMODE:
return "statusbar.tabmode";
case PREF_OMEMO_LOG:
@ -2154,7 +2182,6 @@ _get_default_boolean(preference_t pref)
case PREF_ROSTER_CONTACTS:
case PREF_ROSTER_UNSUBSCRIBED:
case PREF_ROSTER_ROOMS:
case PREF_ROSTER_ROOMS_SERVER:
case PREF_TLS_SHOW:
case PREF_LASTACTIVITY:
case PREF_TRAY_READ:
@ -2168,7 +2195,6 @@ _get_default_boolean(preference_t pref)
case PREF_CARBONS:
case PREF_STATES:
case PREF_OUTTYPE:
case PREF_TITLEBAR_MUC_TITLE_NAME:
case PREF_COLOR_NICK_OWN:
case PREF_INTYPE:
case PREF_INTYPE_CONSOLE:
@ -2211,7 +2237,7 @@ _get_default_string(preference_t pref)
case PREF_STATUSES_CHAT:
case PREF_STATUSES_MUC:
return "none";
case PREF_ROSTER_ROOMS_USE_AS_NAME:
case PREF_ROSTER_ROOMS_TITLE:
return "name";
case PREF_ROSTER_ROOMS_ORDER:
return "name";
@ -2247,10 +2273,12 @@ _get_default_string(preference_t pref)
return "fulljid";
case PREF_STATUSBAR_CHAT:
return "user";
case PREF_STATUSBAR_ROOM:
return "room";
case PREF_STATUSBAR_ROOM_TITLE:
return "name";
case PREF_STATUSBAR_TABMODE:
return "default";
case PREF_TITLEBAR_MUC_TITLE:
return "name";
case PREF_OMEMO_LOG:
return "on";
case PREF_OMEMO_POLICY:

View File

@ -91,8 +91,7 @@ typedef enum {
PREF_ROSTER_ROOMS_BY,
PREF_ROSTER_ROOMS_ORDER,
PREF_ROSTER_ROOMS_UNREAD,
PREF_ROSTER_ROOMS_SERVER,
PREF_ROSTER_ROOMS_USE_AS_NAME,
PREF_ROSTER_ROOMS_TITLE,
PREF_ROSTER_PRIVATE,
PREF_MUC_PRIVILEGES,
PREF_PRESENCE,
@ -144,8 +143,7 @@ typedef enum {
PREF_RESOURCE_MESSAGE,
PREF_INPBLOCK_DYNAMIC,
PREF_ENC_WARN,
PREF_TITLEBAR_MUC_TITLE_JID,
PREF_TITLEBAR_MUC_TITLE_NAME,
PREF_TITLEBAR_MUC_TITLE,
PREF_PGP_LOG,
PREF_PGP_SENDFILE,
PREF_PGP_PUBKEY_AUTOIMPORT,
@ -166,7 +164,7 @@ typedef enum {
PREF_STATUSBAR_SHOW_READ,
PREF_STATUSBAR_SELF,
PREF_STATUSBAR_CHAT,
PREF_STATUSBAR_ROOM,
PREF_STATUSBAR_ROOM_TITLE,
PREF_OMEMO_LOG,
PREF_OMEMO_POLICY,
PREF_OMEMO_TRUST_MODE,

View File

@ -321,13 +321,10 @@ _load_preferences(void)
_set_boolean_preference("roster.contacts", PREF_ROSTER_CONTACTS);
_set_boolean_preference("roster.unsubscribed", PREF_ROSTER_UNSUBSCRIBED);
_set_boolean_preference("roster.rooms", PREF_ROSTER_ROOMS);
_set_boolean_preference("roster.rooms.server", PREF_ROSTER_ROOMS_SERVER);
_set_boolean_preference("privileges", PREF_MUC_PRIVILEGES);
_set_boolean_preference("presence", PREF_PRESENCE);
_set_boolean_preference("intype", PREF_INTYPE);
_set_boolean_preference("enc.warn", PREF_ENC_WARN);
_set_boolean_preference("titlebar.muc.title.name", PREF_TITLEBAR_MUC_TITLE_NAME);
_set_boolean_preference("titlebar.muc.title.jid", PREF_TITLEBAR_MUC_TITLE_JID);
_set_boolean_preference("tls.show", PREF_TLS_SHOW);
_set_boolean_preference("statusbar.show.name", PREF_STATUSBAR_SHOW_NAME);
_set_boolean_preference("statusbar.show.number", PREF_STATUSBAR_SHOW_NUMBER);
@ -356,10 +353,11 @@ _load_preferences(void)
_set_string_preference("roster.rooms.by", PREF_ROSTER_ROOMS_BY);
_set_string_preference("roster.private", PREF_ROSTER_PRIVATE);
_set_string_preference("roster.count", PREF_ROSTER_COUNT);
_set_string_preference("roster.rooms.use.name", PREF_ROSTER_ROOMS_USE_AS_NAME);
_set_string_preference("roster.rooms.title", PREF_ROSTER_ROOMS_TITLE);
_set_string_preference("statusbar.self", PREF_STATUSBAR_SELF);
_set_string_preference("statusbar.chat", PREF_STATUSBAR_CHAT);
_set_string_preference("statusbar.room", PREF_STATUSBAR_ROOM);
_set_string_preference("statusbar.room.title", PREF_STATUSBAR_ROOM_TITLE);
_set_string_preference("titlebar.muc.title", PREF_TITLEBAR_MUC_TITLE);
// load ints from theme and set them to prefs
// with custom set functions

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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");
}

View File

@ -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);

View File

@ -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:
{

View File

@ -2140,11 +2140,7 @@ _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata
if (identity) {
if (name) {
identity->name = strdup(name);
ProfMucWin* mucwin = wins_get_muc(cb_data->room);
if (mucwin) {
free(mucwin->room_name);
mucwin->room_name = strdup(name);
}
mucwin_set_room_name(cb_data->room, name);
} else {
identity->name = NULL;
}

View File

@ -994,13 +994,7 @@ _room_config_handler(xmpp_stanza_t* const stanza, void* const userdata)
xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query);
// Update window name
ProfMucWin* win = wins_get_muc(from);
if (win != NULL) {
free(win->room_name);
win->room_name = strdup(capabilities->identity->name);
// Update features
if (mucwin_set_room_name(from, capabilities->identity->name)) {
muc_set_features(from, capabilities->features);
}
caps_destroy(capabilities);

View File

@ -125,7 +125,7 @@ roster.rooms.order=name
roster.rooms.unread=after
roster.rooms.pos=last
roster.rooms.by=none
roster.rooms.server=false
roster.rooms.title=localpart
roster.rooms.private.char=/
roster.private=room
roster.count=unread
@ -147,7 +147,7 @@ statusbar.position=3
inputwin.position=4
statusbar.self=user
statusbar.chat=user
statusbar.room=room
statusbar.room.title=localpart
statusbar.tabs=10
statusbar.tablen=7
statusbar.show.name=true

View File

@ -120,7 +120,7 @@ roster.rooms.order=name
roster.rooms.unread=after
roster.rooms.pos=first
roster.rooms.by=none
roster.rooms.server=false
roster.rooms.title=localpart
roster.rooms.private.char=/
roster.private=room
roster.count=unread

View File

@ -129,7 +129,6 @@ roster.rooms.order=name
roster.rooms.unread=after
roster.rooms.pos=last
roster.rooms.by=none
roster.rooms.server=false
roster.rooms.private.char=/
roster.private=room
roster.count=unread
@ -138,7 +137,7 @@ roster.contact.char=-
roster.rooms.char=#
roster.header.char=@
roster.private.char=+
roster.rooms.use.name=name
roster.rooms.title=name
occupants=true
occupants.size=15
occupants.jid=false
@ -157,7 +156,7 @@ statusbar.position=3
inputwin.position=4
statusbar.self=user
statusbar.chat=user
statusbar.room=room
statusbar.room.title=localpart
statusbar.tabs=10
statusbar.tablen=7
statusbar.show.name=true