Changeset 3901b5d for protocols


Ignore:
Timestamp:
2012-09-25T22:48:56Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
208db4b
Parents:
ba86713
Message:

Support for receiving messages via the NS (UBM command).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/ns.c

    rba86713 r3901b5d  
    571571                if( num_parts >= 2 )
    572572                        handler->msglen = atoi( cmd[1] );
     573        }
     574        else if( strcmp( cmd[0], "UBM" ) == 0 )
     575        {
     576                if( num_parts >= 7 )
     577                        handler->msglen = atoi( cmd[6] );
    573578        }
    574579        else if( isdigit( cmd[0][0] ) )
     
    773778                                        continue;
    774779                               
     780                                /* FIXME: Use "t" here, guess I should just add it
     781                                   as a prefix like elsewhere in the protocol. */
    775782                                handle = g_strdup_printf( "%s@%s", cn, dn );
    776783                                if( !( ( bu = bee_user_by_handle( ic->bee, ic, handle ) ) ||
     
    798805                }
    799806        }
    800        
    801         return( 1 );
     807        else if( strcmp( cmd[0], "UBM" ) == 0 )
     808        {
     809                char *ct = get_rfc822_header( msg, "Content-Type", msglen );
     810                char *handle;
     811               
     812                if( strncmp( ct, "text/plain", 10 ) != 0 )
     813                {
     814                        g_free( ct );
     815                        return 1;
     816                }
     817                if( strcmp( cmd[2], "1" ) != 0 )
     818                        handle = g_strdup_printf( "%s:%s", cmd[2], cmd[1] );
     819                else
     820                        handle = g_strdup( cmd[1] );
     821               
     822                imcb_buddy_msg( ic, handle, body, 0, 0 );
     823                g_free( handle );
     824        }
     825       
     826        return 1;
    802827}
    803828
     
    866891        xt_add_attr( c, "n", handle );
    867892        xt_add_attr( c, "l", l );
    868         xt_add_attr( c, "t", "1" ); /* 1 means normal, 4 means mobile? */
     893        xt_add_attr( c, "t", "1" ); /* FIXME: Network type, i.e. 32 for Y!MSG */
    869894        xt_insert_child( d, c );
    870895       
     
    958983        if( msn_ns_write( ic, -1, "UUM %d %s %d %d %zd\r\n%s",
    959984                                  ++md->trId, bu->handle,
    960                                   1, /* type == MSN offline message */
     985                                  1, /* type == MSN (offline) message */
    961986                                  1, /* type == IM (not nudge/typing) */
    962987                                  strlen( buf ), buf ) )
Note: See TracChangeset for help on using the changeset viewer.