mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Added /resource command
This commit is contained in:
parent
aae88753a3
commit
1a8c805319
@ -274,6 +274,16 @@ static struct cmd_t command_defs[] =
|
|||||||
"Example : /status jon",
|
"Example : /status jon",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
|
{ "/resource",
|
||||||
|
cmd_resource, parse_args, 1, 2, NULL,
|
||||||
|
{ "/resource set|off [resource]", "Set the contact's resource.",
|
||||||
|
{ "/resource set|off [resource]",
|
||||||
|
"----------------------------",
|
||||||
|
"Set the resource to use when chatting to a contact.",
|
||||||
|
"set resource - Set the resource.",
|
||||||
|
"off - Let the server choose which resource to route messages to.",
|
||||||
|
NULL } } },
|
||||||
|
|
||||||
{ "/join",
|
{ "/join",
|
||||||
cmd_join, parse_args, 1, 5, NULL,
|
cmd_join, parse_args, 1, 5, NULL,
|
||||||
{ "/join room[@server] [nick value] [password value]", "Join a chat room.",
|
{ "/join room[@server] [nick value] [password value]", "Join a chat room.",
|
||||||
|
@ -1527,6 +1527,48 @@ cmd_roster(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cmd_resource(gchar **args, struct cmd_help_t help)
|
||||||
|
{
|
||||||
|
ProfWin *current = wins_get_current();
|
||||||
|
if (current->type != WIN_CHAT) {
|
||||||
|
cons_show("The /resource command is only valid in chat windows.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *cmd = args[0];
|
||||||
|
|
||||||
|
if (g_strcmp0(cmd, "set") == 0) {
|
||||||
|
char *resource = args[1];
|
||||||
|
if (!resource) {
|
||||||
|
cons_show("Usage: %s", help.usage);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *recipent = ui_current_recipient();
|
||||||
|
PContact contact = roster_get_contact(recipent);
|
||||||
|
if (!contact) {
|
||||||
|
cons_show("Cannot choose resource for contact not in roster.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!p_contact_get_resource(contact, resource)) {
|
||||||
|
cons_show("No such resource %s.", resource);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
current->chat_resource = strdup(resource);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
} else if (g_strcmp0(cmd, "off") == 0) {
|
||||||
|
FREE_SET_NULL(current->chat_resource);
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
cons_show("Usage: %s", help.usage);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_status(gchar **args, struct cmd_help_t help)
|
cmd_status(gchar **args, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
|
@ -135,6 +135,7 @@ gboolean cmd_privileges(gchar **args, struct cmd_help_t help);
|
|||||||
gboolean cmd_presence(gchar **args, struct cmd_help_t help);
|
gboolean cmd_presence(gchar **args, struct cmd_help_t help);
|
||||||
gboolean cmd_wrap(gchar **args, struct cmd_help_t help);
|
gboolean cmd_wrap(gchar **args, struct cmd_help_t help);
|
||||||
gboolean cmd_time(gchar **args, struct cmd_help_t help);
|
gboolean cmd_time(gchar **args, struct cmd_help_t help);
|
||||||
|
gboolean cmd_resource(gchar **args, struct cmd_help_t help);
|
||||||
|
|
||||||
gboolean cmd_form_field(char *tag, gchar **args);
|
gboolean cmd_form_field(char *tag, gchar **args);
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ static GTimer *typing_elapsed;
|
|||||||
static void _title_bar_draw(void);
|
static void _title_bar_draw(void);
|
||||||
static void _show_contact_presence(void);
|
static void _show_contact_presence(void);
|
||||||
static void _show_self_presence(void);
|
static void _show_self_presence(void);
|
||||||
|
static void _show_contact_resource(void);
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
static void _show_privacy(void);
|
static void _show_privacy(void);
|
||||||
#endif
|
#endif
|
||||||
@ -181,6 +182,10 @@ _title_bar_draw(void)
|
|||||||
mvwprintw(win, 0, 0, " %s", current_title);
|
mvwprintw(win, 0, 0, " %s", current_title);
|
||||||
|
|
||||||
if (current && current->type == WIN_CHAT) {
|
if (current && current->type == WIN_CHAT) {
|
||||||
|
if (TRUE) {
|
||||||
|
// if (prefs_get_boolean(PREF_RESOURCE)) {
|
||||||
|
_show_contact_resource();
|
||||||
|
}
|
||||||
if (prefs_get_boolean(PREF_PRESENCE)) {
|
if (prefs_get_boolean(PREF_PRESENCE)) {
|
||||||
_show_contact_presence();
|
_show_contact_presence();
|
||||||
}
|
}
|
||||||
@ -320,6 +325,24 @@ _show_privacy(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
_show_contact_resource(void)
|
||||||
|
{
|
||||||
|
int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET);
|
||||||
|
|
||||||
|
ProfWin *current = wins_get_current();
|
||||||
|
if (current && current->chat_resource) {
|
||||||
|
wprintw(win, " ");
|
||||||
|
wattron(win, bracket_attrs);
|
||||||
|
wprintw(win, "[");
|
||||||
|
wattroff(win, bracket_attrs);
|
||||||
|
wprintw(win, current->chat_resource);
|
||||||
|
wattron(win, bracket_attrs);
|
||||||
|
wprintw(win, "]");
|
||||||
|
wattroff(win, bracket_attrs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_show_contact_presence(void)
|
_show_contact_presence(void)
|
||||||
{
|
{
|
||||||
|
@ -104,6 +104,7 @@ win_create(const char * const title, win_type_t type)
|
|||||||
new_win->is_otr = FALSE;
|
new_win->is_otr = FALSE;
|
||||||
new_win->is_trusted = FALSE;
|
new_win->is_trusted = FALSE;
|
||||||
new_win->form = NULL;
|
new_win->form = NULL;
|
||||||
|
new_win->chat_resource = NULL;
|
||||||
scrollok(new_win->win, TRUE);
|
scrollok(new_win->win, TRUE);
|
||||||
|
|
||||||
return new_win;
|
return new_win;
|
||||||
@ -151,6 +152,7 @@ win_free(ProfWin* window)
|
|||||||
if (window->subwin) {
|
if (window->subwin) {
|
||||||
delwin(window->subwin);
|
delwin(window->subwin);
|
||||||
}
|
}
|
||||||
|
free(window->chat_resource);
|
||||||
free(window->from);
|
free(window->from);
|
||||||
form_destroy(window->form);
|
form_destroy(window->form);
|
||||||
free(window);
|
free(window);
|
||||||
|
@ -68,6 +68,7 @@ typedef enum {
|
|||||||
|
|
||||||
typedef struct prof_win_t {
|
typedef struct prof_win_t {
|
||||||
char *from;
|
char *from;
|
||||||
|
char *chat_resource;
|
||||||
WINDOW *win;
|
WINDOW *win;
|
||||||
WINDOW *subwin;
|
WINDOW *subwin;
|
||||||
ProfBuff buffer;
|
ProfBuff buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user