changeset 156d299a5b75 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=156d299a5b75 description: add advanced option to disable testing of file transfer proxies on startup
diffstat:
src/common/config.py | 1 + src/common/connection.py | 4 +++- src/common/connection_handlers.py | 5 ++++- src/common/proxy65_manager.py | 15 ++++++++++++--- 4 files changed, 20 insertions(+), 5 deletions(-)
diffs (97 lines):
diff -r 7d715bcd769d -r 156d299a5b75 src/common/config.py --- a/src/common/config.py Sun Oct 23 19:52:32 2011 +0200 +++ b/src/common/config.py Sun Oct 23 20:26:28 2011 +0200 @@ -290,6 +290,7 @@ 'use_stun_server': [opt_bool, False, _('If True, Gajim will try to use a STUN server when using jingle. The one in "stun_server" option, or the one given by the jabber server.')], 'stun_server': [opt_str, '', _('STUN server to use when using jingle')], 'show_affiliation_in_groupchat': [opt_bool, True, _('If True, Gajim will show affiliation of groupchat occupants by adding a colored square to the status icon')], + 'test_ft_proxies_on_startup': [opt_bool, True, _('If True, Gajim will test file transfer proxies on startup to be sure it works. Openfire's proxies are known to fail this test even if they work.')], }
__options_per_key = { diff -r 7d715bcd769d -r 156d299a5b75 src/common/connection.py --- a/src/common/connection.py Sun Oct 23 19:52:32 2011 +0200 +++ b/src/common/connection.py Sun Oct 23 20:26:28 2011 +0200 @@ -1707,8 +1707,10 @@ gajim.config.get_per('accounts', self.name, 'use_ft_proxies'): our_fjid = helpers.parse_jid(our_jid + '/' + \ self.server_resource) + testit = gajim.config.get_per('accounts', self.name, + 'test_ft_proxies_on_startup') gajim.proxy65_manager.resolve(obj.fjid, self.connection, - our_fjid, self.name) + our_fjid, default=self.name, testit=testit) if common.xmpp.NS_MUC in obj.features and is_muc: type_ = transport_type or 'jabber' self.muc_jid[type_] = obj.fjid diff -r 7d715bcd769d -r 156d299a5b75 src/common/connection_handlers.py --- a/src/common/connection_handlers.py Sun Oct 23 19:52:32 2011 +0200 +++ b/src/common/connection_handlers.py Sun Oct 23 20:26:28 2011 +0200 @@ -1888,10 +1888,13 @@ 'file_transfer_proxies') our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name) + \ '/' + self.server_resource) + testit = gajim.config.get_per('accounts', self.name, + 'test_ft_proxies_on_startup') if cfg_proxies: proxies = [e.strip() for e in cfg_proxies.split(',')] for proxy in proxies: - gajim.proxy65_manager.resolve(proxy, self.connection, our_jid) + gajim.proxy65_manager.resolve(proxy, self.connection, our_jid, + testit=testit)
def _on_roster_set(self, roster): gajim.nec.push_incoming_event(RosterReceivedEvent(None, conn=self, diff -r 7d715bcd769d -r 156d299a5b75 src/common/proxy65_manager.py --- a/src/common/proxy65_manager.py Sun Oct 23 19:52:32 2011 +0200 +++ b/src/common/proxy65_manager.py Sun Oct 23 20:26:28 2011 +0200 @@ -55,15 +55,17 @@ # dict {account: proxy} default proxy for account self.default_proxies = {}
- def resolve(self, proxy, connection, sender_jid, default=None): + def resolve(self, proxy, connection, sender_jid, default=None, + testit=True): """ Start + if testit=False, Gajim won't try to resolve it """ if proxy in self.proxies: resolver = self.proxies[proxy] else: # proxy is being ressolved for the first time - resolver = ProxyResolver(proxy, sender_jid) + resolver = ProxyResolver(proxy, sender_jid, testit) self.proxies[proxy] = resolver resolver.add_connection(connection) if default: @@ -115,6 +117,9 @@ self.host = str(host) self.port = int(port) self.jid = unicode(jid) + if not self.testit: + self.state = S_FINISHED + return self.state = S_INITIAL log.info('start resolving %s:%s' % (self.host, self.port)) self.receiver_tester = ReceiverTester(self.host, self.port, self.jid, @@ -209,7 +214,10 @@ query.setNamespace(common.xmpp.NS_BYTESTREAM) connection.send(iq)
- def __init__(self, proxy, sender_jid): + def __init__(self, proxy, sender_jid, testit): + """ + if testit is False, don't test it, only get IP/port + """ self.proxy = proxy self.state = S_INITIAL self.active_connection = None @@ -221,6 +229,7 @@ self.port = None self.sid = helpers.get_random_string_16() self.sender_jid = sender_jid + self.testit = testit
class HostTester(Socks5, IdleObject): """