Mercurial > pidgin.yaz
comparison plugins/yay/conn.c @ 2010:dff412b306b8
[gaim-migrate @ 2020]
this is Jeremy Brooks's patch to allow specification of host/port for Yahoo. I redid it slightly to work with some of the existing architecture.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 13 Jun 2001 23:12:20 +0000 |
parents | 6497ee3751cf |
children |
comparison
equal
deleted
inserted
replaced
2009:ac9dd6b00b34 | 2010:dff412b306b8 |
---|---|
126 | 126 |
127 conn = g_new0(struct yahoo_conn, 1); | 127 conn = g_new0(struct yahoo_conn, 1); |
128 conn->type = type; | 128 conn->type = type; |
129 | 129 |
130 if (yahoo_connector) { | 130 if (yahoo_connector) { |
131 const char *realhost = host; | |
132 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "Connecting using user-specified connect routine"); | 131 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "Connecting using user-specified connect routine"); |
133 if (!host) { | 132 if ((*yahoo_connector)(session, host, port, conn) < 0) { |
134 switch (type) { | |
135 case YAHOO_CONN_TYPE_AUTH: | |
136 realhost = YAHOO_AUTH_HOST; | |
137 port = YAHOO_AUTH_PORT; | |
138 break; | |
139 case YAHOO_CONN_TYPE_MAIN: | |
140 realhost = YAHOO_PAGER_HOST; | |
141 port = YAHOO_PAGER_PORT; | |
142 break; | |
143 case YAHOO_CONN_TYPE_DUMB: | |
144 realhost = YAHOO_DATA_HOST; | |
145 port = YAHOO_DATA_PORT; | |
146 break; | |
147 } | |
148 } | |
149 if ((*yahoo_connector)(session, realhost, port, conn) < 0) { | |
150 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "connect failed"); | 133 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "connect failed"); |
151 g_free(conn); | 134 g_free(conn); |
152 return NULL; | 135 return NULL; |
153 } | 136 } |
154 session->connlist = g_list_append(session->connlist, conn); | 137 session->connlist = g_list_append(session->connlist, conn); |
155 return conn; | 138 return conn; |
156 } | 139 } |
157 | 140 |
158 if (host) { | 141 if (session->proxy_type) { |
159 conn->socket = yahoo_connect_host(session, host, port, &status); | |
160 } else if (session->proxy_type) { | |
161 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "connecting to proxy"); | 142 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "connecting to proxy"); |
162 conn->socket = yahoo_connect_host(session, session->proxy_host, | 143 conn->socket = yahoo_connect_host(session, session->proxy_host, |
163 session->proxy_port, &status); | 144 session->proxy_port, &status); |
164 if (type == YAHOO_CONN_TYPE_MAIN) | 145 if (type == YAHOO_CONN_TYPE_MAIN) |
165 conn->type = YAHOO_CONN_TYPE_PROXY; | 146 conn->type = YAHOO_CONN_TYPE_PROXY; |
166 } else { | 147 } else |
167 switch (type) { | 148 conn->socket = yahoo_connect_host(session, host, port, &status); |
168 case YAHOO_CONN_TYPE_AUTH: | |
169 conn->socket = yahoo_connect_host(session, YAHOO_AUTH_HOST, | |
170 YAHOO_AUTH_PORT, &status); | |
171 break; | |
172 case YAHOO_CONN_TYPE_MAIN: | |
173 conn->socket = yahoo_connect_host(session, YAHOO_PAGER_HOST, | |
174 YAHOO_PAGER_PORT, &status); | |
175 break; | |
176 case YAHOO_CONN_TYPE_DUMB: | |
177 conn->socket = yahoo_connect_host(session, YAHOO_DATA_HOST, | |
178 YAHOO_DATA_PORT, &status); | |
179 break; | |
180 } | |
181 } | |
182 | 149 |
183 if (conn->socket < 0) { | 150 if (conn->socket < 0) { |
184 g_free(conn); | 151 g_free(conn); |
185 return NULL; | 152 return NULL; |
186 } | 153 } |
233 int yahoo_connect(struct yahoo_session *session, const char *host, int port) | 200 int yahoo_connect(struct yahoo_session *session, const char *host, int port) |
234 { | 201 { |
235 if (!session) | 202 if (!session) |
236 return 0; | 203 return 0; |
237 | 204 |
238 if (!yahoo_new_conn(session, YAHOO_CONN_TYPE_AUTH, host, port)) | 205 if (session->auth_host) |
206 g_free(session->auth_host); | |
207 if (host && *host) | |
208 session->auth_host = g_strdup(host); | |
209 else | |
210 session->auth_host = g_strdup(YAHOO_AUTH_HOST); | |
211 | |
212 if (port) | |
213 session->auth_port = port; | |
214 else | |
215 session->auth_port = YAHOO_AUTH_PORT; | |
216 | |
217 if (!yahoo_new_conn(session, YAHOO_CONN_TYPE_AUTH, session->auth_host, session->auth_port)) | |
239 return 0; | 218 return 0; |
240 | 219 |
241 return 1; | 220 return 1; |
242 } | 221 } |
243 | 222 |
244 int yahoo_major_connect(struct yahoo_session *session, const char *host, int port) | 223 int yahoo_major_connect(struct yahoo_session *session, const char *host, int port) |
245 { | 224 { |
246 if (!session) | 225 if (!session) |
247 return 0; | 226 return 0; |
248 | 227 |
249 if (!yahoo_new_conn(session, YAHOO_CONN_TYPE_MAIN, host, port)) | 228 if (session->pager_host) |
229 g_free(session->pager_host); | |
230 if (host && *host) | |
231 session->pager_host = g_strdup(host); | |
232 else | |
233 session->pager_host = g_strdup(YAHOO_PAGER_HOST); | |
234 | |
235 if (port) | |
236 session->pager_port = port; | |
237 else | |
238 session->pager_port = YAHOO_AUTH_PORT; | |
239 | |
240 if (!yahoo_new_conn(session, YAHOO_CONN_TYPE_MAIN, session->pager_host, session->pager_port)) | |
250 return 0; | 241 return 0; |
251 | 242 |
252 return 1; | 243 return 1; |
253 } | 244 } |
254 | 245 |
305 g_strfreev(grp->buddies); | 296 g_strfreev(grp->buddies); |
306 g_free(grp->name); | 297 g_free(grp->name); |
307 g_free(grp); | 298 g_free(grp); |
308 session->groups = g_list_remove(session->groups, grp); | 299 session->groups = g_list_remove(session->groups, grp); |
309 } | 300 } |
301 if (session->auth_host) | |
302 g_free(session->auth_host); | |
303 session->auth_host = NULL; | |
304 if (session->pager_host) | |
305 g_free(session->pager_host); | |
306 session->pager_host = NULL; | |
310 return 0; | 307 return 0; |
311 } | 308 } |
312 | 309 |
313 int yahoo_delete(struct yahoo_session *session) | 310 int yahoo_delete(struct yahoo_session *session) |
314 { | 311 { |