Ignore:
Timestamp:
2015-04-10T17:10:40Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
d550358
Parents:
11e42dc
git-author:
dequis <dx@…> (09-03-15 10:14:58)
git-committer:
dequis <dx@…> (10-04-15 17:10:40)
Message:

msn: implement PUT /user to set status as online

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    r11e42dc rd80822c  
    178178static void msn_set_away(struct im_connection *ic, char *state, char *message)
    179179{
    180         //char *uux;
    181180        struct msn_data *md = ic->proto_data;
     181        char *nick, *psm, *idle, *statecode, *body, *buf;
    182182
    183183        if (state == NULL) {
     
    187187        }
    188188
    189         if (!msn_ns_write(ic, -1, "CHG %d %s %d:%02d\r\n", ++md->trId, md->away_state->code, MSN_CAP1, MSN_CAP2)) {
    190                 return;
    191         }
    192 
    193         uux = g_markup_printf_escaped("<EndpointData><Capabilities>%d:%02d"
    194                                       "</Capabilities></EndpointData>",
    195                                       MSN_CAP1, MSN_CAP2);
    196         msn_ns_write(ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen(uux), uux);
    197         g_free(uux);
    198 
    199         uux = g_markup_printf_escaped("<PrivateEndpointData><EpName>%s</EpName>"
    200                                       "<Idle>%s</Idle><ClientType>%d</ClientType>"
    201                                       "<State>%s</State></PrivateEndpointData>",
    202                                       md->uuid,
    203                                       strcmp(md->away_state->code, "IDL") ? "false" : "true",
    204                                       1,  /* ? */
    205                                       md->away_state->code);
    206         msn_ns_write(ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen(uux), uux);
    207         g_free(uux);
    208 
    209         uux = g_markup_printf_escaped("<Data><DDP></DDP><PSM>%s</PSM>"
    210                                       "<CurrentMedia></CurrentMedia>"
    211                                       "<MachineGuid>%s</MachineGuid></Data>",
    212                                       message ? message : "", md->uuid);
    213         msn_ns_write(ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen(uux), uux);
    214         g_free(uux);
     189        statecode = (char *) md->away_state->code;
     190        nick = set_getstr(&ic->acc->set, "display_name");
     191        psm = message ? message : "";
     192        idle = strcmp(statecode, "IDL") ? "false" : "true";
     193
     194        body = g_markup_printf_escaped(MSN_PUT_USER_BODY,
     195                nick, psm, psm, md->uuid, statecode, md->uuid, idle, statecode,
     196                MSN_CAP1, MSN_CAP2, MSN_CAP1, MSN_CAP2
     197        );
     198
     199        buf = g_strdup_printf(MSN_PUT_HEADERS, ic->acc->user, ic->acc->user, md->uuid,
     200                "/user", "application/user+xml",
     201                strlen(body), body);
     202        msn_ns_write(ic, -1, "PUT %d %zd\r\n%s", ++md->trId, strlen(buf), buf);
     203
     204        g_free(buf);
     205        g_free(body);
    215206}
    216207
Note: See TracChangeset for help on using the changeset viewer.