Fri, 21 May 2004 14:33:32 +0000
[gaim-migrate @ 9774]
" This patch renames the existing received-*-msg signals
to receiving-*msg to fit the naming of other signals
where a pointer to the message is passed (writing,
sending, displaying)
It adds new received-*-msg signals which are emitted
after the receiving signals, in line with the other
conversation signals (wrote, sent, displayed)
This is necessary to allow plugins which depend on the
final received message to work alongside plugins which
may modify the message.
One known example of this is festival-gaim alongside
gaim-encryption - festival-gaim would try to "speak"
the encrypted text:
http://sf.net/tracker/?func=detail&aid=943216&group_id=89763&atid=591320
I've tested this with gaim-encryption and festival-gaim
(locally modified so gaim-encryption uses the receiving
signal and festival uses the received signal)
All in-tree users of received-*-msg are updated to use
receiving-*-msg if they do modify the message, the
conversation-signals documentation is updated, the
signals-test.c & signal-test.tcl plugins are also updated." --Stu Tomlinson
committer: Luke Schierer <lschiere@pidgin.im>
| 5309 | 1 | /** |
| 2 | * @file dispatch.c Dispatch server functions | |
| 3 | * | |
| 4 | * gaim | |
| 5 | * | |
|
8475
3b5687726055
[gaim-migrate @ 9208]
Christian Hammond <chipx86@chipx86.com>
parents:
7981
diff
changeset
|
6 | * Copyright (C) 2003-2004 Christian Hammond <chipx86@gnupdate.org> |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
7 | * |
| 5309 | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | */ | |
| 22 | #include "msn.h" | |
| 23 | #include "dispatch.h" | |
| 24 | #include "notification.h" | |
| 25 | #include "error.h" | |
| 26 | ||
| 27 | static GHashTable *dispatch_commands = NULL; | |
| 28 | ||
| 29 | static gboolean | |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
30 | cvr_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
31 | size_t param_count) |
| 5309 | 32 | { |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
33 | GaimAccount *account = servconn->session->account; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
34 | GaimConnection *gc = gaim_account_get_connection(account); |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
35 | char outparams[MSN_BUF_LEN]; |
| 5309 | 36 | |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
37 | g_snprintf(outparams, sizeof(outparams), |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
38 | "TWN I %s", gaim_account_get_username(account)); |
| 5309 | 39 | |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
40 | if (!msn_servconn_send_command(servconn, "USR", outparams)) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
41 | { |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
42 | gaim_connection_error(gc, _("Unable to request USR\n")); |
| 5309 | 43 | |
| 44 | return FALSE; | |
| 45 | } | |
| 46 | ||
| 47 | return TRUE; | |
| 48 | } | |
| 49 | ||
| 50 | static gboolean | |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
51 | inf_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
52 | size_t param_count) |
| 5309 | 53 | { |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
54 | GaimAccount *account = servconn->session->account; |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
55 | GaimConnection *gc = gaim_account_get_connection(account); |
| 5309 | 56 | char outparams[MSN_BUF_LEN]; |
| 57 | ||
| 58 | if (strcmp(params[1], "MD5")) { | |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
59 | gaim_connection_error(gc, _("Unable to login using MD5")); |
| 5309 | 60 | |
| 61 | return FALSE; | |
| 62 | } | |
| 63 | ||
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
64 | g_snprintf(outparams, sizeof(outparams), "MD5 I %s", |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
65 | gaim_account_get_username(account)); |
| 5309 | 66 | |
| 67 | if (!msn_servconn_send_command(servconn, "USR", outparams)) { | |
|
6623
75ba9eb9d3f8
[gaim-migrate @ 7147]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
5793
diff
changeset
|
68 | gaim_connection_error(gc, _("Unable to send USR")); |
| 5309 | 69 | |
| 70 | return FALSE; | |
| 71 | } | |
| 72 | ||
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
73 | gaim_connection_update_progress(gc, _("Requesting to send password"), |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
74 | 3, MSN_CONNECT_STEPS); |
| 5309 | 75 | |
| 76 | return TRUE; | |
| 77 | } | |
| 78 | ||
| 79 | static gboolean | |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
80 | ver_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
81 | size_t param_count) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
82 | { |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
83 | MsnSession *session = servconn->session; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
84 | GaimAccount *account = session->account; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
85 | GaimConnection *gc = gaim_account_get_connection(account); |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
86 | gboolean protocol_supported = FALSE; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
87 | char outparams[MSN_BUF_LEN]; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
88 | char proto_str[8]; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
89 | size_t i; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
90 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
91 | g_snprintf(proto_str, sizeof(proto_str), "MSNP%d", session->protocol_ver); |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
92 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
93 | for (i = 1; i < param_count; i++) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
94 | { |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
95 | if (!strcmp(params[i], proto_str)) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
96 | { |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
97 | protocol_supported = TRUE; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
98 | break; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
99 | } |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
100 | } |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
101 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
102 | if (!protocol_supported) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
103 | { |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
104 | gaim_connection_error(gc, _("Protocol version not supported")); |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
105 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
106 | return FALSE; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
107 | } |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
108 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
109 | if (session->protocol_ver >= 8) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
110 | { |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
111 | g_snprintf(outparams, sizeof(outparams), |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
112 | "0x0409 winnt 5.1 i386 MSNMSGR 6.0.0602 MSMSGS %s", |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
113 | gaim_account_get_username(account)); |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
114 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
115 | if (!msn_servconn_send_command(servconn, "CVR", outparams)) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
116 | { |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
117 | gaim_connection_error(gc, _("Unable to request CVR\n")); |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
118 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
119 | return FALSE; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
120 | } |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
121 | } |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
122 | else |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
123 | { |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
124 | if (!msn_servconn_send_command(servconn, "INF", NULL)) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
125 | { |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
126 | gaim_connection_error(gc, _("Unable to request INF\n")); |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
127 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
128 | return FALSE; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
129 | } |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
130 | } |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
131 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
132 | return TRUE; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
133 | } |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
134 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
135 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
136 | xfr_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
137 | size_t param_count) |
| 5309 | 138 | { |
| 139 | MsnSession *session = servconn->session; | |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
140 | GaimConnection *gc = servconn->session->account->gc; |
| 5309 | 141 | char *host; |
| 142 | int port; | |
| 143 | char *c; | |
| 144 | ||
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
145 | if (param_count < 2 || strcmp(params[1], "NS")) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
146 | { |
|
6623
75ba9eb9d3f8
[gaim-migrate @ 7147]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
5793
diff
changeset
|
147 | gaim_connection_error(gc, _("Got invalid XFR")); |
| 5309 | 148 | |
| 149 | return FALSE; | |
| 150 | } | |
| 151 | ||
| 152 | host = g_strdup(params[2]); | |
| 153 | ||
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
154 | if ((c = strchr(host, ':')) != NULL) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
155 | { |
| 5309 | 156 | *c = '\0'; |
| 157 | ||
| 158 | port = atoi(c + 1); | |
| 159 | } | |
| 160 | else | |
| 161 | port = 1863; | |
| 162 | ||
| 163 | session->passport_info.sl = time(NULL); | |
| 164 | ||
| 165 | /* Disconnect from here. */ | |
| 166 | msn_servconn_destroy(servconn); | |
| 167 | session->dispatch_conn = NULL; | |
| 168 | ||
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
169 | /* Reset our transaction ID. */ |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
170 | session->trId = 0; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
171 | |
| 5309 | 172 | /* Now connect to the switchboard. */ |
| 173 | session->notification_conn = msn_notification_new(session, host, port); | |
| 174 | ||
| 175 | g_free(host); | |
| 176 | ||
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
177 | if (!msn_servconn_connect(session->notification_conn)) |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
178 | gaim_connection_error(gc, _("Unable to transfer")); |
| 5309 | 179 | |
| 180 | return FALSE; | |
| 181 | } | |
| 182 | ||
| 183 | static gboolean | |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
184 | unknown_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
185 | size_t param_count) |
| 5309 | 186 | { |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
187 | GaimConnection *gc = servconn->session->account->gc; |
| 5309 | 188 | |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
189 | if (isdigit(*command)) |
|
7937
d24de52f762d
[gaim-migrate @ 8608]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
190 | gaim_connection_error(gc, msn_error_get_text(atoi(command))); |
| 5309 | 191 | else |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
192 | gaim_connection_error(gc, _("Unable to parse message.")); |
| 5309 | 193 | |
| 194 | return FALSE; | |
| 195 | } | |
| 196 | ||
| 197 | static gboolean | |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
198 | connect_cb(gpointer data, gint source, GaimInputCondition cond) |
| 5309 | 199 | { |
| 200 | MsnServConn *dispatch = data; | |
| 201 | MsnSession *session = dispatch->session; | |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
202 | GaimConnection *gc = session->account->gc; |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
203 | char proto_vers[256]; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
204 | size_t i; |
| 5309 | 205 | |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
206 | if (source == -1) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
207 | { |
| 7981 | 208 | gaim_connection_error(session->account->gc, _("Unable to connect.")); |
| 5309 | 209 | return FALSE; |
| 210 | } | |
| 211 | ||
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
212 | gaim_connection_update_progress(gc, _("Connecting"), 1, MSN_CONNECT_STEPS); |
| 5309 | 213 | |
| 214 | if (dispatch->fd != source) | |
| 215 | dispatch->fd = source; | |
| 216 | ||
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
217 | proto_vers[0] = '\0'; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
218 | |
|
6828
f4190a22af19
[gaim-migrate @ 7373]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
219 | for (i = 7; i <= session->protocol_ver; i++) |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
220 | { |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
221 | char old_buf[256]; |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
222 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
223 | strcpy(old_buf, proto_vers); |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
224 | |
| 7386 | 225 | g_snprintf(proto_vers, sizeof(proto_vers), "MSNP%d %s", (int)i, old_buf); |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
226 | } |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
227 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
228 | strncat(proto_vers, "CVR0", sizeof(proto_vers)); |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
229 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
230 | if (!msn_servconn_send_command(dispatch, "VER", proto_vers)) |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
231 | { |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
232 | gaim_connection_error(gc, _("Unable to write to server")); |
| 5309 | 233 | return FALSE; |
| 234 | } | |
| 235 | ||
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
236 | gaim_connection_update_progress(gc, _("Syncing with server"), |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
237 | 2, MSN_CONNECT_STEPS); |
| 5309 | 238 | |
| 239 | return TRUE; | |
| 240 | } | |
| 241 | ||
| 242 | static void | |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
243 | failed_read_cb(gpointer data, gint source, GaimInputCondition cond) |
| 5309 | 244 | { |
| 245 | MsnServConn *dispatch = data; | |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
246 | GaimConnection *gc; |
| 5309 | 247 | |
| 248 | gc = dispatch->session->account->gc; | |
| 249 | ||
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
250 | gaim_connection_error(gc, _("Error reading from server")); |
| 5309 | 251 | } |
| 252 | ||
| 253 | MsnServConn * | |
| 254 | msn_dispatch_new(MsnSession *session, const char *server, int port) | |
| 255 | { | |
| 256 | MsnServConn *dispatch; | |
| 257 | ||
| 258 | dispatch = msn_servconn_new(session); | |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
259 | |
| 5309 | 260 | msn_servconn_set_server(dispatch, server, port); |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
261 | msn_servconn_set_connect_cb(dispatch, connect_cb); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
262 | msn_servconn_set_failed_read_cb(dispatch, failed_read_cb); |
| 5309 | 263 | |
| 264 | if (dispatch_commands == NULL) { | |
| 265 | /* Register the command callbacks. */ | |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
266 | |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
267 | msn_servconn_register_command(dispatch, "CVR", cvr_cmd); |
|
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
268 | msn_servconn_register_command(dispatch, "INF", inf_cmd); |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
269 | msn_servconn_register_command(dispatch, "VER", ver_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
270 | msn_servconn_register_command(dispatch, "XFR", xfr_cmd); |
|
8663
2b46787bdd21
[gaim-migrate @ 9415]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
271 | msn_servconn_register_command(dispatch, "_UNKNOWN_", unknown_cmd); |
| 5309 | 272 | |
| 273 | /* Save this for future use. */ | |
| 274 | dispatch_commands = dispatch->commands; | |
| 275 | } | |
| 276 | else { | |
| 277 | g_hash_table_destroy(dispatch->commands); | |
| 278 | ||
| 279 | dispatch->commands = dispatch_commands; | |
| 280 | } | |
| 281 | ||
| 282 | return dispatch; | |
| 283 | } | |
| 284 |