comparison src/protocols/gg/gg.c @ 13514:6ad9d666e824

[gaim-migrate @ 15890] * Exposed API to get the setup of a proxy. * Added proxy support to the GG PRPL. committer: Tailor Script <tailor@pidgin.im>
author Bartoz Oler <bartosz@pidgin.im>
date Tue, 14 Mar 2006 23:56:57 +0000
parents b03f19de58b8
children fe065eb51c2e
comparison
equal deleted inserted replaced
13513:43d123a4b4d7 13514:6ad9d666e824
52 /* ---------------------------------------------------------------------- */ 52 /* ---------------------------------------------------------------------- */
53 53
54 54
55 /* ----- HELPERS -------------------------------------------------------- */ 55 /* ----- HELPERS -------------------------------------------------------- */
56 56
57 /**
58 * Set up libgadu's proxy.
59 *
60 * @param account Account for which to set up the proxy.
61 *
62 * @return Zero if proxy setup is valid, otherwise -1.
63 */
64 /* static int ggp_setup_proxy(GaimAccount *account) {{{ */
65 static int ggp_setup_proxy(GaimAccount *account)
66 {
67 GaimProxyInfo *gpi;
68
69 gpi = gaim_proxy_get_setup(account);
70
71 if ((gaim_proxy_info_get_type(gpi) != GAIM_PROXY_NONE) &&
72 (gaim_proxy_info_get_host(gpi) == NULL ||
73 gaim_proxy_info_get_port(gpi) <= 0)) {
74
75 gg_proxy_enabled = 0;
76 gaim_notify_error(NULL, NULL, _("Invalid proxy settings"),
77 _("Either the host name or port number specified for your given proxy type is invalid."));
78 return -1;
79 } else if (gaim_proxy_info_get_type(gpi) != GAIM_PROXY_NONE) {
80 gg_proxy_enabled = 1;
81 gg_proxy_host = g_strdup(gaim_proxy_info_get_host(gpi));
82 gg_proxy_port = gaim_proxy_info_get_port(gpi);
83 gg_proxy_username = g_strdup(gaim_proxy_info_get_username(gpi));
84 gg_proxy_password = g_strdup(gaim_proxy_info_get_password(gpi));
85 } else {
86 gg_proxy_enabled = 0;
87 }
88
89 return 0;
90 }
91 /* }}} */
92
57 /* 93 /*
58 */ 94 */
59 /* static void ggp_async_token_handler(gpointer _gc, gint fd, GaimInputCondition cond) {{{ */ 95 /* static void ggp_async_token_handler(gpointer _gc, gint fd, GaimInputCondition cond) {{{ */
60 static void ggp_async_token_handler(gpointer _gc, gint fd, GaimInputCondition cond) 96 static void ggp_async_token_handler(gpointer _gc, gint fd, GaimInputCondition cond)
61 { 97 {
64 GGPToken *token = info->token; 100 GGPToken *token = info->token;
65 GGPTokenCallback cb; 101 GGPTokenCallback cb;
66 102
67 struct gg_token *t = NULL; 103 struct gg_token *t = NULL;
68 104
69 gaim_debug_info("gg", "token_handler: token->req->fd = %d\n", token->req->fd);
70 gaim_debug_info("gg", "token_handler: token->req: check = %d; state = %d;\n", 105 gaim_debug_info("gg", "token_handler: token->req: check = %d; state = %d;\n",
71 token->req->check, token->req->state); 106 token->req->check, token->req->state);
72 107
73 if (gg_token_watch_fd(token->req) == -1 || token->req->state == GG_STATE_ERROR) { 108 if (gg_token_watch_fd(token->req) == -1 || token->req->state == GG_STATE_ERROR) {
74 gaim_debug_error("gg", "token error (1): %d\n", token->req->error); 109 gaim_debug_error("gg", "token error (1): %d\n", token->req->error);
127 /* 162 /*
128 */ 163 */
129 /* static void ggp_token_request(GaimConnection *gc, GGPTokenCallback cb) {{{ */ 164 /* static void ggp_token_request(GaimConnection *gc, GGPTokenCallback cb) {{{ */
130 static void ggp_token_request(GaimConnection *gc, GGPTokenCallback cb) 165 static void ggp_token_request(GaimConnection *gc, GGPTokenCallback cb)
131 { 166 {
132 GGPInfo *info = gc->proto_data; 167 GaimAccount *account;
133 struct gg_http *req; 168 struct gg_http *req;
169 GGPInfo *info;
170
171 account = gaim_connection_get_account(gc);
172
173 if (ggp_setup_proxy(account) == -1)
174 return;
175
176 info = gc->proto_data;
134 177
135 if ((req = gg_token(1)) == NULL) { 178 if ((req = gg_token(1)) == NULL) {
136 gaim_notify_error(gaim_connection_get_account(gc), 179 gaim_notify_error(account,
137 _("Token Error"), 180 _("Token Error"),
138 _("Unable to fetch the token.\n"), NULL); 181 _("Unable to fetch the token.\n"), NULL);
139 return; 182 return;
140 } 183 }
141 184
1500 /* }}} */ 1543 /* }}} */
1501 1544
1502 /* static void ggp_login(GaimAccount *account) {{{ */ 1545 /* static void ggp_login(GaimAccount *account) {{{ */
1503 static void ggp_login(GaimAccount *account) 1546 static void ggp_login(GaimAccount *account)
1504 { 1547 {
1505 GaimConnection *gc = gaim_account_get_connection(account); 1548 GaimConnection *gc;
1506 struct gg_login_params *glp = g_new0(struct gg_login_params, 1); 1549 struct gg_login_params *glp;
1507 GGPInfo *info = g_new0(GGPInfo, 1); 1550 GGPInfo *info;
1551
1552 if (ggp_setup_proxy(account) == -1)
1553 return;
1554
1555 gc = gaim_account_get_connection(account);
1556 glp = g_new0(struct gg_login_params, 1);
1557 info = g_new0(GGPInfo, 1);
1508 1558
1509 /* Probably this should be moved to *_new() function. */ 1559 /* Probably this should be moved to *_new() function. */
1510 info->session = NULL; 1560 info->session = NULL;
1511 info->searchresults_window = NULL; 1561 info->searchresults_window = NULL;
1512 info->chats = NULL; 1562 info->chats = NULL;