aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@google.com>2010-08-23 11:34:36 +0100
committerWilmer van der Gaast <wilmer@google.com>2010-08-23 11:34:36 +0100
commit1aa74f559af18e06195f34b721d65d69c29fcc0f (patch)
treebd3dbb8bd3e86c1d885e2d3ef245ec6091c31040 /protocols
parent241f9f6d9135048578ad603485740b73402edd8a (diff)
Process incoming XMPP groupchat invites in a saner way: Create a temporary
channel the user can easily /join.
Diffstat (limited to 'protocols')
-rw-r--r--protocols/bee.h2
-rw-r--r--protocols/bee_chat.c8
-rw-r--r--protocols/jabber/message.c16
3 files changed, 19 insertions, 7 deletions
diff --git a/protocols/bee.h b/protocols/bee.h
index 2fd3562e..b99c8de7 100644
--- a/protocols/bee.h
+++ b/protocols/bee.h
@@ -122,6 +122,7 @@ typedef struct bee_ui_funcs
gboolean (*chat_remove_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu );
gboolean (*chat_topic)( bee_t *bee, struct groupchat *c, const char *new, bee_user_t *bu );
gboolean (*chat_name_hint)( bee_t *bee, struct groupchat *c, const char *name );
+ gboolean (*chat_invite)( bee_t *bee, bee_user_t *bu, const char *name, const char *msg );
struct file_transfer* (*ft_in_start)( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size );
gboolean (*ft_out_start)( struct im_connection *ic, struct file_transfer *ft );
@@ -174,5 +175,6 @@ G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *c, const char *handl
G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *c, const char *handle, const char *reason );
G_MODULE_EXPORT int bee_chat_msg( bee_t *bee, struct groupchat *c, const char *msg, int flags );
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 );
#endif /* __BEE_H__ */
diff --git a/protocols/bee_chat.c b/protocols/bee_chat.c
index 3be6f189..0314cae5 100644
--- a/protocols/bee_chat.c
+++ b/protocols/bee_chat.c
@@ -232,3 +232,11 @@ struct groupchat *bee_chat_by_title( bee_t *bee, struct im_connection *ic, const
return NULL;
}
+
+void imcb_chat_invite( struct im_connection *ic, const char *name, const char *who, const char *msg )
+{
+ bee_user_t *bu = bee_user_by_handle( ic->bee, ic, who );
+
+ if( bu && ic->bee->ui->chat_invite )
+ ic->bee->ui->chat_invite( ic->bee, bu, name, msg );
+}
diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c
index ce5017fb..6e40e521 100644
--- a/protocols/jabber/message.c
+++ b/protocols/jabber/message.c
@@ -30,7 +30,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
char *type = xt_find_attr( node, "type" );
struct xt_node *body = xt_find_node( node->children, "body" ), *c;
struct jabber_buddy *bud = NULL;
- char *s;
+ char *s, *room = NULL, *reason = NULL;
if( !from )
return XT_HANDLED; /* Consider this packet corrupted. */
@@ -51,19 +51,19 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
for( c = node->children; ( c = xt_find_node( c, "x" ) ); c = c->next )
{
- char *ns = xt_find_attr( c, "xmlns" ), *room;
- struct xt_node *inv, *reason;
+ char *ns = xt_find_attr( c, "xmlns" );
+ struct xt_node *inv;
if( ns && strcmp( ns, XMLNS_MUC_USER ) == 0 &&
( inv = xt_find_node( c->children, "invite" ) ) )
{
+ /* This is an invitation. Set some vars which
+ will be passed to imcb_chat_invite() below. */
room = from;
if( ( from = xt_find_attr( inv, "from" ) ) == NULL )
from = room;
-
- g_string_append_printf( fullmsg, "<< \002BitlBee\002 - Invitation to chatroom %s >>\n", room );
- if( ( reason = xt_find_node( inv->children, "reason" ) ) && reason->text_len > 0 )
- g_string_append( fullmsg, reason->text );
+ if( ( inv = xt_find_node( inv->children, "reason" ) ) && inv->text_len > 0 )
+ reason = inv->text;
}
}
@@ -103,6 +103,8 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
if( fullmsg->len > 0 )
imcb_buddy_msg( ic, from, fullmsg->str,
0, jabber_get_timestamp( node ) );
+ if( room )
+ imcb_chat_invite( ic, room, from, reason );
g_string_free( fullmsg, TRUE );