Changeset ba7618d


Ignore:
Timestamp:
2015-12-27T04:39:17Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
cdd1ded
Parents:
98d46d5
Message:

purple: Show self-messages for private messages only

Those are purple_conversation_write with PURPLE_MESSAGE_SEND flag set,
received through the write_conv UI op.

write_chat and write_im still receive and filter PURPLE_MESSAGE_SEND.
In the case of write_chat it *could* show some of those, but it seems
there's no decent way to tell echoes apart from remote self-messages.
So just keep those hidden for now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/purple/purple.c

    r98d46d5 rba7618d  
    964964}
    965965
    966 void prplcb_conv_chat_msg(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags,
    967                           time_t mtime)
    968 {
     966/* Generic handler for IM or chat messages, covers write_chat, write_im and write_conv */
     967static void handle_conv_msg(PurpleConversation *conv, const char *who, const char *message, guint32 bee_flags, time_t mtime)
     968{
     969        struct im_connection *ic = purple_ic_by_pa(conv->account);
    969970        struct groupchat *gc = conv->ui_data;
    970971        PurpleBuddy *buddy;
    971 
    972         /* ..._SEND means it's an outgoing message, no need to echo those. */
    973         if (flags & PURPLE_MESSAGE_SEND) {
    974                 return;
    975         }
    976972
    977973        buddy = purple_find_buddy(conv->account, who);
     
    980976        }
    981977
    982         imcb_chat_msg(gc, who, (char *) message, 0, mtime);
    983 }
    984 
    985 static void prplcb_conv_im(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags,
    986                            time_t mtime)
    987 {
    988         struct im_connection *ic = purple_ic_by_pa(conv->account);
    989         PurpleBuddy *buddy;
    990 
    991         /* ..._SEND means it's an outgoing message, no need to echo those. */
     978        if (conv->type == PURPLE_CONV_TYPE_IM) {
     979                imcb_buddy_msg(ic, (char *) who, (char *) message, bee_flags, mtime);
     980        } else if (gc) {
     981                imcb_chat_msg(gc, who, (char *) message, bee_flags, mtime);
     982        }
     983}
     984
     985/* Handles write_im and write_chat. Removes echoes of locally sent messages */
     986static void prplcb_conv_msg(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime)
     987{
     988        if (!(flags & PURPLE_MESSAGE_SEND)) {
     989                handle_conv_msg(conv, who, message, 0, mtime);
     990        }
     991}
     992
     993/* Handles write_conv. Only passes self messages from other locations through.
     994 * That is, only writes of PURPLE_MESSAGE_SEND.
     995 * There are more events which might be handled in the future, but some are tricky.
     996 * (images look like <img id="123">, what do i do with that?) */
     997static void prplcb_conv_write(PurpleConversation *conv, const char *who, const char *alias, const char *message,
     998                              PurpleMessageFlags flags, time_t mtime)
     999{
    9921000        if (flags & PURPLE_MESSAGE_SEND) {
    993                 return;
    994         }
    995 
    996         buddy = purple_find_buddy(conv->account, who);
    997         if (buddy != NULL) {
    998                 who = purple_buddy_get_name(buddy);
    999         }
    1000 
    1001         imcb_buddy_msg(ic, (char *) who, (char *) message, 0, mtime);
     1001                handle_conv_msg(conv, who, message, OPT_SELFMESSAGE, mtime);
     1002        }
    10021003}
    10031004
     
    10321033        prplcb_conv_new,           /* create_conversation  */
    10331034        prplcb_conv_free,          /* destroy_conversation */
    1034         prplcb_conv_chat_msg,      /* write_chat           */
    1035         prplcb_conv_im,            /* write_im             */
    1036         NULL,                      /* write_conv           */
     1035        prplcb_conv_msg,           /* write_chat           */
     1036        prplcb_conv_msg,           /* write_im             */
     1037        prplcb_conv_write,         /* write_conv           */
    10371038        prplcb_conv_add_users,     /* chat_add_users       */
    10381039        NULL,                      /* chat_rename_user     */
Note: See TracChangeset for help on using the changeset viewer.