aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
authorjgeboski <jgeboski@gmail.com>2016-06-22 14:54:52 -0400
committerMarius Halden <marius.h@lden.org>2016-07-13 09:31:51 +0200
commite6314bd1c75979f6ec71cd1301239bccca7618a4 (patch)
tree73c3942f2eb2db2dc7bdd445cb1d4017e9447b24 /protocols
parentd9eec2027b7b6c848db465c9b17f72f70864bb25 (diff)
Added an interface for the listing of existing chatrooms
Several protocols can provide a list of existing chatrooms that a user is able join. This is crucial for the usage of several protocols, most notably Purple and Facebook. Plugins wishing to support this extended functionality must implement the new prpl->chat_list() function. This implemented function will in most cases send a remote request for the list of chatrooms. Once the list of chatrooms is obtained, a bee_chat_info_t GSList must be created and assigned to the im_connection->chatlist field. Then a call to the bee_chat_list_finish() is needed to display the list to the user. The chat list is maintained entirely by the plugin, so it is important to ensure all pointers related to the chat list remain valid until the chat list is set to NULL. This list is used internally by bitlbee to calculate indexes, which then allows the user to join a chat with an index, rather than some random identifier. It also important to ensure the list is properly freed whenever it is updated, or when the account is disconnect via the prpl->logout() function. On the user interface side of things, the 'chat list' subcommand was recommissioned. For a user to list the existing chat rooms: chat list <account id> Afterwards a user can join a chatroom in the list with its index. This extends the functionality of the 'chat add' subcommand by adding in support for the exclamation point operator to denote an index. chat add <account id> !<index> [channel]
Diffstat (limited to 'protocols')
-rw-r--r--protocols/bee.h10
-rw-r--r--protocols/bee_chat.c5
-rw-r--r--protocols/nogaim.h8
3 files changed, 23 insertions, 0 deletions
diff --git a/protocols/bee.h b/protocols/bee.h
index d22e4d85..8e665ac8 100644
--- a/protocols/bee.h
+++ b/protocols/bee.h
@@ -83,6 +83,14 @@ typedef struct bee_user {
void *data; /* Can be used by the IM module. */
} bee_user_t;
+typedef struct bee_chat_info {
+ char *title;
+ char *topic;
+
+ /* If less than zero, the user count is ignored when displaying */
+ int userc;
+} bee_chat_info_t;
+
/* This one's mostly used so save space and make it easier (cheaper) to
compare groups of contacts, etc. */
typedef struct bee_group {
@@ -184,4 +192,6 @@ G_MODULE_EXPORT int bee_chat_msg(bee_t *bee, struct groupchat *c, const char *ms
G_MODULE_EXPORT struct groupchat *bee_chat_by_title(bee_t *bee, struct im_connection *ic, const char *title);
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__ */
diff --git a/protocols/bee_chat.c b/protocols/bee_chat.c
index 2fcb0396..76ed7f85 100644
--- a/protocols/bee_chat.c
+++ b/protocols/bee_chat.c
@@ -273,3 +273,8 @@ void imcb_chat_invite(struct im_connection *ic, const char *name, const char *wh
ic->bee->ui->chat_invite(ic->bee, bu, name, msg);
}
}
+
+void bee_chat_list_finish(struct im_connection *ic)
+{
+ cmd_chat_list_finish(ic);
+}
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index e5569313..b2ae2cae 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -95,6 +95,7 @@ struct im_connection {
bee_t *bee;
GSList *groupchats;
+ GSList *chatlist;
};
struct groupchat {
@@ -262,6 +263,13 @@ struct prpl {
/* If null, equivalent to handle_cmp( ic->acc->user, who ) */
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;
void *resv2;