Index: bitlbee.h
===================================================================
--- bitlbee.h (revision 67ea361f9f8b2a197e8e52055e4d779a36a876f5)
+++ bitlbee.h (revision a33ee0fbe4c9b87e38ab46990bba16a7fb362bab)
@@ -173,4 +173,5 @@
gboolean root_command_add(const char *command, int params, void (*func)(irc_t *, char **args), int flags);
gboolean cmd_identify_finish(gpointer data, gint fd, b_input_condition cond);
+void cmd_chat_list_finish(struct im_connection *ic);
gboolean bitlbee_shutdown(gpointer data, gint fd, b_input_condition cond);
Index: doc/user-guide/commands.xml
===================================================================
--- doc/user-guide/commands.xml (revision 67ea361f9f8b2a197e8e52055e4d779a36a876f5)
+++ doc/user-guide/commands.xml (revision a33ee0fbe4c9b87e38ab46990bba16a7fb362bab)
@@ -264,5 +264,5 @@
- chat add <account id> <room> [<channel>]
+ chat add <account id> <room|!index> [<channel>]
@@ -280,4 +280,14 @@
+
+
+
+ chat list <account id> [<server>]
+
+
+
+ List existing chatrooms provided by an account. BitlBee needs this to propogate an internal list of chats. The existing chat can then be added with chat add.
+
+
Index: protocols/bee.h
===================================================================
--- protocols/bee.h (revision 67ea361f9f8b2a197e8e52055e4d779a36a876f5)
+++ protocols/bee.h (revision a33ee0fbe4c9b87e38ab46990bba16a7fb362bab)
@@ -83,4 +83,9 @@
void *data; /* Can be used by the IM module. */
} bee_user_t;
+
+typedef struct bee_chat_info {
+ char *title;
+ char *topic;
+} bee_chat_info_t;
/* This one's mostly used so save space and make it easier (cheaper) to
@@ -185,3 +190,5 @@
G_MODULE_EXPORT void imcb_chat_invite(struct im_connection *ic, const char *name, const char *who, const char *msg);
+G_MODULE_EXPORT void bee_chat_list_finish(struct im_connection *ic);
+
#endif /* __BEE_H__ */
Index: protocols/bee_chat.c
===================================================================
--- protocols/bee_chat.c (revision 67ea361f9f8b2a197e8e52055e4d779a36a876f5)
+++ protocols/bee_chat.c (revision a33ee0fbe4c9b87e38ab46990bba16a7fb362bab)
@@ -274,2 +274,7 @@
}
}
+
+void bee_chat_list_finish(struct im_connection *ic)
+{
+ cmd_chat_list_finish(ic);
+}
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h (revision 67ea361f9f8b2a197e8e52055e4d779a36a876f5)
+++ protocols/nogaim.h (revision a33ee0fbe4c9b87e38ab46990bba16a7fb362bab)
@@ -96,4 +96,5 @@
GSList *groupchats;
+ GSList *chatlist;
};
@@ -263,4 +264,11 @@
gboolean (* handle_is_self) (struct im_connection *, const char *who);
+ /* This sets/updates the im_connection->chatlist field with a
+ * bee_chat_info_t GSList. This function should ensure the
+ * bee_chat_list_finish() function gets called at some point
+ * after the chat list is completely updated.
+ */
+ void (* chat_list) (struct im_connection *, const char *server);
+
/* Some placeholders so eventually older plugins may cooperate with newer BitlBees. */
void *resv1;
Index: root_commands.c
===================================================================
--- root_commands.c (revision 67ea361f9f8b2a197e8e52055e4d779a36a876f5)
+++ root_commands.c (revision a33ee0fbe4c9b87e38ab46990bba16a7fb362bab)
@@ -1218,6 +1218,8 @@
if (g_strcasecmp(cmd[1], "add") == 0) {
- char *channel, *s;
+ bee_chat_info_t *ci;
+ char *channel, *room, *s;
struct irc_channel *ic;
+ guint i;
MIN_ARGS(3);
@@ -1231,6 +1233,25 @@
}
+ if (cmd[3][0] == '!') {
+ if (!acc->prpl->chat_list) {
+ irc_rootmsg(irc, "Listing chatrooms not supported on that account.");
+ return;
+ }
+
+ i = g_ascii_strtoull(cmd[3] + 1, NULL, 10);
+ ci = g_slist_nth_data(acc->ic->chatlist, i - 1);
+
+ if (ci == NULL) {
+ irc_rootmsg(irc, "Invalid chatroom index");
+ return;
+ }
+
+ room = ci->title;
+ } else {
+ room = cmd[3];
+ }
+
if (cmd[4] == NULL) {
- channel = g_strdup(cmd[3]);
+ channel = g_strdup(room);
if ((s = strchr(channel, '@'))) {
*s = 0;
@@ -1252,5 +1273,5 @@
set_setstr(&ic->set, "chat_type", "room") &&
set_setstr(&ic->set, "account", cmd[2]) &&
- set_setstr(&ic->set, "room", cmd[3])) {
+ set_setstr(&ic->set, "room", room)) {
irc_rootmsg(irc, "Chatroom successfully added.");
} else {
@@ -1262,4 +1283,16 @@
}
g_free(channel);
+ } else if (g_strcasecmp(cmd[1], "list") == 0) {
+ MIN_ARGS(2);
+
+ if (!(acc = account_get(irc->b, cmd[2]))) {
+ irc_rootmsg(irc, "Invalid account");
+ return;
+ } else if (!acc->prpl->chat_list) {
+ irc_rootmsg(irc, "Listing chatrooms not supported on that account.");
+ return;
+ }
+
+ acc->prpl->chat_list(acc->ic, cmd[3]);
} else if (g_strcasecmp(cmd[1], "with") == 0) {
irc_user_t *iu;
@@ -1276,6 +1309,5 @@
irc_rootmsg(irc, "Can't open a groupchat with %s.", cmd[2]);
}
- } else if (g_strcasecmp(cmd[1], "list") == 0 ||
- g_strcasecmp(cmd[1], "set") == 0 ||
+ } else if (g_strcasecmp(cmd[1], "set") == 0 ||
g_strcasecmp(cmd[1], "del") == 0) {
irc_rootmsg(irc,
@@ -1287,4 +1319,37 @@
cmd[1]);
}
+}
+
+void cmd_chat_list_finish(struct im_connection *ic)
+{
+ account_t *acc = ic->acc;
+ bee_chat_info_t *ci;
+ char *hformat, *iformat, *topic;
+ GSList *l;
+ guint i = 0;
+ irc_t *irc = ic->bee->ui_data;
+
+ if (ic->chatlist == NULL) {
+ irc_rootmsg(irc, "No existing chatrooms");
+ return;
+ }
+
+ if (strchr(irc->umode, 'b') != NULL) {
+ hformat = "%s\t%s\t%s";
+ iformat = "%u\t%s\t%s";
+ } else {
+ hformat = "%s %-20s %s";
+ iformat = "%5u %-20.20s %s";
+ }
+
+ irc_rootmsg(irc, hformat, "Index", "Title", "Topic");
+
+ for (l = ic->chatlist; l; l = l->next) {
+ ci = l->data;
+ topic = ci->topic ? ci->topic : "";
+ irc_rootmsg(irc, iformat, ++i, ci->title, topic);
+ }
+
+ irc_rootmsg(irc, "%u %s chatrooms", i, acc->tag);
}