aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber/jabber.c
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/jabber/jabber.c')
-rw-r--r--protocols/jabber/jabber.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index 5cc00c9f..e6f38e26 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -64,6 +64,8 @@ static void jabber_init( account_t *acc )
s->flags |= ACC_SET_OFFLINE_ONLY;
s = set_add( &acc->set, "priority", "0", set_eval_priority, acc );
+
+ s = set_add( &acc->set, "proxy", "<local>;<auto>", NULL, acc );
s = set_add( &acc->set, "resource", "BitlBee", NULL, acc );
s->flags |= ACC_SET_OFFLINE_ONLY;
@@ -93,7 +95,7 @@ static void jabber_login( account_t *acc )
{
struct im_connection *ic = imcb_new( acc );
struct jabber_data *jd = g_new0( struct jabber_data, 1 );
- struct ns_srv_reply *srv = NULL;
+ struct ns_srv_reply **srvl = NULL, *srv = NULL;
char *connect_to, *s;
int i;
@@ -193,9 +195,19 @@ static void jabber_login( account_t *acc )
/* Figure out the hostname to connect to. */
if( acc->server && *acc->server )
connect_to = acc->server;
- else if( ( srv = srv_lookup( "xmpp-client", "tcp", jd->server ) ) ||
- ( srv = srv_lookup( "jabber-client", "tcp", jd->server ) ) )
+ else if( ( srvl = srv_lookup( "xmpp-client", "tcp", jd->server ) ) ||
+ ( srvl = srv_lookup( "jabber-client", "tcp", jd->server ) ) )
+ {
+ /* Find the lowest-priority one. These usually come
+ back in random/shuffled order. Not looking at
+ weights etc for now. */
+ srv = *srvl;
+ for( i = 1; srvl[i]; i ++ )
+ if( srvl[i]->prio < srv->prio )
+ srv = srvl[i];
+
connect_to = srv->name;
+ }
else
connect_to = jd->server;
@@ -224,7 +236,7 @@ static void jabber_login( account_t *acc )
{
jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, ic );
}
- g_free( srv );
+ srv_free( srvl );
if( jd->fd == -1 )
{
@@ -265,11 +277,23 @@ static void jabber_logout( struct im_connection *ic )
{
struct jabber_data *jd = ic->proto_data;
+ while( jd->filetransfers )
+ imcb_file_canceled( ic, ( ( struct jabber_transfer *) jd->filetransfers->data )->ft, "Logging out" );
+
+ while( jd->streamhosts )
+ {
+ jabber_streamhost_t *sh = jd->streamhosts->data;
+ jd->streamhosts = g_slist_remove( jd->streamhosts, sh );
+ g_free( sh->jid );
+ g_free( sh->host );
+ g_free( sh );
+ }
+
if( jd->fd >= 0 )
jabber_end_stream( ic );
while( ic->groupchats )
- jabber_chat_free( ic->groupchats );
+ jabber_chat_free( ic->groupchats->data );
if( jd->r_inpa >= 0 )
b_event_remove( jd->r_inpa );
@@ -366,7 +390,7 @@ static void jabber_get_info( struct im_connection *ic, char *who )
imcb_log( ic, "Buddy %s (%d) information:", bud->full_jid, bud->priority );
if( bud->away_state )
imcb_log( ic, "Away state: %s", bud->away_state->full_name );
- imcb_log( ic, "Status message: %s", bud->away_message ? : "(none)" );
+ imcb_log( ic, "Status message: %s", bud->away_message ? bud->away_message : "(none)" );
bud = bud->next;
}
@@ -380,8 +404,10 @@ static void jabber_set_away( struct im_connection *ic, char *state_txt, char *me
/* state_txt == NULL -> Not away.
Unknown state -> fall back to the first defined away state. */
- jd->away_state = state_txt ? jabber_away_state_by_name( state_txt )
- ? : jabber_away_state_list : NULL;
+ if( state_txt == NULL )
+ jd->away_state = NULL;
+ else if( ( jd->away_state = jabber_away_state_by_name( state_txt ) ) == NULL )
+ jd->away_state = jabber_away_state_list;
g_free( jd->away_message );
jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL;
@@ -400,7 +426,7 @@ static void jabber_add_buddy( struct im_connection *ic, char *who, char *group )
return;
}
- if( jabber_add_to_roster( ic, who, NULL ) )
+ if( jabber_add_to_roster( ic, who, NULL, group ) )
presence_send_request( ic, who, "subscribe" );
}
@@ -426,7 +452,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 );
@@ -549,6 +575,7 @@ void jabber_initmodule()
ret->keepalive = jabber_keepalive;
ret->send_typing = jabber_send_typing;
ret->handle_cmp = g_strcasecmp;
+ ret->transfer_request = jabber_si_transfer_request;
register_protocol( ret );
}