Changeset d93c0eb9


Ignore:
Timestamp:
2010-08-14T12:20:59Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
4452e69
Parents:
12767e3
Message:

Read incoming MSN status/away messages.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • lib/xmltree.c

    r12767e3 rd93c0eb9  
    141141/* Feed the parser, don't execute any handler. Returns -1 on errors, 0 on
    142142   end-of-stream and 1 otherwise. */
    143 int xt_feed( struct xt_parser *xt, char *text, int text_len )
     143int xt_feed( struct xt_parser *xt, const char *text, int text_len )
    144144{
    145145        if( !g_markup_parse_context_parse( xt->parser, text, text_len, &xt->gerr ) )
     
    260260}
    261261
     262struct xt_node *xt_from_string( const char *in )
     263{
     264        struct xt_parser *parser;
     265        struct xt_node *ret;
     266       
     267        parser = xt_new( NULL, NULL );
     268        xt_feed( parser, in, strlen( in ) );
     269        ret = parser->root;
     270        parser->root = NULL;
     271        xt_free( parser );
     272       
     273        return ret;
     274}
     275
    262276static void xt_to_string_real( struct xt_node *node, GString *str )
    263277{
  • lib/xmltree.h

    r12767e3 rd93c0eb9  
    7979struct xt_parser *xt_new( const struct xt_handler_entry *handlers, gpointer data );
    8080void xt_reset( struct xt_parser *xt );
    81 int xt_feed( struct xt_parser *xt, char *text, int text_len );
     81int xt_feed( struct xt_parser *xt, const char *text, int text_len );
    8282int xt_handle( struct xt_parser *xt, struct xt_node *node, int depth );
    8383void xt_cleanup( struct xt_parser *xt, struct xt_node *node, int depth );
     84struct xt_node *xt_from_string( const char *in );
    8485char *xt_to_string( struct xt_node *node );
    8586void xt_print( struct xt_node *node );
  • protocols/bee.h

    r12767e3 rd93c0eb9  
    148148 * - 'state' and 'message' can be NULL */
    149149G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message );
     150G_MODULE_EXPORT void imcb_buddy_status_msg( struct im_connection *ic, const char *handle, const char *message );
    150151G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle );
    151152/* Call when a handle says something. 'flags' and 'sent_at may be just 0. */
  • protocols/bee_user.c

    r12767e3 rd93c0eb9  
    187187        /* TODO(wilmer): OPT_AWAY, or just state == NULL ? */
    188188        bu->flags = flags;
    189         bu->status = g_strdup( ( flags & OPT_AWAY ) && state == NULL ? "Away" : state );
    190189        bu->status_msg = g_strdup( message );
     190        if( state && *state )
     191                bu->status = g_strdup( state );
     192        else if( flags & OPT_AWAY )
     193                bu->status = g_strdup( "Away" );
     194        else
     195                bu->status = NULL;
    191196       
    192197        if( bee->ui->user_status )
     
    198203}
    199204
     205/* Same, but only change the away/status message, not any away/online state info. */
     206void imcb_buddy_status_msg( struct im_connection *ic, const char *handle, const char *message )
     207{
     208        bee_t *bee = ic->bee;
     209        bee_user_t *bu, *old;
     210       
     211        if( !( bu = bee_user_by_handle( bee, ic, handle ) ) )
     212        {
     213                return;
     214        }
     215       
     216        old = g_memdup( bu, sizeof( bee_user_t ) );
     217       
     218        bu->status_msg = g_strdup( message );
     219       
     220        if( bee->ui->user_status )
     221                bee->ui->user_status( bee, bu, old );
     222       
     223        g_free( old->status_msg );
     224        g_free( old );
     225}
     226
    200227void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle )
    201228{
  • protocols/msn/ns.c

    r12767e3 rd93c0eb9  
    577577                        md->handler->msglen = atoi( cmd[3] );
    578578        }
     579        else if( strcmp( cmd[0], "NOT" ) == 0 )
     580        {
     581                /* Some kind of notification, not sure if it still exists
     582                   but we have to skip the payload or stuff breaks. */
     583                if( num_parts >= 3 )
     584                        md->handler->msglen = atoi( cmd[2] );
     585        }
    579586        else if( isdigit( cmd[0][0] ) )
    580587        {
     
    686693                }
    687694        }
     695        else if( strcmp( cmd[0], "UBX" ) == 0 )
     696        {
     697                struct xt_node *psm;
     698                char *psm_text = NULL;
     699               
     700                psm = xt_from_string( msg );
     701                if( psm && strcmp( psm->name, "Data" ) == 0 &&
     702                    ( psm = xt_find_node( psm->children, "PSM" ) ) )
     703                        psm_text = psm->text;
     704               
     705                imcb_buddy_status_msg( ic, cmd[1], psm_text );
     706                xt_free_node( psm );
     707        }
    688708       
    689709        return( 1 );
  • protocols/msn/soap.h

    r12767e3 rd93c0eb9  
    1 /* soap.h
    2  *
    3  * SOAP-related functions. Some manager at Microsoft apparently thought
    4  * MSNP wasn't XMLy enough so someone stepped up and changed that. This
    5  * is the result.
    6  *
    7  * Copyright (C) 2010 Wilmer van der Gaast <wilmer@gaast.net>
    8  *
    9  * This program is free software; you can redistribute it and/or modify             
    10  * it under the terms of the GNU General Public License version 2                   
    11  * as published by the Free Software Foundation                                     
    12  *                                                                                   
    13  * This program is distributed in the hope that is will be useful,                 
    14  * bit WITHOU ANY WARRANTY; without even the implied warranty of                   
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                   
    16  * GNU General Public License for more details.                                     
    17  *                                                                                   
    18  * You should have received a copy of the GNU General Public License               
    19  * along with this program; if not, write to the Free Software                     
    20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA         
    21  */
     1  /********************************************************************\
     2  * BitlBee -- An IRC to other IM-networks gateway                     *
     3  *                                                                    *
     4  * Copyright 2002-2010 Wilmer van der Gaast and others                *
     5  \********************************************************************/
     6
     7/* MSN module - All the SOAPy XML stuff.
     8   Some manager at Microsoft apparently thought MSNP wasn't XMLy enough so
     9   someone stepped up and changed that. This is the result. Kilobytes and
     10   more kilobytes of XML vomit to transfer tiny bits of informaiton. */
     11
     12/*
     13  This program is free software; you can redistribute it and/or modify
     14  it under the terms of the GNU General Public License as published by
     15  the Free Software Foundation; either version 2 of the License, or
     16  (at your option) any later version.
     17
     18  This program is distributed in the hope that it will be useful,
     19  but WITHOUT ANY WARRANTY; without even the implied warranty of
     20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     21  GNU General Public License for more details.
     22
     23  You should have received a copy of the GNU General Public License with
     24  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
     25  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
     26  Suite 330, Boston, MA  02111-1307  USA
     27*/
    2228
    2329/* Thanks to http://msnpiki.msnfanatic.com/ for lots of info on this! */
Note: See TracChangeset for help on using the changeset viewer.