comparison src/protocols/simple/simple.c @ 11210:5ba038e1b21f

[gaim-migrate @ 13341] Added an option to connect to a different proxy. This is useful in some internal networks where the hostpart of the userid does not equal the hostname of the registrar server to connect to. committer: Tailor Script <tailor@pidgin.im>
author Thomas Butter <tbutter>
date Mon, 08 Aug 2005 18:08:45 +0000
parents 4c1f45ac00e9
children 90be432e8385
comparison
equal deleted inserted replaced
11209:e552095ec599 11210:5ba038e1b21f
1093 GaimConnection *gc; 1093 GaimConnection *gc;
1094 struct simple_account_data *sip; 1094 struct simple_account_data *sip;
1095 gchar **userserver; 1095 gchar **userserver;
1096 int error=0; 1096 int error=0;
1097 struct getserver_return *serveradr; 1097 struct getserver_return *serveradr;
1098 gchar *hosttoconnect;
1098 1099
1099 const char *username = gaim_account_get_username(account); 1100 const char *username = gaim_account_get_username(account);
1100 1101
1101 gc = gaim_account_get_connection(account); 1102 gc = gaim_account_get_connection(account);
1102 1103
1122 1123
1123 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); 1124 gaim_connection_update_progress(gc, _("Connecting"), 1, 2);
1124 1125
1125 sip->status = g_strdup("available"); 1126 sip->status = g_strdup("available");
1126 1127
1128 if(!gaim_account_get_bool(account, "useproxy", FALSE)) {
1129 hosttoconnect = g_strdup(sip->servername);
1130 } else {
1131 hosttoconnect = g_strdup(gaim_account_get_string(account, "proxy", sip->servername));
1132 }
1133
1127 // TCP case 1134 // TCP case
1128 if(! sip->udp) { 1135 if(! sip->udp) {
1129 // search for SRV record 1136 // search for SRV record
1130 serveradr = getserver(sip->servername, "_sip._tcp"); 1137 serveradr = getserver(hosttoconnect, "_sip._tcp");
1131 gaim_debug_info("simple","connecting to %s port %d", serveradr->name, serveradr->port); 1138 gaim_debug_info("simple","connecting to %s port %d", serveradr->name, serveradr->port);
1132 1139
1133 // open tcp connection to the server 1140 // open tcp connection to the server
1134 error = gaim_proxy_connect(account, serveradr->name, serveradr->port, login_cb, gc); 1141 error = gaim_proxy_connect(account, serveradr->name, serveradr->port, login_cb, gc);
1135 if(error) { 1142 if(error) {
1147 } else { // UDP 1154 } else { // UDP
1148 // search for SRV record 1155 // search for SRV record
1149 struct sockaddr_in addr; 1156 struct sockaddr_in addr;
1150 struct hostent *h; 1157 struct hostent *h;
1151 1158
1152 serveradr = getserver(sip->servername, "_sip._udp"); 1159 serveradr = getserver(hosttoconnect, "_sip._udp");
1153 gaim_debug_info("simple", "using udp with server %s and port %d", serveradr->name, serveradr->port); 1160 gaim_debug_info("simple", "using udp with server %s and port %d", serveradr->name, serveradr->port);
1154 sip->fd = socket(AF_INET, SOCK_DGRAM, 0); 1161 sip->fd = socket(AF_INET, SOCK_DGRAM, 0);
1155 1162
1156 addr.sin_family = AF_INET; 1163 addr.sin_family = AF_INET;
1157 addr.sin_port = htons(5060); 1164 addr.sin_port = htons(5060);
1172 sip->ip = g_strdup(gaim_network_get_my_ip(sip->listenfd)); 1179 sip->ip = g_strdup(gaim_network_get_my_ip(sip->listenfd));
1173 sip->resendtimeout = gaim_timeout_add(2500, (GSourceFunc)resend_timeout, sip); 1180 sip->resendtimeout = gaim_timeout_add(2500, (GSourceFunc)resend_timeout, sip);
1174 do_register(sip); 1181 do_register(sip);
1175 1182
1176 } 1183 }
1184 g_free(hosttoconnect);
1177 1185
1178 // register timeout callback for register / subscribe renewal 1186 // register timeout callback for register / subscribe renewal
1179 sip->registertimeout = gaim_timeout_add((rand()%100)+10*1000, (GSourceFunc)register_timeout, sip); 1187 sip->registertimeout = gaim_timeout_add((rand()%100)+10*1000, (GSourceFunc)register_timeout, sip);
1180 } 1188 }
1181 1189
1306 split = gaim_account_user_split_new(_("Server"), "blubb.com", '@'); 1314 split = gaim_account_user_split_new(_("Server"), "blubb.com", '@');
1307 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); 1315 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
1308 1316
1309 option = gaim_account_option_bool_new(_("Use UDP"), "udp", FALSE); 1317 option = gaim_account_option_bool_new(_("Use UDP"), "udp", FALSE);
1310 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); 1318 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
1319 option = gaim_account_option_bool_new(_("Use Proxy"), "useproxy", FALSE);
1320 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
1321 option = gaim_account_option_string_new(_("Proxy"), "proxy", "");
1322 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
1311 // _simple_plugin = plugin; 1323 // _simple_plugin = plugin;
1312 } 1324 }
1313 1325
1314 GAIM_INIT_PLUGIN(simple, _init_plugin, info); 1326 GAIM_INIT_PLUGIN(simple, _init_plugin, info);