Mercurial > pidgin
annotate src/protocols/msn/dispatch.c @ 7210:234178fd9787
[gaim-migrate @ 7779]
Commitinating my NEWS. What else should I be doing at school? Studying? Hah.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 09 Oct 2003 20:13:05 +0000 |
parents | cdcb43229e33 |
children | 414c701ef1ff |
rev | line source |
---|---|
5309 | 1 /** |
2 * @file dispatch.c Dispatch server functions | |
3 * | |
4 * gaim | |
5 * | |
6 * Copyright (C) 2003 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)) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
190 { |
5309 | 191 char buf[4]; |
192 | |
193 strncpy(buf, command, 4); | |
194 buf[4] = '\0'; | |
195 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
196 gaim_connection_error(gc, (char *)msn_error_get_text(atoi(buf))); |
5309 | 197 } |
198 else | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
199 gaim_connection_error(gc, _("Unable to parse message.")); |
5309 | 200 |
201 return FALSE; | |
202 } | |
203 | |
204 static gboolean | |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
205 connect_cb(gpointer data, gint source, GaimInputCondition cond) |
5309 | 206 { |
207 MsnServConn *dispatch = data; | |
208 MsnSession *session = dispatch->session; | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
209 GaimConnection *gc = session->account->gc; |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
210 char proto_vers[256]; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
211 size_t i; |
5309 | 212 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
213 if (source == -1) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
214 { |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
215 gaim_connection_error(session->account->gc, _("Unable to connect")); |
5309 | 216 return FALSE; |
217 } | |
218 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
219 gaim_connection_update_progress(gc, _("Connecting"), 1, MSN_CONNECT_STEPS); |
5309 | 220 |
221 if (dispatch->fd != source) | |
222 dispatch->fd = source; | |
223 | |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
224 proto_vers[0] = '\0'; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
225 |
6828
cdcb43229e33
[gaim-migrate @ 7373]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
226 for (i = 7; i <= session->protocol_ver; i++) |
6701
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 char old_buf[256]; |
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 strcpy(old_buf, proto_vers); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
231 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
232 g_snprintf(proto_vers, sizeof(proto_vers), "MSNP%d %s", i, old_buf); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
233 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
234 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
235 strncat(proto_vers, "CVR0", sizeof(proto_vers)); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
236 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
237 if (!msn_servconn_send_command(dispatch, "VER", proto_vers)) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
238 { |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
239 gaim_connection_error(gc, _("Unable to write to server")); |
5309 | 240 return FALSE; |
241 } | |
242 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
243 gaim_connection_update_progress(gc, _("Syncing with server"), |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
244 2, MSN_CONNECT_STEPS); |
5309 | 245 |
246 return TRUE; | |
247 } | |
248 | |
249 static void | |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
250 failed_read_cb(gpointer data, gint source, GaimInputCondition cond) |
5309 | 251 { |
252 MsnServConn *dispatch = data; | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
253 GaimConnection *gc; |
5309 | 254 |
255 gc = dispatch->session->account->gc; | |
256 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
257 gaim_connection_error(gc, _("Error reading from server")); |
5309 | 258 } |
259 | |
260 MsnServConn * | |
261 msn_dispatch_new(MsnSession *session, const char *server, int port) | |
262 { | |
263 MsnServConn *dispatch; | |
264 | |
265 dispatch = msn_servconn_new(session); | |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
266 |
5309 | 267 msn_servconn_set_server(dispatch, server, port); |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
268 msn_servconn_set_connect_cb(dispatch, connect_cb); |
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
269 msn_servconn_set_failed_read_cb(dispatch, failed_read_cb); |
5309 | 270 |
271 if (dispatch_commands == NULL) { | |
272 /* Register the command callbacks. */ | |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
273 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
274 msn_servconn_register_command(dispatch, "CVR", cvr_cmd); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
275 msn_servconn_register_command(dispatch, "INF", inf_cmd); |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
276 msn_servconn_register_command(dispatch, "VER", ver_cmd); |
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
277 msn_servconn_register_command(dispatch, "XFR", xfr_cmd); |
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
278 msn_servconn_register_command(dispatch, "_unknown_", unknown_cmd); |
5309 | 279 |
280 /* Save this for future use. */ | |
281 dispatch_commands = dispatch->commands; | |
282 } | |
283 else { | |
284 g_hash_table_destroy(dispatch->commands); | |
285 | |
286 dispatch->commands = dispatch_commands; | |
287 } | |
288 | |
289 return dispatch; | |
290 } | |
291 |