Changeset d550358


Ignore:
Timestamp:
2015-04-10T17:10:40Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
cfeadc3
Parents:
d80822c
git-author:
dequis <dx@…> (09-03-15 08:26:16)
git-committer:
dequis <dx@…> (10-04-15 17:10:40)
Message:

msn: remove unsupported commands, OIMs and dead code

Location:
protocols/msn
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    rd80822c rd550358  
    9696                msn_ns_close(md);
    9797
    98                 msn_msgq_purge(ic, &md->msgq);
    9998                msn_soapq_flush(ic, FALSE);
    10099
  • protocols/msn/msn.h

    rd80822c rd550358  
    218218int msn_ns_finish_login(struct im_connection *ic);
    219219int msn_ns_sendmessage(struct im_connection *ic, struct bee_user *bu, const char *text);
    220 void msn_ns_oim_send_queue(struct im_connection *ic, GSList **msgq);
    221220int msn_ns_command(struct msn_data *md, char **cmd, int num_parts);
    222221int msn_ns_message(struct msn_data *md, char *msg, int msglen, char **cmd, int num_parts);
     
    229228char **msn_linesplit(char *line);
    230229int msn_handler(struct msn_data *h);
    231 void msn_msgq_purge(struct im_connection *ic, GSList **list);
    232230char *msn_p11_challenge(char *challenge);
    233231gint msn_domaintree_cmp(gconstpointer a_, gconstpointer b_);
  • protocols/msn/msn_util.c

    rd80822c rd550358  
    5555
    5656        *groupid = '\0';
    57 #if 0
    58         if (group) {
    59                 int i;
    60                 for (i = 0; i < md->groupcount; i++) {
    61                         if (g_strcasecmp(md->grouplist[i], group) == 0) {
    62                                 g_snprintf(groupid, sizeof(groupid), " %d", i);
    63                                 break;
    64                         }
    65                 }
    66 
    67                 if (*groupid == '\0') {
    68                         /* Have to create this group, it doesn't exist yet. */
    69                         struct msn_groupadd *ga;
    70                         GSList *l;
    71 
    72                         for (l = md->grpq; l; l = l->next) {
    73                                 ga = l->data;
    74                                 if (g_strcasecmp(ga->group, group) == 0) {
    75                                         break;
    76                                 }
    77                         }
    78 
    79                         ga = g_new0(struct msn_groupadd, 1);
    80                         ga->who = g_strdup(who);
    81                         ga->group = g_strdup(group);
    82                         md->grpq = g_slist_prepend(md->grpq, ga);
    83 
    84                         if (l == NULL) {
    85                                 char groupname[strlen(group) + 1];
    86                                 strcpy(groupname, group);
    87                                 http_encode(groupname);
    88                                 g_snprintf(buf, sizeof(buf), "ADG %d %s %d\r\n", ++md->trId, groupname, 0);
    89                                 return msn_write(ic, buf, strlen(buf));
    90                         } else {
    91                                 /* This can happen if the user's doing lots of adds to a
    92                                    new group at once; we're still waiting for the server
    93                                    to confirm group creation. */
    94                                 return 1;
    95                         }
    96                 }
    97         }
    98 #endif
    9957
    10058        if (!((bu = bee_user_by_handle(ic->bee, ic, who)) ||
     
    13290
    13391        *groupid = '\0';
    134 #if 0
    135         if (group) {
    136                 int i;
    137                 for (i = 0; i < md->groupcount; i++) {
    138                         if (g_strcasecmp(md->grouplist[i], group) == 0) {
    139                                 g_snprintf(groupid, sizeof(groupid), " %d", i);
    140                                 break;
    141                         }
    142                 }
    143         }
    144 #endif
    14592
    14693        if (!(bu = bee_user_by_handle(ic->bee, ic, who)) ||
     
    375322}
    376323
    377 void msn_msgq_purge(struct im_connection *ic, GSList **list)
    378 {
    379         struct msn_message *m;
    380         GString *ret;
    381         GSList *l;
    382         int n = 0;
    383 
    384         l = *list;
    385         if (l == NULL) {
    386                 return;
    387         }
    388 
    389         m = l->data;
    390         ret = g_string_sized_new(1024);
    391         g_string_printf(ret, "Warning: Cleaning up MSN (switchboard) connection with unsent "
    392                         "messages to %s:", m->who ? m->who : "unknown recipient");
    393 
    394         while (l) {
    395                 m = l->data;
    396 
    397                 if (strncmp(m->text, "\r\r\r", 3) != 0) {
    398                         g_string_append_printf(ret, "\n%s", m->text);
    399                         n++;
    400                 }
    401 
    402                 g_free(m->who);
    403                 g_free(m->text);
    404                 g_free(m);
    405 
    406                 l = l->next;
    407         }
    408         g_slist_free(*list);
    409         *list = NULL;
    410 
    411         if (n > 0) {
    412                 imcb_log(ic, "%s", ret->str);
    413         }
    414         g_string_free(ret, TRUE);
    415 }
    416 
    417324/* Copied and heavily modified from http://tmsnc.sourceforge.net/chl.c */
    418325char *msn_p11_challenge(char *challenge)
  • protocols/msn/ns.c

    rd80822c rd550358  
    248248                        handler->msglen = atoi(cmd[2]);
    249249                }
    250         } else if (strcmp(cmd[0], "PRP") == 0) {
    251                 imcb_connected(ic);
    252250        } else if (strcmp(cmd[0], "CHL") == 0) {
    253251                char *resp;
     
    267265                g_free(resp);
    268266                return st;
    269         } else if (strcmp(cmd[0], "ILN") == 0 || strcmp(cmd[0], "NLN") == 0) {
    270                 const struct msn_away_state *st;
    271                 const char *handle;
    272                 int cap = 0;
    273 
    274                 if (num_parts < 6) {
    275                         imcb_error(ic, "Syntax error");
    276                         imc_logout(ic, TRUE);
    277                         return(0);
    278                 }
    279                 /* ILN and NLN are more or less the same, except ILN has a trId
    280                    at the start, and NLN has a capability field at the end.
    281                    Does ILN still exist BTW? */
    282                 if (cmd[0][1] == 'I') {
    283                         cmd++;
    284                 } else {
    285                         cap = atoi(cmd[4]);
    286                 }
    287 
    288                 handle = msn_normalize_handle(cmd[2]);
    289                 if (strcmp(handle, ic->acc->user) == 0) {
    290                         return 1; /* That's me! */
    291 
    292                 }
    293                 http_decode(cmd[3]);
    294                 imcb_rename_buddy(ic, handle, cmd[3]);
    295 
    296                 st = msn_away_state_by_code(cmd[1]);
    297                 if (!st) {
    298                         /* FIXME: Warn/Bomb about unknown away state? */
    299                         st = msn_away_state_list + 1;
    300                 }
    301 
    302                 imcb_buddy_status(ic, handle, OPT_LOGGED_IN |
    303                                   (st != msn_away_state_list ? OPT_AWAY : 0) |
    304                                   (cap & 1 ? OPT_MOBILE : 0),
    305                                   st->name, NULL);
    306 
    307         } else if (strcmp(cmd[0], "FLN") == 0) {
    308                 const char *handle;
    309 
    310                 if (cmd[1] == NULL) {
    311                         return 1;
    312                 }
    313 
    314                 handle = msn_normalize_handle(cmd[1]);
    315                 imcb_buddy_status(ic, handle, 0, NULL, NULL);
    316267        } else if (strcmp(cmd[0], "OUT") == 0) {
    317268                int allow_reconnect = TRUE;
     
    329280                imc_logout(ic, allow_reconnect);
    330281                return(0);
    331         } else if (strcmp(cmd[0], "IPG") == 0) {
    332                 imcb_error(ic, "Received IPG command, we don't handle them yet.");
    333 
    334                 handler->msglen = atoi(cmd[1]);
    335 
    336                 if (handler->msglen <= 0) {
    337                         imcb_error(ic, "Syntax error");
    338                         imc_logout(ic, TRUE);
    339                         return(0);
    340                 }
    341         }
    342 #if 0
    343         else if (strcmp(cmd[0], "ADG") == 0) {
    344                 char *group = g_strdup(cmd[3]);
    345                 int groupnum, i;
    346                 GSList *l, *next;
    347 
    348                 http_decode(group);
    349                 if (sscanf(cmd[4], "%d", &groupnum) == 1) {
    350                         if (groupnum >= md->groupcount) {
    351                                 md->grouplist = g_renew(char *, md->grouplist, groupnum + 1);
    352                                 for (i = md->groupcount; i <= groupnum; i++) {
    353                                         md->grouplist[i] = NULL;
    354                                 }
    355                                 md->groupcount = groupnum + 1;
    356                         }
    357                         g_free(md->grouplist[groupnum]);
    358                         md->grouplist[groupnum] = group;
    359                 } else {
    360                         /* Shouldn't happen, but if it does, give up on the group. */
    361                         g_free(group);
    362                         imcb_error(ic, "Syntax error");
    363                         imc_logout(ic, TRUE);
    364                         return 0;
    365                 }
    366 
    367                 for (l = md->grpq; l; l = next) {
    368                         struct msn_groupadd *ga = l->data;
    369                         next = l->next;
    370                         if (g_strcasecmp(ga->group, group) == 0) {
    371                                 if (!msn_buddy_list_add(ic, "FL", ga->who, ga->who, group)) {
    372                                         return 0;
    373                                 }
    374 
    375                                 g_free(ga->group);
    376                                 g_free(ga->who);
    377                                 g_free(ga);
    378                                 md->grpq = g_slist_remove(md->grpq, ga);
    379                         }
    380                 }
    381         }
    382 #endif
    383         else if (strcmp(cmd[0], "GCF") == 0) {
     282        } else if (strcmp(cmd[0], "GCF") == 0) {
    384283                /* Coming up is cmd[2] bytes of stuff we're supposed to
    385284                   censore. Meh. */
    386285                handler->msglen = atoi(cmd[2]);
    387         } else if (strcmp(cmd[0], "UBX") == 0) {
    388                 /* Status message. */
    389                 if (num_parts >= 3) {
    390                         handler->msglen = atoi(cmd[2]);
    391                 }
    392         } else if (strcmp(cmd[0], "NOT") == 0) {
    393                 /* Some kind of notification, poorly documented but
    394                    apparently used to announce address book changes. */
    395                 if (num_parts >= 2) {
    396                         handler->msglen = atoi(cmd[1]);
    397                 }
    398286        } else if ((strcmp(cmd[0], "NFY") == 0) || (strcmp(cmd[0], "SDG") == 0)) {
    399287                if (num_parts >= 3) {
    400288                        handler->msglen = atoi(cmd[2]);
    401                 }
    402         } else if (strcmp(cmd[0], "UBM") == 0) {
    403                 if (num_parts >= 7) {
    404                         handler->msglen = atoi(cmd[6]);
    405289                }
    406290        } else if (strcmp(cmd[0], "QNG") == 0) {
     
    422306                }
    423307        } else {
    424                 /* debug( "Received unknown command from main server: %s", cmd[0] ); */
     308                imcb_error(ic, "Received unknown command from main server: %s", cmd[0]);
    425309        }
    426310
     
    501385                                }
    502386                        } else if (g_strncasecmp(ct, "text/x-msmsgsactivemailnotification", 35) == 0) {
    503                         } else if (g_strncasecmp(ct, "text/x-msmsgsinitialmdatanotification", 37) == 0 ||
    504                                    g_strncasecmp(ct, "text/x-msmsgsoimnotification", 28) == 0) {
    505                                 /* We received an offline message. Or at least notification
    506                                    that there is one waiting for us. Fetching the message(s)
    507                                    and purging them from the server is a lot of SOAPy work
    508                                    not worth doing IMHO. Also I thought it was possible to
    509                                    have the notification server send them directly, I was
    510                                    pretty sure I saw Pidgin do it..
    511 
    512                                    At least give a notification for now, seems like a
    513                                    reasonable thing to do. Only problem is, they'll keep
    514                                    coming back at login time until you read them using a
    515                                    different client. :-( */
    516 
    517                                 char *xml = get_rfc822_header(body, "Mail-Data:", blen);
    518                                 struct xt_node *md, *m;
    519 
    520                                 if (!xml) {
    521                                         return 1;
    522                                 }
    523                                 md = xt_from_string(xml, 0);
    524                                 if (!md) {
    525                                         return 1;
    526                                 }
    527 
    528                                 for (m = md->children; (m = xt_find_node(m, "M")); m = m->next) {
    529                                         struct xt_node *e = xt_find_node(m->children, "E");
    530                                         struct xt_node *rt = xt_find_node(m->children, "RT");
    531                                         struct tm tp;
    532                                         time_t msgtime = 0;
    533 
    534                                         if (!e || !e->text) {
    535                                                 continue;
    536                                         }
    537 
    538                                         memset(&tp, 0, sizeof(tp));
    539                                         if (rt && rt->text &&
    540                                             sscanf(rt->text, "%4d-%2d-%2dT%2d:%2d:%2d.",
    541                                                    &tp.tm_year, &tp.tm_mon, &tp.tm_mday,
    542                                                    &tp.tm_hour, &tp.tm_min, &tp.tm_sec) == 6) {
    543                                                 tp.tm_year -= 1900;
    544                                                 tp.tm_mon--;
    545                                                 msgtime = mktime_utc(&tp);
    546 
    547                                         }
    548                                         imcb_buddy_msg(ic, e->text,
    549                                                        "<< \002BitlBee\002 - Received offline message. BitlBee can't show these. >>", 0,
    550                                                        msgtime);
    551                                 }
    552 
    553                                 g_free(xml);
    554                                 xt_free_node(md);
     387                                /* Notification that a message has been read... Ignore it */
    555388                        } else {
    556389                                debug("Can't handle %s packet from notification server", ct);
     
    559392                        g_free(ct);
    560393                }
    561         } else if (strcmp(cmd[0], "UBX") == 0) {
    562                 struct xt_node *ubx, *psm;
    563                 char *psm_text = NULL;
    564 
    565                 ubx = xt_from_string(msg, msglen);
    566                 if (ubx && strcmp(ubx->name, "Data") == 0 &&
    567                     (psm = xt_find_node(ubx->children, "PSM"))) {
    568                         psm_text = psm->text;
    569                 }
    570 
    571                 imcb_buddy_status_msg(ic, msn_normalize_handle(cmd[1]), psm_text);
    572                 xt_free_node(ubx);
    573394        } else if (strcmp(cmd[0], "ADL") == 0) {
    574395                struct xt_node *adl, *d, *c;
     
    782603
    783604        if ((md->flags & MSN_DONE_ADL) && (md->flags & MSN_GOT_PROFILE)) {
    784                 if (md->flags & MSN_EMAIL_UNVERIFIED) {
    785                         imcb_connected(ic);
    786                 } else {
    787                         return msn_ns_set_display_name(ic, set_getstr(&ic->acc->set, "display_name"));
    788                 }
     605                imcb_connected(ic);
    789606        }
    790607
     
    810627        return retval;
    811628}
    812 
    813 void msn_ns_oim_send_queue(struct im_connection *ic, GSList **msgq)
    814 {
    815         GSList *l;
    816 
    817         for (l = *msgq; l; l = l->next) {
    818                 struct msn_message *m = l->data;
    819                 bee_user_t *bu = bee_user_by_handle(ic->bee, ic, m->who);
    820 
    821                 if (bu) {
    822                         if (!msn_ns_sendmessage(ic, bu, m->text)) {
    823                                 return;
    824                         }
    825                 }
    826         }
    827 
    828         while (*msgq != NULL) {
    829                 struct msn_message *m = (*msgq)->data;
    830 
    831                 *msgq = g_slist_remove(*msgq, m);
    832                 g_free(m->who);
    833                 g_free(m->text);
    834                 g_free(m);
    835         }
    836 }
Note: See TracChangeset for help on using the changeset viewer.