Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    rdf1fb67 ref5c185  
    5454       
    5555        s = set_add( &acc->set, "tls", "try", set_eval_tls, acc );
     56        s->flags |= ACC_SET_OFFLINE_ONLY;
     57       
     58        s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc );
    5659        s->flags |= ACC_SET_OFFLINE_ONLY;
    5760}
     
    189192                imc_logout( ic, TRUE );
    190193        }
     194       
     195        if( set_getbool( &acc->set, "xmlconsole" ) )
     196        {
     197                jd->flags |= JFLAG_XMLCONSOLE;
     198                /* Shouldn't really do this at this stage already, maybe. But
     199                   I think this shouldn't break anything. */
     200                imcb_add_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL );
     201        }
    191202}
    192203
     
    196207       
    197208        jabber_end_stream( ic );
     209       
     210        while( ic->groupchats )
     211                jabber_chat_free( ic->groupchats );
    198212       
    199213        if( jd->r_inpa >= 0 )
     
    224238        struct jabber_buddy *bud;
    225239        struct xt_node *node;
     240        char *s;
    226241        int st;
    227242       
    228         bud = jabber_buddy_by_jid( ic, who, 0 );
     243        if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )
     244                return jabber_write( ic, message, strlen( message ) );
     245       
     246        if( ( s = strchr( who, '=' ) ) && jabber_chat_by_name( ic, s + 1 ) )
     247                bud = jabber_buddy_by_ext_jid( ic, who, 0 );
     248        else
     249                bud = jabber_buddy_by_jid( ic, who, 0 );
    229250       
    230251        node = xt_new_node( "body", message, NULL );
     
    311332static void jabber_add_buddy( struct im_connection *ic, char *who, char *group )
    312333{
     334        struct jabber_data *jd = ic->proto_data;
     335       
     336        if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )
     337        {
     338                jd->flags |= JFLAG_XMLCONSOLE;
     339                imcb_add_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL );
     340                return;
     341        }
     342       
    313343        if( jabber_add_to_roster( ic, who, NULL ) )
    314344                presence_send_request( ic, who, "subscribe" );
     
    317347static void jabber_remove_buddy( struct im_connection *ic, char *who, char *group )
    318348{
     349        struct jabber_data *jd = ic->proto_data;
     350       
     351        if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )
     352        {
     353                jd->flags &= ~JFLAG_XMLCONSOLE;
     354                /* Not necessary for now. And for now the code isn't too
     355                   happy if the buddy is completely gone right after calling
     356                   this function already.
     357                imcb_remove_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL );
     358                */
     359                return;
     360        }
     361       
    319362        /* We should always do this part. Clean up our administration a little bit. */
    320363        jabber_buddy_remove_bare( ic, who );
     
    322365        if( jabber_remove_from_roster( ic, who ) )
    323366                presence_send_request( ic, who, "unsubscribe" );
     367}
     368
     369static struct groupchat *jabber_chat_join_( struct im_connection *ic, char *room, char *nick, char *password )
     370{
     371        if( strchr( room, '@' ) == NULL )
     372                imcb_error( ic, "Invalid room name: %s", room );
     373        else if( jabber_chat_by_name( ic, room ) )
     374                imcb_error( ic, "Already present in chat `%s'", room );
     375        else
     376                return jabber_chat_join( ic, room, nick, password );
     377       
     378        return NULL;
     379}
     380
     381static void jabber_chat_msg_( struct groupchat *c, char *message, int flags )
     382{
     383        if( c && message )
     384                jabber_chat_msg( c, message, flags );
     385}
     386
     387static void jabber_chat_topic_( struct groupchat *c, char *topic )
     388{
     389        if( c && topic )
     390                jabber_chat_topic( c, topic );
     391}
     392
     393static void jabber_chat_leave_( struct groupchat *c )
     394{
     395        if( c )
     396                jabber_chat_leave( c, NULL );
    324397}
    325398
     
    388461        ret->buddy_msg = jabber_buddy_msg;
    389462        ret->away_states = jabber_away_states;
    390 //      ret->get_status_string = jabber_get_status_string;
    391463        ret->set_away = jabber_set_away;
    392464//      ret->set_info = jabber_set_info;
     
    394466        ret->add_buddy = jabber_add_buddy;
    395467        ret->remove_buddy = jabber_remove_buddy;
    396 //      ret->chat_msg = jabber_chat_msg;
     468        ret->chat_msg = jabber_chat_msg_;
     469        ret->chat_topic = jabber_chat_topic_;
    397470//      ret->chat_invite = jabber_chat_invite;
    398 //      ret->chat_leave = jabber_chat_leave;
    399 //      ret->chat_open = jabber_chat_open;
     471        ret->chat_leave = jabber_chat_leave_;
     472        ret->chat_join = jabber_chat_join_;
    400473        ret->keepalive = jabber_keepalive;
    401474        ret->send_typing = jabber_send_typing;
Note: See TracChangeset for help on using the changeset viewer.