aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/jabber')
-rw-r--r--protocols/jabber/io.c154
-rw-r--r--protocols/jabber/iq.c136
-rw-r--r--protocols/jabber/jabber.c92
-rw-r--r--protocols/jabber/jabber.h46
-rw-r--r--protocols/jabber/jabber_util.c54
-rw-r--r--protocols/jabber/message.c12
-rw-r--r--protocols/jabber/presence.c40
-rw-r--r--protocols/jabber/sasl.c48
8 files changed, 291 insertions, 291 deletions
diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c
index f05cc93d..6e699301 100644
--- a/protocols/jabber/io.c
+++ b/protocols/jabber/io.c
@@ -25,23 +25,23 @@
#include "ssl_client.h"
static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond );
-static gboolean jabber_write_queue( struct gaim_connection *gc );
+static gboolean jabber_write_queue( struct im_connection *ic );
-int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node )
+int jabber_write_packet( struct im_connection *ic, struct xt_node *node )
{
char *buf;
int st;
buf = xt_to_string( node );
- st = jabber_write( gc, buf, strlen( buf ) );
+ st = jabber_write( ic, buf, strlen( buf ) );
g_free( buf );
return st;
}
-int jabber_write( struct gaim_connection *gc, char *buf, int len )
+int jabber_write( struct im_connection *ic, char *buf, int len )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
gboolean ret;
if( jd->tx_len == 0 )
@@ -53,8 +53,8 @@ int jabber_write( struct gaim_connection *gc, char *buf, int len )
/* Try if we can write it immediately so we don't have to do
it via the event handler. If not, add the handler. (In
most cases it probably won't be necessary.) */
- if( ( ret = jabber_write_queue( gc ) ) && jd->tx_len > 0 )
- jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, gc );
+ if( ( ret = jabber_write_queue( ic ) ) && jd->tx_len > 0 )
+ jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, ic );
}
else
{
@@ -84,16 +84,16 @@ int jabber_write( struct gaim_connection *gc, char *buf, int len )
the socket is ready for more data). */
static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond )
{
- struct jabber_data *jd = ((struct gaim_connection *)data)->proto_data;
+ struct jabber_data *jd = ((struct im_connection *)data)->proto_data;
return jd->fd != -1 &&
jabber_write_queue( data ) &&
jd->tx_len > 0;
}
-static gboolean jabber_write_queue( struct gaim_connection *gc )
+static gboolean jabber_write_queue( struct im_connection *ic )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
int st;
if( jd->ssl )
@@ -116,8 +116,8 @@ static gboolean jabber_write_queue( struct gaim_connection *gc )
closesocket( jd->fd ); /* Shouldn't be necessary after errors? */
jd->fd = -1;
- hide_login_progress_error( gc, "Short write() to server" );
- signoff( gc );
+ hide_login_progress_error( ic, "Short write() to server" );
+ signoff( ic );
return FALSE;
}
else if( st > 0 )
@@ -141,8 +141,8 @@ static gboolean jabber_write_queue( struct gaim_connection *gc )
static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition cond )
{
- struct gaim_connection *gc = data;
- struct jabber_data *jd = gc->proto_data;
+ struct im_connection *ic = data;
+ struct jabber_data *jd = ic->proto_data;
char buf[512];
int st;
@@ -159,8 +159,8 @@ static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition
/* Parse. */
if( xt_feed( jd->xt, buf, st ) < 0 )
{
- hide_login_progress_error( gc, "XML stream error" );
- signoff( gc );
+ hide_login_progress_error( ic, "XML stream error" );
+ signoff( ic );
return FALSE;
}
@@ -175,7 +175,7 @@ static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition
if( jd->flags & JFLAG_STREAM_RESTART )
{
jd->flags &= ~JFLAG_STREAM_RESTART;
- jabber_start_stream( gc );
+ jabber_start_stream( ic );
}
/* Garbage collection. */
@@ -195,28 +195,28 @@ static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition
/* If there's no version attribute, assume
this is an old server that can't do SASL
authentication. */
- if( !sasl_supported( gc ) )
+ if( !sasl_supported( ic ) )
{
/* If there's no version= tag, we suppose
this server does NOT implement: XMPP 1.0,
SASL and TLS. */
- if( set_getbool( &gc->acc->set, "tls" ) )
+ if( set_getbool( &ic->acc->set, "tls" ) )
{
- hide_login_progress( gc, "TLS is turned on for this "
+ hide_login_progress( ic, "TLS is turned on for this "
"account, but is not supported by this server" );
- signoff( gc );
+ signoff( ic );
return FALSE;
}
else
{
- return jabber_init_iq_auth( gc );
+ return jabber_init_iq_auth( ic );
}
}
}
else
{
- hide_login_progress( gc, "XML stream error" );
- signoff( gc );
+ hide_login_progress( ic, "XML stream error" );
+ signoff( ic );
return FALSE;
}
}
@@ -226,8 +226,8 @@ static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition
closesocket( jd->fd );
jd->fd = -1;
- hide_login_progress_error( gc, "Error while reading from server" );
- signoff( gc );
+ hide_login_progress_error( ic, "Error while reading from server" );
+ signoff( ic );
return FALSE;
}
@@ -237,24 +237,24 @@ static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition
gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond )
{
- struct gaim_connection *gc = data;
+ struct im_connection *ic = data;
if( source == -1 )
{
- hide_login_progress( gc, "Could not connect to server" );
- signoff( gc );
+ hide_login_progress( ic, "Could not connect to server" );
+ signoff( ic );
return FALSE;
}
- set_login_progress( gc, 1, "Connected to server, logging in" );
+ set_login_progress( ic, 1, "Connected to server, logging in" );
- return jabber_start_stream( gc );
+ return jabber_start_stream( ic );
}
gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond )
{
- struct gaim_connection *gc = data;
- struct jabber_data *jd = gc->proto_data;
+ struct im_connection *ic = data;
+ struct jabber_data *jd = ic->proto_data;
if( source == NULL )
{
@@ -262,14 +262,14 @@ gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition co
already, set it to NULL here to prevent a double cleanup: */
jd->ssl = NULL;
- hide_login_progress( gc, "Could not connect to server" );
- signoff( gc );
+ hide_login_progress( ic, "Could not connect to server" );
+ signoff( ic );
return FALSE;
}
- set_login_progress( gc, 1, "Connected to server, logging in" );
+ set_login_progress( ic, 1, "Connected to server, logging in" );
- return jabber_start_stream( gc );
+ return jabber_start_stream( ic );
}
static xt_status jabber_end_of_stream( struct xt_node *node, gpointer data )
@@ -280,12 +280,12 @@ static xt_status jabber_end_of_stream( struct xt_node *node, gpointer data )
static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )
{
- struct gaim_connection *gc = data;
- struct jabber_data *jd = gc->proto_data;
+ struct im_connection *ic = data;
+ struct jabber_data *jd = ic->proto_data;
struct xt_node *c, *reply;
int trytls;
- trytls = g_strcasecmp( set_getstr( &gc->acc->set, "tls" ), "try" ) == 0;
+ trytls = g_strcasecmp( set_getstr( &ic->acc->set, "tls" ), "try" ) == 0;
c = xt_find_node( node->children, "starttls" );
if( c && !jd->ssl )
{
@@ -294,20 +294,20 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )
c = xt_find_node( c->children, "required" );
- if( c && ( !trytls && !set_getbool( &gc->acc->set, "tls" ) ) )
+ if( c && ( !trytls && !set_getbool( &ic->acc->set, "tls" ) ) )
{
- hide_login_progress( gc, "Server requires TLS connections, but TLS is turned off for this account" );
- signoff( gc );
+ hide_login_progress( ic, "Server requires TLS connections, but TLS is turned off for this account" );
+ signoff( ic );
return XT_ABORT;
}
/* Only run this if the tls setting is set to true or try: */
- if( ( trytls || set_getbool( &gc->acc->set, "tls" ) ) )
+ if( ( trytls || set_getbool( &ic->acc->set, "tls" ) ) )
{
reply = xt_new_node( "starttls", NULL, NULL );
xt_add_attr( reply, "xmlns", XMLNS_TLS );
- if( !jabber_write_packet( gc, reply ) )
+ if( !jabber_write_packet( ic, reply ) )
{
xt_free_node( reply );
return XT_ABORT;
@@ -324,10 +324,10 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )
habit of not advertising <starttls/> anymore when already
using SSL/TLS. */
- if( !trytls && set_getbool( &gc->acc->set, "tls" ) )
+ if( !trytls && set_getbool( &ic->acc->set, "tls" ) )
{
- hide_login_progress( gc, "TLS is turned on for this account, but is not supported by this server" );
- signoff( gc );
+ hide_login_progress( ic, "TLS is turned on for this account, but is not supported by this server" );
+ signoff( ic );
return XT_ABORT;
}
@@ -345,20 +345,20 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )
support it after all, we should try to do authentication the
other way. jabber.com doesn't seem to do SASL while it pretends
to be XMPP 1.0 compliant! */
- else if( !( jd->flags & JFLAG_AUTHENTICATED ) && sasl_supported( gc ) )
+ else if( !( jd->flags & JFLAG_AUTHENTICATED ) && sasl_supported( ic ) )
{
- if( !jabber_init_iq_auth( gc ) )
+ if( !jabber_init_iq_auth( ic ) )
return XT_ABORT;
}
if( ( c = xt_find_node( node->children, "bind" ) ) )
{
- reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &gc->acc->set, "resource" ), NULL ) );
+ reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) );
xt_add_attr( reply, "xmlns", XMLNS_BIND );
reply = jabber_make_packet( "iq", "set", NULL, reply );
- jabber_cache_add( gc, reply, jabber_pkt_bind_sess );
+ jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
- if( !jabber_write_packet( gc, reply ) )
+ if( !jabber_write_packet( ic, reply ) )
return XT_ABORT;
jd->flags |= JFLAG_WAIT_BIND;
@@ -369,9 +369,9 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )
reply = xt_new_node( "session", NULL, NULL );
xt_add_attr( reply, "xmlns", XMLNS_SESSION );
reply = jabber_make_packet( "iq", "set", NULL, reply );
- jabber_cache_add( gc, reply, jabber_pkt_bind_sess );
+ jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
- if( !jabber_write_packet( gc, reply ) )
+ if( !jabber_write_packet( ic, reply ) )
return XT_ABORT;
jd->flags |= JFLAG_WAIT_SESSION;
@@ -382,7 +382,7 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )
to bind/initialize the session. */
if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
{
- if( !jabber_get_roster( gc ) )
+ if( !jabber_get_roster( ic ) )
return XT_ABORT;
}
@@ -391,8 +391,8 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )
static xt_status jabber_pkt_proceed_tls( struct xt_node *node, gpointer data )
{
- struct gaim_connection *gc = data;
- struct jabber_data *jd = gc->proto_data;
+ struct im_connection *ic = data;
+ struct jabber_data *jd = ic->proto_data;
char *xmlns;
xmlns = xt_find_attr( node, "xmlns" );
@@ -416,16 +416,16 @@ static xt_status jabber_pkt_proceed_tls( struct xt_node *node, gpointer data )
}
jd->w_inpa = jd->r_inpa = 0;
- set_login_progress( gc, 1, "Converting stream to TLS" );
+ set_login_progress( ic, 1, "Converting stream to TLS" );
- jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, gc );
+ jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, ic );
return XT_HANDLED;
}
static xt_status jabber_pkt_stream_error( struct xt_node *node, gpointer data )
{
- struct gaim_connection *gc = data;
+ struct im_connection *ic = data;
struct xt_node *c;
char *s, *type = NULL, *text = NULL;
@@ -451,8 +451,8 @@ static xt_status jabber_pkt_stream_error( struct xt_node *node, gpointer data )
/* Tssk... */
if( type == NULL )
{
- hide_login_progress_error( gc, "Unknown stream error reported by server" );
- signoff( gc );
+ hide_login_progress_error( ic, "Unknown stream error reported by server" );
+ signoff( ic );
return XT_ABORT;
}
@@ -461,17 +461,17 @@ static xt_status jabber_pkt_stream_error( struct xt_node *node, gpointer data )
infinite loop! */
if( strcmp( type, "conflict" ) == 0 )
{
- hide_login_progress( gc, "Account and resource used from a different location" );
- gc->wants_to_die = TRUE;
+ hide_login_progress( ic, "Account and resource used from a different location" );
+ ic->wants_to_die = TRUE;
}
else
{
s = g_strdup_printf( "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" );
- hide_login_progress_error( gc, s );
+ hide_login_progress_error( ic, s );
g_free( s );
}
- signoff( gc );
+ signoff( ic );
return XT_ABORT;
}
@@ -499,35 +499,35 @@ static const struct xt_handler_entry jabber_handlers[] = {
{ NULL, NULL, NULL }
};
-gboolean jabber_start_stream( struct gaim_connection *gc )
+gboolean jabber_start_stream( struct im_connection *ic )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
int st;
char *greet;
/* We'll start our stream now, so prepare everything to receive one
from the server too. */
xt_free( jd->xt ); /* In case we're RE-starting. */
- jd->xt = xt_new( gc );
+ jd->xt = xt_new( ic );
jd->xt->handlers = (struct xt_handler_entry*) jabber_handlers;
if( jd->r_inpa <= 0 )
- jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, gc );
+ jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic );
greet = g_strdup_printf( "<?xml version='1.0' ?>"
"<stream:stream to=\"%s\" xmlns=\"jabber:client\" "
"xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">", jd->server );
- st = jabber_write( gc, greet, strlen( greet ) );
+ st = jabber_write( ic, greet, strlen( greet ) );
g_free( greet );
return st;
}
-void jabber_end_stream( struct gaim_connection *gc )
+void jabber_end_stream( struct im_connection *ic )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
/* Let's only do this if the queue is currently empty, otherwise it'd
take too long anyway. */
@@ -537,14 +537,14 @@ void jabber_end_stream( struct gaim_connection *gc )
struct xt_node *node;
int st = 1;
- if( gc->flags & OPT_LOGGED_IN )
+ if( ic->flags & OPT_LOGGED_IN )
{
node = jabber_make_packet( "presence", "unavailable", NULL, NULL );
- st = jabber_write_packet( gc, node );
+ st = jabber_write_packet( ic, node );
xt_free_node( node );
}
if( st )
- jabber_write( gc, eos, strlen( eos ) );
+ jabber_write( ic, eos, strlen( eos ) );
}
}
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c
index 914dd02b..86d97e15 100644
--- a/protocols/jabber/iq.c
+++ b/protocols/jabber/iq.c
@@ -23,13 +23,13 @@
#include "jabber.h"
-static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
-static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
+static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
+static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
{
- struct gaim_connection *gc = data;
- struct jabber_data *jd = gc->proto_data;
+ struct im_connection *ic = data;
+ struct jabber_data *jd = ic->proto_data;
struct xt_node *c, *reply = NULL;
char *type, *s;
int st, pack = 1;
@@ -38,8 +38,8 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
if( !type )
{
- hide_login_progress_error( gc, "Received IQ packet without type." );
- signoff( gc );
+ hide_login_progress_error( ic, "Received IQ packet without type." );
+ signoff( ic );
return XT_ABORT;
}
@@ -59,16 +59,16 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
entry = g_hash_table_lookup( jd->node_cache, s );
if( entry == NULL )
- serv_got_crap( gc, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s );
+ serv_got_crap( ic, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s );
else if( entry->func )
- return entry->func( gc, node, entry->node );
+ return entry->func( ic, node, entry->node );
}
else if( strcmp( type, "get" ) == 0 )
{
if( !( c = xt_find_node( node->children, "query" ) ) ||
!( s = xt_find_attr( c, "xmlns" ) ) )
{
- serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );
+ serv_got_crap( ic, "WARNING: Received incomplete IQ-%s packet", type );
return XT_HANDLED;
}
@@ -131,7 +131,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
if( !( c = xt_find_node( node->children, "query" ) ) ||
!( s = xt_find_attr( c, "xmlns" ) ) )
{
- serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );
+ serv_got_crap( ic, "WARNING: Received incomplete IQ-%s packet", type );
return XT_HANDLED;
}
@@ -140,20 +140,20 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
sent even if we added this buddy in our own session. */
if( strcmp( s, XMLNS_ROSTER ) == 0 )
{
- int bare_len = strlen( gc->acc->user );
+ int bare_len = strlen( ic->acc->user );
if( ( s = xt_find_attr( node, "from" ) ) == NULL ||
- ( strncmp( s, gc->acc->user, bare_len ) == 0 &&
+ ( strncmp( s, ic->acc->user, bare_len ) == 0 &&
( s[bare_len] == 0 || s[bare_len] == '/' ) ) )
{
- jabber_parse_roster( gc, node, NULL );
+ jabber_parse_roster( ic, node, NULL );
/* Should we generate a reply here? Don't think it's
very important... */
}
else
{
- serv_got_crap( gc, "WARNING: %s tried to fake a roster push!", s ? s : "(unknown)" );
+ serv_got_crap( ic, "WARNING: %s tried to fake a roster push!", s ? s : "(unknown)" );
xt_free_node( reply );
reply = jabber_make_error_packet( node, "not-allowed", "cancel" );
@@ -181,7 +181,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
xt_add_attr( reply, "id", s );
}
- st = jabber_write_packet( gc, reply );
+ st = jabber_write_packet( ic, reply );
xt_free_node( reply );
if( !st )
return XT_ABORT;
@@ -190,12 +190,12 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
return XT_HANDLED;
}
-static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
-static xt_status jabber_finish_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
+static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
+static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
-int jabber_init_iq_auth( struct gaim_connection *gc )
+int jabber_init_iq_auth( struct im_connection *ic )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct xt_node *node;
int st;
@@ -203,23 +203,23 @@ int jabber_init_iq_auth( struct gaim_connection *gc )
xt_add_attr( node, "xmlns", XMLNS_AUTH );
node = jabber_make_packet( "iq", "get", NULL, node );
- jabber_cache_add( gc, node, jabber_do_iq_auth );
- st = jabber_write_packet( gc, node );
+ jabber_cache_add( ic, node, jabber_do_iq_auth );
+ st = jabber_write_packet( ic, node );
return st;
}
-static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )
+static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct xt_node *reply, *query;
xt_status st;
char *s;
if( !( query = xt_find_node( node->children, "query" ) ) )
{
- serv_got_crap( gc, "WARNING: Received incomplete IQ packet while authenticating" );
- signoff( gc );
+ serv_got_crap( ic, "WARNING: Received incomplete IQ packet while authenticating" );
+ signoff( ic );
return XT_HANDLED;
}
@@ -227,7 +227,7 @@ static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *
reply = xt_new_node( "query", NULL, NULL );
xt_add_attr( reply, "xmlns", XMLNS_AUTH );
xt_add_child( reply, xt_new_node( "username", jd->username, NULL ) );
- xt_add_child( reply, xt_new_node( "resource", set_getstr( &gc->acc->set, "resource" ), NULL ) );
+ xt_add_child( reply, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) );
if( xt_find_node( query->children, "digest" ) && ( s = xt_find_attr( jd->xt->root, "id" ) ) )
{
@@ -240,7 +240,7 @@ static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *
shaInit( &sha );
shaUpdate( &sha, (unsigned char*) s, strlen( s ) );
- shaUpdate( &sha, (unsigned char*) gc->acc->pass, strlen( gc->acc->pass ) );
+ shaUpdate( &sha, (unsigned char*) ic->acc->pass, strlen( ic->acc->pass ) );
shaFinal( &sha, hash );
for( i = 0; i < 20; i ++ )
@@ -251,40 +251,40 @@ static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *
else if( xt_find_node( query->children, "password" ) )
{
/* We'll have to stick with plaintext. Let's hope we're using SSL/TLS... */
- xt_add_child( reply, xt_new_node( "password", gc->acc->pass, NULL ) );
+ xt_add_child( reply, xt_new_node( "password", ic->acc->pass, NULL ) );
}
else
{
xt_free_node( reply );
- hide_login_progress( gc, "Can't find suitable authentication method" );
- signoff( gc );
+ hide_login_progress( ic, "Can't find suitable authentication method" );
+ signoff( ic );
return XT_ABORT;
}
reply = jabber_make_packet( "iq", "set", NULL, reply );
- jabber_cache_add( gc, reply, jabber_finish_iq_auth );
- st = jabber_write_packet( gc, reply );
+ jabber_cache_add( ic, reply, jabber_finish_iq_auth );
+ st = jabber_write_packet( ic, reply );
return st ? XT_HANDLED : XT_ABORT;
}
-static xt_status jabber_finish_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )
+static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
char *type;
if( !( type = xt_find_attr( node, "type" ) ) )
{
- serv_got_crap( gc, "WARNING: Received incomplete IQ packet while authenticating" );
- signoff( gc );
+ serv_got_crap( ic, "WARNING: Received incomplete IQ packet while authenticating" );
+ signoff( ic );
return XT_HANDLED;
}
if( strcmp( type, "error" ) == 0 )
{
- hide_login_progress( gc, "Authentication failure" );
- signoff( gc );
+ hide_login_progress( ic, "Authentication failure" );
+ signoff( ic );
return XT_ABORT;
}
else if( strcmp( type, "result" ) == 0 )
@@ -292,16 +292,16 @@ static xt_status jabber_finish_iq_auth( struct gaim_connection *gc, struct xt_no
/* This happens when we just successfully authenticated the
old (non-SASL) way. */
jd->flags |= JFLAG_AUTHENTICATED;
- if( !jabber_get_roster( gc ) )
+ if( !jabber_get_roster( ic ) )
return XT_ABORT;
}
return XT_HANDLED;
}
-xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )
+xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct xt_node *c;
char *s;
@@ -309,8 +309,8 @@ xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node
{
c = xt_find_node( c->children, "jid" );
if( c && c->text_len && ( s = strchr( c->text, '/' ) ) &&
- strcmp( s + 1, set_getstr( &gc->acc->set, "resource" ) ) != 0 )
- serv_got_crap( gc, "Server changed session resource string to `%s'", s + 1 );
+ strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 )
+ serv_got_crap( ic, "Server changed session resource string to `%s'", s + 1 );
jd->flags &= ~JFLAG_WAIT_BIND;
}
@@ -321,38 +321,38 @@ xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node
if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
{
- if( !jabber_get_roster( gc ) )
+ if( !jabber_get_roster( ic ) )
return XT_ABORT;
}
return XT_HANDLED;
}
-int jabber_get_roster( struct gaim_connection *gc )
+int jabber_get_roster( struct im_connection *ic )
{
struct xt_node *node;
int st;
- set_login_progress( gc, 1, "Authenticated, requesting buddy list" );
+ set_login_progress( ic, 1, "Authenticated, requesting buddy list" );
node = xt_new_node( "query", NULL, NULL );
xt_add_attr( node, "xmlns", XMLNS_ROSTER );
node = jabber_make_packet( "iq", "get", NULL, node );
- jabber_cache_add( gc, node, jabber_parse_roster );
- st = jabber_write_packet( gc, node );
+ jabber_cache_add( ic, node, jabber_parse_roster );
+ st = jabber_write_packet( ic, node );
return st;
}
-static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )
+static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
{
struct xt_node *query, *c;
int initial = ( orig != NULL );
if( !( query = xt_find_node( node->children, "query" ) ) )
{
- serv_got_crap( gc, "WARNING: Received NULL roster packet" );
+ serv_got_crap( ic, "WARNING: Received NULL roster packet" );
return XT_HANDLED;
}
@@ -370,24 +370,24 @@ static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node
else if( initial )
{
if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) )
- add_buddy( gc, NULL, jid, name );
+ add_buddy( ic, NULL, jid, name );
}
else
{
/* This is a roster push item. Find out what changed exactly. */
if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) )
{
- if( find_buddy( gc, jid ) == NULL )
- add_buddy( gc, NULL, jid, name );
+ if( find_buddy( ic, jid ) == NULL )
+ add_buddy( ic, NULL, jid, name );
else if( name )
- serv_buddy_rename( gc, jid, name );
+ serv_buddy_rename( ic, jid, name );
}
else if( strcmp( sub, "remove" ) == 0 )
{
/* Don't have any API call for this yet! So let's
just try to handle this as well as we can. */
- jabber_buddy_remove_bare( gc, jid );
- serv_got_update( gc, jid, 0, 0, 0, 0, 0, 0 );
+ jabber_buddy_remove_bare( ic, jid );
+ serv_got_update( ic, jid, 0, 0, 0, 0, 0, 0 );
/* FIXME! */
}
}
@@ -396,12 +396,12 @@ static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node
}
if( initial )
- account_online( gc );
+ account_online( ic );
return XT_HANDLED;
}
-int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid )
+int jabber_get_vcard( struct im_connection *ic, char *bare_jid )
{
struct xt_node *node;
@@ -412,13 +412,13 @@ int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid )
xt_add_attr( node, "xmlns", XMLNS_VCARD );
node = jabber_make_packet( "iq", "get", bare_jid, node );
- jabber_cache_add( gc, node, jabber_iq_display_vcard );
- return jabber_write_packet( gc, node );
+ jabber_cache_add( ic, node, jabber_iq_display_vcard );
+ return jabber_write_packet( ic, node );
}
-static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )
+static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
{
- struct xt_node *vc, *c, *sc; /* subchild, gc is already in use ;-) */
+ struct xt_node *vc, *c, *sc; /* subchild, ic is already in use ;-) */
GString *reply;
char *s;
@@ -427,7 +427,7 @@ static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_
( vc = xt_find_node( node->children, "vCard" ) ) == NULL )
{
s = xt_find_attr( orig, "to" ); /* If this returns NULL something's wrong.. */
- serv_got_crap( gc, "Could not retrieve vCard of %s", s ? s : "(NULL)" );
+ serv_got_crap( ic, "Could not retrieve vCard of %s", s ? s : "(NULL)" );
return XT_HANDLED;
}
@@ -535,13 +535,13 @@ static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_
/* *sigh* */
- serv_got_crap( gc, reply->str );
+ serv_got_crap( ic, reply->str );
g_string_free( reply, TRUE );
return XT_HANDLED;
}
-int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name )
+int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name )
{
struct xt_node *node;
int st;
@@ -557,13 +557,13 @@ int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name )
xt_add_attr( node, "xmlns", XMLNS_ROSTER );
node = jabber_make_packet( "iq", "set", NULL, node );
- st = jabber_write_packet( gc, node );
+ st = jabber_write_packet( ic, node );
xt_free_node( node );
return st;
}
-int jabber_remove_from_roster( struct gaim_connection *gc, char *handle )
+int jabber_remove_from_roster( struct im_connection *ic, char *handle )
{
struct xt_node *node;
int st;
@@ -578,7 +578,7 @@ int jabber_remove_from_roster( struct gaim_connection *gc, char *handle )
xt_add_attr( node, "xmlns", XMLNS_ROSTER );
node = jabber_make_packet( "iq", "set", NULL, node );
- st = jabber_write_packet( gc, node );
+ st = jabber_write_packet( ic, node );
xt_free_node( node );
return st;
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index fa9c3473..23de1103 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -32,7 +32,7 @@
#include "bitlbee.h"
#include "jabber.h"
-static void jabber_acc_init( account_t *acc )
+static void jabber_init( account_t *acc )
{
set_t *s;
@@ -58,21 +58,21 @@ static void jabber_acc_init( account_t *acc )
static void jabber_login( account_t *acc )
{
- struct gaim_connection *gc = new_gaim_conn( acc );
+ struct im_connection *ic = new_gaim_conn( acc );
struct jabber_data *jd = g_new0( struct jabber_data, 1 );
struct ns_srv_reply *srv = NULL;
char *connect_to, *s;
- jd->gc = gc;
- gc->proto_data = jd;
+ jd->ic = ic;
+ ic->proto_data = jd;
jd->username = g_strdup( acc->user );
jd->server = strchr( jd->username, '@' );
if( jd->server == NULL )
{
- hide_login_progress( gc, "Incomplete account name (format it like <username@jabberserver.name>)" );
- signoff( gc );
+ hide_login_progress( ic, "Incomplete account name (format it like <username@jabberserver.name>)" );
+ signoff( ic );
return;
}
@@ -158,14 +158,14 @@ static void jabber_login( account_t *acc )
else
connect_to = jd->server;
- set_login_progress( gc, 0, "Connecting" );
+ set_login_progress( ic, 0, "Connecting" );
if( set_getint( &acc->set, "port" ) < JABBER_PORT_MIN ||
set_getint( &acc->set, "port" ) > JABBER_PORT_MAX )
{
- serv_got_crap( gc, "Incorrect port number, must be in the %d-%d range",
+ serv_got_crap( ic, "Incorrect port number, must be in the %d-%d range",
JABBER_PORT_MIN, JABBER_PORT_MAX );
- signoff( gc );
+ signoff( ic );
return;
}
@@ -174,27 +174,27 @@ static void jabber_login( account_t *acc )
non-standard ports... */
if( set_getbool( &acc->set, "ssl" ) )
{
- jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, gc );
+ jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, ic );
jd->fd = jd->ssl ? ssl_getfd( jd->ssl ) : -1;
}
else
{
- jd->fd = proxy_connect( connect_to, srv ? srv->port : 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, ic );
}
g_free( srv );
if( jd->fd == -1 )
{
- hide_login_progress( gc, "Could not connect to server" );
- signoff( gc );
+ hide_login_progress( ic, "Could not connect to server" );
+ signoff( ic );
}
}
-static void jabber_close( struct gaim_connection *gc )
+static void jabber_logout( struct im_connection *ic )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
- jabber_end_stream( gc );
+ jabber_end_stream( ic );
if( jd->r_inpa >= 0 )
b_event_remove( jd->r_inpa );
@@ -218,14 +218,14 @@ static void jabber_close( struct gaim_connection *gc )
g_free( jd );
}
-static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )
+static int jabber_send_im( struct im_connection *ic, char *who, char *message, int flags )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct jabber_buddy *bud;
struct xt_node *node;
int st;
- bud = jabber_buddy_by_jid( gc, who, 0 );
+ bud = jabber_buddy_by_jid( ic, who, 0 );
node = xt_new_node( "body", message, NULL );
node = jabber_make_packet( "message", "chat", bud ? bud->full_jid : who, node );
@@ -250,13 +250,13 @@ static int jabber_send_im( struct gaim_connection *gc, char *who, char *message,
bud->flags |= JBFLAG_PROBED_XEP85;
}
- st = jabber_write_packet( gc, node );
+ st = jabber_write_packet( ic, node );
xt_free_node( node );
return st;
}
-static GList *jabber_away_states( struct gaim_connection *gc )
+static GList *jabber_away_states( struct im_connection *ic )
{
static GList *l = NULL;
int i;
@@ -268,13 +268,13 @@ static GList *jabber_away_states( struct gaim_connection *gc )
return l;
}
-static void jabber_get_info( struct gaim_connection *gc, char *who )
+static void jabber_get_info( struct im_connection *ic, char *who )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct jabber_buddy *bud;
if( strchr( who, '/' ) )
- bud = jabber_buddy_by_jid( gc, who, 0 );
+ bud = jabber_buddy_by_jid( ic, who, 0 );
else
{
char *s = jabber_normalize( who );
@@ -284,19 +284,19 @@ static void jabber_get_info( struct gaim_connection *gc, char *who )
while( bud )
{
- serv_got_crap( gc, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s",
+ serv_got_crap( ic, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s",
bud->full_jid, bud->priority,
bud->away_state ? bud->away_state->full_name : "(none)",
bud->away_message ? : "(none)" );
bud = bud->next;
}
- jabber_get_vcard( gc, bud ? bud->full_jid : who );
+ jabber_get_vcard( ic, bud ? bud->full_jid : who );
}
-static void jabber_set_away( struct gaim_connection *gc, char *state_txt, char *message )
+static void jabber_set_away( struct im_connection *ic, char *state_txt, char *message )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct jabber_away_state *state;
/* Save all this info. We need it, for example, when changing the priority setting. */
@@ -305,43 +305,43 @@ static void jabber_set_away( struct gaim_connection *gc, char *state_txt, char *
g_free( jd->away_message );
jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL;
- presence_send_update( gc );
+ presence_send_update( ic );
}
-static void jabber_add_buddy( struct gaim_connection *gc, char *who )
+static void jabber_add_buddy( struct im_connection *ic, char *who, char *group )
{
- if( jabber_add_to_roster( gc, who, NULL ) )
- presence_send_request( gc, who, "subscribe" );
+ if( jabber_add_to_roster( ic, who, NULL ) )
+ presence_send_request( ic, who, "subscribe" );
}
-static void jabber_remove_buddy( struct gaim_connection *gc, char *who, char *group )
+static void jabber_remove_buddy( struct im_connection *ic, char *who, char *group )
{
/* We should always do this part. Clean up our administration a little bit. */
- jabber_buddy_remove_bare( gc, who );
+ jabber_buddy_remove_bare( ic, who );
- if( jabber_remove_from_roster( gc, who ) )
- presence_send_request( gc, who, "unsubscribe" );
+ if( jabber_remove_from_roster( ic, who ) )
+ presence_send_request( ic, who, "unsubscribe" );
}
-static void jabber_keepalive( struct gaim_connection *gc )
+static void jabber_keepalive( struct im_connection *ic )
{
/* Just any whitespace character is enough as a keepalive for XMPP sessions. */
- jabber_write( gc, "\n", 1 );
+ jabber_write( ic, "\n", 1 );
/* This runs the garbage collection every minute, which means every packet
is in the cache for about a minute (which should be enough AFAIK). */
- jabber_cache_clean( gc );
+ jabber_cache_clean( ic );
}
-static int jabber_send_typing( struct gaim_connection *gc, char *who, int typing )
+static int jabber_send_typing( struct im_connection *ic, char *who, int typing )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct jabber_buddy *bud;
/* Enable typing notification related code from now. */
jd->flags |= JFLAG_WANT_TYPING;
- if( ( bud = jabber_buddy_by_jid( gc, who, 0 ) ) == NULL )
+ if( ( bud = jabber_buddy_by_jid( ic, who, 0 ) ) == NULL )
{
/* Sending typing notifications to unknown buddies is
unsupported for now. Shouldn't be a problem, I think. */
@@ -368,7 +368,7 @@ static int jabber_send_typing( struct gaim_connection *gc, char *who, int typing
xt_add_attr( node, "xmlns", XMLNS_CHATSTATES );
node = jabber_make_packet( "message", "chat", bud->full_jid, node );
- st = jabber_write_packet( gc, node );
+ st = jabber_write_packet( ic, node );
xt_free_node( node );
return st;
@@ -377,14 +377,14 @@ static int jabber_send_typing( struct gaim_connection *gc, char *who, int typing
return 1;
}
-void jabber_init()
+void jabber_initmodule()
{
struct prpl *ret = g_new0( struct prpl, 1 );
ret->name = "jabber";
ret->login = jabber_login;
- ret->acc_init = jabber_acc_init;
- ret->close = jabber_close;
+ ret->init = jabber_init;
+ ret->logout = jabber_logout;
ret->send_im = jabber_send_im;
ret->away_states = jabber_away_states;
// ret->get_status_string = jabber_get_status_string;
diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h
index 0a0f3c2c..42f57ae1 100644
--- a/protocols/jabber/jabber.h
+++ b/protocols/jabber/jabber.h
@@ -57,7 +57,7 @@ typedef enum
struct jabber_data
{
- struct gaim_connection *gc;
+ struct im_connection *ic;
int fd;
void *ssl;
@@ -86,7 +86,7 @@ struct jabber_away_state
char *full_name;
};
-typedef xt_status (*jabber_cache_event) ( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
+typedef xt_status (*jabber_cache_event) ( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
struct jabber_cache_entry
{
@@ -136,33 +136,33 @@ struct jabber_buddy
/* iq.c */
xt_status jabber_pkt_iq( struct xt_node *node, gpointer data );
-int jabber_init_iq_auth( struct gaim_connection *gc );
-xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
-int jabber_get_roster( struct gaim_connection *gc );
-int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid );
-int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name );
-int jabber_remove_from_roster( struct gaim_connection *gc, char *handle );
+int jabber_init_iq_auth( struct im_connection *ic );
+xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
+int jabber_get_roster( struct im_connection *ic );
+int jabber_get_vcard( struct im_connection *ic, char *bare_jid );
+int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name );
+int jabber_remove_from_roster( struct im_connection *ic, char *handle );
/* message.c */
xt_status jabber_pkt_message( struct xt_node *node, gpointer data );
/* presence.c */
xt_status jabber_pkt_presence( struct xt_node *node, gpointer data );
-int presence_send_update( struct gaim_connection *gc );
-int presence_send_request( struct gaim_connection *gc, char *handle, char *request );
+int presence_send_update( struct im_connection *ic );
+int presence_send_request( struct im_connection *ic, char *handle, char *request );
/* jabber_util.c */
char *set_eval_priority( set_t *set, char *value );
char *set_eval_tls( set_t *set, char *value );
struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_node *children );
struct xt_node *jabber_make_error_packet( struct xt_node *orig, char *err_cond, char *err_type );
-void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func );
-struct xt_node *jabber_cache_get( struct gaim_connection *gc, char *id );
+void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_cache_event func );
+struct xt_node *jabber_cache_get( struct im_connection *ic, char *id );
void jabber_cache_entry_free( gpointer entry );
-void jabber_cache_clean( struct gaim_connection *gc );
+void jabber_cache_clean( struct im_connection *ic );
const struct jabber_away_state *jabber_away_state_by_code( char *code );
const struct jabber_away_state *jabber_away_state_by_name( char *name );
-void jabber_buddy_ask( struct gaim_connection *gc, char *handle );
+void jabber_buddy_ask( struct im_connection *ic, char *handle );
char *jabber_normalize( char *orig );
typedef enum
@@ -171,25 +171,25 @@ typedef enum
GET_BUDDY_EXACT = 2, /* Get an exact message (only makes sense with bare JIDs). */
} get_buddy_flags_t;
-struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_jid );
-struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid, get_buddy_flags_t flags );
-int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid );
-int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid );
+struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid );
+struct jabber_buddy *jabber_buddy_by_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 );
extern const struct jabber_away_state jabber_away_state_list[];
/* io.c */
-int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node );
-int jabber_write( struct gaim_connection *gc, char *buf, int len );
+int jabber_write_packet( struct im_connection *ic, struct xt_node *node );
+int jabber_write( struct im_connection *ic, char *buf, int len );
gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond );
gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond );
-gboolean jabber_start_stream( struct gaim_connection *gc );
-void jabber_end_stream( struct gaim_connection *gc );
+gboolean jabber_start_stream( struct im_connection *ic );
+void jabber_end_stream( struct im_connection *ic );
/* sasl.c */
xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data );
xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data );
xt_status sasl_pkt_result( struct xt_node *node, gpointer data );
-gboolean sasl_supported( struct gaim_connection *gc );
+gboolean sasl_supported( struct im_connection *ic );
#endif
diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c
index 4ca0c1fc..cc237b03 100644
--- a/protocols/jabber/jabber_util.c
+++ b/protocols/jabber/jabber_util.c
@@ -41,7 +41,7 @@ char *set_eval_priority( set_t *set, char *value )
/* Only run this stuff if the account is online ATM,
and if the setting seems to be acceptable. */
- if( acc->gc )
+ if( acc->ic )
{
/* Although set_eval functions usually are very nice and
convenient, they have one disadvantage: If I would just
@@ -57,7 +57,7 @@ char *set_eval_priority( set_t *set, char *value )
/* (Yes, sorry, I prefer the hack. :-P) */
- presence_send_update( acc->gc );
+ presence_send_update( acc->ic );
}
return value;
@@ -129,9 +129,9 @@ struct xt_node *jabber_make_error_packet( struct xt_node *orig, char *err_cond,
/* Cache a node/packet for later use. Mainly useful for IQ packets if you need
them when you receive the response. Use this BEFORE sending the packet so
it'll get a new id= tag, and do NOT free() the packet after writing it! */
-void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func )
+void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_cache_event func )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
char *id = g_strdup_printf( "%s%05x", JABBER_CACHED_ID, ( next_id++ ) & 0xfffff );
struct jabber_cache_entry *entry = g_new0( struct jabber_cache_entry, 1 );
@@ -158,9 +158,9 @@ gboolean jabber_cache_clean_entry( gpointer key, gpointer entry, gpointer nullpo
during the first run and deleting marked nodes during a next run, every
node should be available in the cache for at least a minute (assuming the
function is indeed called every minute). */
-void jabber_cache_clean( struct gaim_connection *gc )
+void jabber_cache_clean( struct im_connection *ic )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, NULL );
}
@@ -213,17 +213,17 @@ const struct jabber_away_state *jabber_away_state_by_name( char *name )
struct jabber_buddy_ask_data
{
- struct gaim_connection *gc;
+ struct im_connection *ic;
char *handle;
char *realname;
};
static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla )
{
- presence_send_request( bla->gc, bla->handle, "subscribed" );
+ presence_send_request( bla->ic, bla->handle, "subscribed" );
- if( find_buddy( bla->gc, bla->handle ) == NULL )
- show_got_added( bla->gc, bla->handle, NULL );
+ if( find_buddy( bla->ic, bla->handle ) == NULL )
+ show_got_added( bla->ic, bla->handle, NULL );
g_free( bla->handle );
g_free( bla );
@@ -231,22 +231,22 @@ static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla
static void jabber_buddy_ask_no( gpointer w, struct jabber_buddy_ask_data *bla )
{
- presence_send_request( bla->gc, bla->handle, "subscribed" );
+ presence_send_request( bla->ic, bla->handle, "subscribed" );
g_free( bla->handle );
g_free( bla );
}
-void jabber_buddy_ask( struct gaim_connection *gc, char *handle )
+void jabber_buddy_ask( struct im_connection *ic, char *handle )
{
struct jabber_buddy_ask_data *bla = g_new0( struct jabber_buddy_ask_data, 1 );
char *buf;
- bla->gc = gc;
+ bla->ic = ic;
bla->handle = g_strdup( handle );
buf = g_strdup_printf( "The user %s wants to add you to his/her buddy list.", handle );
- do_ask_dialog( gc, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no );
+ do_ask_dialog( ic, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no );
g_free( buf );
}
@@ -270,9 +270,9 @@ char *jabber_normalize( char *orig )
buddies from transports don't (usually) have resources. So we'll really have
to deal with that properly. Set their ->resource property to NULL. Do *NOT*
allow to mix this stuff, though... */
-struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_jid_ )
+struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid_ )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct jabber_buddy *bud, *new, *bi;
char *s, *full_jid;
@@ -342,9 +342,9 @@ struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_ji
/* Finds a buddy from our structures. Can find both full- and bare JIDs. When
asked for a bare JID, it uses the "resource_select" setting to see which
resource to pick. */
-struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid_, get_buddy_flags_t flags )
+struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, get_buddy_flags_t flags )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct jabber_buddy *bud;
char *s, *jid;
@@ -370,10 +370,10 @@ struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid_
}
}
- if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && find_buddy( gc, jid ) )
+ if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && find_buddy( ic, jid ) )
{
*s = '/';
- bud = jabber_buddy_add( gc, jid );
+ bud = jabber_buddy_add( ic, jid );
}
g_free( jid );
@@ -390,8 +390,8 @@ struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid_
if( bud == NULL )
/* No match. Create it now? */
- return ( ( flags & GET_BUDDY_CREAT ) && find_buddy( gc, jid_ ) ) ?
- jabber_buddy_add( gc, jid_ ) : NULL;
+ return ( ( flags & GET_BUDDY_CREAT ) && find_buddy( ic, jid_ ) ) ?
+ jabber_buddy_add( ic, jid_ ) : NULL;
else if( bud->resource && ( flags & GET_BUDDY_EXACT ) )
/* We want an exact match, so in thise case there shouldn't be a /resource. */
return NULL;
@@ -408,7 +408,7 @@ struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid_
best_time = bud;
}
- if( ( set = set_getstr( &gc->acc->set, "resource_select" ) ) == NULL )
+ if( ( set = set_getstr( &ic->acc->set, "resource_select" ) ) == NULL )
return NULL;
else if( strcmp( set, "activity" ) == 0 )
return best_time;
@@ -420,9 +420,9 @@ struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid_
/* Remove one specific full JID from our list. Use this when a buddy goes
off-line (because (s)he can still be online from a different location.
XXX: See above, we should accept bare JIDs too... */
-int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid_ )
+int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct jabber_buddy *bud, *prev, *bi;
char *s, *full_jid;
@@ -494,9 +494,9 @@ int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid_ )
/* Remove a buddy completely; removes all resources that belong to the
specified bare JID. Use this when removing someone from the contact
list, for example. */
-int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid_ )
+int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid_ )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct jabber_buddy *bud, *next;
char *bare_jid;
diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c
index ac72f661..6c105d1d 100644
--- a/protocols/jabber/message.c
+++ b/protocols/jabber/message.c
@@ -25,7 +25,7 @@
xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
{
- struct gaim_connection *gc = data;
+ struct im_connection *ic = data;
char *from = xt_find_attr( node, "from" );
char *type = xt_find_attr( node, "type" );
struct xt_node *body = xt_find_node( node->children, "body" ), *c;
@@ -46,7 +46,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
if( ( s = strchr( from, '/' ) ) )
{
- if( ( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) ) )
+ if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ) )
bud->last_act = time( NULL );
else
*s = 0; /* We need to generate a bare JID now. */
@@ -75,7 +75,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
fullmsg = g_string_append( fullmsg, body->text );
if( fullmsg->len > 0 )
- serv_got_im( gc, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len );
+ serv_got_im( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len );
g_string_free( fullmsg, TRUE );
@@ -83,18 +83,18 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
if( xt_find_node( node->children, "composing" ) )
{
bud->flags |= JBFLAG_DOES_XEP85;
- serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 1 );
+ serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 1 );
}
/* No need to send a "stopped typing" signal when there's a message. */
else if( xt_find_node( node->children, "active" ) && ( body == NULL ) )
{
bud->flags |= JBFLAG_DOES_XEP85;
- serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 0 );
+ serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 0 );
}
else if( xt_find_node( node->children, "paused" ) )
{
bud->flags |= JBFLAG_DOES_XEP85;
- serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 2 );
+ serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 2 );
}
if( s )
diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c
index 2e6b41ab..2db32fd1 100644
--- a/protocols/jabber/presence.c
+++ b/protocols/jabber/presence.c
@@ -25,7 +25,7 @@
xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
{
- struct gaim_connection *gc = data;
+ struct im_connection *ic = data;
char *from = xt_find_attr( node, "from" );
char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */
struct xt_node *c;
@@ -37,10 +37,10 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
if( type == NULL )
{
- if( !( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )
+ if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )
{
- if( set_getbool( &gc->irc->set, "debug" ) )
- serv_got_crap( gc, "WARNING: Could not handle presence information from JID: %s", from );
+ if( set_getbool( &ic->irc->set, "debug" ) )
+ serv_got_crap( ic, "WARNING: Could not handle presence information from JID: %s", from );
return XT_HANDLED;
}
@@ -65,19 +65,19 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
else
bud->priority = 0;
- serv_got_update( gc, bud->bare_jid, 1, 0, 0, 0,
+ serv_got_update( ic, bud->bare_jid, 1, 0, 0, 0,
bud->away_state ? UC_UNAVAILABLE : 0, 0 );
}
else if( strcmp( type, "unavailable" ) == 0 )
{
- if( jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) == NULL )
+ if( jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) == NULL )
{
- if( set_getbool( &gc->irc->set, "debug" ) )
- serv_got_crap( gc, "WARNING: Received presence information from unknown JID: %s", from );
+ if( set_getbool( &ic->irc->set, "debug" ) )
+ serv_got_crap( ic, "WARNING: Received presence information from unknown JID: %s", from );
return XT_HANDLED;
}
- jabber_buddy_remove( gc, from );
+ jabber_buddy_remove( ic, from );
if( ( s = strchr( from, '/' ) ) )
{
@@ -85,24 +85,24 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
/* Only count this as offline if there's no other resource
available anymore. */
- if( jabber_buddy_by_jid( gc, from, 0 ) == NULL )
- serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );
+ if( jabber_buddy_by_jid( ic, from, 0 ) == NULL )
+ serv_got_update( ic, from, 0, 0, 0, 0, 0, 0 );
*s = '/';
}
else
{
- serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );
+ serv_got_update( ic, from, 0, 0, 0, 0, 0, 0 );
}
}
else if( strcmp( type, "subscribe" ) == 0 )
{
- jabber_buddy_ask( gc, from );
+ jabber_buddy_ask( ic, from );
}
else if( strcmp( type, "subscribed" ) == 0 )
{
/* Not sure about this one, actually... */
- serv_got_crap( gc, "%s just accepted your authorization request", from );
+ serv_got_crap( ic, "%s just accepted your authorization request", from );
}
else if( strcmp( type, "unsubscribe" ) == 0 || strcmp( type, "unsubscribed" ) == 0 )
{
@@ -130,29 +130,29 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
/* Whenever presence information is updated, call this function to inform the
server. */
-int presence_send_update( struct gaim_connection *gc )
+int presence_send_update( struct im_connection *ic )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
struct xt_node *node;
char *show = jd->away_state->code;
char *status = jd->away_message;
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 ) );
+ xt_add_child( node, xt_new_node( "priority", set_getstr( &ic->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 ) );
- st = jabber_write_packet( gc, node );
+ st = jabber_write_packet( ic, node );
xt_free_node( node );
return st;
}
/* Send a subscribe/unsubscribe request to a buddy. */
-int presence_send_request( struct gaim_connection *gc, char *handle, char *request )
+int presence_send_request( struct im_connection *ic, char *handle, char *request )
{
struct xt_node *node;
int st;
@@ -161,7 +161,7 @@ int presence_send_request( struct gaim_connection *gc, char *handle, char *reque
xt_add_attr( node, "to", handle );
xt_add_attr( node, "type", request );
- st = jabber_write_packet( gc, node );
+ st = jabber_write_packet( ic, node );
xt_free_node( node );
return st;
diff --git a/protocols/jabber/sasl.c b/protocols/jabber/sasl.c
index 68953ced..4943f59e 100644
--- a/protocols/jabber/sasl.c
+++ b/protocols/jabber/sasl.c
@@ -26,25 +26,25 @@
xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
{
- struct gaim_connection *gc = data;
- struct jabber_data *jd = gc->proto_data;
+ struct im_connection *ic = data;
+ struct jabber_data *jd = ic->proto_data;
struct xt_node *c, *reply;
char *s;
int sup_plain = 0, sup_digest = 0;
- if( !sasl_supported( gc ) )
+ if( !sasl_supported( ic ) )
{
/* Should abort this now, since we should already be doing
IQ authentication. Strange things happen when you try
to do both... */
- serv_got_crap( gc, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" );
+ serv_got_crap( ic, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" );
return XT_HANDLED;
}
s = xt_find_attr( node, "xmlns" );
if( !s || strcmp( s, XMLNS_SASL ) != 0 )
{
- signoff( gc );
+ signoff( ic );
return XT_ABORT;
}
@@ -61,8 +61,8 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
if( !sup_plain && !sup_digest )
{
- hide_login_progress( gc, "No known SASL authentication schemes supported" );
- signoff( gc );
+ hide_login_progress( ic, "No known SASL authentication schemes supported" );
+ signoff( ic );
return XT_ABORT;
}
@@ -82,17 +82,17 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
xt_add_attr( reply, "mechanism", "PLAIN" );
/* With SASL PLAIN in XMPP, the text should be b64(\0user\0pass) */
- len = strlen( jd->username ) + strlen( gc->acc->pass ) + 2;
+ len = strlen( jd->username ) + strlen( ic->acc->pass ) + 2;
s = g_malloc( len + 1 );
s[0] = 0;
strcpy( s + 1, jd->username );
- strcpy( s + 2 + strlen( jd->username ), gc->acc->pass );
+ strcpy( s + 2 + strlen( jd->username ), ic->acc->pass );
reply->text = base64_encode( s, len );
reply->text_len = strlen( reply->text );
g_free( s );
}
- if( !jabber_write_packet( gc, reply ) )
+ if( !jabber_write_packet( ic, reply ) )
{
xt_free_node( reply );
return XT_ABORT;
@@ -180,8 +180,8 @@ static char *sasl_get_part( char *data, char *field )
xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data )
{
- struct gaim_connection *gc = data;
- struct jabber_data *jd = gc->proto_data;
+ struct im_connection *ic = data;
+ struct jabber_data *jd = ic->proto_data;
struct xt_node *reply = NULL;
char *nonce = NULL, *realm = NULL, *cnonce = NULL, cnonce_bin[30];
char *digest_uri = NULL;
@@ -221,7 +221,7 @@ xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data )
/* Generate the MD5 hash of username:realm:password,
I decided to call it H. */
md5_init( &H );
- s = g_strdup_printf( "%s:%s:%s", jd->username, realm, gc->acc->pass );
+ s = g_strdup_printf( "%s:%s:%s", jd->username, realm, ic->acc->pass );
md5_append( &H, (unsigned char *) s, strlen( s ) );
g_free( s );
md5_finish( &H, Hr );
@@ -271,15 +271,15 @@ xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data )
reply = xt_new_node( "response", s, NULL );
xt_add_attr( reply, "xmlns", XMLNS_SASL );
- if( !jabber_write_packet( gc, reply ) )
+ if( !jabber_write_packet( ic, reply ) )
goto silent_error;
ret = XT_HANDLED;
goto silent_error;
error:
- hide_login_progress( gc, "Incorrect SASL challenge received" );
- signoff( gc );
+ hide_login_progress( ic, "Incorrect SASL challenge received" );
+ signoff( ic );
silent_error:
g_free( digest_uri );
@@ -295,26 +295,26 @@ silent_error:
xt_status sasl_pkt_result( struct xt_node *node, gpointer data )
{
- struct gaim_connection *gc = data;
- struct jabber_data *jd = gc->proto_data;
+ struct im_connection *ic = data;
+ struct jabber_data *jd = ic->proto_data;
char *s;
s = xt_find_attr( node, "xmlns" );
if( !s || strcmp( s, XMLNS_SASL ) != 0 )
{
- signoff( gc );
+ signoff( ic );
return XT_ABORT;
}
if( strcmp( node->name, "success" ) == 0 )
{
- set_login_progress( gc, 1, "Authentication finished" );
+ set_login_progress( ic, 1, "Authentication finished" );
jd->flags |= JFLAG_AUTHENTICATED | JFLAG_STREAM_RESTART;
}
else if( strcmp( node->name, "failure" ) == 0 )
{
- hide_login_progress( gc, "Authentication failure" );
- signoff( gc );
+ hide_login_progress( ic, "Authentication failure" );
+ signoff( ic );
return XT_ABORT;
}
@@ -324,9 +324,9 @@ xt_status sasl_pkt_result( struct xt_node *node, gpointer data )
/* This one is needed to judge if we'll do authentication using IQ or SASL.
It's done by checking if the <stream:stream> from the server has a
version attribute. I don't know if this is the right way though... */
-gboolean sasl_supported( struct gaim_connection *gc )
+gboolean sasl_supported( struct im_connection *ic )
{
- struct jabber_data *jd = gc->proto_data;
+ struct jabber_data *jd = ic->proto_data;
return ( (void*) ( jd->xt && jd->xt->root && xt_find_attr( jd->xt->root, "version" ) ) ) != NULL;
}