Changeset f485008


Ignore:
Timestamp:
2010-05-01T23:55:48Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
a348d00
Parents:
c521362
Message:

Support at least incoming groupchats. Not sure yet how starting them is
going to work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/purple/purple.c

    rc521362 rf485008  
    365365}
    366366
     367static void purple_chat_msg( struct groupchat *gc, char *message, int flags )
     368{
     369        PurpleConversation *pc = gc->data;
     370       
     371        purple_conv_chat_send( purple_conversation_get_chat_data( pc ), message );
     372}
     373
    367374void purple_transfer_request( struct im_connection *ic, file_transfer_t *ft, char *handle );
    368375
     
    506513};
    507514
    508 static void prplcb_conv_im( PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime )
    509 {
    510         struct im_connection *ic = purple_ic_by_pa( conv->account );
     515void prplcb_conv_new( PurpleConversation *conv )
     516{
     517        if( conv->type == PURPLE_CONV_TYPE_CHAT )
     518        {
     519                struct im_connection *ic = purple_ic_by_pa( conv->account );
     520                struct groupchat *gc;
     521               
     522                gc = imcb_chat_new( ic, conv->name );
     523                conv->ui_data = gc;
     524                gc->data = conv;
     525        }
     526}
     527
     528void prplcb_conv_free( PurpleConversation *conv )
     529{
     530        struct groupchat *gc = conv->ui_data;
     531       
     532        imcb_chat_free( gc );
     533}
     534
     535void prplcb_conv_add_users( PurpleConversation *conv, GList *cbuddies, gboolean new_arrivals )
     536{
     537        struct groupchat *gc = conv->ui_data;
     538        GList *b;
     539       
     540        for( b = cbuddies; b; b = b->next )
     541        {
     542                PurpleConvChatBuddy *pcb = b->data;
     543               
     544                imcb_chat_add_buddy( gc, pcb->name );
     545        }
     546}
     547
     548void prplcb_conv_del_users( PurpleConversation *conv, GList *cbuddies )
     549{
     550        struct groupchat *gc = conv->ui_data;
     551        GList *b;
     552       
     553        for( b = cbuddies; b; b = b->next )
     554                imcb_chat_remove_buddy( gc, b->data, "" );
     555}
     556
     557void prplcb_conv_chat_msg( PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime )
     558{
     559        struct groupchat *gc = conv->ui_data;
    511560        PurpleBuddy *buddy;
    512561       
     
    519568                who = purple_buddy_get_name( buddy );
    520569       
     570        imcb_chat_msg( gc, who, (char*) message, 0, mtime );
     571}
     572
     573static void prplcb_conv_im( PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime )
     574{
     575        struct im_connection *ic = purple_ic_by_pa( conv->account );
     576        PurpleBuddy *buddy;
     577       
     578        /* ..._SEND means it's an outgoing message, no need to echo those. */
     579        if( flags & PURPLE_MESSAGE_SEND )
     580                return;
     581       
     582        buddy = purple_find_buddy( conv->account, who );
     583        if( buddy != NULL )
     584                who = purple_buddy_get_name( buddy );
     585       
    521586        imcb_buddy_msg( ic, (char*) who, (char*) message, 0, mtime );
    522587}
     
    524589static PurpleConversationUiOps bee_conv_uiops =
    525590{
    526         NULL,                      /* create_conversation  */
    527         NULL,                      /* destroy_conversation */
    528         NULL,                      /* write_chat           */
     591        prplcb_conv_new,           /* create_conversation  */
     592        prplcb_conv_free,          /* destroy_conversation */
     593        prplcb_conv_chat_msg,      /* write_chat           */
    529594        prplcb_conv_im,            /* write_im             */
    530595        NULL,                      /* write_conv           */
    531         NULL,                      /* chat_add_users       */
     596        prplcb_conv_add_users,     /* chat_add_users       */
    532597        NULL,                      /* chat_rename_user     */
    533         NULL,                      /* chat_remove_users    */
     598        prplcb_conv_del_users,     /* chat_remove_users    */
    534599        NULL,                      /* chat_update_user     */
    535600        NULL,                      /* present              */
     
    918983        funcs.send_typing = purple_send_typing;
    919984        funcs.handle_cmp = g_strcasecmp;
    920         /* TODO(wilmer): Set this one only for protocols that support it? */
     985        /* TODO(wilmer): Set these only for protocols that support them? */
     986        funcs.chat_msg = purple_chat_msg;
    921987        funcs.transfer_request = purple_transfer_request;
    922988       
Note: See TracChangeset for help on using the changeset viewer.