Changeset 99fe030 for protocols


Ignore:
Timestamp:
2015-05-13T08:05:01Z (5 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
a6bed1a
Parents:
a733669
Message:

msn: Implement sending typing notifications

Also remove some old unused debug stuff

Location:
protocols/msn
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    ra733669 r99fe030  
    144144{
    145145        struct bee_user *bu = bee_user_by_handle(ic->bee, ic, who);
    146 
    147 #ifdef DEBUG
    148         if (strcmp(who, "raw") == 0) {
    149                 msn_ns_write(ic, -1, "%s\r\n", message);
    150                 return 0;
    151         }
    152 #endif
    153 
    154         msn_ns_sendmessage(ic, bu, message);
    155         return(0);
     146        msn_ns_send_message(ic, bu, message);
     147        return 0;
    156148}
    157149
     
    277269                return 0;
    278270        } else if (typing & OPT_TYPING) {
    279                 return(msn_buddy_msg(ic, who, TYPING_NOTIFICATION_MESSAGE, 0));
     271                return msn_ns_send_typing(ic, bu);
    280272        } else {
    281273                return 1;
  • protocols/msn/msn.h

    ra733669 r99fe030  
    2626#ifndef _MSN_H
    2727#define _MSN_H
    28 
    29 /* Some hackish magicstrings to make special-purpose messages/switchboards.
    30  */
    31 #define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r"
    32 #define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r"
    33 
    34 #ifdef DEBUG_MSN
    35 #define debug(text ...) imcb_log(ic, text);
    36 #else
    37 #define debug(text ...)
    38 #endif
    3928
    4029/* This should be MSN Messenger 7.0.0813
     
    7665#define MSN_MESSAGE_HEADERS MSN_BASE_HEADERS \
    7766        "Messaging: 2.0\r\n" \
    78         "Message-Type: Text\r\n" \
     67        "Message-Type: %s\r\n" \
    7968        "Content-Length: %zd\r\n" \
    8069        "Content-Type: text/plain; charset=UTF-8\r\n" \
     
    10291        "</user>"
    10392
    104 #define MSN_TYPING_HEADERS "MIME-Version: 1.0\r\n" \
    105         "Content-Type: text/x-msmsgscontrol\r\n" \
    106         "TypingUser: %s\r\n" \
    107         "\r\n\r\n"
    108 
    10993#define PROFILE_URL "http://members.msn.com/"
    11094
     
    235219void msn_auth_got_contact_list(struct im_connection *ic);
    236220int msn_ns_finish_login(struct im_connection *ic);
    237 int msn_ns_sendmessage(struct im_connection *ic, struct bee_user *bu, const char *text);
     221int msn_ns_send_typing(struct im_connection *ic, struct bee_user *bu);
     222int msn_ns_send_message(struct im_connection *ic, struct bee_user *bu, const char *text);
    238223int msn_ns_command(struct msn_data *md, char **cmd, int num_parts);
    239224int msn_ns_message(struct msn_data *md, char *msg, int msglen, char **cmd, int num_parts);
  • protocols/msn/ns.c

    ra733669 r99fe030  
    724724}
    725725
    726 // TODO: typing notifications, nudges lol, etc
    727 int msn_ns_sendmessage(struct im_connection *ic, bee_user_t *bu, const char *text)
     726static int msn_ns_send_sdg(struct im_connection *ic, bee_user_t *bu, const char *message_type, const char *text)
    728727{
    729728        struct msn_data *md = ic->proto_data;
     
    731730        char *buf;
    732731
    733         if (strncmp(text, "\r\r\r", 3) == 0) {
    734                 /* Err. Shouldn't happen but I guess it can. Don't send others
    735                    any of the "SHAKE THAT THING" messages. :-D */
    736                 return 1;
    737         }
    738 
    739         buf = g_strdup_printf(MSN_MESSAGE_HEADERS, bu->handle, ic->acc->user, md->uuid, strlen(text), text);
     732        buf = g_strdup_printf(MSN_MESSAGE_HEADERS, bu->handle, ic->acc->user, md->uuid, message_type, strlen(text), text);
    740733        retval = msn_ns_write(ic, -1, "SDG %d %zd\r\n%s", ++md->trId, strlen(buf), buf);
    741734        g_free(buf);
    742735        return retval;
    743736}
     737
     738int msn_ns_send_typing(struct im_connection *ic, bee_user_t *bu)
     739{
     740        return msn_ns_send_sdg(ic, bu, "Control/Typing", "");
     741}
     742
     743int msn_ns_send_message(struct im_connection *ic, bee_user_t *bu, const char *text)
     744{
     745        return msn_ns_send_sdg(ic, bu, "Text", text);
     746}
     747
Note: See TracChangeset for help on using the changeset viewer.