aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-07-24 16:06:22 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2010-07-24 16:06:22 +0200
commit03f38289e15c27b93f8fdecf22a03353e4d01096 (patch)
tree500a849a6e92779ab5386bff0fa0b169487d073b
parentc8791f25459aeb32f770c46bd3a3613c9fd2d0e2 (diff)
Adding protocol-specific chatroom settings. First one to use this: AIM
chatrooms to use exchange numbers other than 4.
-rw-r--r--irc_im.c11
-rw-r--r--protocols/jabber/jabber.c2
-rw-r--r--protocols/nogaim.h15
-rw-r--r--protocols/oscar/oscar.c29
4 files changed, 48 insertions, 9 deletions
diff --git a/irc_im.c b/irc_im.c
index 8a10cede..4dbcddce 100644
--- a/irc_im.c
+++ b/irc_im.c
@@ -692,7 +692,7 @@ static gboolean bee_irc_channel_chat_join( irc_channel_t *ic )
nick = ic->irc->user->nick;
ic->flags |= IRC_CHANNEL_CHAT_PICKME;
- acc->prpl->chat_join( acc->ic, room, nick, NULL );
+ acc->prpl->chat_join( acc->ic, room, nick, NULL, &ic->set );
ic->flags &= ~IRC_CHANNEL_CHAT_PICKME;
return FALSE;
@@ -787,7 +787,7 @@ static gboolean bee_irc_channel_init( irc_channel_t *ic )
static char *set_eval_room_account( set_t *set, char *value )
{
struct irc_channel *ic = set->data;
- account_t *acc;
+ account_t *acc, *oa;
if( !( acc = account_get( ic->irc->b, value ) ) )
return SET_INVALID;
@@ -797,6 +797,13 @@ static char *set_eval_room_account( set_t *set, char *value )
return SET_INVALID;
}
+ if( set->value && ( oa = account_get( ic->irc->b, set->value ) ) &&
+ oa->prpl->chat_free_settings )
+ oa->prpl->chat_free_settings( oa, &ic->set );
+
+ if( acc->prpl->chat_add_settings )
+ acc->prpl->chat_add_settings( acc, &ic->set );
+
return g_strdup_printf( "%s(%s)", acc->prpl->name, acc->user );
}
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index 7147a628..01353f8e 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -440,7 +440,7 @@ static void jabber_remove_buddy( struct im_connection *ic, char *who, char *grou
presence_send_request( ic, who, "unsubscribe" );
}
-static struct groupchat *jabber_chat_join_( struct im_connection *ic, const char *room, const char *nick, const char *password )
+static struct groupchat *jabber_chat_join_( struct im_connection *ic, const char *room, const char *nick, const char *password, set_t **sets )
{
if( strchr( room, '@' ) == NULL )
imcb_error( ic, "Invalid room name: %s", room );
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index 1d9ac71e..46f6535a 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -211,13 +211,19 @@ struct prpl {
* your protocol does not support publicly named group chats, then do
* not implement this. */
struct groupchat *
- (* chat_join) (struct im_connection *, const char *room, const char *nick, const char *password);
+ (* chat_join) (struct im_connection *, const char *room,
+ const char *nick, const char *password, set_t **sets);
/* Change the topic, if supported. Note that BitlBee expects the IM
server to confirm the topic change with a regular topic change
event. If it doesn't do that, you have to fake it to make it
visible to the user. */
void (* chat_topic) (struct groupchat *, char *topic);
+ /* If your protocol module needs any special info for joining chatrooms
+ other than a roomname + nickname, add them here. */
+ void (* chat_add_settings) (account_t *acc, set_t **head);
+ void (* chat_free_settings) (account_t *acc, set_t **head);
+
/* You can tell what away states your protocol supports, so that
* BitlBee will try to map the IRC away reasons to them. If your
* protocol doesn't have any, just return one generic "Away". */
@@ -233,6 +239,13 @@ struct prpl {
/* Incoming transfer request */
void (* transfer_request) (struct im_connection *, file_transfer_t *ft, char *handle );
+
+ /* Some placeholders so eventually older plugins may cooperate with newer BitlBees. */
+ void *resv1;
+ void *resv2;
+ void *resv3;
+ void *resv4;
+ void *resv5;
};
/* im_api core stuff. */
diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c
index 11539852..fdf0d82c 100644
--- a/protocols/oscar/oscar.c
+++ b/protocols/oscar/oscar.c
@@ -2505,7 +2505,8 @@ void oscar_chat_leave(struct groupchat *c)
oscar_chat_kill(c->ic, c->data);
}
-struct groupchat *oscar_chat_join(struct im_connection * ic, const char * room, const char * nick, const char * password )
+struct groupchat *oscar_chat_join_internal(struct im_connection *ic, const char *room,
+ const char *nick, const char *password, int exchange_number)
{
struct oscar_data * od = (struct oscar_data *)ic->proto_data;
aim_conn_t * cur;
@@ -2513,13 +2514,13 @@ struct groupchat *oscar_chat_join(struct im_connection * ic, const char * room,
if((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) {
int st;
- st = aim_chatnav_createroom(od->sess, cur, room, 4);
+ st = aim_chatnav_createroom(od->sess, cur, room, exchange_number);
return NULL;
} else {
struct create_room * cr = g_new0(struct create_room, 1);
- cr->exchange = 4;
+ cr->exchange = exchange_number;
cr->name = g_strdup(room);
od->create_rooms = g_slist_append(od->create_rooms, cr);
aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV);
@@ -2528,6 +2529,12 @@ struct groupchat *oscar_chat_join(struct im_connection * ic, const char * room,
}
}
+struct groupchat *oscar_chat_join(struct im_connection *ic, const char *room,
+ const char *nick, const char *password, set_t **sets)
+{
+ return oscar_chat_join_internal(ic, room, nick, password, set_getint(sets, "exchange_number"));
+}
+
struct groupchat *oscar_chat_with(struct im_connection * ic, char *who)
{
struct oscar_data * od = (struct oscar_data *)ic->proto_data;
@@ -2544,7 +2551,7 @@ struct groupchat *oscar_chat_with(struct im_connection * ic, char *who)
*s = '0';
c = imcb_chat_new(ic, chatname);
- ret = oscar_chat_join(ic, chatname, NULL, NULL);
+ ret = oscar_chat_join_internal(ic, chatname, NULL, NULL, 4);
aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0);
g_free(chatname);
@@ -2556,7 +2563,7 @@ void oscar_accept_chat(void *data)
{
struct aim_chat_invitation * inv = data;
- oscar_chat_join(inv->ic, inv->name, NULL, NULL);
+ oscar_chat_join_internal(inv->ic, inv->name, NULL, NULL, 4);
g_free(inv->name);
g_free(inv);
}
@@ -2569,6 +2576,16 @@ void oscar_reject_chat(void *data)
g_free(inv);
}
+void oscar_chat_add_settings(account_t *acc, set_t **head)
+{
+ set_add(head, "exchange_number", "4", set_eval_int, NULL);
+}
+
+void oscar_chat_free_settings(account_t *acc, set_t **head)
+{
+ set_del(head, "exchange_number");
+}
+
void oscar_initmodule()
{
struct prpl *ret = g_new0(struct prpl, 1);
@@ -2589,6 +2606,8 @@ void oscar_initmodule()
ret->chat_leave = oscar_chat_leave;
ret->chat_with = oscar_chat_with;
ret->chat_join = oscar_chat_join;
+ ret->chat_add_settings = oscar_chat_add_settings;
+ ret->chat_free_settings = oscar_chat_free_settings;
ret->add_permit = oscar_add_permit;
ret->add_deny = oscar_add_deny;
ret->rem_permit = oscar_rem_permit;