Mercurial > pidgin.yaz
diff src/protocols/msn/dispatch.c @ 6701:b7e113a59b51
[gaim-migrate @ 7227]
Updated to MSN Protocol 9.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 02 Sep 2003 04:32:16 +0000 |
parents | 156e6643f9db |
children | cdcb43229e33 |
line wrap: on
line diff
--- a/src/protocols/msn/dispatch.c Tue Sep 02 04:28:34 2003 +0000 +++ b/src/protocols/msn/dispatch.c Tue Sep 02 04:32:16 2003 +0000 @@ -4,7 +4,7 @@ * gaim * * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -27,28 +27,19 @@ static GHashTable *dispatch_commands = NULL; static gboolean -ver_cmd(MsnServConn *servconn, const char *command, const char **params, +cvr_cmd(MsnServConn *servconn, const char *command, const char **params, size_t param_count) { - GaimConnection *gc = servconn->session->account->gc; - size_t i; - gboolean msnp5_found = FALSE; + GaimAccount *account = servconn->session->account; + GaimConnection *gc = gaim_account_get_connection(account); + char outparams[MSN_BUF_LEN]; - for (i = 1; i < param_count; i++) { - if (!strcmp(params[i], "MSNP5")) { - msnp5_found = TRUE; - break; - } - } + g_snprintf(outparams, sizeof(outparams), + "TWN I %s", gaim_account_get_username(account)); - if (!msnp5_found) { - gaim_connection_error(gc, _("Protocol not supported")); - - return FALSE; - } - - if (!msn_servconn_send_command(servconn, "INF", NULL)) { - gaim_connection_error(gc, _("Unable to request INF")); + if (!msn_servconn_send_command(servconn, "USR", outparams)) + { + gaim_connection_error(gc, _("Unable to request USR\n")); return FALSE; } @@ -86,6 +77,62 @@ } static gboolean +ver_cmd(MsnServConn *servconn, const char *command, const char **params, + size_t param_count) +{ + MsnSession *session = servconn->session; + GaimAccount *account = session->account; + GaimConnection *gc = gaim_account_get_connection(account); + gboolean protocol_supported = FALSE; + char outparams[MSN_BUF_LEN]; + char proto_str[8]; + size_t i; + + g_snprintf(proto_str, sizeof(proto_str), "MSNP%d", session->protocol_ver); + + for (i = 1; i < param_count; i++) + { + if (!strcmp(params[i], proto_str)) + { + protocol_supported = TRUE; + break; + } + } + + if (!protocol_supported) + { + gaim_connection_error(gc, _("Protocol version not supported")); + + return FALSE; + } + + if (session->protocol_ver >= 8) + { + g_snprintf(outparams, sizeof(outparams), + "0x0409 winnt 5.1 i386 MSNMSGR 6.0.0602 MSMSGS %s", + gaim_account_get_username(account)); + + if (!msn_servconn_send_command(servconn, "CVR", outparams)) + { + gaim_connection_error(gc, _("Unable to request CVR\n")); + + return FALSE; + } + } + else + { + if (!msn_servconn_send_command(servconn, "INF", NULL)) + { + gaim_connection_error(gc, _("Unable to request INF\n")); + + return FALSE; + } + } + + return TRUE; +} + +static gboolean xfr_cmd(MsnServConn *servconn, const char *command, const char **params, size_t param_count) { @@ -95,7 +142,8 @@ int port; char *c; - if (param_count < 2 || strcmp(params[1], "NS")) { + if (param_count < 2 || strcmp(params[1], "NS")) + { gaim_connection_error(gc, _("Got invalid XFR")); return FALSE; @@ -103,7 +151,8 @@ host = g_strdup(params[2]); - if ((c = strchr(host, ':')) != NULL) { + if ((c = strchr(host, ':')) != NULL) + { *c = '\0'; port = atoi(c + 1); @@ -117,14 +166,16 @@ msn_servconn_destroy(servconn); session->dispatch_conn = NULL; + /* Reset our transaction ID. */ + session->trId = 0; + /* Now connect to the switchboard. */ session->notification_conn = msn_notification_new(session, host, port); g_free(host); - if (!msn_servconn_connect(session->notification_conn)) { + if (!msn_servconn_connect(session->notification_conn)) gaim_connection_error(gc, _("Unable to transfer")); - } return FALSE; } @@ -135,7 +186,8 @@ { GaimConnection *gc = servconn->session->account->gc; - if (isdigit(*command)) { + if (isdigit(*command)) + { char buf[4]; strncpy(buf, command, 4); @@ -155,8 +207,11 @@ MsnServConn *dispatch = data; MsnSession *session = dispatch->session; GaimConnection *gc = session->account->gc; + char proto_vers[256]; + size_t i; - if (source == -1) { + if (source == -1) + { gaim_connection_error(session->account->gc, _("Unable to connect")); return FALSE; } @@ -166,8 +221,21 @@ if (dispatch->fd != source) dispatch->fd = source; - if (!msn_servconn_send_command(dispatch, "VER", - "MSNP7 MSNP6 MSNP5 MSNP4 CVR0")) { + proto_vers[0] = '\0'; + + for (i = session->protocol_ver; i >= 7; i--) + { + char old_buf[256]; + + strcpy(old_buf, proto_vers); + + g_snprintf(proto_vers, sizeof(proto_vers), "MSNP%d %s", i, old_buf); + } + + strncat(proto_vers, "CVR0", sizeof(proto_vers)); + + if (!msn_servconn_send_command(dispatch, "VER", proto_vers)) + { gaim_connection_error(gc, _("Unable to write to server")); return FALSE; } @@ -195,15 +263,17 @@ MsnServConn *dispatch; dispatch = msn_servconn_new(session); - + msn_servconn_set_server(dispatch, server, port); msn_servconn_set_connect_cb(dispatch, connect_cb); msn_servconn_set_failed_read_cb(dispatch, failed_read_cb); if (dispatch_commands == NULL) { /* Register the command callbacks. */ + + msn_servconn_register_command(dispatch, "CVR", cvr_cmd); + msn_servconn_register_command(dispatch, "INF", inf_cmd); msn_servconn_register_command(dispatch, "VER", ver_cmd); - msn_servconn_register_command(dispatch, "INF", inf_cmd); msn_servconn_register_command(dispatch, "XFR", xfr_cmd); msn_servconn_register_command(dispatch, "_unknown_", unknown_cmd);