1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Merge remote-tracking branch 'incertia/master'

This commit is contained in:
James Booth 2014-11-24 00:54:51 +00:00
commit ed228ebb59
4 changed files with 31 additions and 3 deletions

View File

@ -169,11 +169,12 @@ static struct cmd_t command_defs[] =
{ "/roster",
cmd_roster, parse_args_with_freetext, 0, 3, NULL,
{ "/roster [show|hide|by|size|add|remove|nick|clearnick] [offline|resource] [percent] [group|presence|none] [jid] [nickname]", "Manage your roster.",
{ "/roster [show|hide|by|size|add|remove|nick|clearnick] [offline|resource] [percent] [group|presence|none] [jid] [nickname]",
{ "/roster [online|show|hide|by|size|add|remove|nick|clearnick] [offline|resource] [percent] [group|presence|none] [jid] [nickname]", "Manage your roster.",
{ "/roster [online|show|hide|by|size|add|remove|nick|clearnick] [offline|resource] [percent] [group|presence|none] [jid] [nickname]",
"-------------------------------------------------------------------------------------------------------------------------",
"View, add to, and remove from your roster.",
"Passing no arguments lists all contacts in your roster.",
"online - Show all online contacts in your roster.",
"show - Show the roster panel in the console window.",
"hide - Hide the roster panel.",
"show offline - Show offline contacts in the roster panel.",
@ -1252,6 +1253,7 @@ cmd_init(void)
roster_ac = autocomplete_new();
autocomplete_add(roster_ac, "add");
autocomplete_add(roster_ac, "online");
autocomplete_add(roster_ac, "nick");
autocomplete_add(roster_ac, "clearnick");
autocomplete_add(roster_ac, "remove");

View File

@ -1358,6 +1358,14 @@ cmd_roster(gchar **args, struct cmd_help_t help)
if (args[0] == NULL) {
GSList *list = roster_get_contacts();
cons_show_roster(list);
g_slist_free(list);
return TRUE;
// show roster, only online contacts
} else if(g_strcmp0(args[0], "online") == 0){
GSList *list = roster_get_contacts_online();
cons_show_roster(list);
g_slist_free(list);
return TRUE;
// set roster size
@ -4056,4 +4064,3 @@ gint _compare_commands(Command *a, Command *b)
return result;
}

View File

@ -307,6 +307,24 @@ roster_get_contacts(void)
return result;
}
GSList *
roster_get_contacts_online(void)
{
GSList *result = NULL;
GHashTableIter iter;
gpointer key;
gpointer value;
g_hash_table_iter_init(&iter, contacts);
while (g_hash_table_iter_next(&iter, &key, &value)) {
if(strcmp(p_contact_presence(value), "offline"))
result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_contacts);
}
// resturn all contact structs
return result;
}
gboolean
roster_has_pending_subscriptions(void)
{

View File

@ -57,6 +57,7 @@ gboolean roster_add(const char * const barejid, const char * const name, GSList
const char * const subscription, gboolean pending_out);
char * roster_barejid_from_name(const char * const name);
GSList * roster_get_contacts(void);
GSList * roster_get_contacts_online(void);
gboolean roster_has_pending_subscriptions(void);
char * roster_contact_autocomplete(char *search_str);
char * roster_fulljid_autocomplete(char *search_str);