diff options
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 20 | ||||
-rw-r--r-- | src/command/commands.c | 117 |
2 files changed, 62 insertions, 75 deletions
diff --git a/src/command/command.c b/src/command/command.c index b579fdcf..bea6cbcd 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -307,12 +307,13 @@ static struct cmd_t command_defs[] = { "/room", cmd_room, parse_args, 1, 1, NULL, - { "/room accept|destroy|config", "Room configuration.", - { "/room accept|destroy|config", - "---------------------------", + { "/room accept|destroy|config|info", "Room configuration.", + { "/room accept|destroy|config|info", + "--------------------------------", "accept - Accept default room configuration.", "destroy - Reject default room configuration.", "config - Edit room configuration.", + "info - Show room details.", NULL } } }, { "/form", @@ -1226,6 +1227,7 @@ cmd_init(void) autocomplete_add(room_ac, "accept"); autocomplete_add(room_ac, "destroy"); autocomplete_add(room_ac, "config"); + autocomplete_add(room_ac, "info"); form_ac = autocomplete_new(); autocomplete_add(form_ac, "submit"); @@ -1257,9 +1259,7 @@ cmd_uninit(void) autocomplete_free(autoaway_mode_ac); autocomplete_free(autoconnect_ac); autocomplete_free(theme_ac); - if (theme_load_ac != NULL) { - autocomplete_free(theme_load_ac); - } + autocomplete_free(theme_load_ac); autocomplete_free(account_ac); autocomplete_free(account_set_ac); autocomplete_free(account_clear_ac); @@ -1356,7 +1356,7 @@ void cmd_reset_autocomplete() { roster_reset_search_attempts(); - muc_reset_invites_ac(); + muc_invites_reset_ac(); accounts_reset_all_search(); accounts_reset_enabled_search(); prefs_reset_boolean_choice(); @@ -1370,7 +1370,7 @@ cmd_reset_autocomplete() if (ui_current_win_type() == WIN_MUC) { char *recipient = ui_current_recipient(); - muc_reset_autocomplete(recipient); + muc_autocomplete_reset(recipient); } autocomplete_reset(who_ac); @@ -1605,7 +1605,7 @@ _cmd_complete_parameters(char *input, int *size) // autocomplete nickname in chat rooms if (ui_current_win_type() == WIN_MUC) { char *recipient = ui_current_recipient(); - Autocomplete nick_ac = muc_get_roster_ac(recipient); + Autocomplete nick_ac = muc_roster_ac(recipient); if (nick_ac != NULL) { gchar *nick_choices[] = { "/msg", "/info", "/caps", "/status", "/software" } ; @@ -1655,7 +1655,7 @@ _cmd_complete_parameters(char *input, int *size) gchar *invite_choices[] = { "/decline", "/join" }; for (i = 0; i < ARRAY_SIZE(invite_choices); i++) { result = autocomplete_param_with_func(input, size, invite_choices[i], - muc_find_invite); + muc_invites_find); if (result != NULL) { ui_replace_input(input, result, size); g_free(result); diff --git a/src/command/commands.c b/src/command/commands.c index 045ad00a..2b8a0d2c 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -476,7 +476,7 @@ cmd_disconnect(gchar **args, struct cmd_help_t help) cons_show("%s logged out successfully.", jid); jabber_disconnect(); roster_clear(); - muc_clear_invites(); + muc_invites_clear(); chat_sessions_clear(); ui_disconnected(); free(jid); @@ -726,7 +726,7 @@ static void _who_room(const char * const presence) { char *room = ui_current_recipient(); - GList *list = muc_get_roster(room); + GList *list = muc_roster(room); // no arg, show all contacts if ((presence == NULL) || (g_strcmp0(presence, "any") == 0)) { @@ -737,9 +737,9 @@ _who_room(const char * const presence) GList *filtered = NULL; while (list != NULL) { - PContact contact = list->data; - if (p_contact_is_available(contact)) { - filtered = g_list_append(filtered, contact); + Occupant *occupant = list->data; + if (muc_occupant_available(occupant)) { + filtered = g_list_append(filtered, occupant); } list = g_list_next(list); } @@ -751,51 +751,24 @@ _who_room(const char * const presence) GList *filtered = NULL; while (list != NULL) { - PContact contact = list->data; - if (!p_contact_is_available(contact)) { - filtered = g_list_append(filtered, contact); + Occupant *occupant = list->data; + if (!muc_occupant_available(occupant)) { + filtered = g_list_append(filtered, occupant); } 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); + Occupant *occupant = list->data; + const char *presence_str = string_from_resource_presence(occupant->presence); + if (strcmp(presence_str, presence) == 0) { + filtered = g_list_append(filtered, occupant); } list = g_list_next(list); } @@ -1048,7 +1021,7 @@ cmd_msg(gchar **args, struct cmd_help_t help) if (win_type == WIN_MUC) { char *room_name = ui_current_recipient(); - if (muc_nick_in_roster(room_name, usr)) { + if (muc_roster_contains_nick(room_name, usr)) { GString *full_jid = g_string_new(room_name); g_string_append(full_jid, "/"); g_string_append(full_jid, usr); @@ -1464,6 +1437,7 @@ cmd_info(gchar **args, struct cmd_help_t help) jabber_conn_status_t conn_status = jabber_get_connection_status(); win_type_t win_type = ui_current_win_type(); PContact pcontact = NULL; + Occupant *occupant = NULL; if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); @@ -1473,28 +1447,34 @@ cmd_info(gchar **args, struct cmd_help_t help) switch (win_type) { case WIN_MUC: - if (usr != NULL) { - ui_info_room(usr); + if (usr) { + char *room = ui_current_recipient(); + occupant = muc_roster_item(room, usr); + if (occupant) { + ui_info_room(room, occupant); + } else { + ui_current_print_line("No such occupant \"%s\" in room.", usr); + } } else { ui_current_print_line("You must specify a nickname."); } break; case WIN_CHAT: - if (usr != NULL) { + if (usr) { ui_current_print_line("No parameter required when in chat."); } else { ui_info(); } break; case WIN_PRIVATE: - if (usr != NULL) { + if (usr) { ui_current_print_line("No parameter required when in chat."); } else { ui_info_private(); } break; case WIN_CONSOLE: - if (usr != NULL) { + if (usr) { char *usr_jid = roster_barejid_from_name(usr); if (usr_jid == NULL) { usr_jid = usr; @@ -1522,6 +1502,7 @@ cmd_caps(gchar **args, struct cmd_help_t help) jabber_conn_status_t conn_status = jabber_get_connection_status(); win_type_t win_type = ui_current_win_type(); PContact pcontact = NULL; + Occupant *occupant = NULL; if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); @@ -1533,11 +1514,10 @@ cmd_caps(gchar **args, struct cmd_help_t help) case WIN_MUC: if (args[0] != NULL) { char *room = ui_current_recipient(); - pcontact = muc_get_participant(room, args[0]); - if (pcontact != NULL) { + occupant = muc_roster_item(room, args[0]); + if (occupant) { Jid *jidp = jid_create_from_bare_and_resource(room, args[0]); - Resource *resource = p_contact_get_resource(pcontact, args[0]); - cons_show_caps(jidp->fulljid, resource); + cons_show_caps(jidp->fulljid, occupant->presence); jid_destroy(jidp); } else { cons_show("No such participant \"%s\" in room.", args[0]); @@ -1562,7 +1542,7 @@ cmd_caps(gchar **args, struct cmd_help_t help) if (resource == NULL) { cons_show("Could not find resource %s, for contact %s", jid->barejid, jid->resourcepart); } else { - cons_show_caps(jid->fulljid, resource); + cons_show_caps(jid->fulljid, resource->presence); } } } @@ -1578,9 +1558,8 @@ cmd_caps(gchar **args, struct cmd_help_t help) char *recipient = ui_current_recipient(); Jid *jid = jid_create(recipient); if (jid) { - pcontact = muc_get_participant(jid->barejid, jid->resourcepart); - Resource *resource = p_contact_get_resource(pcontact, jid->resourcepart); - cons_show_caps(jid->resourcepart, resource); + occupant = muc_roster_item(jid->barejid, jid->resourcepart); + cons_show_caps(jid->resourcepart, occupant->presence); jid_destroy(jid); } } @@ -1598,7 +1577,7 @@ cmd_software(gchar **args, struct cmd_help_t help) { jabber_conn_status_t conn_status = jabber_get_connection_status(); win_type_t win_type = ui_current_win_type(); - PContact pcontact = NULL; + Occupant *occupant = NULL; char *recipient; if (conn_status != JABBER_CONNECTED) { @@ -1611,8 +1590,8 @@ cmd_software(gchar **args, struct cmd_help_t help) case WIN_MUC: if (args[0] != NULL) { recipient = ui_current_recipient(); - pcontact = muc_get_participant(recipient, args[0]); - if (pcontact != NULL) { + occupant = muc_roster_item(recipient, args[0]); + if (occupant) { Jid *jid = jid_create_from_bare_and_resource(recipient, args[0]); iq_send_software_version(jid->fulljid); jid_destroy(jid); @@ -1715,10 +1694,10 @@ cmd_join(gchar **args, struct cmd_help_t help) nick = account->muc_nick; } - if (!muc_room_is_active(room)) { + if (!muc_active(room)) { presence_join_room(room, nick, passwd); - muc_join_room(room, nick, passwd, FALSE); - } else if (muc_get_roster_received(room)) { + muc_join(room, nick, passwd, FALSE); + } else if (muc_roster_complete(room)) { ui_room_join(room, TRUE); } @@ -1767,7 +1746,7 @@ cmd_invite(gchar **args, struct cmd_help_t help) gboolean cmd_invites(gchar **args, struct cmd_help_t help) { - GSList *invites = muc_get_invites(); + GSList *invites = muc_invites(); cons_show_room_invites(invites); g_slist_free_full(invites, g_free); return TRUE; @@ -1776,10 +1755,10 @@ cmd_invites(gchar **args, struct cmd_help_t help) gboolean cmd_decline(gchar **args, struct cmd_help_t help) { - if (!muc_invites_include(args[0])) { + if (!muc_invites_contain(args[0])) { cons_show("No such invite exists."); } else { - muc_remove_invite(args[0]); + muc_invites_remove(args[0]); cons_show("Declined invite to %s.", args[0]); } @@ -2083,7 +2062,8 @@ cmd_room(gchar **args, struct cmd_help_t help) if ((g_strcmp0(args[0], "accept") != 0) && (g_strcmp0(args[0], "destroy") != 0) && - (g_strcmp0(args[0], "config") != 0)) { + (g_strcmp0(args[0], "config") != 0) && + (g_strcmp0(args[0], "info") != 0)) { cons_show("Usage: %s", help.usage); return TRUE; } @@ -2097,6 +2077,13 @@ cmd_room(gchar **args, struct cmd_help_t help) ui_index = 0; } + if (g_strcmp0(args[0], "info") == 0) { + char *role = muc_role_str(room); + char *affiliation = muc_affiliation_str(room); + ui_current_print_line("Affiliation: %s, Role: %s", affiliation, role); + return TRUE; + } + if (g_strcmp0(args[0], "accept") == 0) { gboolean requires_config = muc_requires_config(room); if (!requires_config) { @@ -2171,8 +2158,8 @@ cmd_bookmark(gchar **args, struct cmd_help_t help) // default to current nickname, password, and autojoin "on" if (cmd == NULL) { char *jid = ui_current_recipient(); - char *nick = muc_get_room_nick(jid); - char *password = muc_get_room_password(jid); + char *nick = muc_nick(jid); + char *password = muc_password(jid); gboolean added = bookmark_add(jid, nick, password, "on"); if (added) { ui_current_print_formatted_line('!', 0, "Bookmark added for %s.", jid); |