mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Added /roster show|hide command, only show roster on connect success
This commit is contained in:
parent
5d59d17642
commit
497b07c1c3
@ -169,11 +169,13 @@ static struct cmd_t command_defs[] =
|
||||
|
||||
{ "/roster",
|
||||
cmd_roster, parse_args_with_freetext, 0, 3, NULL,
|
||||
{ "/roster [add|remove|nick|clearnick] [jid] [nickname]", "Manage your roster.",
|
||||
{ "/roster [add|remove|nick|clearnick] [jid] [nickname]",
|
||||
"----------------------------------------------------",
|
||||
{ "/roster [show|hide|add|remove|nick|clearnick] [jid] [nickname]", "Manage your roster.",
|
||||
{ "/roster [show|hide|add|remove|nick|clearnick] [jid] [nickname]",
|
||||
"--------------------------------------------------------------",
|
||||
"View, add to, and remove from your roster.",
|
||||
"Passing no arguments lists all contacts in your roster.",
|
||||
"The 'show' command will show the roster panel in the console window.",
|
||||
"The 'hide' command will hide the roster panel.",
|
||||
"The 'add' command will add a new item, jid is required, nickname is optional.",
|
||||
"The 'remove' command removes a contact, jid is required.",
|
||||
"The 'nick' command changes a contacts nickname, both jid and nickname are required,",
|
||||
@ -1230,6 +1232,8 @@ cmd_init(void)
|
||||
autocomplete_add(roster_ac, "nick");
|
||||
autocomplete_add(roster_ac, "clearnick");
|
||||
autocomplete_add(roster_ac, "remove");
|
||||
autocomplete_add(roster_ac, "show");
|
||||
autocomplete_add(roster_ac, "hide");
|
||||
|
||||
group_ac = autocomplete_new();
|
||||
autocomplete_add(group_ac, "show");
|
||||
|
@ -1330,6 +1330,18 @@ cmd_roster(gchar **args, struct cmd_help_t help)
|
||||
cons_show_roster(list);
|
||||
return TRUE;
|
||||
|
||||
// show/hide roster
|
||||
} else if (g_strcmp0(args[0], "show") == 0) {
|
||||
cons_show("Roster enabled.");
|
||||
prefs_set_boolean(PREF_ROSTER, TRUE);
|
||||
ui_show_roster();
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(args[0], "hide") == 0) {
|
||||
cons_show("Roster disabled.");
|
||||
prefs_set_boolean(PREF_ROSTER, FALSE);
|
||||
ui_hide_roster();
|
||||
return TRUE;
|
||||
|
||||
// add contact
|
||||
} else if (strcmp(args[0], "add") == 0) {
|
||||
char *jid = args[1];
|
||||
|
@ -453,6 +453,10 @@ _get_group(preference_t pref)
|
||||
case PREF_MUC_PRIVILEGES:
|
||||
case PREF_PRESENCE:
|
||||
case PREF_WRAP:
|
||||
case PREF_ROSTER:
|
||||
case PREF_ROSTER_OFFLINE:
|
||||
case PREF_ROSTER_RESOURCE:
|
||||
case PREF_ROSTER_BY:
|
||||
return PREF_GROUP_UI;
|
||||
case PREF_STATES:
|
||||
case PREF_OUTTYPE:
|
||||
@ -573,6 +577,14 @@ _get_key(preference_t pref)
|
||||
return "presence";
|
||||
case PREF_WRAP:
|
||||
return "wrap";
|
||||
case PREF_ROSTER:
|
||||
return "roster";
|
||||
case PREF_ROSTER_OFFLINE:
|
||||
return "roster.offline";
|
||||
case PREF_ROSTER_RESOURCE:
|
||||
return "roster.resource";
|
||||
case PREF_ROSTER_BY:
|
||||
return "roster.by";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@ -618,6 +630,8 @@ _get_default_string(preference_t pref)
|
||||
case PREF_STATUSES_CHAT:
|
||||
case PREF_STATUSES_MUC:
|
||||
return "all";
|
||||
case PREF_ROSTER_BY:
|
||||
return "none";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -58,6 +58,10 @@ typedef enum {
|
||||
PREF_HISTORY,
|
||||
PREF_MOUSE,
|
||||
PREF_OCCUPANTS,
|
||||
PREF_ROSTER,
|
||||
PREF_ROSTER_OFFLINE,
|
||||
PREF_ROSTER_RESOURCE,
|
||||
PREF_ROSTER_BY,
|
||||
PREF_MUC_PRIVILEGES,
|
||||
PREF_PRESENCE,
|
||||
PREF_WRAP,
|
||||
|
@ -122,6 +122,10 @@ handle_login_account_success(char *account_name)
|
||||
|
||||
log_info("%s logged in successfully", account->jid);
|
||||
account_free(account);
|
||||
|
||||
if (prefs_get_boolean(PREF_ROSTER)) {
|
||||
ui_show_roster();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -941,6 +941,15 @@ _cons_titlebar_setting(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cons_roster_setting(void)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_ROSTER))
|
||||
cons_show("Roster (/roster) : show");
|
||||
else
|
||||
cons_show("Roster (/roster) : hide");
|
||||
}
|
||||
|
||||
static void
|
||||
_cons_show_ui_prefs(void)
|
||||
{
|
||||
@ -955,6 +964,7 @@ _cons_show_ui_prefs(void)
|
||||
cons_mouse_setting();
|
||||
cons_statuses_setting();
|
||||
cons_occupants_setting();
|
||||
cons_roster_setting();
|
||||
cons_privileges_setting();
|
||||
cons_titlebar_setting();
|
||||
cons_presence_setting();
|
||||
@ -1573,6 +1583,7 @@ console_init_module(void)
|
||||
cons_splash_setting = _cons_splash_setting;
|
||||
cons_autoconnect_setting = _cons_autoconnect_setting;
|
||||
cons_occupants_setting = _cons_occupants_setting;
|
||||
cons_roster_setting = _cons_roster_setting;
|
||||
cons_vercheck_setting = _cons_vercheck_setting;
|
||||
cons_mouse_setting = _cons_mouse_setting;
|
||||
cons_statuses_setting = _cons_statuses_setting;
|
||||
|
@ -2985,6 +2985,25 @@ _ui_room_hide_occupants(const char * const room)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_show_roster(void)
|
||||
{
|
||||
ProfWin *window = wins_get_console();
|
||||
if (window && !window->subwin) {
|
||||
wins_show_subwin(window);
|
||||
ui_roster();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_hide_roster(void)
|
||||
{
|
||||
ProfWin *window = wins_get_console();
|
||||
if (window && window->subwin) {
|
||||
wins_hide_subwin(window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_win_handle_switch(const wint_t * const ch)
|
||||
{
|
||||
@ -3291,6 +3310,8 @@ ui_init_module(void)
|
||||
ui_roster = _ui_roster;
|
||||
ui_room_show_occupants = _ui_room_show_occupants;
|
||||
ui_room_hide_occupants = _ui_room_hide_occupants;
|
||||
ui_show_roster = _ui_show_roster;
|
||||
ui_hide_roster = _ui_hide_roster;
|
||||
ui_room_role_change = _ui_room_role_change;
|
||||
ui_room_affiliation_change = _ui_room_affiliation_change;
|
||||
ui_switch_to_room = _ui_switch_to_room;
|
||||
|
@ -175,6 +175,8 @@ void (*ui_room_member_presence)(const char * const room,
|
||||
const char * const nick, const char * const show, const char * const status);
|
||||
void (*ui_room_show_occupants)(const char * const room);
|
||||
void (*ui_room_hide_occupants)(const char * const room);
|
||||
void (*ui_show_roster)(void);
|
||||
void (*ui_hide_roster)(void);
|
||||
void (*ui_roster_add)(const char * const barejid, const char * const name);
|
||||
void (*ui_roster_remove)(const char * const barejid);
|
||||
void (*ui_contact_already_in_group)(const char * const contact, const char * const group);
|
||||
@ -298,6 +300,7 @@ void (*cons_flash_setting)(void);
|
||||
void (*cons_splash_setting)(void);
|
||||
void (*cons_vercheck_setting)(void);
|
||||
void (*cons_occupants_setting)(void);
|
||||
void (*cons_roster_setting)(void);
|
||||
void (*cons_presence_setting)(void);
|
||||
void (*cons_wrap_setting)(void);
|
||||
void (*cons_mouse_setting)(void);
|
||||
|
@ -71,7 +71,7 @@ win_create(const char * const title, win_type_t type)
|
||||
new_win->from = strdup(title);
|
||||
int cols = getmaxx(stdscr);
|
||||
|
||||
if ((type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) || (type == WIN_CONSOLE)) {
|
||||
if (type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) {
|
||||
int main_cols = win_main_width();
|
||||
new_win->win = newpad(PAD_SIZE, main_cols);
|
||||
wbkgd(new_win->win, COLOUR_TEXT);
|
||||
|
Loading…
Reference in New Issue
Block a user