# HG changeset patch # User Christian Hammond # Date 1086493522 0 # Node ID d1fd3de2feca95be996139c737ca4e6e8dd7bfcc # Parent ab6636c5a13688a31c120b5be0a8d218d45aec99 [gaim-migrate @ 9994] You know, I should have removed these now unused files BEFORE doing the copyright updates. Yeah. committer: Tailor Script diff -r ab6636c5a136 -r d1fd3de2feca src/protocols/msn/Makefile.am --- a/src/protocols/msn/Makefile.am Sun Jun 06 03:42:55 2004 +0000 +++ b/src/protocols/msn/Makefile.am Sun Jun 06 03:45:22 2004 +0000 @@ -22,10 +22,10 @@ msg.h \ msn.c \ msn.h \ + nexus.c \ + nexus.h \ notification.c \ notification.h \ - nexus.c \ - nexus.h \ object.c \ object.h \ page.c \ @@ -50,10 +50,10 @@ switchboard.h \ sync.c \ sync.h \ + table.c \ + table.h \ transaction.c \ transaction.h \ - table.c \ - table.h \ user.c \ user.h \ userlist.c \ diff -r ab6636c5a136 -r d1fd3de2feca src/protocols/msn/dispatch.c --- a/src/protocols/msn/dispatch.c Sun Jun 06 03:42:55 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,286 +0,0 @@ -/** - * @file dispatch.c Dispatch server functions - * - * gaim - * - * Gaim is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "msn.h" -#include "dispatch.h" -#include "notification.h" -#include "error.h" - -static GHashTable *dispatch_commands = NULL; - -static gboolean -cvr_cmd(MsnServConn *servconn, const char *command, const char **params, - size_t param_count) -{ - GaimAccount *account = servconn->session->account; - GaimConnection *gc = gaim_account_get_connection(account); - char outparams[MSN_BUF_LEN]; - - g_snprintf(outparams, sizeof(outparams), - "TWN I %s", gaim_account_get_username(account)); - - if (!msn_servconn_send_command(servconn, "USR", outparams)) - { - gaim_connection_error(gc, _("Unable to request USR\n")); - - return FALSE; - } - - return TRUE; -} - -static gboolean -inf_cmd(MsnServConn *servconn, const char *command, const char **params, - size_t param_count) -{ - GaimAccount *account = servconn->session->account; - GaimConnection *gc = gaim_account_get_connection(account); - char outparams[MSN_BUF_LEN]; - - if (strcmp(params[1], "MD5")) { - gaim_connection_error(gc, _("Unable to login using MD5")); - - return FALSE; - } - - g_snprintf(outparams, sizeof(outparams), "MD5 I %s", - gaim_account_get_username(account)); - - if (!msn_servconn_send_command(servconn, "USR", outparams)) { - gaim_connection_error(gc, _("Unable to send USR")); - - return FALSE; - } - - gaim_connection_update_progress(gc, _("Requesting to send password"), - 3, MSN_CONNECT_STEPS); - - return TRUE; -} - -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) -{ - MsnSession *session = servconn->session; - GaimConnection *gc = servconn->session->account->gc; - char *host; - int port; - char *c; - - if (param_count < 2 || strcmp(params[1], "NS")) - { - gaim_connection_error(gc, _("Got invalid XFR")); - - return FALSE; - } - - host = g_strdup(params[2]); - - if ((c = strchr(host, ':')) != NULL) - { - *c = '\0'; - - port = atoi(c + 1); - } - else - port = 1863; - - session->passport_info.sl = time(NULL); - - /* Disconnect from here. */ - 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)) - gaim_connection_error(gc, _("Unable to transfer")); - - return FALSE; -} - -static gboolean -unknown_cmd(MsnServConn *servconn, const char *command, const char **params, - size_t param_count) -{ - GaimConnection *gc = servconn->session->account->gc; - - if (isdigit(*command)) - gaim_connection_error(gc, msn_error_get_text(atoi(command))); - else - gaim_connection_error(gc, _("Unable to parse message.")); - - return FALSE; -} - -static gboolean -connect_cb(gpointer data, gint source, GaimInputCondition cond) -{ - MsnServConn *dispatch = data; - MsnSession *session = dispatch->session; - GaimConnection *gc = session->account->gc; - char proto_vers[256]; - size_t i; - - if (source == -1) - { - gaim_connection_error(session->account->gc, _("Unable to connect.")); - return FALSE; - } - - gaim_connection_update_progress(gc, _("Connecting"), 1, MSN_CONNECT_STEPS); - - if (dispatch->fd != source) - dispatch->fd = source; - - proto_vers[0] = '\0'; - - for (i = 7; i <= session->protocol_ver; i++) - { - char old_buf[256]; - - strcpy(old_buf, proto_vers); - - g_snprintf(proto_vers, sizeof(proto_vers), "MSNP%d %s", (int)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; - } - - gaim_connection_update_progress(gc, _("Syncing with server"), - 2, MSN_CONNECT_STEPS); - - return TRUE; -} - -static void -failed_read_cb(gpointer data, gint source, GaimInputCondition cond) -{ - MsnServConn *dispatch = data; - GaimConnection *gc; - - gc = dispatch->session->account->gc; - - gaim_connection_error(gc, _("Error reading from server")); -} - -MsnServConn * -msn_dispatch_new(MsnSession *session, const char *server, int port) -{ - 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, "XFR", xfr_cmd); - msn_servconn_register_command(dispatch, "_UNKNOWN_", unknown_cmd); - - /* Save this for future use. */ - dispatch_commands = dispatch->commands; - } - else { - g_hash_table_destroy(dispatch->commands); - - dispatch->commands = dispatch_commands; - } - - return dispatch; -} - diff -r ab6636c5a136 -r d1fd3de2feca src/protocols/msn/dispatch.h --- a/src/protocols/msn/dispatch.h Sun Jun 06 03:42:55 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/** - * @file dispatch.h Dispatch server functions - * - * gaim - * - * Gaim is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef _MSN_DISPATCH_H_ -#define _MSN_DISPATCH_H_ - -#include "session.h" -#include "servconn.h" - -MsnServConn *msn_dispatch_new(MsnSession *session, const char *server, - int port); - -#endif /* _MSN_DISPATCH_H_ */ diff -r ab6636c5a136 -r d1fd3de2feca src/protocols/msn/ft.c --- a/src/protocols/msn/ft.c Sun Jun 06 03:42:55 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,522 +0,0 @@ -/** - * @file msn.c The MSN protocol plugin - * - * gaim - * - * Gaim is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#include "msn.h" - -static struct gaim_xfer * -find_xfer_by_cookie(GaimConnection *gc, unsigned long cookie) -{ - GSList *g; - struct msn_data *md = (struct msn_data *)gc->proto_data; - struct gaim_xfer *xfer = NULL; - struct msn_xfer_data *xfer_data; - - for (g = md->file_transfers; g != NULL; g = g->next) { - xfer = (struct gaim_xfer *)g->data; - xfer_data = (struct msn_xfer_data *)xfer->data; - - if (xfer_data->cookie == cookie) - break; - - xfer = NULL; - } - - return xfer; -} - -static void -msn_xfer_init(struct gaim_xfer *xfer) -{ - GaimAccount *account; - struct msn_xfer_data *xfer_data; - struct msn_switchboard *ms; - char header[MSN_BUF_LEN]; - char buf[MSN_BUF_LEN]; - - account = gaim_xfer_get_account(xfer); - - ms = msn_find_switch(account->gc, xfer->who); - - xfer_data = (struct msn_xfer_data *)xfer->data; - - if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { - /* - * NOTE: We actually have to wait for the next Invitation message - * before the transfer starts. We handle that in - * msn_xfer_start(). - */ - - g_snprintf(header, sizeof(header), - "MIME-Version: 1.0\r\n" - "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n" - "Invitation-Command: ACCEPT\r\n" - "Invitation-Cookie: %lu\r\n" - "Launch-Application: FALSE\r\n" - "Request-Data: IP-Address:\r\n", - (unsigned long)xfer_data->cookie); - - g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s\r\n\r\n", - ++ms->trId, strlen(header) + strlen("\r\n\r\n"), - header); - - if (msn_write(ms->fd, buf, strlen(buf)) < 0) { - msn_kill_switch(ms); - gaim_xfer_destroy(xfer); - - return; - } - } -} - -static void -msn_xfer_start(struct gaim_xfer *xfer) -{ - struct msn_xfer_data *xfer_data; - - xfer_data = (struct msn_xfer_data *)xfer->data; - - xfer_data->transferring = TRUE; - - if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { - char sendbuf[MSN_BUF_LEN]; - - /* Send the TFR string to request the start of a transfer. */ - g_snprintf(sendbuf, sizeof(sendbuf), "TFR\r\n"); - - if (msn_write(xfer->fd, sendbuf, strlen(sendbuf)) < 0) { - gaim_xfer_cancel_remote(xfer); - } - } -} - -static void -msn_xfer_end(struct gaim_xfer *xfer) -{ - GaimAccount *account; - struct msn_xfer_data *xfer_data; - struct msn_data *md; - - account = gaim_xfer_get_account(xfer); - xfer_data = (struct msn_xfer_data *)xfer->data; - md = (struct msn_data *)account->gc->proto_data; - - if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { - char sendbuf[MSN_BUF_LEN]; - - g_snprintf(sendbuf, sizeof(sendbuf), "BYE 16777989\r\n"); - - msn_write(xfer->fd, sendbuf, strlen(sendbuf)); - - md->file_transfers = g_slist_remove(md->file_transfers, xfer); - - g_free(xfer_data); - xfer->data = NULL; - } -} - -static void -msn_xfer_cancel_send(struct gaim_xfer *xfer) -{ - GaimAccount *account; - struct msn_xfer_data *xfer_data; - struct msn_data *md; - - xfer_data = (struct msn_xfer_data *)xfer->data; - - xfer_data->do_cancel = TRUE; - - account = gaim_xfer_get_account(xfer); - md = (struct msn_data *)account->gc->proto_data; - - md->file_transfers = g_slist_remove(md->file_transfers, xfer); - - g_free(xfer_data); - xfer->data = NULL; -} - -static void -msn_xfer_cancel_recv(struct gaim_xfer *xfer) -{ - GaimAccount *account; - struct msn_xfer_data *xfer_data; - struct msn_data *md; - - account = gaim_xfer_get_account(xfer); - xfer_data = (struct msn_xfer_data *)xfer->data; - md = (struct msn_data *)account->gc->proto_data; - - md->file_transfers = g_slist_remove(md->file_transfers, xfer); - - g_free(xfer_data); - xfer->data = NULL; -} - -static size_t -msn_xfer_read(char **buffer, struct gaim_xfer *xfer) -{ - struct msn_xfer_data *xfer_data; - unsigned char header[3]; - size_t len, size; - - xfer_data = (struct msn_xfer_data *)xfer->data; - - if (xfer_data->do_cancel) - { - write(xfer->fd, "CCL\n", 4); - - return 0; - } - - if (read(xfer->fd, header, sizeof(header)) < 3) { - gaim_xfer_set_completed(xfer, TRUE); - return 0; - } - - if (header[0] != 0) { - gaim_debug(GAIM_DEBUG_ERROR, "msn", - "MSNFTP: Invalid header[0]: %d. Aborting.\n", - header[0]); - return 0; - } - - size = header[1] | (header[2] << 8); - - *buffer = g_new0(char, size); - - for (len = 0; - len < size; - len += read(xfer->fd, *buffer + len, size - len)) - ; - - if (len == 0) - gaim_xfer_set_completed(xfer, TRUE); - - return len; -} - -static size_t -msn_xfer_write(const char *buffer, size_t size, struct gaim_xfer *xfer) -{ - GaimAccount *account; - struct msn_xfer_data *xfer_data; - struct msn_data *md; - unsigned char header[3]; - - xfer_data = (struct msn_xfer_data *)xfer->data; - account = gaim_xfer_get_account(xfer); - md = (struct msn_data *)account->gc->proto_data; - - if (xfer_data->do_cancel) - { - header[0] = 1; - header[1] = 0; - header[2] = 0; - - if (write(xfer->fd, header, sizeof(header)) < 3) { - gaim_xfer_cancel_remote(xfer); - return 0; - } - } - else - { - /* Not implemented yet. */ - } - - return 0; -} - -static int -msn_process_msnftp(struct gaim_xfer *xfer, gint source, const char *buf) -{ - struct msn_xfer_data *xfer_data; - GaimAccount *account; - char sendbuf[MSN_BUF_LEN]; - - xfer_data = (struct msn_xfer_data *)xfer->data; - account = gaim_xfer_get_account(xfer); - - if (!g_ascii_strncasecmp(buf, "VER MSNFTP", 10)) { - /* Send the USR string */ - g_snprintf(sendbuf, sizeof(sendbuf), "USR %s %lu\r\n", - account->gc->username, - (unsigned long)xfer_data->authcookie); - - if (msn_write(source, sendbuf, strlen(sendbuf)) < 0) { - gaim_xfer_cancel_remote(xfer); /* ? */ - - return 0; - } - } - else if (!g_ascii_strncasecmp(buf, "FIL", 3)) { - gaim_input_remove(xfer_data->inpa); - xfer_data->inpa = 0; - - gaim_xfer_start(xfer, source, NULL, 0); - } -#if 0 - char *tmp = buf; - - /* - * This data is the size, but we already have - * the size, so who cares. - */ - GET_NEXT(tmp); - - /* Send the TFR string to request the start of a transfer. */ - g_snprintf(sendbuf, sizeof(sendbuf), "TFR\r\n"); - - - if (msn_write(source, sendbuf, strlen(sendbuf)) < 0) { - gaim_xfer_cancel(xfer); - - return 0; - } -#endif - - return 1; -} - -static void -msn_msnftp_cb(gpointer data, gint source, GaimInputCondition cond) -{ - struct gaim_xfer *xfer; - struct msn_xfer_data *xfer_data; - char buf[MSN_BUF_LEN]; - gboolean cont = TRUE; - size_t len; - - xfer = (struct gaim_xfer *)data; - xfer_data = (struct msn_xfer_data *)xfer->data; - - len = read(source, buf, sizeof(buf)); - - if (len <= 0) { - gaim_xfer_cancel_remote(xfer); - return; - } - - xfer_data->rxqueue = g_realloc(xfer_data->rxqueue, - len + xfer_data->rxlen); - memcpy(xfer_data->rxqueue + xfer_data->rxlen, buf, len); - xfer_data->rxlen += len; - - while (cont) { - char *end = xfer_data->rxqueue; - char *cmd; - int cmdlen; - int i = 0; - - if (!xfer_data->rxlen) - return; - - for (i = 0; i < xfer_data->rxlen - 1; end++, i++) { - if (*end == '\r' && *(end + 1) == '\n') - break; - } - - if (i == xfer_data->rxlen - 1) - return; - - cmdlen = end - xfer_data->rxqueue + 2; - cmd = xfer_data->rxqueue; - - xfer_data->rxlen -= cmdlen; - - if (xfer_data->rxlen) - xfer_data->rxqueue = g_memdup(cmd + cmdlen, xfer_data->rxlen); - else { - xfer_data->rxqueue = NULL; - cmd = g_realloc(cmd, cmdlen + 1); - } - - cmd[cmdlen] = '\0'; - - g_strchomp(cmd); - - cont = msn_process_msnftp(xfer, source, cmd); - - g_free(cmd); - } -} - -static void -msn_msnftp_connect(gpointer data, gint source, GaimInputCondition cond) -{ - GaimAccount *account; - struct gaim_xfer *xfer; - struct msn_xfer_data *xfer_data; - char buf[MSN_BUF_LEN]; - - xfer = (struct gaim_xfer *)data; - account = gaim_xfer_get_account(xfer); - xfer_data = (struct msn_xfer_data *)xfer->data; - - if (source == -1 || !g_slist_find(gaim_connections_get_all(), account->gc)) { - gaim_debug(GAIM_DEBUG_ERROR, "msn", - "MSNFTP: Error establishing connection\n"); - close(source); - - gaim_xfer_cancel_remote(xfer); - - return; - } - - g_snprintf(buf, sizeof(buf), "VER MSNFTP\r\n"); - - if (msn_write(source, buf, strlen(buf)) < 0) { - gaim_xfer_cancel_remote(xfer); - return; - } - - xfer_data->inpa = gaim_input_add(source, GAIM_INPUT_READ, - msn_msnftp_cb, xfer); -} - -void -msn_process_ft_msg(struct msn_switchboard *ms, char *msg) -{ - struct gaim_xfer *xfer; - struct msn_xfer_data *xfer_data; - struct msn_data *md = ms->gc->proto_data; - char *tmp = msg; - - if (strstr(msg, "Application-GUID: " MSN_FT_GUID) && - strstr(msg, "Invitation-Command: INVITE")) { - - /* - * First invitation message, requesting an ACCEPT or CANCEL from - * the recipient. Used in incoming file transfers. - */ - - char *filename; - char *cookie_s, *filesize_s; - - tmp = strstr(msg, "Invitation-Cookie"); - GET_NEXT(tmp); - cookie_s = tmp; - GET_NEXT(tmp); - GET_NEXT(tmp); - filename = tmp; - - /* Needed for filenames with spaces */ - tmp = strchr(tmp, '\r'); - *tmp = '\0'; - tmp += 2; - - GET_NEXT(tmp); - filesize_s = tmp; - GET_NEXT(tmp); - - /* Setup the MSN-specific file transfer data */ - xfer_data = g_new0(struct msn_xfer_data, 1); - xfer_data->cookie = atoi(cookie_s); - xfer_data->transferring = FALSE; - - /* Build the file transfer handle. */ - xfer = gaim_xfer_new(ms->gc->account, GAIM_XFER_RECEIVE, ms->msguser); - xfer->data = xfer_data; - - /* Set the info about the incoming file. */ - gaim_xfer_set_filename(xfer, filename); - gaim_xfer_set_size(xfer, atoi(filesize_s)); - - /* Setup our I/O op functions */ - gaim_xfer_set_init_fnc(xfer, msn_xfer_init); - gaim_xfer_set_start_fnc(xfer, msn_xfer_start); - gaim_xfer_set_end_fnc(xfer, msn_xfer_end); - gaim_xfer_set_cancel_send_fnc(xfer, msn_xfer_cancel_send); - gaim_xfer_set_cancel_recv_fnc(xfer, msn_xfer_cancel_recv); - gaim_xfer_set_read_fnc(xfer, msn_xfer_read); - gaim_xfer_set_write_fnc(xfer, msn_xfer_write); - - /* Keep track of this transfer for later. */ - md->file_transfers = g_slist_append(md->file_transfers, xfer); - - /* Now perform the request */ - gaim_xfer_request(xfer); - } - else if (strstr(msg, "Invitation-Command: ACCEPT")) { - - /* - * XXX I hope these checks don't return false positives, but they - * seem like they should work. The only issue is alternative - * protocols, *maybe*. - */ - - if (strstr(msg, "AuthCookie:")) { - - /* - * Second invitation request, sent after the recipient accepts - * the request. Used in incoming file transfers. - */ - char *cookie_s, *ip, *port_s, *authcookie_s; - char ip_s[16]; - - tmp = strstr(msg, "Invitation-Cookie"); - GET_NEXT(tmp); - cookie_s = tmp; - GET_NEXT(tmp); - GET_NEXT(tmp); - ip = tmp; - GET_NEXT(tmp); - GET_NEXT(tmp); - port_s = tmp; - GET_NEXT(tmp); - GET_NEXT(tmp); - authcookie_s = tmp; - GET_NEXT(tmp); - - xfer = find_xfer_by_cookie(ms->gc, atoi(cookie_s)); - - if (xfer == NULL) - { - gaim_debug(GAIM_DEBUG_ERROR, "msn", - "MSNFTP : Cookie not found. " - "File transfer aborted.\n"); - return; - } - - xfer_data = (struct msn_xfer_data *)xfer->data; - xfer_data->authcookie = atol(authcookie_s); - - strncpy(ip_s, ip, sizeof(ip_s)); - - if (gaim_proxy_connect(xfer->account, ip_s, atoi(port_s), - msn_msnftp_connect, xfer) != 0) { - - gaim_xfer_cancel_remote(xfer); - - return; - } - } - else - { - /* - * An accept message from the recipient. Used in outgoing - * file transfers. - */ - } - } -} - diff -r ab6636c5a136 -r d1fd3de2feca src/protocols/msn/msnobject.c --- a/src/protocols/msn/msnobject.c Sun Jun 06 03:42:55 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,253 +0,0 @@ -/** - * @file msnobject.c MSNObject API - * - * gaim - * - * Gaim is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "msnobject.h" - -#define GET_STRING_TAG(field, id) \ - if ((tag = strstr(str, id "=\"")) != NULL) \ - { \ - tag += strlen(id "=\""); \ - c = strchr(tag, '"'); \ - if (c != NULL) \ - obj->field = g_strndup(tag, c - tag); \ - } - -#define GET_INT_TAG(field, id) \ - if ((tag = strstr(str, id "=\"")) != NULL) \ - { \ - char buf[16]; \ - tag += strlen(id "=\""); \ - c = strchr(tag, '"'); \ - if (c != NULL) \ - { \ - strncpy(buf, tag, c - tag); \ - buf[c - tag] = '\0'; \ - obj->field = atoi(buf); \ - } \ - } - -MsnObject * -msn_object_new(void) -{ - MsnObject *obj; - - obj = g_new0(MsnObject, 1); - - msn_object_set_type(obj, MSN_OBJECT_UNKNOWN); - msn_object_set_friendly(obj, "AAA="); - - return obj; -} - -MsnObject * -msn_object_new_from_string(const char *str) -{ - MsnObject *obj; - char *tag, *c; - - g_return_val_if_fail(str != NULL, NULL); - g_return_val_if_fail(!strncmp(str, "creator != NULL) - g_free(obj->creator); - - if (obj->location != NULL) - g_free(obj->location); - - if (obj->friendly != NULL) - g_free(obj->friendly); - - if (obj->sha1d != NULL) - g_free(obj->sha1d); - - if (obj->sha1c != NULL) - g_free(obj->sha1c); - - g_free(obj); -} - -char * -msn_object_to_string(const MsnObject *obj) -{ - char *str; - - g_return_val_if_fail(obj != NULL, NULL); - - str = g_strdup_printf("", - msn_object_get_creator(obj), - msn_object_get_size(obj), - msn_object_get_type(obj), - msn_object_get_location(obj), - msn_object_get_friendly(obj), - msn_object_get_sha1d(obj), - msn_object_get_sha1c(obj)); - - return str; -} - -void -msn_object_set_creator(MsnObject *obj, const char *creator) -{ - g_return_if_fail(obj != NULL); - - if (obj->creator != NULL) - g_free(obj->creator); - - obj->creator = (creator == NULL ? NULL : g_strdup(creator)); -} - -void -msn_object_set_size(MsnObject *obj, int size) -{ - g_return_if_fail(obj != NULL); - - obj->size = size; -} - -void -msn_object_set_type(MsnObject *obj, MsnObjectType type) -{ - g_return_if_fail(obj != NULL); - - obj->type = type; -} - -void -msn_object_set_location(MsnObject *obj, const char *location) -{ - g_return_if_fail(obj != NULL); - - if (obj->location != NULL) - g_free(obj->location); - - obj->location = (location == NULL ? NULL : g_strdup(location)); -} - -void -msn_object_set_friendly(MsnObject *obj, const char *friendly) -{ - g_return_if_fail(obj != NULL); - - if (obj->friendly != NULL) - g_free(obj->friendly); - - obj->friendly = (friendly == NULL ? NULL : g_strdup(friendly)); -} - -void -msn_object_set_sha1d(MsnObject *obj, const char *sha1d) -{ - g_return_if_fail(obj != NULL); - - if (obj->sha1d != NULL) - g_free(obj->sha1d); - - obj->sha1d = (sha1d == NULL ? NULL : g_strdup(sha1d)); -} - -void -msn_object_set_sha1c(MsnObject *obj, const char *sha1c) -{ - g_return_if_fail(obj != NULL); - - if (obj->sha1c != NULL) - g_free(obj->sha1c); - - obj->sha1c = (sha1c == NULL ? NULL : g_strdup(sha1c)); -} - -const char * -msn_object_get_creator(const MsnObject *obj) -{ - g_return_val_if_fail(obj != NULL, NULL); - - return obj->creator; -} - -int -msn_object_get_size(const MsnObject *obj) -{ - g_return_val_if_fail(obj != NULL, 0); - - return obj->size; -} - -MsnObjectType -msn_object_get_type(const MsnObject *obj) -{ - g_return_val_if_fail(obj != NULL, MSN_OBJECT_UNKNOWN); - - return obj->type; -} - -const char * -msn_object_get_location(const MsnObject *obj) -{ - g_return_val_if_fail(obj != NULL, NULL); - - return obj->location; -} - -const char * -msn_object_get_friendly(const MsnObject *obj) -{ - g_return_val_if_fail(obj != NULL, NULL); - - return obj->friendly; -} - -const char * -msn_object_get_sha1d(const MsnObject *obj) -{ - g_return_val_if_fail(obj != NULL, NULL); - - return obj->sha1d; -} - -const char * -msn_object_get_sha1c(const MsnObject *obj) -{ - g_return_val_if_fail(obj != NULL, NULL); - - return obj->sha1c; -} diff -r ab6636c5a136 -r d1fd3de2feca src/protocols/msn/msnobject.h --- a/src/protocols/msn/msnobject.h Sun Jun 06 03:42:55 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,196 +0,0 @@ -/** - * @file msnobject.h MSNObject API - * - * gaim - * - * Gaim is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef _MSN_OBJECT_H_ -#define _MSN_OBJECT_H_ - -#include "internal.h" - -typedef enum -{ - MSN_OBJECT_UNKNOWN = -1, /**< Unknown object */ - MSN_OBJECT_RESERVED1 = 1, /**< Reserved */ - MSN_OBJECT_EMOTICON = 2, /**< Custom Emoticon */ - MSN_OBJECT_USERTILE = 3, /**< UserTile (buddy icon) */ - MSN_OBJECT_RESERVED2 = 4, /**< Reserved */ - MSN_OBJECT_BACKGROUND = 5 /**< Background */ - -} MsnObjectType; - -typedef struct -{ - char *creator; - int size; - MsnObjectType type; - char *location; - char *friendly; - char *sha1d; - char *sha1c; - -} MsnObject; - -/** - * Creates a MsnObject structure. - * - * @return A new MsnObject structure. - */ -MsnObject *msn_object_new(void); - -/** - * Creates a MsnObject structure from a string. - * - * @param str The string. - * - * @return The new MsnObject structure. - */ -MsnObject *msn_object_new_from_string(const char *str); - -/** - * Destroys an MsnObject structure. - * - * @param obj The object structure. - */ -void msn_object_destroy(MsnObject *obj); - -/** - * Outputs a string representation of an MsnObject. - * - * @param obj The object. - * - * @return The string representation. This must be freed. - */ -char *msn_object_to_string(const MsnObject *obj); - -/** - * Sets the creator field in a MsnObject. - * - * @param creator The creator value. - */ -void msn_object_set_creator(MsnObject *obj, const char *creator); - -/** - * Sets the size field in a MsnObject. - * - * @param size The size value. - */ -void msn_object_set_size(MsnObject *obj, int size); - -/** - * Sets the type field in a MsnObject. - * - * @param type The type value. - */ -void msn_object_set_type(MsnObject *obj, MsnObjectType type); - -/** - * Sets the location field in a MsnObject. - * - * @param location The location value. - */ -void msn_object_set_location(MsnObject *obj, const char *location); - -/** - * Sets the friendly name field in a MsnObject. - * - * @param friendly The friendly name value. - */ -void msn_object_set_friendly(MsnObject *obj, const char *friendly); - -/** - * Sets the SHA1D field in a MsnObject. - * - * @param sha1d The sha1d value. - */ -void msn_object_set_sha1d(MsnObject *obj, const char *sha1d); - -/** - * Sets the SHA1C field in a MsnObject. - * - * @param sha1c The sha1c value. - */ -void msn_object_set_sha1c(MsnObject *obj, const char *sha1c); - -/** - * Returns a MsnObject's creator value. - * - * @param obj The object. - * - * @return The creator value. - */ -const char *msn_object_get_creator(const MsnObject *obj); - -/** - * Returns a MsnObject's size value. - * - * @param obj The object. - * - * @return The size value. - */ -int msn_object_get_size(const MsnObject *obj); - -/** - * Returns a MsnObject's type. - * - * @param obj The object. - * - * @return The object type. - */ -MsnObjectType msn_object_get_type(const MsnObject *obj); - -/** - * Returns a MsnObject's location value. - * - * @param obj The object. - * - * @return The location value. - */ -const char *msn_object_get_location(const MsnObject *obj); - -/** - * Returns a MsnObject's friendly name value. - * - * @param obj The object. - * - * @return The friendly name value. - */ -const char *msn_object_get_friendly(const MsnObject *obj); - -/** - * Returns a MsnObject's SHA1D value. - * - * @param obj The object. - * - * @return The SHA1D value. - */ -const char *msn_object_get_sha1d(const MsnObject *obj); - -/** - * Returns a MsnObject's SHA1C value. - * - * @param obj The object. - * - * @return The SHA1C value. - */ -const char *msn_object_get_sha1c(const MsnObject *obj); - -#endif /* _MSN_OBJECT_H_ */ diff -r ab6636c5a136 -r d1fd3de2feca src/protocols/msn/msnslp.c --- a/src/protocols/msn/msnslp.c Sun Jun 06 03:42:55 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,564 +0,0 @@ -/** - * @file msnslp.c MSNSLP support - * - * gaim - * - * Gaim is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "msn.h" -#include "msnslp.h" - -MsnSlpSession * -msn_slp_session_new(MsnSwitchBoard *swboard, gboolean local_initiated) -{ - MsnSlpSession *slpsession; - - g_return_val_if_fail(swboard != NULL, NULL); - - slpsession = g_new0(MsnSlpSession, 1); - - slpsession->swboard = swboard; - slpsession->local_initiated = local_initiated; - - return slpsession; -} - -void -msn_slp_session_destroy(MsnSlpSession *session) -{ - g_return_if_fail(session != NULL); - - if (session->orig_body != NULL) - g_free(session->orig_body); - - if (session->outgoing_msg != NULL) - msn_message_unref(session->outgoing_msg); - - if (session->call_id != NULL) - g_free(session->call_id); - - if (session->branch != NULL) - g_free(session->branch); - - g_free(session); -} - -static void -msn_slp_session_send_message(MsnSlpSession *slpsession, - const char *local_user, const char *remote_user, - const char *header, const char *branch, - int cseq, const char *call_id, - const char *content) -{ - MsnMessage *invite_msg; - char *body; - - g_return_if_fail(slpsession != NULL); - g_return_if_fail(header != NULL); - g_return_if_fail(branch != NULL); - g_return_if_fail(call_id != NULL); - - if (branch == NULL) - branch = "null"; - - body = g_strdup_printf( - "%s\r\n" - "To: \r\n" - "From: \r\n" - "Via: MSNSLP/1.0/TLP ;branch={%s}\r\n" - "CSeq: %d\r\n" - "Call-ID: {%s}\r\n" - "Max-Forwards: 0\r\n" - "Content-Type: application/x-msnmsgr-sessionreqbody\r\n" - "Content-Length: %d\r\n" - "\r\n" - "%s" - "\r\n\r\n", - header, - remote_user, - local_user, - branch, cseq, call_id, - (content == NULL ? 0 : (int)strlen(content) + 5), - (content == NULL ? "" : content)); - - gaim_debug_misc("msn", "Message = {%s}\n", body); - - invite_msg = msn_message_new_msnslp(); - - msn_message_set_bin_data(invite_msg, body, strlen(body)); - - g_free(body); - - msn_slp_session_send_msg(slpsession, invite_msg); -} - -static gboolean -send_error_500(MsnSlpSession *slpsession, const char *call_id, MsnMessage *msg) -{ - MsnUser *local_user; - - g_return_val_if_fail(slpsession != NULL, TRUE); - g_return_val_if_fail(msg != NULL, TRUE); - - local_user = slpsession->swboard->servconn->session->user; - - msn_slp_session_send_message(slpsession, msg->passport, - msn_user_get_passport(local_user), - "MSNSLP/1.0 500 Internal Error", - slpsession->branch, 1, call_id, NULL); - - return TRUE; -} - -static gboolean -send_cb(gpointer user_data) -{ - MsnSlpSession *slpsession = (MsnSlpSession *)user_data; - MsnMessage *msg; - char data[1200]; - size_t len; - - len = fread(data, 1, 1200, slpsession->send_fp); - - slpsession->remaining_size -= len; - - msg = msn_message_new_msnslp(); - msn_message_set_bin_data(msg, data, len); - - msn_slp_session_send_msg(slpsession, msg); - - if (slpsession->remaining_size <= 0) - { - slpsession->send_timer = 0; - - return FALSE; - } - - return TRUE; -} - -gboolean -msn_slp_session_msg_received(MsnSlpSession *slpsession, MsnMessage *msg) -{ - const char *body; - const char *c, *c2; - GaimAccount *account; - - g_return_val_if_fail(slpsession != NULL, TRUE); - g_return_val_if_fail(msg != NULL, TRUE); - g_return_val_if_fail(msg->msnslp_message, TRUE); - g_return_val_if_fail(!strcmp(msn_message_get_content_type(msg), - "application/x-msnmsgrp2p"), TRUE); - - account = slpsession->swboard->servconn->session->account; - - body = msn_message_get_bin_data(msg, NULL); - - gaim_debug_misc("msn", "MSNSLP Message: {%s}\n", body); - - if (*body == '\0') - { - /* ACK. Ignore it. */ - gaim_debug_info("msn", "Received MSNSLP ACK\n"); - - return FALSE; - } - - if (slpsession->send_fp != NULL && slpsession->remaining_size == 0) - { - /* - * In theory, if we received something while send_fp is non-NULL, - * but remaining_size is 0, then this is a data ack message. - * - * Say BYE-BYE. - */ - MsnUser *local_user; - char *header; - - fclose(slpsession->send_fp); - slpsession->send_fp = NULL; - - header = g_strdup_printf("BYE MSNMSGR:%s MSNSLP/1.0", - msg->passport); - - local_user = slpsession->swboard->servconn->session->user; - - msn_slp_session_send_message(slpsession, msg->passport, - msn_user_get_passport(local_user), - header, - "A0D624A6-6C0C-4283-A9E0-BC97B4B46D32", - 0, slpsession->call_id, ""); - - g_free(header); - - return TRUE; - } - - if (!strncmp(body, "MSNSLP/1.0 ", strlen("MSNSLP/1.0 "))) - { - /* Make sure this is "OK" */ - const char *status = body + strlen("MSNSLP/1.0 "); - - if (strncmp(status, "200 OK", 6)) - { - /* It's not valid. Kill this off. */ - char temp[32]; - const char *c; - - /* Eww */ - if ((c = strchr(status, '\r')) || (c = strchr(status, '\n')) || - (c = strchr(status, '\0'))) - { - strncpy(temp, status, c - status); - temp[c - status] = '\0'; - } - - gaim_debug_error("msn", "Received non-OK result: %s\n", temp); - - return TRUE; - } - } - else if (!strncmp(body, "INVITE", strlen("INVITE"))) - { - /* Parse it. Oh this is fun. */ - char *branch, *call_id, *temp; - unsigned int session_id, app_id; - - /* First, branch. */ - if ((c = strstr(body, ";branch={")) == NULL) - return send_error_500(slpsession, NULL, msg); - - c += strlen(";branch={"); - - if ((c2 = strchr(c, '}')) == NULL) - return send_error_500(slpsession, NULL, msg); - - branch = g_strndup(c, c2 - c); - - if (slpsession->branch != NULL) - slpsession->branch = branch; - - /* Second, Call-ID */ - if ((c = strstr(body, "Call-ID: {")) == NULL) - return send_error_500(slpsession, NULL, msg); - - c += strlen("Call-ID: {"); - - if ((c2 = strchr(c, '}')) == NULL) - return send_error_500(slpsession, NULL, msg); - - call_id = g_strndup(c, c2 - c); - - if (slpsession->call_id != NULL) - slpsession->call_id = call_id; - - /* Third, SessionID */ - if ((c = strstr(body, "SessionID: ")) == NULL) - return send_error_500(slpsession, NULL, msg); - - c += strlen("SessionID: "); - - if ((c2 = strchr(c, '\r')) == NULL) - return send_error_500(slpsession, NULL, msg); - - temp = g_strndup(c, c2 - c); - session_id = atoi(temp); - g_free(temp); - - /* Fourth, AppID */ - if ((c = strstr(body, "AppID: ")) == NULL) - return send_error_500(slpsession, NULL, msg); - - c += strlen("AppID: "); - - if ((c2 = strchr(c, '\r')) == NULL) - return send_error_500(slpsession, NULL, msg); - - temp = g_strndup(c, c2 - c); - app_id = atoi(temp); - g_free(temp); - - if (app_id == 1) - { - MsnSession *session; - MsnMessage *new_msg; - MsnUser *local_user; - MsnUser *remote_user; - char *content; - char nil_body[4]; - struct stat st; - - /* Send the 200 OK message. */ - content = g_strdup_printf("SessionID: %d", session_id); - msn_slp_session_send_ack(slpsession, msg); - - session = slpsession->swboard->servconn->session; - - local_user = session->user; - - msn_slp_session_send_message(slpsession, msg->passport, - msn_user_get_passport(local_user), - "MSNSLP/1.0 200 OK", - branch, 1, call_id, content); - - g_free(content); - - /* Send the Data Preparation message. */ - memset(nil_body, 0, sizeof(nil_body)); - - slpsession->session_id = session_id; - - remote_user = msn_user_new(session, msg->passport, NULL); - - slpsession->receiver = remote_user; - slpsession->sender = session->user; - - new_msg = msn_message_new_msnslp(); - msn_message_set_bin_data(new_msg, nil_body, 4); - new_msg->msnslp_footer.value = 1; - - msn_slp_session_send_msg(slpsession, new_msg); - - slpsession->send_fp = - fopen(gaim_account_get_buddy_icon(account), "rb"); - - if (stat(gaim_account_get_buddy_icon(account), &st) == 0) - slpsession->remaining_size = st.st_size; - - slpsession->send_timer = gaim_timeout_add(10, send_cb, slpsession); - } - else - return send_error_500(slpsession, call_id, msg); - - return FALSE; - } - - /* Now send an ack, since we got this. */ - msn_slp_session_send_ack(slpsession, msg); - - return FALSE; -} - -static void -send_msg_part(MsnSlpSession *slpsession, MsnMessage *msg) -{ - msg->msnslp_header.length = - (slpsession->orig_len - slpsession->offset > 1202 - ? 1202 : slpsession->orig_len - slpsession->offset); - - if (slpsession->offset > 0) - { - msn_message_set_bin_data(msg, - slpsession->orig_body + slpsession->offset, - msg->msnslp_header.length); - } - - msg->msnslp_header.offset = slpsession->offset; - - msn_switchboard_send_msg(slpsession->swboard, msg); - - if (slpsession->offset + msg->msnslp_header.length == slpsession->orig_len) - { - msn_message_destroy(msg); - - g_free(slpsession->orig_body); - - slpsession->offset = 0; - slpsession->orig_len = 0; - slpsession->orig_body = NULL; - slpsession->outgoing_msg = NULL; - } - else - slpsession->offset += msg->msnslp_header.length; -} - -void -msn_slp_session_send_msg(MsnSlpSession *slpsession, MsnMessage *msg) -{ - const void *temp; - - g_return_if_fail(slpsession != NULL); - g_return_if_fail(msg != NULL); - g_return_if_fail(msg->msnslp_message); - g_return_if_fail(slpsession->outgoing_msg == NULL); - - msg->msnslp_header.session_id = slpsession->session_id; - - slpsession->outgoing_msg = msn_message_ref(msg); - - if (slpsession->base_id == 0) - { - slpsession->base_id = rand() % 0x0FFFFFF0 + 4; - slpsession->prev_msg_id = slpsession->base_id; - } - else if (slpsession->offset == 0) - slpsession->prev_msg_id = ++slpsession->base_id; - - msg->msnslp_header.id = slpsession->prev_msg_id; - /*msg->msnslp_header.ack_id = rand() % 0xFFFFFF00;*/ - msg->msnslp_header.ack_id = 0x1407C7DE; - - msn_message_set_charset(msg, NULL); - - if (msg->msnslp_header.session_id != 0) - msg->msnslp_footer.value = 1; - - temp = msn_message_get_bin_data(msg, &slpsession->orig_len); - - slpsession->orig_body = g_memdup(temp, slpsession->orig_len); - - msg->msnslp_header.total_size = slpsession->orig_len; - msg->msnslp_header.length = slpsession->orig_len; - - send_msg_part(slpsession, msg); -} - -void -msn_slp_session_send_ack(MsnSlpSession *slpsession, MsnMessage *acked_msg) -{ - MsnMessage *msg; - gboolean new_base_id = FALSE; - - g_return_if_fail(slpsession != NULL); - g_return_if_fail(acked_msg != NULL); - g_return_if_fail(acked_msg->msnslp_message); - g_return_if_fail(slpsession->outgoing_msg == NULL); - - msg = msn_message_new_msnslp_ack(acked_msg); - - if (slpsession->base_id == 0) - { - slpsession->base_id = rand() % 0x0FFFFE00 + 10; - slpsession->prev_msg_id = slpsession->base_id; - - new_base_id = TRUE; - } - else - slpsession->prev_msg_id = ++slpsession->base_id; - - msg->msnslp_header.id = slpsession->prev_msg_id; - - if (new_base_id) - slpsession->prev_msg_id -= 4; - - msn_switchboard_send_msg(slpsession->swboard, msg); -} - -void -msn_slp_session_request_user_display(MsnSlpSession *slpsession, - MsnUser *local_user, - MsnUser *remote_user, - const MsnObject *obj) -{ - long session_id; - char *msnobj_data; - char *msnobj_base64; - char *header; - char *content; - - g_return_if_fail(slpsession != NULL); - g_return_if_fail(local_user != NULL); - g_return_if_fail(remote_user != NULL); - g_return_if_fail(obj != NULL); - - msnobj_data = msn_object_to_string(obj); - msnobj_base64 = gaim_base64_encode(msnobj_data, strlen(msnobj_data)); - g_free(msnobj_data); - - session_id = rand() % 0xFFFFFF00 + 4; - - if (slpsession->branch != NULL) - g_free(slpsession->branch); - - slpsession->branch = g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X", - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111); - - if (slpsession->call_id != NULL) - g_free(slpsession->call_id); - - slpsession->call_id = g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X", - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111, - rand() % 0xAAFF + 0x1111); - - content = g_strdup_printf( - "EUF-GUID: {A4268EEC-FEC5-49E5-95C3-F126696BDBF6}\r\n" - "SessionID: %lu\r\n" - "AppID: 1\r\n" - "Context: %s", - session_id, - msnobj_base64); - - g_free(msnobj_base64); - - header = g_strdup_printf("INVITE MSNMSGR:%s MSNSLP/1.0", - msn_user_get_passport(remote_user)); - - msn_slp_session_send_message(slpsession, - msn_user_get_passport(local_user), - msn_user_get_passport(remote_user), - header, slpsession->branch, 0, - slpsession->call_id, content); - - g_free(header); - g_free(content); -} - -gboolean -msn_p2p_msg(MsnServConn *servconn, MsnMessage *msg) -{ - MsnSwitchBoard *swboard = servconn->data; - gboolean session_ended = FALSE; - -#if 0 - FILE *fp; - size_t len; - char *buf; - - buf = msn_message_to_string(msg, &len); - /* Windows doesn't like Unix paths */ - fp = fopen("/tmp/msn-msg", "ab"); - fwrite(buf, 1, len, fp); - fclose(fp); - - g_free(buf); -#endif - - if (swboard->slp_session == NULL) - swboard->slp_session = msn_slp_session_new(swboard, FALSE); - - session_ended = msn_slp_session_msg_received(swboard->slp_session, msg); - - if (session_ended) - msn_slp_session_destroy(swboard->slp_session); - - return FALSE; -} diff -r ab6636c5a136 -r d1fd3de2feca src/protocols/msn/msnslp.h --- a/src/protocols/msn/msnslp.h Sun Jun 06 03:42:55 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ -/** - * @file msnslp.h MSNSLP support - * - * gaim - * - * Gaim is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef _MSN_SLP_H_ -#define _MSN_SLP_H_ - -typedef struct _MsnSlpSession MsnSlpSession; - -#include "msnobject.h" -#include "user.h" - -#include "switchboard.h" - -struct _MsnSlpSession -{ - gboolean local_initiated; - - MsnSwitchBoard *swboard; - - char *branch; - char *call_id; - - long session_id; - long base_id; - long prev_msg_id; - - size_t offset; - - void *orig_body; - size_t orig_len; - - guint send_timer; - FILE *send_fp; - - size_t remaining_size; - - MsnUser *receiver; - MsnUser *sender; - - MsnMessage *outgoing_msg; -}; - -/** - * Creates a MSNSLP session. - * - * @param swboard The switchboard. - * @param local_initiated TRUE if the session was initiated locally. - * - * @return The new MSNSLP session handle. - */ -MsnSlpSession *msn_slp_session_new(MsnSwitchBoard *swboard, - gboolean local_initiated); - -/** - * Destroys a MSNSLP session handle. - * - * This does not close the connection. - * - * @param slpsession The MSNSLP session to destroy. - */ -void msn_slp_session_destroy(MsnSlpSession *slpsession); - -/** - * Notifies the MSNSLP session handle that a message was received. - * - * @param slpsession The MSNSLP session. - * @param msg The message. - * - * @return TRUE if the session was closed, or FALSE otherwise. - */ -gboolean msn_slp_session_msg_received(MsnSlpSession *slpsession, - MsnMessage *msg); - -/** - * Sends a message over a MSNSLP session. - * - * @param slpsession The MSNSLP session to send the message over. - * @param msg The message to send. - */ -void msn_slp_session_send_msg(MsnSlpSession *session, MsnMessage *msg); - -/** - * Sends an acknowledgement message over a MSNSLP session for the - * specified message. - * - * @param slpsession The MSNSLP session to send the acknowledgement over. - * @param acked_msg The message to acknowledge. - */ -void msn_slp_session_send_ack(MsnSlpSession *session, MsnMessage *acked_msg); - -/** - * Requests a User Display image over a MSNSLP session. - * - * @param slpsession The MSNSLP session to request the image over. - * @param localUser The local user initiating the invite. - * @param remoteUser The remote user the invite is sent to. - * @param obj The MSNObject representing the user display info. - */ -void msn_slp_session_request_user_display(MsnSlpSession *session, - MsnUser *localUser, - MsnUser *remoteUser, - const MsnObject *obj); - -/** - * Processes application/x-msnmsgrp2p messages. - * - * @param servconn The server connection. - * @param msg The message. - * - * @return TRUE - */ -gboolean msn_p2p_msg(MsnServConn *servconn, MsnMessage *msg); - -#endif /* _MSN_SLP_H_ */