Changeset 1aa74f55 for protocols


Ignore:
Timestamp:
2010-08-23T10:34:36Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
bd599b9
Parents:
241f9f6
Message:

Process incoming XMPP groupchat invites in a saner way: Create a temporary
channel the user can easily /join.

Location:
protocols
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/bee.h

    r241f9f6 r1aa74f55  
    123123        gboolean (*chat_topic)( bee_t *bee, struct groupchat *c, const char *new, bee_user_t *bu );
    124124        gboolean (*chat_name_hint)( bee_t *bee, struct groupchat *c, const char *name );
     125        gboolean (*chat_invite)( bee_t *bee, bee_user_t *bu, const char *name, const char *msg );
    125126       
    126127        struct file_transfer* (*ft_in_start)( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size );
     
    175176G_MODULE_EXPORT int bee_chat_msg( bee_t *bee, struct groupchat *c, const char *msg, int flags );
    176177G_MODULE_EXPORT struct groupchat *bee_chat_by_title( bee_t *bee, struct im_connection *ic, const char *title );
     178G_MODULE_EXPORT void imcb_chat_invite( struct im_connection *ic, const char *name, const char *who, const char *msg );
    177179
    178180#endif /* __BEE_H__ */
  • protocols/bee_chat.c

    r241f9f6 r1aa74f55  
    233233        return NULL;
    234234}
     235
     236void imcb_chat_invite( struct im_connection *ic, const char *name, const char *who, const char *msg )
     237{
     238        bee_user_t *bu = bee_user_by_handle( ic->bee, ic, who );
     239       
     240        if( bu && ic->bee->ui->chat_invite )
     241                ic->bee->ui->chat_invite( ic->bee, bu, name, msg );
     242}
  • protocols/jabber/message.c

    r241f9f6 r1aa74f55  
    3131        struct xt_node *body = xt_find_node( node->children, "body" ), *c;
    3232        struct jabber_buddy *bud = NULL;
    33         char *s;
     33        char *s, *room = NULL, *reason = NULL;
    3434       
    3535        if( !from )
     
    5252                for( c = node->children; ( c = xt_find_node( c, "x" ) ); c = c->next )
    5353                {
    54                         char *ns = xt_find_attr( c, "xmlns" ), *room;
    55                         struct xt_node *inv, *reason;
     54                        char *ns = xt_find_attr( c, "xmlns" );
     55                        struct xt_node *inv;
    5656                       
    5757                        if( ns && strcmp( ns, XMLNS_MUC_USER ) == 0 &&
    5858                            ( inv = xt_find_node( c->children, "invite" ) ) )
    5959                        {
     60                                /* This is an invitation. Set some vars which
     61                                   will be passed to imcb_chat_invite() below. */
    6062                                room = from;
    6163                                if( ( from = xt_find_attr( inv, "from" ) ) == NULL )
    6264                                        from = room;
    63 
    64                                 g_string_append_printf( fullmsg, "<< \002BitlBee\002 - Invitation to chatroom %s >>\n", room );
    65                                 if( ( reason = xt_find_node( inv->children, "reason" ) ) && reason->text_len > 0 )
    66                                         g_string_append( fullmsg, reason->text );
     65                                if( ( inv = xt_find_node( inv->children, "reason" ) ) && inv->text_len > 0 )
     66                                        reason = inv->text;
    6767                        }
    6868                }
     
    104104                        imcb_buddy_msg( ic, from, fullmsg->str,
    105105                                        0, jabber_get_timestamp( node ) );
     106                if( room )
     107                        imcb_chat_invite( ic, room, from, reason );
    106108               
    107109                g_string_free( fullmsg, TRUE );
Note: See TracChangeset for help on using the changeset viewer.