aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber/conference.c
diff options
context:
space:
mode:
authorulim <a.sporto+bee@gmail.com>2007-12-04 02:08:43 +0100
committerulim <a.sporto+bee@gmail.com>2007-12-04 02:08:43 +0100
commit08135dff0e668622fc858d2ad8a7d0bdbdb8cb24 (patch)
treed46ae0a920d1db0a9f710cb916657ae549db31cb /protocols/jabber/conference.c
parentfa30fa598d2e77c998f9156d0f31ccf99b0c781f (diff)
parentaaf92a9eb64327892e39fdbd7113d797d1d68cec (diff)
Merged in current devel
Wilmer van der Gaast 2007-12-02 Imported setuid() patch from Simo Leone <simo@archlinux...> with some Wilmer van der Gaast 2007-12-02 Forgot to return something in jabber_chat_join_failed(). Wilmer van der Gaast 2007-12-02 Merging a change I should've pulled before committing three other changes. Wilmer van der Gaast 2007-12-02 Added charset checks on incoming msgs (from the IRC side) to prevent possible Wilmer van der Gaast 2007-12-02 Handling of presence-error packets (only useful for groupchats now), moved Wilmer van der Gaast 2007-12-02 Defining DEBUG via CFLAGS so that it'll always be there, even when a file Wilmer van der Gaast 2007-12-02 Removed retarded printf() (ARGH) and moved the event handling handling of Wilmer van der Gaast 2007-11-29 printf() in daemons considered harmful. Wilmer van der Gaast 2007-11-28 Fixed the epoll+ForkDaemon combination. The libevent event handling
Diffstat (limited to 'protocols/jabber/conference.c')
-rw-r--r--protocols/jabber/conference.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c
index 008bbe63..c5bc0e68 100644
--- a/protocols/jabber/conference.c
+++ b/protocols/jabber/conference.c
@@ -23,6 +23,8 @@
#include "jabber.h"
+static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
+
struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password )
{
struct jabber_chat *jc;
@@ -34,14 +36,13 @@ struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *
node = xt_new_node( "x", NULL, NULL );
xt_add_attr( node, "xmlns", XMLNS_MUC );
node = jabber_make_packet( "presence", NULL, roomjid, node );
+ jabber_cache_add( ic, node, jabber_chat_join_failed );
if( !jabber_write_packet( ic, node ) )
{
g_free( roomjid );
- xt_free_node( node );
return NULL;
}
- xt_free_node( node );
jc = g_new0( struct jabber_chat, 1 );
jc->name = jabber_normalize( room );
@@ -64,6 +65,45 @@ struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *
return c;
}
+static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
+{
+ struct jabber_error *err;
+ struct jabber_buddy *bud;
+ char *room;
+
+ room = xt_find_attr( orig, "to" );
+ if( ( bud = jabber_buddy_by_jid( ic, room, 0 ) ) )
+ jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) );
+
+ err = jabber_error_parse( xt_find_node( node->children, "error" ), XMLNS_STANZA_ERROR );
+ if( err )
+ {
+ imcb_error( ic, "Error joining groupchat %s: %s%s%s",
+ bud->bare_jid, err->code, err->text ? ": " : "",
+ err->text ? err->text : "" );
+ jabber_error_free( err );
+ }
+
+ return XT_HANDLED;
+}
+
+struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name )
+{
+ char *normalized = jabber_normalize( name );
+ struct groupchat *ret;
+ struct jabber_chat *jc;
+
+ for( ret = ic->groupchats; ret; ret = ret->next )
+ {
+ jc = ret->data;
+ if( strcmp( normalized, jc->name ) == 0 )
+ break;
+ }
+ g_free( normalized );
+
+ return ret;
+}
+
void jabber_chat_free( struct groupchat *c )
{
struct jabber_chat *jc = c->data;
@@ -147,7 +187,7 @@ void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bu
struct jabber_chat *jc;
char *s;
- if( ( chat = jabber_chat_by_name( ic, bud->bare_jid ) ) == NULL )
+ if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) ) == NULL )
{
/* How could this happen?? We could do kill( self, 11 )
now or just wait for the OS to do it. :-) */
@@ -249,7 +289,7 @@ void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud
return;
}
- else if( ( chat = jabber_chat_by_name( ic, bud->bare_jid ) ) == NULL )
+ else if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) ) == NULL )
{
/* How could this happen?? We could do kill( self, 11 )
now or just wait for the OS to do it. :-) */