add stun_server option in pref window.
This commit is contained in:
		
							parent
							
								
									b65590bacd
								
							
						
					
					
						commit
						5401b457d5
					
				
					 4 changed files with 88 additions and 8 deletions
				
			
		| 
						 | 
					@ -1962,7 +1962,6 @@ $T will be replaced by auto-not-available timeout</property>
 | 
				
			||||||
                              <packing>
 | 
					                              <packing>
 | 
				
			||||||
                                <property name="left_attach">1</property>
 | 
					                                <property name="left_attach">1</property>
 | 
				
			||||||
                                <property name="right_attach">2</property>
 | 
					                                <property name="right_attach">2</property>
 | 
				
			||||||
                                <property name="x_options"></property>
 | 
					 | 
				
			||||||
                              </packing>
 | 
					                              </packing>
 | 
				
			||||||
                            </child>
 | 
					                            </child>
 | 
				
			||||||
                            <child>
 | 
					                            <child>
 | 
				
			||||||
| 
						 | 
					@ -1975,7 +1974,6 @@ $T will be replaced by auto-not-available timeout</property>
 | 
				
			||||||
                                <property name="right_attach">2</property>
 | 
					                                <property name="right_attach">2</property>
 | 
				
			||||||
                                <property name="top_attach">1</property>
 | 
					                                <property name="top_attach">1</property>
 | 
				
			||||||
                                <property name="bottom_attach">2</property>
 | 
					                                <property name="bottom_attach">2</property>
 | 
				
			||||||
                                <property name="x_options"></property>
 | 
					 | 
				
			||||||
                              </packing>
 | 
					                              </packing>
 | 
				
			||||||
                            </child>
 | 
					                            </child>
 | 
				
			||||||
                            <child>
 | 
					                            <child>
 | 
				
			||||||
| 
						 | 
					@ -2066,7 +2064,6 @@ $T will be replaced by auto-not-available timeout</property>
 | 
				
			||||||
                              <packing>
 | 
					                              <packing>
 | 
				
			||||||
                                <property name="left_attach">1</property>
 | 
					                                <property name="left_attach">1</property>
 | 
				
			||||||
                                <property name="right_attach">2</property>
 | 
					                                <property name="right_attach">2</property>
 | 
				
			||||||
                                <property name="x_options"></property>
 | 
					 | 
				
			||||||
                              </packing>
 | 
					                              </packing>
 | 
				
			||||||
                            </child>
 | 
					                            </child>
 | 
				
			||||||
                            <child>
 | 
					                            <child>
 | 
				
			||||||
| 
						 | 
					@ -2079,7 +2076,6 @@ $T will be replaced by auto-not-available timeout</property>
 | 
				
			||||||
                                <property name="right_attach">2</property>
 | 
					                                <property name="right_attach">2</property>
 | 
				
			||||||
                                <property name="top_attach">1</property>
 | 
					                                <property name="top_attach">1</property>
 | 
				
			||||||
                                <property name="bottom_attach">2</property>
 | 
					                                <property name="bottom_attach">2</property>
 | 
				
			||||||
                                <property name="x_options"></property>
 | 
					 | 
				
			||||||
                              </packing>
 | 
					                              </packing>
 | 
				
			||||||
                            </child>
 | 
					                            </child>
 | 
				
			||||||
                          </widget>
 | 
					                          </widget>
 | 
				
			||||||
