From 5401b457d5bacc26128b766745503d787db72dc1 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 30 Nov 2009 21:10:24 +0100 Subject: [PATCH] add stun_server option in pref window. --- data/glade/preferences_window.glade | 72 +++++++++++++++++++++++++++-- src/common/config.py | 1 + src/common/jingle_rtp.py | 12 ++++- src/config.py | 11 ++++- 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/data/glade/preferences_window.glade b/data/glade/preferences_window.glade index d3ea20d10..c9d6a34b1 100644 --- a/data/glade/preferences_window.glade +++ b/data/glade/preferences_window.glade @@ -1962,7 +1962,6 @@ $T will be replaced by auto-not-available timeout 1 2 - @@ -1975,7 +1974,6 @@ $T will be replaced by auto-not-available timeout 2 1 2 - @@ -2066,7 +2064,6 @@ $T will be replaced by auto-not-available timeout 1 2 - @@ -2079,7 +2076,6 @@ $T will be replaced by auto-not-available timeout 2 1 2 - @@ -2102,6 +2098,74 @@ $T will be replaced by auto-not-available timeout 1 + + + True + 0 + none + + + True + 12 + + + True + 3 + 6 + 6 + + + True + 0 + STUN server: + + + GTK_FILL + + + + + True + <i>(example: stunserver.org)</i> + True + + + 2 + 3 + GTK_FILL + + + + + True + True + + + + 1 + 2 + + + + + + + + + True + <b>Connection</b> + True + + + label_item + + + + + False + 2 + + 5 diff --git a/src/common/config.py b/src/common/config.py index 5108e60b1..fb5f0ebfd 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -276,6 +276,7 @@ class Config: 'audio_output_device': [opt_str, 'autoaudiosink'], 'video_input_device': [opt_str, 'autovideosrc ! videoscale ! ffmpegcolorspace'], 'video_output_device': [opt_str, 'autovideosink'], + 'stun_server': [opt_str, '', _('STUN server to use when using jingle')], } __options_per_key = { diff --git a/src/common/jingle_rtp.py b/src/common/jingle_rtp.py index d445d0efb..3750a67d1 100644 --- a/src/common/jingle_rtp.py +++ b/src/common/jingle_rtp.py @@ -70,8 +70,16 @@ class JingleRTPContent(JingleContent): # FIXME: Consider a workaround, here... # pidgin and telepathy-gabble don't follow the XEP, and it won't work # due to bad controlling-mode - params = {'controlling-mode': self.session.weinitiate,# 'debug': False} - 'stun-ip': '69.0.208.27', 'debug': False} + params = {'controlling-mode': self.session.weinitiate, 'debug': False} + stun_server = gajim.config.get('stun-server') + if stun_server: + try: + ip = socket.getaddrinfo(stun_server, 0, socket.AF_UNSPEC, + socket.SOCK_STREAM)[0][4][0] + except socket.gaierror, (errnum, errstr): + log.warn('Lookup of stun ip failed: %s' % errstr) + else: + params['stun-ip'] = ip self.p2pstream = self.p2psession.new_stream(participant, farsight.DIRECTION_RECV, 'nice', params) diff --git a/src/config.py b/src/config.py index 32acea179..df0673d7f 100644 --- a/src/config.py +++ b/src/config.py @@ -421,8 +421,7 @@ class PreferencesWindow: buf = self.xml.get_widget('msg_textview').get_buffer() buf.connect('changed', self.on_msg_textview_changed) - ### Style tab ### - # Audio + ### Audio / Video tab ### def create_av_combobox(opt_name, device_dict): combobox = self.xml.get_widget(opt_name + '_combobox') cell = gtk.CellRendererText() @@ -446,6 +445,11 @@ class PreferencesWindow: 'video_output'): combobox = self.xml.get_widget(opt_name + '_combobox') combobox.set_sensitive(False) + + # Connection + entry = self.xml.get_widget('stun_server_entry') + entry.set_text(gajim.config.get('stun_server')) + ### Advanced tab ### # open links with if os.name == 'nt': @@ -1057,6 +1061,9 @@ class PreferencesWindow: def on_video_output_combobox_changed(self, widget): self.on_av_combobox_changed(widget, 'video_output') + def stun_server_entry_changed(self, widget): + gajim.config.set('stun_server', widget.get_text().decode('utf-8')) + def on_applications_combobox_changed(self, widget): gajim.config.set('autodetect_browser_mailer', False) if widget.get_active() == 4: