Changeset bb95d43 for protocols/jabber


Ignore:
Timestamp:
2007-06-04T11:32:37Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
54f2f55
Parents:
6286f80
Message:

Added a real XML-console to the Jabber module! Add the handle "xmlconsole"
(without any @server part) to your contact list and you'll see all XMPP
traffic going in and out, and messages sent to the buddy will be sent as
packets to the server.

Location:
protocols/jabber
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    r6286f80 rbb95d43  
    4444        struct jabber_data *jd = ic->proto_data;
    4545        gboolean ret;
     46       
     47        if( jd->flags & JFLAG_XMLCONSOLE )
     48        {
     49                char *msg;
     50               
     51                msg = g_strdup_printf( "TX: %s", buf );
     52                imcb_buddy_msg( ic, JABBER_XMLCONSOLE_HANDLE, msg, 0, 0 );
     53                g_free( msg );
     54        }
    4655       
    4756        if( jd->tx_len == 0 )
     
    484493}
    485494
     495static xt_status jabber_xmlconsole( struct xt_node *node, gpointer data )
     496{
     497        struct im_connection *ic = data;
     498        struct jabber_data *jd = ic->proto_data;
     499       
     500        if( jd->flags & JFLAG_XMLCONSOLE )
     501        {
     502                char *msg, *pkt;
     503               
     504                pkt = xt_to_string( node );
     505                msg = g_strdup_printf( "RX: %s", pkt );
     506                imcb_buddy_msg( ic, JABBER_XMLCONSOLE_HANDLE, msg, 0, 0 );
     507                g_free( msg );
     508                g_free( pkt );
     509        }
     510       
     511        return XT_NEXT;
     512}
     513
    486514static const struct xt_handler_entry jabber_handlers[] = {
     515        { NULL,                 "stream:stream",        jabber_xmlconsole },
    487516        { "stream:stream",      "<root>",               jabber_end_of_stream },
    488517        { "message",            "stream:stream",        jabber_pkt_message },
  • protocols/jabber/jabber.c

    r6286f80 rbb95d43  
    226226        int st;
    227227       
     228        if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )
     229                return jabber_write( ic, message, strlen( message ) );
     230       
    228231        bud = jabber_buddy_by_jid( ic, who, 0 );
    229232       
     
    311314static void jabber_add_buddy( struct im_connection *ic, char *who, char *group )
    312315{
     316        struct jabber_data *jd = ic->proto_data;
     317       
     318        if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )
     319        {
     320                jd->flags |= JFLAG_XMLCONSOLE;
     321                imcb_add_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL );
     322                return;
     323        }
     324       
    313325        if( jabber_add_to_roster( ic, who, NULL ) )
    314326                presence_send_request( ic, who, "subscribe" );
     
    317329static void jabber_remove_buddy( struct im_connection *ic, char *who, char *group )
    318330{
     331        struct jabber_data *jd = ic->proto_data;
     332       
     333        if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )
     334        {
     335                jd->flags &= ~JFLAG_XMLCONSOLE;
     336                /* FIXME imcb_remove_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL ); */
     337                return;
     338        }
     339       
    319340        /* We should always do this part. Clean up our administration a little bit. */
    320341        jabber_buddy_remove_bare( ic, who );
  • protocols/jabber/jabber.h

    r6286f80 rbb95d43  
    3232typedef enum
    3333{
    34         JFLAG_STREAM_STARTED = 1,       /* Set when we detected the beginning of the stream
     34        JFLAG_STREAM_STARTED = 1,       /* Set when we detected the beginning of the stream
    3535                                           and want to do auth. */
    36         JFLAG_AUTHENTICATED = 2,        /* Set when we're successfully authenticatd. */
    37         JFLAG_STREAM_RESTART = 4,       /* Set when we want to restart the stream (after
     36        JFLAG_AUTHENTICATED = 2,        /* Set when we're successfully authenticatd. */
     37        JFLAG_STREAM_RESTART = 4,       /* Set when we want to restart the stream (after
    3838                                           SASL or TLS). */
    39         JFLAG_WAIT_SESSION = 8,         /* Set if we sent a <session> tag and need a reply
     39        JFLAG_WAIT_SESSION = 8,         /* Set if we sent a <session> tag and need a reply
    4040                                           before we continue. */
    41         JFLAG_WAIT_BIND = 16,           /* ... for <bind> tag. */
    42         JFLAG_WANT_TYPING = 32,         /* Set if we ever sent a typing notification, this
     41        JFLAG_WAIT_BIND = 16,           /* ... for <bind> tag. */
     42        JFLAG_WANT_TYPING = 32,         /* Set if we ever sent a typing notification, this
    4343                                           activates all XEP-85 related code. */
     44        JFLAG_XMLCONSOLE = 64,          /* If the user added an xmlconsole buddy. */
    4445} jabber_flags_t;
    4546
     
    5657} jabber_buddy_flags_t;
    5758
    58 #define JABBER_PORT_DEFAULT "5222"
    59 #define JABBER_PORT_MIN 5220
    60 #define JABBER_PORT_MAX 5229
    61 
    6259struct jabber_data
    6360{
     
    124121        struct jabber_buddy *me;
    125122};
     123
     124#define JABBER_XMLCONSOLE_HANDLE "xmlconsole"
     125
     126#define JABBER_PORT_DEFAULT "5222"
     127#define JABBER_PORT_MIN 5220
     128#define JABBER_PORT_MAX 5229
    126129
    127130/* Prefixes to use for packet IDs (mainly for IQ packets ATM). Usually the
  • protocols/jabber/xmltree.c

    r6286f80 rbb95d43  
    188188                                               g_strcasecmp( xt->handlers[i].parent, "<root>" ) == 0 ) ) )
    189189                        {
    190                                 xt_print( node );
    191                                
    192190                                st = xt->handlers[i].func( node, xt->data );
    193191                               
Note: See TracChangeset for help on using the changeset viewer.