mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 18:16:21 +00:00
Added /roster show|hide offline
This commit is contained in:
@@ -169,17 +169,19 @@ static struct cmd_t command_defs[] =
|
|||||||
|
|
||||||
{ "/roster",
|
{ "/roster",
|
||||||
cmd_roster, parse_args_with_freetext, 0, 3, NULL,
|
cmd_roster, parse_args_with_freetext, 0, 3, NULL,
|
||||||
{ "/roster [show|hide|add|remove|nick|clearnick] [jid] [nickname]", "Manage your roster.",
|
{ "/roster [show|hide|add|remove|nick|clearnick] [offline] [jid] [nickname]", "Manage your roster.",
|
||||||
{ "/roster [show|hide|add|remove|nick|clearnick] [jid] [nickname]",
|
{ "/roster [show|hide|add|remove|nick|clearnick] [offline] [jid] [nickname]",
|
||||||
"--------------------------------------------------------------",
|
"------------------------------------------------------------------------",
|
||||||
"View, add to, and remove from your roster.",
|
"View, add to, and remove from your roster.",
|
||||||
"Passing no arguments lists all contacts in your roster.",
|
"Passing no arguments lists all contacts in your roster.",
|
||||||
"The 'show' command will show the roster panel in the console window.",
|
"show - Show the roster panel in the console window.",
|
||||||
"The 'hide' command will hide the roster panel.",
|
"hide - Hide the roster panel.",
|
||||||
"The 'add' command will add a new item, jid is required, nickname is optional.",
|
"show offline - Show offline contacts in the roster panel.",
|
||||||
"The 'remove' command removes a contact, jid is required.",
|
"hide offline - Hide offline contacts in the roster panel.",
|
||||||
"The 'nick' command changes a contacts nickname, both jid and nickname are required,",
|
"add - Add a new item, jid is required, nickname is optional.",
|
||||||
"The 'clearnick' command removes the current nickname, jid is required.",
|
"remove - Removes a contact, jid is required.",
|
||||||
|
"nick - Changes a contacts nickname, both jid and nickname are required,",
|
||||||
|
"clearnick - Removes the current nickname, jid is required.",
|
||||||
"",
|
"",
|
||||||
"Example : /roster (show your roster)",
|
"Example : /roster (show your roster)",
|
||||||
"Example : /roster add someone@contacts.org (add the contact)",
|
"Example : /roster add someone@contacts.org (add the contact)",
|
||||||
@@ -1039,6 +1041,7 @@ static Autocomplete disco_ac;
|
|||||||
static Autocomplete close_ac;
|
static Autocomplete close_ac;
|
||||||
static Autocomplete wins_ac;
|
static Autocomplete wins_ac;
|
||||||
static Autocomplete roster_ac;
|
static Autocomplete roster_ac;
|
||||||
|
static Autocomplete roster_option_ac;
|
||||||
static Autocomplete group_ac;
|
static Autocomplete group_ac;
|
||||||
static Autocomplete bookmark_ac;
|
static Autocomplete bookmark_ac;
|
||||||
static Autocomplete bookmark_property_ac;
|
static Autocomplete bookmark_property_ac;
|
||||||
@@ -1235,6 +1238,9 @@ cmd_init(void)
|
|||||||
autocomplete_add(roster_ac, "show");
|
autocomplete_add(roster_ac, "show");
|
||||||
autocomplete_add(roster_ac, "hide");
|
autocomplete_add(roster_ac, "hide");
|
||||||
|
|
||||||
|
roster_option_ac = autocomplete_new();
|
||||||
|
autocomplete_add(roster_option_ac, "offline");
|
||||||
|
|
||||||
group_ac = autocomplete_new();
|
group_ac = autocomplete_new();
|
||||||
autocomplete_add(group_ac, "show");
|
autocomplete_add(group_ac, "show");
|
||||||
autocomplete_add(group_ac, "add");
|
autocomplete_add(group_ac, "add");
|
||||||
@@ -1404,6 +1410,7 @@ cmd_uninit(void)
|
|||||||
autocomplete_free(close_ac);
|
autocomplete_free(close_ac);
|
||||||
autocomplete_free(wins_ac);
|
autocomplete_free(wins_ac);
|
||||||
autocomplete_free(roster_ac);
|
autocomplete_free(roster_ac);
|
||||||
|
autocomplete_free(roster_option_ac);
|
||||||
autocomplete_free(group_ac);
|
autocomplete_free(group_ac);
|
||||||
autocomplete_free(bookmark_ac);
|
autocomplete_free(bookmark_ac);
|
||||||
autocomplete_free(bookmark_property_ac);
|
autocomplete_free(bookmark_property_ac);
|
||||||
@@ -1572,6 +1579,7 @@ cmd_reset_autocomplete()
|
|||||||
autocomplete_reset(close_ac);
|
autocomplete_reset(close_ac);
|
||||||
autocomplete_reset(wins_ac);
|
autocomplete_reset(wins_ac);
|
||||||
autocomplete_reset(roster_ac);
|
autocomplete_reset(roster_ac);
|
||||||
|
autocomplete_reset(roster_option_ac);
|
||||||
autocomplete_reset(group_ac);
|
autocomplete_reset(group_ac);
|
||||||
autocomplete_reset(bookmark_ac);
|
autocomplete_reset(bookmark_ac);
|
||||||
autocomplete_reset(bookmark_property_ac);
|
autocomplete_reset(bookmark_property_ac);
|
||||||
@@ -2000,6 +2008,14 @@ _roster_autocomplete(char *input, int *size)
|
|||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
result = autocomplete_param_with_ac(input, size, "/roster show", roster_option_ac, TRUE);
|
||||||
|
if (result != NULL) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = autocomplete_param_with_ac(input, size, "/roster hide", roster_option_ac, TRUE);
|
||||||
|
if (result != NULL) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
result = autocomplete_param_with_ac(input, size, "/roster", roster_ac, TRUE);
|
result = autocomplete_param_with_ac(input, size, "/roster", roster_ac, TRUE);
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1332,16 +1332,35 @@ cmd_roster(gchar **args, struct cmd_help_t help)
|
|||||||
|
|
||||||
// show/hide roster
|
// show/hide roster
|
||||||
} else if (g_strcmp0(args[0], "show") == 0) {
|
} else if (g_strcmp0(args[0], "show") == 0) {
|
||||||
cons_show("Roster enabled.");
|
if (args[1] == NULL) {
|
||||||
prefs_set_boolean(PREF_ROSTER, TRUE);
|
cons_show("Roster enabled.");
|
||||||
ui_show_roster();
|
prefs_set_boolean(PREF_ROSTER, TRUE);
|
||||||
return TRUE;
|
ui_show_roster();
|
||||||
|
return TRUE;
|
||||||
|
} else if (g_strcmp0(args[1], "offline") == 0) {
|
||||||
|
cons_show("Roster offline enabled");
|
||||||
|
prefs_set_boolean(PREF_ROSTER_OFFLINE, TRUE);
|
||||||
|
ui_roster();
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
cons_show("Usage: %s", help.usage);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
} else if (g_strcmp0(args[0], "hide") == 0) {
|
} else if (g_strcmp0(args[0], "hide") == 0) {
|
||||||
cons_show("Roster disabled.");
|
if (args[1] == NULL) {
|
||||||
prefs_set_boolean(PREF_ROSTER, FALSE);
|
cons_show("Roster disabled.");
|
||||||
ui_hide_roster();
|
prefs_set_boolean(PREF_ROSTER, FALSE);
|
||||||
return TRUE;
|
ui_hide_roster();
|
||||||
|
return TRUE;
|
||||||
|
} else if (g_strcmp0(args[1], "offline") == 0) {
|
||||||
|
cons_show("Roster offline disabled");
|
||||||
|
prefs_set_boolean(PREF_ROSTER_OFFLINE, FALSE);
|
||||||
|
ui_roster();
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
cons_show("Usage: %s", help.usage);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
// add contact
|
// add contact
|
||||||
} else if (strcmp(args[0], "add") == 0) {
|
} else if (strcmp(args[0], "add") == 0) {
|
||||||
char *jid = args[1];
|
char *jid = args[1];
|
||||||
|
|||||||
@@ -2821,45 +2821,49 @@ _ui_roster(void)
|
|||||||
if (p_contact_subscribed(contact)) {
|
if (p_contact_subscribed(contact)) {
|
||||||
const char *name = p_contact_name_or_jid(contact);
|
const char *name = p_contact_name_or_jid(contact);
|
||||||
const char *presence = p_contact_presence(contact);
|
const char *presence = p_contact_presence(contact);
|
||||||
int presence_colour = win_presence_colour(presence);
|
|
||||||
|
|
||||||
wattron(window->subwin, presence_colour);
|
if ((g_strcmp0(presence, "offline") != 0) || ((g_strcmp0(presence, "offline") == 0) &&
|
||||||
|
(prefs_get_boolean(PREF_ROSTER_OFFLINE)))) {
|
||||||
|
int presence_colour = win_presence_colour(presence);
|
||||||
|
|
||||||
GString *msg = g_string_new(" ");
|
wattron(window->subwin, presence_colour);
|
||||||
g_string_append(msg, name);
|
|
||||||
win_printline_nowrap(window->subwin, msg->str);
|
|
||||||
g_string_free(msg, TRUE);
|
|
||||||
|
|
||||||
wattroff(window->subwin, presence_colour);
|
GString *msg = g_string_new(" ");
|
||||||
|
g_string_append(msg, name);
|
||||||
GList *resources = p_contact_get_available_resources(contact);
|
|
||||||
GList *ordered_resources = NULL;
|
|
||||||
|
|
||||||
// sort in order of availabiltiy
|
|
||||||
while (resources != NULL) {
|
|
||||||
Resource *resource = resources->data;
|
|
||||||
ordered_resources = g_list_insert_sorted(ordered_resources, resource, (GCompareFunc)resource_compare_availability);
|
|
||||||
resources = g_list_next(resources);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_list_free(resources);
|
|
||||||
|
|
||||||
while (ordered_resources) {
|
|
||||||
Resource *resource = ordered_resources->data;
|
|
||||||
const char *resource_presence = string_from_resource_presence(resource->presence);
|
|
||||||
int resource_presence_colour = win_presence_colour(resource_presence);
|
|
||||||
wattron(window->subwin, resource_presence_colour);
|
|
||||||
|
|
||||||
GString *msg = g_string_new(" ");
|
|
||||||
g_string_append(msg, resource->name);
|
|
||||||
win_printline_nowrap(window->subwin, msg->str);
|
win_printline_nowrap(window->subwin, msg->str);
|
||||||
g_string_free(msg, TRUE);
|
g_string_free(msg, TRUE);
|
||||||
|
|
||||||
wattroff(window->subwin, resource_presence_colour);
|
wattroff(window->subwin, presence_colour);
|
||||||
|
|
||||||
ordered_resources = g_list_next(ordered_resources);
|
GList *resources = p_contact_get_available_resources(contact);
|
||||||
|
GList *ordered_resources = NULL;
|
||||||
|
|
||||||
|
// sort in order of availabiltiy
|
||||||
|
while (resources != NULL) {
|
||||||
|
Resource *resource = resources->data;
|
||||||
|
ordered_resources = g_list_insert_sorted(ordered_resources, resource, (GCompareFunc)resource_compare_availability);
|
||||||
|
resources = g_list_next(resources);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free(resources);
|
||||||
|
|
||||||
|
while (ordered_resources) {
|
||||||
|
Resource *resource = ordered_resources->data;
|
||||||
|
const char *resource_presence = string_from_resource_presence(resource->presence);
|
||||||
|
int resource_presence_colour = win_presence_colour(resource_presence);
|
||||||
|
wattron(window->subwin, resource_presence_colour);
|
||||||
|
|
||||||
|
GString *msg = g_string_new(" ");
|
||||||
|
g_string_append(msg, resource->name);
|
||||||
|
win_printline_nowrap(window->subwin, msg->str);
|
||||||
|
g_string_free(msg, TRUE);
|
||||||
|
|
||||||
|
wattroff(window->subwin, resource_presence_colour);
|
||||||
|
|
||||||
|
ordered_resources = g_list_next(ordered_resources);
|
||||||
|
}
|
||||||
|
g_list_free(ordered_resources);
|
||||||
}
|
}
|
||||||
g_list_free(ordered_resources);
|
|
||||||
}
|
}
|
||||||
curr_contact = g_slist_next(curr_contact);
|
curr_contact = g_slist_next(curr_contact);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user