-
-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve MUC title behaviour for roster, statusbar, and titlebar #1892
Merged
jubalh
merged 1 commit into
profanity-im:master
from
ike08:improvement/muc-title-behaviour
Oct 9, 2023
Merged
Improve MUC title behaviour for roster, statusbar, and titlebar #1892
jubalh
merged 1 commit into
profanity-im:master
from
ike08:improvement/muc-title-behaviour
Oct 9, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Abstract Continuation of #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 #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 [email protected] /room config /field1 "" /form submit /quit ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/join [email protected]` | 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 [email protected]` | 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 [email protected] /room config /field1 "my_room" /form submit /quit ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/join [email protected]` | 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 [email protected]` | 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 [email protected]` | 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 [email protected] ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/bookmark join [email protected]` | 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 [email protected] /bookmark add [email protected] name "my_bookmark" ``` | Test | Roster | Statusbar | Titlebar | | :--- | :--- | :--- | :--- | | `/bookmark join [email protected]` | 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 [email protected]` | 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 [email protected] ``` | Test | Titlebar | | :--- | :--- | | `/msg [email protected]` | tst<span/>@dmn.im | #### Test: with contact nick ``` /roster add [email protected] 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.
jubalh
approved these changes
Oct 9, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope I didn't miss anything or forgot to test something!
All looks good!
Thank you especially for great explanation/summary!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Abstract
Continuation of #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 #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.
Command Definitions
/help roster
- room title bookmark|jid|localpart|name : Display the bookmark name, JID, JID localpart, or room name as the roster title for MUCs.
- No /roster show|hide server
- No /roster room use jid|name
/help statusbar
- room title bookmark|jid|localpart|name : Display the bookmark name, JID, JID localpart, or room name as the title for MUC tabs.
- No /statusbar room jid|room
/help titlebar
- room title bookmark|jid|localpart|name : Display the bookmark name, JID, JID localpart, or room name as the MUC window title.
- No /titlebar show|hide jid|name
Autocomplete
/roster room <TAB>
title
/roster room title <TAB>
bookmark|jid|localpart|name
/statusbar room <TAB>
title
/statusbar room title <TAB>
bookmark|jid|localpart|name
/titlebar room <TAB>
title
/titlebar room title <TAB>
bookmark|jid|localpart|name
/roster room <TAB>
use
,show
, orhide
/roster room use <TAB>
name
/roster room show <TAB>
server
/roster room hide <TAB>
server
/statusbar room <TAB>
jid
orroom
/titlebar show <TAB>
jid
orname
/titlebar hide <TAB>
jid
orname
Set Preferences
/roster room title bookmark
/roster room title jid
/roster room title localpart
/roster room title name
/roster room title invalid
/statusbar room title bookmark
/statusbar room title jid
/statusbar room title localpart
/statusbar room title name
/statusbar room title invalid
/titlebar room title bookmark
/titlebar room title jid
/titlebar room title localpart
/titlebar room title name
/titlebar room title invalid
/roster room use jid
/roster room use name
/roster room show server
/roster room hide server
/statusbar room jid
/statusbar room room
/titlebar show jid
/titlebar hide jid
/titlebar show name
/titlebar hide name
Display Set Preferences
- Room tab display (/statusbar) : name
- MUC window title (/titlebar) : name
Test MUC Window
Test: without name preference, without room name field
/join [email protected]
/room config
/field2 edit
/msg tst
/roster room by service
Test: with name preference, without room name field
/join [email protected]
/room config
/field2 edit
/msg tst
/roster room by service
Test: without name preference, with room name field
/join [email protected]
/room config
/field2 edit
/msg tst
/roster room by service
Test: with name preference, with room name field
/join [email protected]
/room config
/field2 edit
/msg tst
/roster room by service
Test: with localpart preference
/join [email protected]
/room config
/field2 edit
/msg tst
/roster room by service
Test: with bookmark preference, without bookmark name
/bookmark join [email protected]
/room config
/field2 edit
/msg tst
/roster room by service
Test: with bookmark preference, with bookmark name
/bookmark join [email protected]
/room config
/field2 edit
/msg tst
/roster room by service
Test: with jid preference
/join [email protected]
/room config
/field2 edit
/msg tst
/roster room by service
Test Contact Chat Window Title
Test: without contact nick
/msg [email protected]
Test: with contact nick
/msg my_tst
Test Preference Upgrade
Test /roster
sed -i '/\[ui\]/a\roster.rooms.use.name=name' profrc
sed -i '/\[ui\]/a\roster.rooms.use.name=' profrc
sed -i '/\[ui\]/a\roster.rooms.server=' profrc
sed -i '/\[ui\]/a\roster.rooms.use.name=jid' profrc
roster.rooms.title=jid
sed -i '/\[ui\]/a\roster.rooms.use.name=jid' profrc
sed -i '/\[ui\]/a\roster.rooms.server=false' profrc
roster.rooms.title=localpart
sed -i '/\[ui\]/a\roster.rooms.use.name=jid' profrc
sed -i '/\[ui\]/a\roster.rooms.server=true' profrc
roster.rooms.title=jid
sed -i '/\[ui\]/a\roster.rooms.use.name=jid' profrc
sed -i '/\[ui\]/a\roster.rooms.server=' profrc
roster.rooms.title=jid
sed -i '/\[ui\]/a\statusbar.room=' profrc
sed -i '/\[ui\]/a\statusbar.room=room' profrc
statusbar.room.title=localpart
sed -i '/\[ui\]/a\statusbar.room=jid' profrc
statusbar.room.title=jid
sed -i '/\[ui\]/a\titlebar.muc.title.jid=' profrc
sed -i '/\[ui\]/a\titlebar.muc.title.name=' profrc
sed -i '/\[ui\]/a\titlebar.muc.title.jid=true' profrc
sed -i '/\[ui\]/a\titlebar.muc.title.name=true' profrc
sed -i '/\[ui\]/a\titlebar.muc.title.jid=false' profrc
sed -i '/\[ui\]/a\titlebar.muc.title.name=false' profrc
sed -i '/\[ui\]/a\titlebar.muc.title.jid=true' profrc
sed -i '/\[ui\]/a\titlebar.muc.title.name=false' profrc
titlebar.muc.title=jid
sed -i '/\[ui\]/a\titlebar.muc.title.jid=false' profrc
sed -i '/\[ui\]/a\titlebar.muc.title.name=true' profrc
sed -i '/\[ui\]/a\titlebar.muc.title.jid=true' profrc
sed -i '/\[ui\]/a\titlebar.muc.title.name=true' profrc
Test Valgrind
No memory leaks detected relating to these changes.