Mercurial > pidgin
annotate src/protocols/msn/servconn.c @ 8622:ffed55cbdd67
[gaim-migrate @ 9373]
Any objections to this?
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Fri, 09 Apr 2004 02:49:30 +0000 |
| parents | fc27237783ee |
| children | 1e211dde3cae |
| rev | line source |
|---|---|
| 5309 | 1 /** |
| 2 * @file servconn.c Server connection functions | |
| 3 * | |
| 4 * gaim | |
| 5 * | |
|
8475
06f57183e29f
[gaim-migrate @ 9208]
Christian Hammond <chipx86@chipx86.com>
parents:
8299
diff
changeset
|
6 * Copyright (C) 2003-2004 Christian Hammond <chipx86@gnupdate.org> |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6122
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 "servconn.h" | |
|
8569
ee13d1befabe
[gaim-migrate @ 9317]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
24 #include "error.h" |
| 5309 | 25 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
26 static void read_cb(gpointer data, gint source, GaimInputCondition cond); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
27 |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
28 typedef struct |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
29 { |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
30 char *command; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
31 MsnMessage *msg; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
32 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
33 } MsnQueueEntry; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
34 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
35 static gboolean |
|
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5785
diff
changeset
|
36 process_message(MsnServConn *servconn, MsnMessage *msg) |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
37 { |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
38 MsnServConnMsgCb cb; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
39 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
40 cb = g_hash_table_lookup(servconn->msg_types, |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
41 msn_message_get_content_type(msg)); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
42 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
43 if (cb == NULL) { |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
44 gaim_debug(GAIM_DEBUG_WARNING, "msn", |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
45 "Unhandled content-type '%s': %s\n", |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
46 msn_message_get_content_type(msg), |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
47 msn_message_get_body(msg)); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
48 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
49 return FALSE; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
50 } |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
51 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
52 cb(servconn, msg); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
53 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
54 return TRUE; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
55 } |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
56 |
| 5309 | 57 static gboolean |
|
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5785
diff
changeset
|
58 process_single_line(MsnServConn *servconn, char *str) |
| 5309 | 59 { |
|
5897
e3733414ca08
[gaim-migrate @ 6329]
Christian Hammond <chipx86@chipx86.com>
parents:
5793
diff
changeset
|
60 MsnSession *session = servconn->session; |
| 5309 | 61 MsnServConnCommandCb cb; |
|
5897
e3733414ca08
[gaim-migrate @ 6329]
Christian Hammond <chipx86@chipx86.com>
parents:
5793
diff
changeset
|
62 GSList *l, *l_next = NULL; |
| 5309 | 63 gboolean result; |
| 64 size_t param_count = 0; | |
| 65 char *command, *param_start; | |
| 66 char **params = NULL; | |
| 67 | |
| 68 command = str; | |
| 69 | |
| 70 /** | |
| 71 * See how many spaces we have in this. | |
| 72 */ | |
| 73 param_start = strchr(command, ' '); | |
| 74 | |
| 75 if (param_start != NULL) { | |
| 76 params = g_strsplit(param_start + 1, " ", 0); | |
| 77 | |
| 78 for (param_count = 0; params[param_count] != NULL; param_count++) | |
| 79 ; | |
| 80 | |
| 81 *param_start = '\0'; | |
| 82 } | |
| 83 | |
| 84 cb = g_hash_table_lookup(servconn->commands, command); | |
| 85 | |
| 86 if (cb == NULL) { | |
|
7938
160547821ea2
[gaim-migrate @ 8609]
Christian Hammond <chipx86@chipx86.com>
parents:
7604
diff
changeset
|
87 cb = g_hash_table_lookup(servconn->commands, "_unknown_"); |
| 5309 | 88 |
| 89 if (cb == NULL) { | |
|
8569
ee13d1befabe
[gaim-migrate @ 9317]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
90 if (isdigit(*str)) |
|
ee13d1befabe
[gaim-migrate @ 9317]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
91 msn_error_handle(session, atoi(str)); |
|
ee13d1befabe
[gaim-migrate @ 9317]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
92 else |
|
ee13d1befabe
[gaim-migrate @ 9317]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
93 gaim_debug(GAIM_DEBUG_WARNING, "msn", |
| 5309 | 94 "Unhandled command '%s'\n", str); |
| 95 | |
| 96 if (params != NULL) | |
| 97 g_strfreev(params); | |
| 98 | |
| 99 return TRUE; | |
| 100 } | |
| 101 } | |
| 102 | |
| 103 result = cb(servconn, command, (const char **)params, param_count); | |
| 104 | |
| 105 if (params != NULL) | |
| 106 g_strfreev(params); | |
| 107 | |
|
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
108 if (g_list_find(session->servconns, servconn) == NULL) |
|
5897
e3733414ca08
[gaim-migrate @ 6329]
Christian Hammond <chipx86@chipx86.com>
parents:
5793
diff
changeset
|
109 return result; |
|
e3733414ca08
[gaim-migrate @ 6329]
Christian Hammond <chipx86@chipx86.com>
parents:
5793
diff
changeset
|
110 |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
111 /* Process all queued messages that are waiting on this command. */ |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
112 for (l = servconn->msg_queue; l != NULL; l = l_next) { |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
113 MsnQueueEntry *entry = l->data; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
114 MsnMessage *msg; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
115 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
116 l_next = l->next; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
117 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
118 if (entry->command == NULL || |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
119 !g_ascii_strcasecmp(entry->command, command)) { |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
120 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
121 MsnUser *sender; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
122 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
123 msg = entry->msg; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
124 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
125 msn_message_ref(msg); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
126 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
127 sender = msn_message_get_sender(msg); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
128 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
129 servconn->msg_passport = g_strdup(msn_user_get_passport(sender)); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
130 servconn->msg_friendly = g_strdup(msn_user_get_name(sender)); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
131 |
|
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5785
diff
changeset
|
132 process_message(servconn, msg); |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
133 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
134 g_free(servconn->msg_passport); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
135 g_free(servconn->msg_friendly); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
136 |
| 6122 | 137 msn_servconn_unqueue_message(servconn, entry->msg); |
| 138 | |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
139 msn_message_destroy(msg); |
|
5744
6b87c127fe7b
[gaim-migrate @ 6168]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
140 entry->msg = NULL; |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
141 } |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
142 } |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
143 |
| 5309 | 144 return result; |
| 145 } | |
| 146 | |
| 147 static gboolean | |
|
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5785
diff
changeset
|
148 process_multi_line(MsnServConn *servconn, char *buffer) |
| 5309 | 149 { |
| 150 char msg_str[MSN_BUF_LEN]; | |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
151 gboolean result = TRUE; |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
152 |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
153 if (servconn->multiline_type == MSN_MULTILINE_MSG) { |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
154 MsnMessage *msg; |
|
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
155 size_t header_len; |
| 5309 | 156 |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
157 g_snprintf(msg_str, sizeof(msg_str), |
|
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
158 "MSG %s %s %d\r\n", |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
159 servconn->msg_passport, servconn->msg_friendly, |
|
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
160 servconn->multiline_len); |
|
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
161 |
|
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
162 header_len = strlen(msg_str); |
|
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
163 |
|
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
164 memcpy(msg_str + header_len, buffer, servconn->multiline_len); |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
165 |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
166 gaim_debug(GAIM_DEBUG_MISC, "msn", |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
167 "Message: {%s}\n", buffer); |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
168 |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
169 msg = msn_message_new_from_str(servconn->session, msg_str); |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
170 |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
171 result = process_message(servconn, msg); |
| 5309 | 172 |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
173 msn_message_destroy(msg); |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
174 } |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
175 else if (servconn->multiline_type == MSN_MULTILINE_IPG) { |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
176 g_snprintf(msg_str, sizeof(msg_str), |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
177 "IPG %d\r\n%s", |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
178 servconn->multiline_len, buffer); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5317
diff
changeset
|
179 |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
180 gaim_debug(GAIM_DEBUG_MISC, "msn", |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
181 "Incoming Page: {%s}\n", buffer); |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
182 } |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
183 else if (servconn->multiline_type == MSN_MULTILINE_NOT) { |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
184 g_snprintf(msg_str, sizeof(msg_str), |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
185 "NOT %d\r\n%s", |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
186 servconn->multiline_len, buffer); |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
187 |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
188 gaim_debug(GAIM_DEBUG_MISC, "msn", |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
189 "Notification: {%s}\n", buffer); |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
190 } |
| 5309 | 191 |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
192 return result; |
| 5309 | 193 } |
| 194 | |
| 195 static void | |
|
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5785
diff
changeset
|
196 connect_cb(gpointer data, gint source, GaimInputCondition cond) |
| 5309 | 197 { |
| 198 MsnServConn *servconn = data; | |
| 199 | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
200 gaim_debug_info("msn", "In servconn's connect_cb\n"); |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
201 |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
202 servconn->fd = source; |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
203 |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
204 if (source > 0) |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
205 { |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
206 /* Someone wants to know we connected. */ |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
207 servconn->connect_cb(servconn); |
| 5309 | 208 servconn->inpa = gaim_input_add(servconn->fd, GAIM_INPUT_READ, |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
209 read_cb, data); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
210 } |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
211 else |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
212 { |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
213 GaimConnection *gc = servconn->session->account->gc; |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
214 gaim_connection_error(gc, _("Unable to connect.")); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
215 } |
| 5309 | 216 } |
| 217 | |
| 218 MsnServConn * | |
| 219 msn_servconn_new(MsnSession *session) | |
| 220 { | |
| 221 MsnServConn *servconn; | |
| 222 | |
| 223 g_return_val_if_fail(session != NULL, NULL); | |
| 224 | |
| 225 servconn = g_new0(MsnServConn, 1); | |
| 226 | |
| 227 servconn->session = session; | |
| 228 | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
229 if (session->http_method) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
230 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
231 servconn->http_data = g_new0(MsnHttpMethodData, 1); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
232 servconn->http_data->virgin = TRUE; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
233 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
234 |
| 5309 | 235 servconn->commands = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 236 g_free, NULL); | |
| 237 | |
| 238 servconn->msg_types = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 239 g_free, NULL); | |
| 240 | |
|
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
241 session->servconns = g_list_append(session->servconns, servconn); |
|
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
242 |
| 5309 | 243 return servconn; |
| 244 } | |
| 245 | |
| 246 gboolean | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
247 msn_servconn_connect(MsnServConn *servconn, const char *host, int port) |
| 5309 | 248 { |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
249 MsnSession *session; |
| 5309 | 250 int i; |
| 251 | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
252 g_return_val_if_fail(servconn != NULL, FALSE); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
253 g_return_val_if_fail(host != NULL, FALSE); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
254 g_return_val_if_fail(port > 0, FALSE); |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
255 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
256 session = servconn->session; |
| 5309 | 257 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
258 if (servconn->connected) |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
259 msn_servconn_disconnect(servconn); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
260 |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
261 if (session->http_method) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
262 { |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
263 servconn->http_data->gateway_ip = g_strdup(host); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
264 host = "gateway.messenger.hotmail.com"; |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
265 port = 80; |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
266 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
267 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
268 i = gaim_proxy_connect(session->account, host, port, connect_cb, |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
269 servconn); |
| 5309 | 270 |
| 271 if (i == 0) | |
| 272 servconn->connected = TRUE; | |
| 273 | |
| 274 return servconn->connected; | |
| 275 } | |
| 276 | |
| 277 void | |
| 278 msn_servconn_disconnect(MsnServConn *servconn) | |
| 279 { | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
280 MsnSession *session; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
281 |
| 5309 | 282 g_return_if_fail(servconn != NULL); |
| 283 g_return_if_fail(servconn->connected); | |
| 284 | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
285 session = servconn->session; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
286 |
| 5309 | 287 if (servconn->inpa) |
| 288 gaim_input_remove(servconn->inpa); | |
| 289 | |
|
5744
6b87c127fe7b
[gaim-migrate @ 6168]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
290 close(servconn->fd); |
|
6b87c127fe7b
[gaim-migrate @ 6168]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
291 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
292 servconn->connected = FALSE; |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
293 |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
294 if (servconn->http_data != NULL) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
295 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
296 if (servconn->http_data->session_id != NULL) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
297 g_free(servconn->http_data->session_id); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
298 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
299 if (servconn->http_data->old_gateway_ip != NULL) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
300 g_free(servconn->http_data->old_gateway_ip); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
301 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
302 if (servconn->http_data->gateway_ip != NULL) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
303 g_free(servconn->http_data->gateway_ip); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
304 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
305 if (servconn->http_data->timer) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
7938
diff
changeset
|
306 gaim_timeout_remove(servconn->http_data->timer); |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
307 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
308 g_free(servconn->http_data); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
309 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
310 |
|
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
311 if (servconn->rxqueue != NULL) |
|
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
312 g_free(servconn->rxqueue); |
| 5309 | 313 |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
314 while (servconn->txqueue != NULL) { |
| 5309 | 315 g_free(servconn->txqueue->data); |
| 316 | |
| 317 servconn->txqueue = g_slist_remove(servconn->txqueue, | |
| 318 servconn->txqueue->data); | |
| 319 } | |
| 320 | |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
321 while (servconn->msg_queue != NULL) { |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
322 MsnQueueEntry *entry = servconn->msg_queue->data; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
323 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
324 msn_servconn_unqueue_message(servconn, entry->msg); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
325 } |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
326 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
327 if (servconn->disconnect_cb) |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
328 servconn->disconnect_cb(servconn); |
| 5309 | 329 } |
| 330 | |
| 331 void | |
| 332 msn_servconn_destroy(MsnServConn *servconn) | |
| 333 { | |
|
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
334 MsnSession *session; |
|
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
335 |
| 5309 | 336 g_return_if_fail(servconn != NULL); |
| 337 | |
|
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
338 session = servconn->session; |
|
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
339 |
|
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
340 session->servconns = g_list_remove(session->servconns, servconn); |
|
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
341 |
| 5309 | 342 if (servconn->connected) |
| 343 msn_servconn_disconnect(servconn); | |
| 344 | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
345 #if 0 |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
346 /* shx: not used */ |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
347 if (servconn->host != NULL) |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
348 g_free(servconn->host); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
349 #endif |
| 5309 | 350 |
| 351 g_free(servconn); | |
| 352 } | |
| 353 | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
354 #if 0 |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
355 /* shx: this isn't used */ |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
356 |
| 5309 | 357 void |
| 358 msn_servconn_set_server(MsnServConn *servconn, const char *server, int port) | |
| 359 { | |
| 360 g_return_if_fail(servconn != NULL); | |
| 361 g_return_if_fail(server != NULL); | |
| 362 g_return_if_fail(port > 0); | |
| 363 | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
364 if (servconn->host != NULL) |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
365 g_free(servconn->host); |
| 5309 | 366 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
367 servconn->host = g_strdup(server); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
368 servconn->port = port; |
| 5309 | 369 } |
| 370 | |
| 371 const char * | |
| 372 msn_servconn_get_server(const MsnServConn *servconn) | |
| 373 { | |
| 374 g_return_val_if_fail(servconn != NULL, NULL); | |
| 375 | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
376 return servconn->host; |
| 5309 | 377 } |
| 378 | |
| 379 int | |
| 380 msn_servconn_get_port(const MsnServConn *servconn) | |
| 381 { | |
| 382 g_return_val_if_fail(servconn != NULL, 0); | |
| 383 | |
| 384 return servconn->port; | |
| 385 } | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
386 #endif |
| 5309 | 387 |
| 388 void | |
| 389 msn_servconn_set_connect_cb(MsnServConn *servconn, | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
390 gboolean (*connect_cb)(MsnServConn *servconn)) |
| 5309 | 391 { |
| 392 g_return_if_fail(servconn != NULL); | |
| 393 | |
| 394 servconn->connect_cb = connect_cb; | |
| 395 } | |
| 396 | |
| 397 void | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
398 msn_servconn_set_disconnect_cb(MsnServConn *servconn, |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
399 void (*disconnect_cb)(MsnServConn |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
400 *servconn)) |
| 5309 | 401 { |
| 402 g_return_if_fail(servconn != NULL); | |
| 403 | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
404 servconn->disconnect_cb = disconnect_cb; |
| 5309 | 405 } |
| 406 | |
| 407 size_t | |
| 408 msn_servconn_write(MsnServConn *servconn, const char *buf, size_t size) | |
| 409 { | |
| 410 g_return_val_if_fail(servconn != NULL, 0); | |
| 411 | |
| 412 gaim_debug(GAIM_DEBUG_MISC, "msn", "C: %s%s", buf, | |
| 413 (*(buf + size - 1) == '\n' ? "" : "\n")); | |
| 414 | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
415 if (servconn->session->http_method) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
416 return msn_http_servconn_write(servconn, buf, size, |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
417 servconn->http_data->server_type); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
418 else |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
419 return write(servconn->fd, buf, size); |
| 5309 | 420 } |
| 421 | |
| 422 gboolean | |
| 423 msn_servconn_send_command(MsnServConn *servconn, const char *command, | |
| 424 const char *params) | |
| 425 { | |
| 426 char buf[MSN_BUF_LEN]; | |
| 427 | |
| 428 g_return_val_if_fail(servconn != NULL, FALSE); | |
| 429 g_return_val_if_fail(command != NULL, FALSE); | |
| 430 | |
| 431 if (params == NULL) | |
| 432 g_snprintf(buf, sizeof(buf), "%s %u\r\n", command, | |
| 433 servconn->session->trId++); | |
| 434 else | |
| 435 g_snprintf(buf, sizeof(buf), "%s %u %s\r\n", | |
| 436 command, servconn->session->trId++, params); | |
| 437 | |
| 438 return (msn_servconn_write(servconn, buf, strlen(buf)) > 0); | |
| 439 } | |
| 440 | |
| 441 void | |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
442 msn_servconn_queue_message(MsnServConn *servconn, const char *command, |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
443 MsnMessage *msg) |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
444 { |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
445 MsnQueueEntry *entry; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
446 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
447 g_return_if_fail(servconn != NULL); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
448 g_return_if_fail(msg != NULL); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
449 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
450 entry = g_new0(MsnQueueEntry, 1); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
451 entry->msg = msg; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
452 entry->command = (command == NULL ? NULL : g_strdup(command)); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
453 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
454 servconn->msg_queue = g_slist_append(servconn->msg_queue, entry); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
455 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
456 msn_message_ref(msg); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
457 } |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
458 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
459 void |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
460 msn_servconn_unqueue_message(MsnServConn *servconn, MsnMessage *msg) |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
461 { |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
462 MsnQueueEntry *entry = NULL; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
463 GSList *l; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
464 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
465 g_return_if_fail(servconn != NULL); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
466 g_return_if_fail(msg != NULL); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
467 |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
468 for (l = servconn->msg_queue; l != NULL; l = l->next) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
469 { |
|
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
470 entry = l->data; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
471 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
472 if (entry->msg == msg) |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
473 break; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
474 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
475 entry = NULL; |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
476 } |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
477 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
478 g_return_if_fail(entry != NULL); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
479 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
480 msn_message_unref(msg); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
481 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
482 servconn->msg_queue = g_slist_remove(servconn->msg_queue, entry); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
483 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
484 if (entry->command != NULL) |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
485 g_free(entry->command); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
486 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
487 g_free(entry); |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
488 } |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
489 |
|
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
490 void |
| 5309 | 491 msn_servconn_register_command(MsnServConn *servconn, const char *command, |
| 492 MsnServConnCommandCb cb) | |
| 493 { | |
| 494 char *command_up; | |
| 495 | |
| 496 g_return_if_fail(servconn != NULL); | |
| 497 g_return_if_fail(command != NULL); | |
| 498 g_return_if_fail(cb != NULL); | |
| 499 | |
| 500 command_up = g_ascii_strup(command, -1); | |
| 501 | |
| 502 g_hash_table_insert(servconn->commands, command_up, cb); | |
| 503 } | |
| 504 | |
| 505 void | |
| 506 msn_servconn_register_msg_type(MsnServConn *servconn, | |
| 507 const char *content_type, | |
| 508 MsnServConnMsgCb cb) | |
| 509 { | |
| 510 g_return_if_fail(servconn != NULL); | |
| 511 g_return_if_fail(content_type != NULL); | |
| 512 g_return_if_fail(cb != NULL); | |
| 513 | |
| 514 g_hash_table_insert(servconn->msg_types, g_strdup(content_type), cb); | |
| 515 } | |
| 516 | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
517 static void |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
518 failed_io(MsnServConn *servconn) |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
519 { |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
520 GaimConnection *gc = |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
521 gaim_account_get_connection(servconn->session->account); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
522 |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
523 gaim_connection_error(gc, _("IO Error.")); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
524 |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
525 msn_servconn_disconnect(servconn); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
526 } |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
527 |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
528 static void |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
529 read_cb(gpointer data, gint source, GaimInputCondition cond) |
| 5309 | 530 { |
| 531 MsnServConn *servconn = (MsnServConn *)data; | |
|
5899
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
532 MsnSession *session = servconn->session; |
| 5309 | 533 char buf[MSN_BUF_LEN]; |
| 534 gboolean cont = TRUE; | |
| 535 int len; | |
| 536 | |
| 537 len = read(servconn->fd, buf, sizeof(buf)); | |
| 538 | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
539 if (len <= 0) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
540 { |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
541 failed_io(servconn); |
| 5309 | 542 |
| 543 return; | |
| 544 } | |
| 545 | |
| 546 servconn->rxqueue = g_realloc(servconn->rxqueue, len + servconn->rxlen); | |
| 547 memcpy(servconn->rxqueue + servconn->rxlen, buf, len); | |
| 548 servconn->rxlen += len; | |
| 549 | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
550 if (session->http_method) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
551 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
552 char *result_msg = NULL; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
553 size_t result_len = 0; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
554 gboolean error; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
555 char *tmp; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
556 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
557 tmp = g_strndup(servconn->rxqueue, servconn->rxlen); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
558 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
559 if (!msn_http_servconn_parse_data(servconn, tmp, |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
560 servconn->rxlen, &result_msg, |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
561 &result_len, &error)) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
562 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
563 g_free(tmp); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
564 return; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
565 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
566 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
567 g_free(tmp); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
568 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
569 if (error) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
570 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
571 gaim_connection_error( |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
572 gaim_account_get_connection(session->account), |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
573 _("Received HTTP error. Please report this.")); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
574 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
575 return; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
576 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
577 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
578 if (servconn->http_data->session_id != NULL && |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
579 !strcmp(servconn->http_data->session_id, "close")) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
580 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
581 msn_servconn_destroy(servconn); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
582 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
583 return; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
584 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
585 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
586 #if 0 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
587 if (strcmp(servconn->http_data->gateway_ip, |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
588 msn_servconn_get_server(servconn)) != 0) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
589 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
590 int i; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
591 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
592 /* Evil hackery. I promise to remove it, even though I can't. */ |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
593 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
594 servconn->connected = FALSE; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
595 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
596 if (servconn->inpa) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
597 gaim_input_remove(servconn->inpa); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
598 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
599 close(servconn->fd); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
600 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
601 i = gaim_proxy_connect(session->account, servconn->host, |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
602 servconn->port, servconn->login_cb, |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
603 servconn); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
604 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
605 if (i == 0) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
606 servconn->connected = TRUE; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
607 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
608 #endif |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
609 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
610 g_free(servconn->rxqueue); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
611 servconn->rxqueue = result_msg; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
612 servconn->rxlen = result_len; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
613 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
614 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
615 while (cont) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
616 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
617 if (servconn->parsing_multiline) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
618 { |
| 5309 | 619 char *msg; |
| 620 | |
| 621 if (servconn->rxlen == 0) | |
| 622 break; | |
| 623 | |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
624 if (servconn->multiline_len > servconn->rxlen) |
| 5309 | 625 break; |
| 626 | |
| 627 msg = servconn->rxqueue; | |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
628 servconn->rxlen -= servconn->multiline_len; |
| 5309 | 629 |
| 630 if (servconn->rxlen) { | |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
631 servconn->rxqueue = g_memdup(msg + servconn->multiline_len, |
| 5309 | 632 servconn->rxlen); |
| 633 } | |
| 634 else { | |
| 635 servconn->rxqueue = NULL; | |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
636 msg = g_realloc(msg, servconn->multiline_len + 1); |
| 5309 | 637 } |
| 638 | |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
639 msg[servconn->multiline_len] = '\0'; |
|
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
640 servconn->parsing_multiline = FALSE; |
| 5309 | 641 |
|
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5785
diff
changeset
|
642 process_multi_line(servconn, msg); |
| 5309 | 643 |
|
5899
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
644 if (g_list_find(session->servconns, servconn) != NULL) { |
|
5962
115769a4c6fc
[gaim-migrate @ 6409]
Christian Hammond <chipx86@chipx86.com>
parents:
5899
diff
changeset
|
645 servconn->multiline_len = 0; |
|
5899
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
646 |
|
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
647 if (servconn->msg_passport != NULL) |
|
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
648 g_free(servconn->msg_passport); |
|
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
649 |
|
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
650 if (servconn->msg_friendly != NULL) |
|
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
651 g_free(servconn->msg_friendly); |
|
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
652 } |
|
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
653 else |
|
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
654 cont = 0; |
|
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
655 |
| 5309 | 656 g_free(msg); |
| 657 } | |
| 658 else { | |
| 659 char *end = servconn->rxqueue; | |
| 660 char *cmd; | |
| 661 int cmdlen, i; | |
| 662 | |
| 663 if (!servconn->rxlen) | |
| 664 return; | |
| 665 | |
| 666 for (i = 0; i < servconn->rxlen - 1; end++, i++) { | |
| 667 if (*end == '\r' && end[1] == '\n') | |
| 668 break; | |
| 669 } | |
| 670 | |
| 671 if (i == servconn->rxlen - 1) | |
| 672 return; | |
| 673 | |
| 674 cmdlen = end - servconn->rxqueue + 2; | |
| 675 cmd = servconn->rxqueue; | |
| 676 servconn->rxlen -= cmdlen; | |
| 677 | |
| 678 if (servconn->rxlen) | |
| 679 servconn->rxqueue = g_memdup(cmd + cmdlen, servconn->rxlen); | |
| 680 else { | |
| 681 servconn->rxqueue = NULL; | |
| 682 cmd = g_realloc(cmd, cmdlen + 1); | |
| 683 } | |
| 684 | |
| 685 cmd[cmdlen] = '\0'; | |
| 686 | |
| 687 gaim_debug(GAIM_DEBUG_MISC, "msn", "S: %s", cmd); | |
| 688 | |
| 689 g_strchomp(cmd); | |
| 690 | |
|
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5785
diff
changeset
|
691 cont = process_single_line(servconn, cmd); |
| 5309 | 692 |
| 693 g_free(cmd); | |
| 694 } | |
| 695 } | |
| 696 } |
