diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2007-11-19 23:14:39 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2007-11-19 23:14:39 +0000 |
commit | ef5c1855b406e462fb8b90b517f1672a47bcc4b5 (patch) | |
tree | b66355c56985c10f0c7201db45d99152de02921b /protocols/jabber | |
parent | 50e1776cb0c76b3328d458dd8a1bfb379b6b0e43 (diff) |
Added Jabber groupchat topic support.
Diffstat (limited to 'protocols/jabber')
-rw-r--r-- | protocols/jabber/conference.c | 28 | ||||
-rw-r--r-- | protocols/jabber/jabber.c | 7 | ||||
-rw-r--r-- | protocols/jabber/jabber.h | 1 | ||||
-rw-r--r-- | protocols/jabber/sasl.c | 2 |
4 files changed, 37 insertions, 1 deletions
diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index 3fc9ee70..008bbe63 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -96,6 +96,25 @@ int jabber_chat_msg( struct groupchat *c, char *message, int flags ) return 1; } +int jabber_chat_topic( struct groupchat *c, char *topic ) +{ + struct im_connection *ic = c->ic; + struct jabber_chat *jc = c->data; + struct xt_node *node; + + node = xt_new_node( "subject", topic, NULL ); + node = jabber_make_packet( "message", "groupchat", jc->name, node ); + + if( !jabber_write_packet( ic, node ) ) + { + xt_free_node( node ); + return 0; + } + xt_free_node( node ); + + return 1; +} + int jabber_chat_leave( struct groupchat *c, const char *reason ) { struct im_connection *ic = c->ic; @@ -213,6 +232,7 @@ void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bu void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ) { + struct xt_node *subject = xt_find_node( node->children, "subject" ); struct xt_node *body = xt_find_node( node->children, "body" ); struct groupchat *chat; char *s; @@ -236,6 +256,14 @@ void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud return; } + if( subject ) + { + s = strchr( bud->ext_jid, '/' ); + if( s ) *s = 0; + imcb_chat_topic( chat, bud->ext_jid, subject->text_len > 0 ? + subject->text : NULL, jabber_get_timestamp( node ) ); + if( s ) *s = '/'; + } if( body && body->text_len > 0 ) { s = strchr( bud->ext_jid, '/' ); diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index ab26efc9..e7be63fd 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -384,6 +384,12 @@ static void jabber_chat_msg_( struct groupchat *c, char *message, int flags ) jabber_chat_msg( c, message, flags ); } +static void jabber_chat_topic_( struct groupchat *c, char *topic ) +{ + if( c && topic ) + jabber_chat_topic( c, topic ); +} + static void jabber_chat_leave_( struct groupchat *c ) { if( c ) @@ -460,6 +466,7 @@ void jabber_initmodule() ret->add_buddy = jabber_add_buddy; ret->remove_buddy = jabber_remove_buddy; ret->chat_msg = jabber_chat_msg_; + ret->chat_topic = jabber_chat_topic_; // ret->chat_invite = jabber_chat_invite; ret->chat_leave = jabber_chat_leave_; ret->chat_join = jabber_chat_join_; diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 7af7f98e..e26c3899 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -228,6 +228,7 @@ gboolean sasl_supported( struct im_connection *ic ); struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password ); void jabber_chat_free( struct groupchat *c ); int jabber_chat_msg( struct groupchat *ic, char *message, int flags ); +int jabber_chat_topic( struct groupchat *c, char *topic ); int jabber_chat_leave( struct groupchat *c, const char *reason ); void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); diff --git a/protocols/jabber/sasl.c b/protocols/jabber/sasl.c index 6eee37b3..87059051 100644 --- a/protocols/jabber/sasl.c +++ b/protocols/jabber/sasl.c @@ -331,5 +331,5 @@ gboolean sasl_supported( struct im_connection *ic ) { struct jabber_data *jd = ic->proto_data; - return ( (void*) ( jd->xt && jd->xt->root && xt_find_attr( jd->xt->root, "version" ) ) ) != NULL; + return ( jd->xt && jd->xt->root && xt_find_attr( jd->xt->root, "version" ) ) != 0; } |