aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/jabber')
-rw-r--r--protocols/jabber/iq.c4
-rw-r--r--protocols/jabber/jabber.c7
-rw-r--r--protocols/jabber/jabber.h1
-rw-r--r--protocols/jabber/jabber_util.c26
-rw-r--r--protocols/jabber/message.c2
5 files changed, 36 insertions, 4 deletions
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c
index 95b21e1e..68777b0b 100644
--- a/protocols/jabber/iq.c
+++ b/protocols/jabber/iq.c
@@ -64,7 +64,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
/* Of course this is a very essential query to support. ;-) */
if( strcmp( s, XMLNS_VERSION ) == 0 )
{
- xt_add_child( reply, xt_new_node( "name", "BitlBee", NULL ) );
+ xt_add_child( reply, xt_new_node( "name", set_getstr( &ic->acc->set, "user_agent" ), NULL ) );
xt_add_child( reply, xt_new_node( "version", BITLBEE_VERSION, NULL ) );
xt_add_child( reply, xt_new_node( "os", ARCH, NULL ) );
}
@@ -104,7 +104,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
c = xt_new_node( "identity", NULL, NULL );
xt_add_attr( c, "category", "client" );
xt_add_attr( c, "type", "pc" );
- xt_add_attr( c, "name", "BitlBee" );
+ xt_add_attr( c, "name", set_getstr( &ic->acc->set, "user_agent" ) );
xt_add_child( reply, c );
for( f = features; *f; f ++ )
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index 2841c0db..5cc00c9f 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -79,6 +79,8 @@ static void jabber_init( account_t *acc )
s = set_add( &acc->set, "tls", "try", set_eval_tls, acc );
s->flags |= ACC_SET_OFFLINE_ONLY;
+ s = set_add( &acc->set, "user_agent", "BitlBee", NULL, acc );
+
s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc );
s->flags |= ACC_SET_OFFLINE_ONLY;
@@ -285,6 +287,8 @@ static void jabber_logout( struct im_connection *ic )
if( jd->node_cache )
g_hash_table_destroy( jd->node_cache );
+ jabber_buddy_remove_all( ic );
+
xt_free( jd->xt );
g_free( jd->away_message );
@@ -469,7 +473,8 @@ static void jabber_chat_invite_( struct groupchat *c, char *who, char *msg )
static void jabber_keepalive( struct im_connection *ic )
{
/* Just any whitespace character is enough as a keepalive for XMPP sessions. */
- jabber_write( ic, "\n", 1 );
+ if( !jabber_write( ic, "\n", 1 ) )
+ return;
/* This runs the garbage collection every minute, which means every packet
is in the cache for about a minute (which should be enough AFAIK). */
diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h
index 40cf3957..3f4144b8 100644
--- a/protocols/jabber/jabber.h
+++ b/protocols/jabber/jabber.h
@@ -229,6 +229,7 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid, g
struct jabber_buddy *jabber_buddy_by_ext_jid( struct im_connection *ic, char *jid, get_buddy_flags_t flags );
int jabber_buddy_remove( struct im_connection *ic, char *full_jid );
int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid );
+void jabber_buddy_remove_all( struct im_connection *ic );
time_t jabber_get_timestamp( struct xt_node *xt );
struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns );
void jabber_error_free( struct jabber_error *err );
diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c
index b8b625f7..651b7068 100644
--- a/protocols/jabber/jabber_util.c
+++ b/protocols/jabber/jabber_util.c
@@ -664,6 +664,32 @@ int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid )
}
}
+static gboolean jabber_buddy_remove_all_cb( gpointer key, gpointer value, gpointer data )
+{
+ struct jabber_buddy *bud, *next;
+
+ bud = value;
+ while( bud )
+ {
+ next = bud->next;
+ g_free( bud->ext_jid );
+ g_free( bud->full_jid );
+ g_free( bud->away_message );
+ g_free( bud );
+ bud = next;
+ }
+
+ return TRUE;
+}
+
+void jabber_buddy_remove_all( struct im_connection *ic )
+{
+ struct jabber_data *jd = ic->proto_data;
+
+ g_hash_table_foreach_remove( jd->buddies, jabber_buddy_remove_all_cb, NULL );
+ g_hash_table_destroy( jd->buddies );
+}
+
time_t jabber_get_timestamp( struct xt_node *xt )
{
struct xt_node *c;
diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c
index e8161029..fa915bd8 100644
--- a/protocols/jabber/message.c
+++ b/protocols/jabber/message.c
@@ -54,7 +54,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
char *ns = xt_find_attr( c, "xmlns" ), *room;
struct xt_node *inv, *reason;
- if( strcmp( ns, XMLNS_MUC_USER ) == 0 &&
+ if( ns && strcmp( ns, XMLNS_MUC_USER ) == 0 &&
( inv = xt_find_node( c->children, "invite" ) ) )
{
room = from;