| 
						 | 
					@ -2102,6 +2098,74 @@ $T will be replaced by auto-not-available timeout</property>
 | 
				
			||||||
                    <property name="position">1</property>
 | 
					                    <property name="position">1</property>
 | 
				
			||||||
                  </packing>
 | 
					                  </packing>
 | 
				
			||||||
                </child>
 | 
					                </child>
 | 
				
			||||||
 | 
					                <child>
 | 
				
			||||||
 | 
					                  <widget class="GtkFrame" id="frame7">
 | 
				
			||||||
 | 
					                    <property name="visible">True</property>
 | 
				
			||||||
 | 
					                    <property name="label_xalign">0</property>
 | 
				
			||||||
 | 
					                    <property name="shadow_type">none</property>
 | 
				
			||||||
 | 
					                    <child>
 | 
				
			||||||
 | 
					                      <widget class="GtkAlignment" id="alignment9">
 | 
				
			||||||
 | 
					                        <property name="visible">True</property>
 | 
				
			||||||
 | 
					                        <property name="left_padding">12</property>
 | 
				
			||||||
 | 
					                        <child>
 | 
				
			||||||
 | 
					                          <widget class="GtkTable" id="table9">
 | 
				
			||||||
 | 
					                            <property name="visible">True</property>
 | 
				
			||||||
 | 
					                            <property name="n_columns">3</property>
 | 
				
			||||||
 | 
					                            <property name="column_spacing">6</property>
 | 
				
			||||||
 | 
					                            <property name="row_spacing">6</property>
 | 
				
			||||||
 | 
					                            <child>
 | 
				
			||||||
 | 
					                              <widget class="GtkLabel" id="label24">
 | 
				
			||||||
 | 
					                                <property name="visible">True</property>
 | 
				
			||||||
 | 
					                                <property name="xalign">0</property>
 | 
				
			||||||
 | 
					                                <property name="label" translatable="yes">STUN server:</property>
 | 
				
			||||||
 | 
					                              </widget>
 | 
				
			||||||
 | 
					                              <packing>
 | 
				
			||||||
 | 
					                                <property name="x_options">GTK_FILL</property>
 | 
				
			||||||
 | 
					                              </packing>
 | 
				
			||||||
 | 
					                            </child>
 | 
				
			||||||
 | 
					                            <child>
 | 
				
			||||||
 | 
					                              <widget class="GtkLabel" id="label25">
 | 
				
			||||||
 | 
					                                <property name="visible">True</property>
 | 
				
			||||||
 | 
					                                <property name="label" translatable="yes"><i>(example: stunserver.org)</i></property>
 | 
				
			||||||
 | 
					                                <property name="use_markup">True</property>
 | 
				
			||||||
 | 
					                              </widget>
 | 
				
			||||||
 | 
					                              <packing>
 | 
				
			||||||
 | 
					                                <property name="left_attach">2</property>
 | 
				
			||||||
 | 
					                                <property name="right_attach">3</property>
 | 
				
			||||||
 | 
					                                <property name="x_options">GTK_FILL</property>
 | 
				
			||||||
 | 
					                              </packing>
 | 
				
			||||||
 | 
					                            </child>
 | 
				
			||||||
 | 
					                            <child>
 | 
				
			||||||
 | 
					                              <widget class="GtkEntry" id="stun_server_entry">
 | 
				
			||||||
 | 
					                                <property name="visible">True</property>
 | 
				
			||||||
 | 
					                                <property name="can_focus">True</property>
 | 
				
			||||||
 | 
					                                <property name="invisible_char">●</property>
 | 
				
			||||||
 | 
					                              </widget>
 | 
				
			||||||
 | 
					                              <packing>
 | 
				
			||||||
 | 
					                                <property name="left_attach">1</property>
 | 
				
			||||||
 | 
					                                <property name="right_attach">2</property>
 | 
				
			||||||
 | 
					                              </packing>
 | 
				
			||||||
 | 
					                            </child>
 | 
				
			||||||
 | 
					                          </widget>
 | 
				
			||||||
 | 
					                        </child>
 | 
				
			||||||
 | 
					                      </widget>
 | 
				
			||||||
 | 
					                    </child>
 | 
				
			||||||
 | 
					                    <child>
 | 
				
			||||||
 | 
					                      <widget class="GtkLabel" id="label22">
 | 
				
			||||||
 | 
					                        <property name="visible">True</property>
 | 
				
			||||||
 | 
					                        <property name="label" translatable="yes"><b>Connection</b></property>
 | 
				
			||||||
 | 
					                        <property name="use_markup">True</property>
 | 
				
			||||||
 | 
					                      </widget>
 | 
				
			||||||
 | 
					                      <packing>
 | 
				
			||||||
 | 
					                        <property name="type">label_item</property>
 | 
				
			||||||
 | 
					                      </packing>
 | 
				
			||||||
 | 
					                    </child>
 | 
				
			||||||
 | 
					                  </widget>
 | 
				
			||||||
 | 
					                  <packing>
 | 
				
			||||||
 | 
					                    <property name="expand">False</property>
 | 
				
			||||||
 | 
					                    <property name="position">2</property>
 | 
				
			||||||
 | 
					                  </packing>
 | 
				
			||||||
 | 
					                </child>
 | 
				
			||||||
              </widget>
 | 
					              </widget>
 | 
				
			||||||
              <packing>
 | 
					              <packing>
 | 
				
			||||||
                <property name="position">5</property>
 | 
					                <property name="position">5</property>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -276,6 +276,7 @@ class Config:
 | 
				
			||||||
		'audio_output_device': [opt_str, 'autoaudiosink'],
 | 
							'audio_output_device': [opt_str, 'autoaudiosink'],
 | 
				
			||||||
		'video_input_device': [opt_str, 'autovideosrc ! videoscale ! ffmpegcolorspace'],
 | 
							'video_input_device': [opt_str, 'autovideosrc ! videoscale ! ffmpegcolorspace'],
 | 
				
			||||||
		'video_output_device': [opt_str, 'autovideosink'],
 | 
							'video_output_device': [opt_str, 'autovideosink'],
 | 
				
			||||||
 | 
							'stun_server': [opt_str, '', _('STUN server to use when using jingle')],
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__options_per_key = {
 | 
						__options_per_key = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,8 +70,16 @@ class JingleRTPContent(JingleContent):
 | 
				
			||||||
		# FIXME: Consider a workaround, here...
 | 
							# FIXME: Consider a workaround, here...
 | 
				
			||||||
		# pidgin and telepathy-gabble don't follow the XEP, and it won't work
 | 
							# pidgin and telepathy-gabble don't follow the XEP, and it won't work
 | 
				
			||||||
		# due to bad controlling-mode
 | 
							# due to bad controlling-mode
 | 
				
			||||||
		params = {'controlling-mode': self.session.weinitiate,# 'debug': False}
 | 
							params = {'controlling-mode': self.session.weinitiate, 'debug': False}
 | 
				
			||||||
			'stun-ip': '69.0.208.27', '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,
 | 
							self.p2pstream = self.p2psession.new_stream(participant,
 | 
				
			||||||
			farsight.DIRECTION_RECV, 'nice', params)
 | 
								farsight.DIRECTION_RECV, 'nice', params)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -421,8 +421,7 @@ class PreferencesWindow:
 | 
				
			||||||
		buf = self.xml.get_widget('msg_textview').get_buffer()
 | 
							buf = self.xml.get_widget('msg_textview').get_buffer()
 | 
				
			||||||
		buf.connect('changed', self.on_msg_textview_changed)
 | 
							buf.connect('changed', self.on_msg_textview_changed)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		### Style tab ###
 | 
							### Audio / Video tab ###
 | 
				
			||||||
		# Audio
 | 
					 | 
				
			||||||
		def create_av_combobox(opt_name, device_dict):
 | 
							def create_av_combobox(opt_name, device_dict):
 | 
				
			||||||
			combobox = self.xml.get_widget(opt_name + '_combobox')
 | 
								combobox = self.xml.get_widget(opt_name + '_combobox')
 | 
				
			||||||
			cell = gtk.CellRendererText()
 | 
								cell = gtk.CellRendererText()
 | 
				
			||||||
| 
						 | 
					@ -446,6 +445,11 @@ class PreferencesWindow:
 | 
				
			||||||
			'video_output'):
 | 
								'video_output'):
 | 
				
			||||||
				combobox = self.xml.get_widget(opt_name + '_combobox')
 | 
									combobox = self.xml.get_widget(opt_name + '_combobox')
 | 
				
			||||||
				combobox.set_sensitive(False)
 | 
									combobox.set_sensitive(False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							# Connection
 | 
				
			||||||
 | 
							entry = self.xml.get_widget('stun_server_entry')
 | 
				
			||||||
 | 
							entry.set_text(gajim.config.get('stun_server'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		### Advanced tab ###
 | 
							### Advanced tab ###
 | 
				
			||||||
		# open links with
 | 
							# open links with
 | 
				
			||||||
		if os.name == 'nt':
 | 
							if os.name == 'nt':
 | 
				
			||||||
| 
						 | 
					@ -1057,6 +1061,9 @@ class PreferencesWindow:
 | 
				
			||||||
	def on_video_output_combobox_changed(self, widget):
 | 
						def on_video_output_combobox_changed(self, widget):
 | 
				
			||||||
		self.on_av_combobox_changed(widget, 'video_output')
 | 
							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):
 | 
						def on_applications_combobox_changed(self, widget):
 | 
				
			||||||
		gajim.config.set('autodetect_browser_mailer', False)
 | 
							gajim.config.set('autodetect_browser_mailer', False)
 | 
				
			||||||
		if widget.get_active() == 4:
 | 
							if widget.get_active() == 4:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue