aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/jabber/io.c17
-rw-r--r--protocols/jabber/jabber.c12
-rw-r--r--protocols/jabber/jabber.h2
-rw-r--r--protocols/jabber/presence.c24
-rw-r--r--protocols/jabber/xmltree.c3
5 files changed, 49 insertions, 9 deletions
diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c
index db869714..8c0b239e 100644
--- a/protocols/jabber/io.c
+++ b/protocols/jabber/io.c
@@ -169,8 +169,6 @@ static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition
return TRUE;
}
-static gboolean jabber_start_stream( struct gaim_connection *gc );
-
gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond )
{
struct gaim_connection *gc = data;
@@ -209,7 +207,7 @@ static const struct xt_handler_entry jabber_handlers[] = {
{ NULL, NULL, NULL }
};
-static gboolean jabber_start_stream( struct gaim_connection *gc )
+gboolean jabber_start_stream( struct gaim_connection *gc )
{
struct jabber_data *jd = gc->proto_data;
int st;
@@ -235,3 +233,16 @@ static gboolean jabber_start_stream( struct gaim_connection *gc )
return st;
}
+
+gboolean jabber_end_stream( struct gaim_connection *gc )
+{
+ struct jabber_data *jd = gc->proto_data;
+ char eos[] = "</stream:stream>";
+
+ /* Let's only do this if the queue is currently empty, otherwise it'd
+ take too long anyway. */
+ if( jd->tx_len > 0 )
+ return TRUE;
+ else
+ return jabber_write( gc, eos, strlen( eos ) );
+}
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index 84d7e366..132a355c 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -90,6 +90,8 @@ static void jabber_close( struct gaim_connection *gc )
{
struct jabber_data *jd = gc->proto_data;
+ jabber_end_stream( gc );
+
if( jd->r_inpa >= 0 )
b_event_remove( jd->r_inpa );
if( jd->w_inpa >= 0 )
@@ -108,7 +110,15 @@ static void jabber_close( struct gaim_connection *gc )
static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )
{
- return 0;
+ struct xt_node *node;
+ int st;
+
+ node = xt_new_node( "body", message, NULL );
+ node = jabber_make_packet( "message", "chat", who, node );
+ st = jabber_write_packet( gc, node );
+ xt_free_node( node );
+
+ return st;
}
static GList *jabber_away_states( struct gaim_connection *gc )
diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h
index 85765628..93e2baab 100644
--- a/protocols/jabber/jabber.h
+++ b/protocols/jabber/jabber.h
@@ -55,6 +55,8 @@ struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_
int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node );
int jabber_write( struct gaim_connection *gc, char *buf, int len );
gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond );
+gboolean jabber_start_stream( struct gaim_connection *gc );
+gboolean jabber_end_stream( struct gaim_connection *gc );
struct jabber_data
{
diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c
index 46e2b3b2..8004ed40 100644
--- a/protocols/jabber/presence.c
+++ b/protocols/jabber/presence.c
@@ -25,10 +25,30 @@
xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
{
+ struct gaim_connection *gc = data;
char *from = xt_find_attr( node, "from" );
+ char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */
+ char *s;
- printf( "Received PRES from %s:\n", from );
- xt_print( node );
+ if( !from )
+ return XT_HANDLED;
+
+ s = strchr( from, '/' );
+ if( s )
+ *s = 0;
+
+ if( type == NULL )
+ serv_got_update( gc, from, 1, 0, 0, 0, 0, 0 );
+ else if( strcmp( type, "unavailable" ) == 0 )
+ serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );
+ else
+ {
+ printf( "Received PRES from %s:\n", from );
+ xt_print( node );
+ }
+
+ if( s )
+ *s = '/';
return XT_HANDLED;
}
diff --git a/protocols/jabber/xmltree.c b/protocols/jabber/xmltree.c
index 3d0a2919..049eb5ef 100644
--- a/protocols/jabber/xmltree.c
+++ b/protocols/jabber/xmltree.c
@@ -304,9 +304,6 @@ void xt_print( struct xt_node *node )
int i;
struct xt_node *c;
- printf( "%s\n", xt_to_string( node ) );
- return;
-
/* Indentation */
for( c = node; c->parent; c = c->parent )
printf( "\t" );