Changeset - e91e25f449ee
[Not reviewed]
0 2 0
HanzZ - 12 years ago 2013-03-07 12:45:47
hanzz.k@gmail.com
Allow setting libpurple proxy
2 files changed with 34 insertions and 0 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -298,6 +298,39 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
 
				purple_account_set_int_wrapped(account, "port", atoi(s.back().c_str()));  
 
			}
 

	
 
			if (!CONFIG_STRING_DEFAULTED(config, "proxy.type", "").empty()) {
 
				PurpleProxyInfo *info = purple_proxy_info_new();
 
				if (CONFIG_STRING_DEFAULTED(config, "proxy.type", "") == "http") {
 
					purple_proxy_info_set_type(info, PURPLE_PROXY_HTTP);
 
				}
 
				else if (CONFIG_STRING_DEFAULTED(config, "proxy.type", "") == "socks4") {
 
					purple_proxy_info_set_type(info, PURPLE_PROXY_SOCKS4);
 
				}
 
				else if (CONFIG_STRING_DEFAULTED(config, "proxy.type", "") == "socks5") {
 
					purple_proxy_info_set_type(info, PURPLE_PROXY_SOCKS5);
 
				}
 
				else {
 
					LOG4CXX_ERROR(logger, "Unknown proxy.type " << CONFIG_STRING_DEFAULTED(config, "proxy.type", ""));
 
				}
 

	
 
				info->username = NULL;
 
				info->password = NULL;
 

	
 
				purple_proxy_info_set_type(info, PURPLE_PROXY_SOCKS5);
 
				purple_proxy_info_set_host(info, CONFIG_STRING_DEFAULTED(config, "proxy.host", "").c_str());
 
				if (CONFIG_INT_DEFAULTED(config, "proxy.port", 0)) {
 
					purple_proxy_info_set_port(info, CONFIG_INT_DEFAULTED(config, "proxy.port", 0));
 
				}
 
				if (!CONFIG_STRING_DEFAULTED(config, "proxy.username", "").empty()) {
 
					purple_proxy_info_set_username(info, CONFIG_STRING_DEFAULTED(config, "proxy.username", "").c_str());
 
				}
 

	
 
				if (!CONFIG_STRING_DEFAULTED(config, "proxy.password", "").empty()) {
 
					purple_proxy_info_set_password(info, CONFIG_STRING_DEFAULTED(config, "proxy.password", "").c_str());
 
				}
 

	
 
				purple_account_set_proxy_info(account, info);
 
			}
 
		}
 

	
 
		void handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password) {
include/transport/config.h
Show inline comments
 
@@ -52,6 +52,7 @@ const myType &safeAs(const boost::program_options::variable_value &var, const my
 
#define CONFIG_STRING_DEFAULTED(PTR, KEY, DEF) ((*PTR).hasKey(KEY) ? Transport::safeAs<std::string>((*PTR)[KEY], DEF) : DEF)
 
#define CONFIG_BOOL_DEFAULTED(PTR, KEY, DEF) ((*PTR).hasKey(KEY) ? Transport::safeAs<bool>((*PTR)[KEY], DEF) : DEF)
 
#define CONFIG_LIST_DEFAULTED(PTR, KEY, DEF) ((*PTR).hasKey(KEY) ? Transport::safeAs<std::list<std::string> >((*PTR)[KEY], DEF) : DEF)
 
#define CONFIG_INT_DEFAULTED(PTR, KEY, DEF) ((*PTR).hasKey(KEY) ? Transport::safeAs<int>((*PTR)[KEY], DEF) : DEF)
 

	
 
namespace Transport {
 

	
0 comments (0 inline, 0 general)