mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-29 07:26:21 +00:00
Added _who_room function
This commit is contained in:
@@ -61,6 +61,7 @@ static gboolean _cmd_set_boolean_preference(gchar *arg, struct cmd_help_t help,
|
|||||||
static int _strtoi(char *str, int *saveptr, int min, int max);
|
static int _strtoi(char *str, int *saveptr, int min, int max);
|
||||||
static void _cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size);
|
static void _cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size);
|
||||||
static gint _compare_commands(Command *a, Command *b);
|
static gint _compare_commands(Command *a, Command *b);
|
||||||
|
static void _who_room(const char * const presence);
|
||||||
|
|
||||||
extern GHashTable *commands;
|
extern GHashTable *commands;
|
||||||
|
|
||||||
@@ -711,6 +712,88 @@ cmd_theme(gchar **args, struct cmd_help_t help)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_who_room(const char * const presence)
|
||||||
|
{
|
||||||
|
char *room = ui_current_recipient();
|
||||||
|
GList *list = muc_get_roster(room);
|
||||||
|
|
||||||
|
// no arg, show all contacts
|
||||||
|
if ((presence == NULL) || (g_strcmp0(presence, "any") == 0)) {
|
||||||
|
ui_room_roster(room, list, NULL);
|
||||||
|
|
||||||
|
// available
|
||||||
|
} else if (strcmp("available", presence) == 0) {
|
||||||
|
GList *filtered = NULL;
|
||||||
|
|
||||||
|
while (list != NULL) {
|
||||||
|
PContact contact = list->data;
|
||||||
|
if (p_contact_is_available(contact)) {
|
||||||
|
filtered = g_list_append(filtered, contact);
|
||||||
|
}
|
||||||
|
list = g_list_next(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_room_roster(room, filtered, "available");
|
||||||
|
|
||||||
|
// unavailable
|
||||||
|
} else if (strcmp("unavailable", presence) == 0) {
|
||||||
|
GList *filtered = NULL;
|
||||||
|
|
||||||
|
while (list != NULL) {
|
||||||
|
PContact contact = list->data;
|
||||||
|
if (!p_contact_is_available(contact)) {
|
||||||
|
filtered = g_list_append(filtered, contact);
|
||||||
|
}
|
||||||
|
list = g_list_next(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_room_roster(room, filtered, "unavailable");
|
||||||
|
|
||||||
|
// online, available resources
|
||||||
|
} else if (strcmp("online", presence) == 0) {
|
||||||
|
GList *filtered = NULL;
|
||||||
|
|
||||||
|
while (list != NULL) {
|
||||||
|
PContact contact = list->data;
|
||||||
|
if (p_contact_has_available_resource(contact)) {
|
||||||
|
filtered = g_list_append(filtered, contact);
|
||||||
|
}
|
||||||
|
list = g_list_next(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_room_roster(room, filtered, "online");
|
||||||
|
|
||||||
|
// offline, no available resources
|
||||||
|
} else if (strcmp("offline", presence) == 0) {
|
||||||
|
GList *filtered = NULL;
|
||||||
|
|
||||||
|
while (list != NULL) {
|
||||||
|
PContact contact = list->data;
|
||||||
|
if (!p_contact_has_available_resource(contact)) {
|
||||||
|
filtered = g_list_append(filtered, contact);
|
||||||
|
}
|
||||||
|
list = g_list_next(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_room_roster(room, filtered, "offline");
|
||||||
|
|
||||||
|
// show specific status
|
||||||
|
} else {
|
||||||
|
GList *filtered = NULL;
|
||||||
|
|
||||||
|
while (list != NULL) {
|
||||||
|
PContact contact = list->data;
|
||||||
|
if (strcmp(p_contact_presence(contact), presence) == 0) {
|
||||||
|
filtered = g_list_append(filtered, contact);
|
||||||
|
}
|
||||||
|
list = g_list_next(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_room_roster(room, filtered, presence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_who(gchar **args, struct cmd_help_t help)
|
cmd_who(gchar **args, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
@@ -739,93 +822,14 @@ cmd_who(gchar **args, struct cmd_help_t help)
|
|||||||
&& (strcmp(presence, "any") != 0)) {
|
&& (strcmp(presence, "any") != 0)) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
|
|
||||||
// valid arg
|
|
||||||
} else {
|
} else {
|
||||||
if (win_type == WIN_MUC) {
|
if (win_type == WIN_MUC) {
|
||||||
if (group != NULL) {
|
if (group != NULL) {
|
||||||
cons_show("The group argument is not valid when in a chat room.");
|
cons_show("The group argument is not valid when in a chat room.");
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *room = ui_current_recipient();
|
|
||||||
GList *list = muc_get_roster(room);
|
|
||||||
|
|
||||||
// no arg, show all contacts
|
|
||||||
if ((presence == NULL) || (g_strcmp0(presence, "any") == 0)) {
|
|
||||||
ui_room_roster(room, list, NULL);
|
|
||||||
|
|
||||||
// available
|
|
||||||
} else if (strcmp("available", presence) == 0) {
|
|
||||||
GList *filtered = NULL;
|
|
||||||
|
|
||||||
while (list != NULL) {
|
|
||||||
PContact contact = list->data;
|
|
||||||
if (p_contact_is_available(contact)) {
|
|
||||||
filtered = g_list_append(filtered, contact);
|
|
||||||
}
|
|
||||||
list = g_list_next(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_room_roster(room, filtered, "available");
|
|
||||||
|
|
||||||
// unavailable
|
|
||||||
} else if (strcmp("unavailable", presence) == 0) {
|
|
||||||
GList *filtered = NULL;
|
|
||||||
|
|
||||||
while (list != NULL) {
|
|
||||||
PContact contact = list->data;
|
|
||||||
if (!p_contact_is_available(contact)) {
|
|
||||||
filtered = g_list_append(filtered, contact);
|
|
||||||
}
|
|
||||||
list = g_list_next(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_room_roster(room, filtered, "unavailable");
|
|
||||||
|
|
||||||
// online, available resources
|
|
||||||
} else if (strcmp("online", presence) == 0) {
|
|
||||||
GList *filtered = NULL;
|
|
||||||
|
|
||||||
while (list != NULL) {
|
|
||||||
PContact contact = list->data;
|
|
||||||
if (p_contact_has_available_resource(contact)) {
|
|
||||||
filtered = g_list_append(filtered, contact);
|
|
||||||
}
|
|
||||||
list = g_list_next(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_room_roster(room, filtered, "online");
|
|
||||||
|
|
||||||
// offline, no available resources
|
|
||||||
} else if (strcmp("offline", presence) == 0) {
|
|
||||||
GList *filtered = NULL;
|
|
||||||
|
|
||||||
while (list != NULL) {
|
|
||||||
PContact contact = list->data;
|
|
||||||
if (!p_contact_has_available_resource(contact)) {
|
|
||||||
filtered = g_list_append(filtered, contact);
|
|
||||||
}
|
|
||||||
list = g_list_next(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_room_roster(room, filtered, "offline");
|
|
||||||
|
|
||||||
// show specific status
|
|
||||||
} else {
|
} else {
|
||||||
GList *filtered = NULL;
|
_who_room(presence);
|
||||||
|
|
||||||
while (list != NULL) {
|
|
||||||
PContact contact = list->data;
|
|
||||||
if (strcmp(p_contact_presence(contact), presence) == 0) {
|
|
||||||
filtered = g_list_append(filtered, contact);
|
|
||||||
}
|
|
||||||
list = g_list_next(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_room_roster(room, filtered, presence);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// not in groupchat window
|
|
||||||
} else {
|
} else {
|
||||||
cons_show("");
|
cons_show("");
|
||||||
GSList *list = NULL;
|
GSList *list = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user