Mercurial > pidgin
annotate src/protocols/msn/dispatch.c @ 8718:6ab61697426e
[gaim-migrate @ 9473]
simguy wants this
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 20 Apr 2004 04:04:41 +0000 |
parents | 17ef51dc609c |
children | ab6636c5a136 |
rev | line source |
---|---|
5309 | 1 /** |
2 * @file dispatch.c Dispatch server functions | |
3 * | |
4 * gaim | |
5 * | |
8475
06f57183e29f
[gaim-migrate @ 9208]
Christian Hammond <chipx86@chipx86.com>
parents:
7981
diff
changeset
|
6 * Copyright (C) 2003-2004 Christian Hammond <chipx86@gnupdate.org> |
6701
b7e113a59b51
[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
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
30 cvr_cmd(MsnServConn *servconn, const char *command, const char **params, |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
31 size_t param_count) |
5309 | 32 { |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
33 GaimAccount *account = servconn->session->account; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
34 GaimConnection *gc = gaim_account_get_connection(account); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
35 char outparams[MSN_BUF_LEN]; |
5309 | 36 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
37 g_snprintf(outparams, sizeof(outparams), |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
38 "TWN I %s", gaim_account_get_username(account)); |
5309 | 39 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
40 if (!msn_servconn_send_command(servconn, "USR", outparams)) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
41 { |
b7e113a59b51
[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
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
51 inf_cmd(MsnServConn *servconn, const char *command, const char **params, |
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
52 size_t param_count) |
5309 | 53 { |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
54 GaimAccount *account = servconn->session->account; |
187c740f2a4e
[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
187c740f2a4e
[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
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
64 g_snprintf(outparams, sizeof(outparams), "MD5 I %s", |
187c740f2a4e
[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 | 68 gaim_connection_error(gc, _("Unable to send USR")); |
5309 | 69 |
70 return FALSE; | |
71 } | |
72 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
73 gaim_connection_update_progress(gc, _("Requesting to send password"), |
187c740f2a4e
[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
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
80 ver_cmd(MsnServConn *servconn, const char *command, const char **params, |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
81 size_t param_count) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
82 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
83 MsnSession *session = servconn->session; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
84 GaimAccount *account = session->account; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
85 GaimConnection *gc = gaim_account_get_connection(account); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
86 gboolean protocol_supported = FALSE; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
87 char outparams[MSN_BUF_LEN]; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
88 char proto_str[8]; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
89 size_t i; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
90 |
b7e113a59b51
[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); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
92 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
93 for (i = 1; i < param_count; i++) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
94 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
95 if (!strcmp(params[i], proto_str)) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
96 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
97 protocol_supported = TRUE; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
98 break; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
99 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
100 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
101 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
102 if (!protocol_supported) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
103 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
104 gaim_connection_error(gc, _("Protocol version not supported")); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
105 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
106 return FALSE; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
107 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
108 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
109 if (session->protocol_ver >= 8) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
110 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
111 g_snprintf(outparams, sizeof(outparams), |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
112 "0x0409 winnt 5.1 i386 MSNMSGR 6.0.0602 MSMSGS %s", |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
113 gaim_account_get_username(account)); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
114 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
115 if (!msn_servconn_send_command(servconn, "CVR", outparams)) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
116 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
117 gaim_connection_error(gc, _("Unable to request CVR\n")); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
118 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
119 return FALSE; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
120 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
121 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
122 else |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
123 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
124 if (!msn_servconn_send_command(servconn, "INF", NULL)) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
125 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
126 gaim_connection_error(gc, _("Unable to request INF\n")); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
127 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
128 return FALSE; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
129 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
130 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
131 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
132 return TRUE; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
133 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
134 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
135 static gboolean |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
136 xfr_cmd(MsnServConn *servconn, const char *command, const char **params, |
952710ac6635
[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
187c740f2a4e
[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
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
145 if (param_count < 2 || strcmp(params[1], "NS")) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
146 { |
6623 | 147 gaim_connection_error(gc, _("Got invalid XFR")); |
5309 | 148 |
149 return FALSE; | |
150 } | |
151 | |
152 host = g_strdup(params[2]); | |
153 | |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
154 if ((c = strchr(host, ':')) != NULL) |
b7e113a59b51
[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
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
169 /* Reset our transaction ID. */ |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
170 session->trId = 0; |
b7e113a59b51
[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
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
177 if (!msn_servconn_connect(session->notification_conn)) |
5564
187c740f2a4e
[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
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
184 unknown_cmd(MsnServConn *servconn, const char *command, const char **params, |
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
185 size_t param_count) |
5309 | 186 { |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
187 GaimConnection *gc = servconn->session->account->gc; |
5309 | 188 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
189 if (isdigit(*command)) |
7937
0dc286295b36
[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
187c740f2a4e
[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
952710ac6635
[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
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
202 GaimConnection *gc = session->account->gc; |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
203 char proto_vers[256]; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
204 size_t i; |
5309 | 205 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
206 if (source == -1) |
b7e113a59b51
[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
187c740f2a4e
[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
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
217 proto_vers[0] = '\0'; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
218 |
6828
cdcb43229e33
[gaim-migrate @ 7373]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
219 for (i = 7; i <= session->protocol_ver; i++) |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
220 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
221 char old_buf[256]; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
222 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
223 strcpy(old_buf, proto_vers); |
b7e113a59b51
[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
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
226 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
227 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
228 strncat(proto_vers, "CVR0", sizeof(proto_vers)); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
229 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
230 if (!msn_servconn_send_command(dispatch, "VER", proto_vers)) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
231 { |
5564
187c740f2a4e
[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
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
236 gaim_connection_update_progress(gc, _("Syncing with server"), |
187c740f2a4e
[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
952710ac6635
[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
187c740f2a4e
[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
187c740f2a4e
[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
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
259 |
5309 | 260 msn_servconn_set_server(dispatch, server, port); |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
261 msn_servconn_set_connect_cb(dispatch, connect_cb); |
952710ac6635
[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
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
266 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
267 msn_servconn_register_command(dispatch, "CVR", cvr_cmd); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
268 msn_servconn_register_command(dispatch, "INF", inf_cmd); |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
269 msn_servconn_register_command(dispatch, "VER", ver_cmd); |
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
270 msn_servconn_register_command(dispatch, "XFR", xfr_cmd); |
8663
17ef51dc609c
[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 |