aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/jabber/jabber.c44
-rw-r--r--protocols/jabber/jabber.h1
-rw-r--r--protocols/jabber/presence.c19
3 files changed, 32 insertions, 32 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index 132a355c..13eac23e 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -121,6 +121,7 @@ static int jabber_send_im( struct gaim_connection *gc, char *who, char *message,
return st;
}
+/* TODO: For away state handling, implement some list like the one for MSN. */
static GList *jabber_away_states( struct gaim_connection *gc )
{
GList *l = NULL;
@@ -135,11 +136,19 @@ static GList *jabber_away_states( struct gaim_connection *gc )
static void jabber_set_away( struct gaim_connection *gc, char *state, char *message )
{
+ /* For now let's just always set state to "away" and send the message, if available. */
+ presence_send( gc, NULL, g_strcasecmp( state, "Online" ) == 0 ? NULL : "away", message );
+}
+
+static void jabber_keepalive( struct gaim_connection *gc )
+{
+ /* Just any whitespace character is enough as a keepalive for XMPP sessions. */
+ jabber_write( gc, "\n", 1 );
}
void jabber_init()
{
- struct prpl *ret = g_new0(struct prpl, 1);
+ struct prpl *ret = g_new0( struct prpl, 1 );
ret->name = "jabber";
ret->login = jabber_login;
@@ -157,7 +166,7 @@ void jabber_init()
// ret->chat_invite = jabber_chat_invite;
// ret->chat_leave = jabber_chat_leave;
// ret->chat_open = jabber_chat_open;
-// ret->keepalive = jabber_keepalive;
+ ret->keepalive = jabber_keepalive;
// ret->add_permit = jabber_add_permit;
// ret->rem_permit = jabber_rem_permit;
// ret->add_deny = jabber_add_deny;
@@ -165,34 +174,5 @@ void jabber_init()
// ret->send_typing = jabber_send_typing;
ret->handle_cmp = g_strcasecmp;
- register_protocol(ret);
-}
-
-#if 0
-int main( int argc, char *argv[] )
-{
- struct xt_parser *xt = xt_new( NULL );
- struct xt_node *msg;
- int i;
- char buf[512];
-
- msg = xt_new_node( "message", NULL, xt_new_node( "body", "blaataap-test", NULL ) );
- xt_add_child( msg, xt_new_node( "html", NULL, xt_new_node( "body", "<b>blaataap in html</b>", NULL ) ) );
- xt_add_attr( msg, "xmlns", "jabber:client" );
- xt_add_attr( xt_find_node( msg->children, "html" ), "xmlns", "html rotte zooi" );
- printf( "%s\n", xt_to_string( msg ) );
-
- while( ( i = read( 0, buf, 512 ) ) > 0 )
- {
- if( xt_feed( xt, buf, i ) < 1 )
- break;
- }
- xt->handlers = jabber_handlers;
- xt_handle( xt, NULL );
-
- xt_cleanup( xt, NULL );
- printf( "%d\n", xt->root );
-
- xt_free( xt );
+ register_protocol( ret );
}
-#endif
diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h
index 45747fcb..775cd787 100644
--- a/protocols/jabber/jabber.h
+++ b/protocols/jabber/jabber.h
@@ -45,6 +45,7 @@ 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_announce( struct gaim_connection *gc );
+int presence_send( struct gaim_connection *gc, char *to, char *show, char *status );
/* jabber_util.c */
char *set_eval_resprio( set_t *set, char *value );
diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c
index 8004ed40..75e8786c 100644
--- a/protocols/jabber/presence.c
+++ b/protocols/jabber/presence.c
@@ -53,6 +53,8 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
return XT_HANDLED;
}
+/* Send the <presence/> tag that finalizes the whole login process, from here
+ we'll actually show up as online to our buddies. */
int presence_announce( struct gaim_connection *gc )
{
struct xt_node *node;
@@ -68,3 +70,20 @@ int presence_announce( struct gaim_connection *gc )
xt_free_node( node );
return st;
}
+
+int presence_send( struct gaim_connection *gc, char *to, char *show, char *status )
+{
+ struct xt_node *node;
+ int st;
+
+ node = jabber_make_packet( "presence", NULL, to, NULL );
+ if( 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 );
+
+ xt_free_node( node );
+ return st;
+}