aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-10-07 19:46:28 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-10-07 19:46:28 +0200
commit36e9f62a6e6fdb1217b3b819320ac5a94025c448 (patch)
treec91d57d1f8fa144e1ffce2ae3143de5b30460b0c /protocols
parent090f1cbe72373b31e753af4a1442ddd53b02791b (diff)
Added SRV lookups to automatically find out the correct server for a
domain.
Diffstat (limited to 'protocols')
-rw-r--r--protocols/jabber/jabber.c20
-rw-r--r--protocols/jabber/presence.c7
2 files changed, 22 insertions, 5 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index 706d31c3..2c0f7945 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -58,6 +58,8 @@ static void jabber_login( account_t *acc )
{
struct gaim_connection *gc = new_gaim_conn( acc );
struct jabber_data *jd = g_new0( struct jabber_data, 1 );
+ struct ns_srv_reply *srv = NULL;
+ char *connect_to;
jd->gc = gc;
gc->proto_data = jd;
@@ -78,15 +80,29 @@ static void jabber_login( account_t *acc )
jd->node_cache = xt_new_node( "cache", NULL, NULL );
+ /* Figure out the hostname to connect to. */
+ if( acc->server )
+ connect_to = acc->server;
+ else if( ( srv = srv_lookup( "xmpp-client", "tcp", jd->server ) ) ||
+ ( srv = srv_lookup( "jabber-client", "tcp", jd->server ) ) )
+ connect_to = srv->name;
+ else
+ connect_to = jd->server;
+
+ /* For non-SSL connections we can try to use the port # from the SRV
+ reply, but let's not do that when using SSL, SSL usually runs on
+ non-standard ports... */
if( set_getbool( &acc->set, "ssl" ) )
{
- jd->ssl = ssl_connect( acc->server ? acc->server : jd->server, set_getint( &acc->set, "port" ), jabber_connected_ssl, gc );
+ jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, gc );
jd->fd = ssl_getfd( jd->ssl );
}
else
{
- jd->fd = proxy_connect( acc->server ? acc->server : jd->server, set_getint( &acc->set, "port" ), jabber_connected_plain, gc );
+ jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, gc );
}
+
+ g_free( srv );
}
static void jabber_close( struct gaim_connection *gc )
diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c
index 57301270..5bef498d 100644
--- a/protocols/jabber/presence.c
+++ b/protocols/jabber/presence.c
@@ -37,6 +37,9 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
if( s )
*s = 0;
+ /* Will implement better parsing of away states/msgs when we
+ finally do those API changes. Which will probably be after
+ merging this module into the main tree. */
if( type == NULL )
serv_got_update( gc, from, 1, 0, 0, 0, 0, 0 );
else if( strcmp( type, "unavailable" ) == 0 )
@@ -83,13 +86,11 @@ int presence_send_update( struct gaim_connection *gc )
int st;
node = jabber_make_packet( "presence", NULL, NULL, NULL );
+ xt_add_child( node, xt_new_node( "priority", set_getstr( &gc->acc->set, "priority" ), NULL ) );
if( show && *show )
xt_add_child( node, xt_new_node( "show", show, NULL ) );
if( status )
xt_add_child( node, xt_new_node( "status", status, NULL ) );
- /* if( set_getint( &gc->acc->set, "priority" ) != 0 ) */
- /* Let's just send this every time... */
- xt_add_child( node, xt_new_node( "priority", set_getstr( &gc->acc->set, "priority" ), NULL ) );
st = jabber_write_packet( gc, node );