add checkbutton to YesNoDialog. Ability to fall back from tls to ssl and then plain. Warn user when using insecure connection. fixes #1923

This commit is contained in:
Yann Leboulanger 2008-02-04 21:38:36 +00:00
parent 8bb9df92d4
commit 848c492926
6 changed files with 377 additions and 313 deletions

View file

@ -176,34 +176,135 @@
<property name="column_spacing">6</property> <property name="column_spacing">6</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
<child> <child>
<widget class="GtkEntry" id="resource_entry1"> <widget class="GtkLabel" id="label2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Jabber ID:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Password:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="password_entry1">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Resource is sent to the Jabber server in order to separate the same JID in two or more parts depending on the number of the clients connected in the same server with the same account. So you might be connected in the same account with resource 'Home' and 'Work' at the same time. The resource which has the highest priority will get the events. (see below)</property> <property name="visibility">False</property>
<property name="invisible_char">*</property> <property name="invisible_char">*</property>
<property name="text" translatable="yes">Gajim</property> <property name="activates_default">True</property>
<signal name="focus_out_event" handler="on_resource_entry1_focus_out_event"/> <signal name="changed" handler="on_password_entry1_changed"/>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">3</property> <property name="right_attach">2</property>
<property name="top_attach">2</property> <property name="top_attach">1</property>
<property name="bottom_attach">3</property> <property name="bottom_attach">2</property>
<property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property> <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkEntry" id="jid_entry1"> <widget class="GtkCheckButton" id="save_password_checkbutton1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="invisible_char">*</property> <property name="tooltip" translatable="yes">If checked, Gajim will remember the password for this account</property>
<property name="activates_default">True</property> <property name="label" translatable="yes">Save pass_word</property>
<signal name="focus_out_event" handler="on_jid_entry1_focus_out_event"/> <property name="use_underline">True</property>
<property name="focus_on_click">False</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_save_password_checkbutton1_toggled"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Resour_ce:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Priori_ty:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="adjust_priority_with_status_checkbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Priority will change automatically according to your status.</property>
<property name="label" translatable="yes">_Adjust to status</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_adjust_priority_with_status_checkbutton1_toggled"/>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="priority_spinbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Priority is used in Jabber to determine who gets the events from the jabber server when two or more clients are connected using the same account; The client with the highest priority gets the events</property>
<property name="adjustment">5 0 127 1 5 5</property>
<property name="climb_rate">1</property>
<property name="numeric">True</property>
<signal name="value_changed" handler="on_priority_spinbutton1_value_changed"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property> <property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -266,138 +367,37 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkSpinButton" id="priority_spinbutton1"> <widget class="GtkEntry" id="jid_entry1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Priority is used in Jabber to determine who gets the events from the jabber server when two or more clients are connected using the same account; The client with the highest priority gets the events</property>
<property name="adjustment">5 0 127 1 5 5</property>
<property name="climb_rate">1</property>
<property name="numeric">True</property>
<signal name="value_changed" handler="on_priority_spinbutton1_value_changed"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="adjust_priority_with_status_checkbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Priority will change automatically according to your status.</property>
<property name="label" translatable="yes">_Adjust to status</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_adjust_priority_with_status_checkbutton1_toggled"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Priori_ty:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Resour_ce:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="save_password_checkbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">If checked, Gajim will remember the password for this account</property>
<property name="label" translatable="yes">Save pass_word</property>
<property name="use_underline">True</property>
<property name="focus_on_click">False</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_save_password_checkbutton1_toggled"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="password_entry1">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="invisible_char">*</property> <property name="invisible_char">*</property>
<property name="activates_default">True</property> <property name="activates_default">True</property>
<signal name="changed" handler="on_password_entry1_changed"/> <signal name="focus_out_event" handler="on_jid_entry1_focus_out_event"/>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">3</property>
<property name="top_attach">1</property> <property name="y_options"></property>
<property name="bottom_attach">2</property> </packing>
</child>
<child>
<widget class="GtkEntry" id="resource_entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Resource is sent to the Jabber server in order to separate the same JID in two or more parts depending on the number of the clients connected in the same server with the same account. So you might be connected in the same account with resource 'Home' and 'Work' at the same time. The resource which has the highest priority will get the events. (see below)</property>
<property name="invisible_char">*</property>
<property name="text" translatable="yes">Gajim</property>
<signal name="focus_out_event" handler="on_resource_entry1_focus_out_event"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property> <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Password:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Jabber ID:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
</widget> </widget>
</child> </child>
<child> <child>
@ -615,15 +615,15 @@
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<widget class="GtkCheckButton" id="use_ssl_checkbutton1"> <widget class="GtkCheckButton" id="warn_when_insecure_connection_checkbutton1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Check this so Gajim will connect in port 5223 where legacy servers are expected to have SSL capabilities. Note that Gajim uses TLS encryption by default if broadcasted by the server, and with this option enabled TLS will be disabled</property> <property name="tooltip" translatable="yes">Check this so Gajim will ask you before sending your password over an insecure connection.</property>
<property name="label" translatable="yes">Use _SSL (legacy)</property> <property name="label" translatable="yes">_Warn before using an insecure connection</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="response_id">0</property> <property name="response_id">0</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<signal name="toggled" handler="on_use_ssl_checkbutton1_toggled"/> <signal name="toggled" handler="on_warn_when_insecure_connection_checkbutton1_toggled"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -1061,125 +1061,6 @@ You might consider to change possible firewall settings.</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">2</property> <property name="column_spacing">2</property>
<property name="row_spacing">5</property> <property name="row_spacing">5</property>
<child>
<widget class="GtkEntry" id="jabber_id_entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_jabber_id_entry2_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="label" translatable="yes">Jabber ID:</property>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">E-Mail:</property>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="email_entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_email_entry2_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="label" translatable="yes">Last Name:</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="last_name_entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_last_name_entry2_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="label" translatable="yes">First Name:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="first_name_entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_first_name_entry2_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Personal Information&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child> <child>
<widget class="GtkVBox" id="vbox10"> <widget class="GtkVBox" id="vbox10">
<property name="visible">True</property> <property name="visible">True</property>
@ -1261,6 +1142,125 @@ You might consider to change possible firewall settings.</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Personal Information&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="first_name_entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_first_name_entry2_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="label" translatable="yes">First Name:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="last_name_entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_last_name_entry2_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="label" translatable="yes">Last Name:</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="email_entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_email_entry2_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">E-Mail:</property>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="label" translatable="yes">Jabber ID:</property>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="jabber_id_entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_jabber_id_entry2_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="position">1</property> <property name="position">1</property>

View file

@ -282,7 +282,8 @@ class Config:
'keyid': [ opt_str, '', '', True ], 'keyid': [ opt_str, '', '', True ],
'gpg_sign_presence': [ opt_bool, True, _('If disabled, don\'t sign presences with GPG key, even if GPG is configured.') ], 'gpg_sign_presence': [ opt_bool, True, _('If disabled, don\'t sign presences with GPG key, even if GPG is configured.') ],
'keyname': [ opt_str, '', '', True ], 'keyname': [ opt_str, '', '', True ],
'usessl': [ opt_bool, False, '', True ], 'connection_types': [ opt_str, 'tls ssl plain', _('Ordered list (space separated) of connection type to try. Can contain tls, ssl or plain')],
'warn_when_insecure_connection': [ opt_bool, True, _('Show a warning dialog before sending password on an insecure connection.') ],
'ssl_fingerprint_sha1': [ opt_str, '', '', True ], 'ssl_fingerprint_sha1': [ opt_str, '', '', True ],
'use_srv': [ opt_bool, True, '', True ], 'use_srv': [ opt_bool, True, '', True ],
'use_custom_host': [ opt_bool, False, '', True ], 'use_custom_host': [ opt_bool, False, '', True ],

View file

@ -466,22 +466,18 @@ class Connection(ConnectionHandlers):
h = hostname h = hostname
p = 5222 p = 5222
# autodetect [for SSL in 5223/443 and for TLS if broadcasted] ssl_p = 5223
secur = None # use_srv = False # wants ssl? disable srv lookup
if usessl:
p = 5223
secur = 1 # 1 means force SSL no matter what the port will be
use_srv = False # wants ssl? disable srv lookup
if use_custom: if use_custom:
h = custom_h h = custom_h
p = custom_p p = custom_p
ssl_p = custom_p
use_srv = False use_srv = False
hosts = []
# SRV resolver # SRV resolver
self._proxy = proxy self._proxy = proxy
self._secure = secur self._hosts = [ {'host': h, 'port': p, 'ssl_port': ssl_p, 'prio': 10,
self._hosts = [ {'host': h, 'port': p, 'prio': 10, 'weight': 10} ] 'weight': 10} ]
self._hostname = hostname self._hostname = hostname
if use_srv: if use_srv:
# add request for srv query to the resolve, on result '_on_resolve' # add request for srv query to the resolve, on result '_on_resolve'
@ -495,6 +491,12 @@ class Connection(ConnectionHandlers):
# SRV query returned at least one valid result, we put it in hosts dict # SRV query returned at least one valid result, we put it in hosts dict
if len(result_array) != 0: if len(result_array) != 0:
self._hosts = [i for i in result_array] self._hosts = [i for i in result_array]
# Add ssl port
ssl_p = 5223
if gajim.config.get_per('accounts', self.name, 'use_custom_host'):
ssl_p = gajim.config.get_per('accounts', self.name, 'custom_port')
for i in self._hosts:
i['ssl_port'] = ssl_p
self.connect_to_next_host() self.connect_to_next_host()
def on_proxy_failure(self, reason): def on_proxy_failure(self, reason):
@ -506,8 +508,9 @@ class Connection(ConnectionHandlers):
self.dispatch('CONNECTION_LOST', self.dispatch('CONNECTION_LOST',
(_('Connection to proxy failed'), reason)) (_('Connection to proxy failed'), reason))
def connect_to_next_host(self, retry = False): def connect_to_next_type(self):
if len(self._hosts): if len(self._connection_types):
self._current_type = self._connection_types.pop(0)
if self.last_connection: if self.last_connection:
self.last_connection.socket.disconnect() self.last_connection.socket.disconnect()
self.last_connection = None self.last_connection = None
@ -516,27 +519,45 @@ class Connection(ConnectionHandlers):
con = common.xmpp.NonBlockingClient(self._hostname, caller = self, con = common.xmpp.NonBlockingClient(self._hostname, caller = self,
on_connect = self.on_connect_success, on_connect = self.on_connect_success,
on_proxy_failure = self.on_proxy_failure, on_proxy_failure = self.on_proxy_failure,
on_connect_failure = self.connect_to_next_host) on_connect_failure = self.connect_to_next_type)
else: else:
con = common.xmpp.NonBlockingClient(self._hostname, debug = [], caller = self, con = common.xmpp.NonBlockingClient(self._hostname, debug = [],
on_connect = self.on_connect_success, caller = self, on_connect = self.on_connect_success,
on_proxy_failure = self.on_proxy_failure, on_proxy_failure = self.on_proxy_failure,
on_connect_failure = self.connect_to_next_host) on_connect_failure = self.connect_to_next_type)
self.last_connection = con self.last_connection = con
# increase default timeout for server responses # increase default timeout for server responses
common.xmpp.dispatcher_nb.DEFAULT_TIMEOUT_SECONDS = self.try_connecting_for_foo_secs common.xmpp.dispatcher_nb.DEFAULT_TIMEOUT_SECONDS = self.try_connecting_for_foo_secs
con.set_idlequeue(gajim.idlequeue) con.set_idlequeue(gajim.idlequeue)
host = self.select_next_host(self._hosts)
self._current_host = host
self._hosts.remove(host)
# FIXME: this is a hack; need a better way # FIXME: this is a hack; need a better way
if self.on_connect_success == self._on_new_account: if self.on_connect_success == self._on_new_account:
con.RegisterDisconnectHandler(self._on_new_account) con.RegisterDisconnectHandler(self._on_new_account)
log.info("Connecting to %s: [%s:%d]", self.name, host['host'], host['port']) if self._current_type == 'ssl':
con.connect((host['host'], host['port']), proxy = self._proxy, port = self._current_host['ssl_port']
secure = self._secure) secur = 1
else:
port = self._current_host['port']
if self._current_type == 'plain':
secur = 0
else:
secur = None
log.info('Connecting to %s: [%s:%d]', self.name,
self._current_host['host'], port)
con.connect((self._current_host['host'], port), proxy=self._proxy,
secure = secur)
else:
self.connect_to_next_host()
def connect_to_next_host(self, retry = False):
if len(self._hosts):
self._connection_types = gajim.config.get_per('accounts', self.name,
'connection_types').split()
host = self.select_next_host(self._hosts)
self._current_host = host
self._hosts.remove(host)
self.connect_to_next_type()
else: else:
if not retry and self.retrycount == 0: if not retry and self.retrycount == 0:
log.debug("Out of hosts, giving up connecting to %s", self.name) log.debug("Out of hosts, giving up connecting to %s", self.name)
@ -565,15 +586,26 @@ class Connection(ConnectionHandlers):
if not self.connected: # We went offline during connecting process if not self.connected: # We went offline during connecting process
# FIXME - not possible, maybe it was when we used threads # FIXME - not possible, maybe it was when we used threads
return return
_con_type = con_type
# xmpp returns 'tcp', but we set 'plain' in connection_types in config
if _con_type == 'tcp':
_con_type = 'plain'
if _con_type != self._current_type:
self.connect_to_next_type()
return
if _con_type == 'plain' and gajim.config.get_per('accounts', self.name,
'warn_when_insecure_connection'):
self.dispatch('PLAIN_CONNECTION', (con,))
return True
return self.connection_accepted(con, con_type)
def connection_accepted(self, con, con_type):
self.hosts = [] self.hosts = []
if not con_type:
log.debug('Could not connect to %s:%s' % (self._current_host['host'],
self._current_host['port']))
self.connected_hostname = self._current_host['host'] self.connected_hostname = self._current_host['host']
self.on_connect_failure = None self.on_connect_failure = None
con.RegisterDisconnectHandler(self._disconnectedReconnCB) con.RegisterDisconnectHandler(self._disconnectedReconnCB)
log.debug(_('Connected to server %s:%s with %s') % (self._current_host['host'], log.debug('Connected to server %s:%s with %s' % (
self._current_host['port'], con_type)) self._current_host['host'], self._current_host['port'], con_type))
name = gajim.config.get_per('accounts', self.name, 'name') name = gajim.config.get_per('accounts', self.name, 'name')
hostname = gajim.config.get_per('accounts', self.name, 'hostname') hostname = gajim.config.get_per('accounts', self.name, 'hostname')
@ -603,11 +635,17 @@ class Connection(ConnectionHandlers):
self._register_handlers(con, con_type) self._register_handlers(con, con_type)
con.auth(name, self.password, self.server_resource, 1, self.__on_auth) con.auth(name, self.password, self.server_resource, 1, self.__on_auth)
def ssl_certificate_accepted(self): def ssl_certificate_accepted(self):
name = gajim.config.get_per('accounts', self.name, 'name') name = gajim.config.get_per('accounts', self.name, 'name')
self._register_handlers(self.connection, 'ssl') self._register_handlers(self.connection, 'ssl')
self.connection.auth(name, self.password, self.server_resource, 1, self.__on_auth) self.connection.auth(name, self.password, self.server_resource, 1,
self.__on_auth)
def plain_connection_accepted(self):
name = gajim.config.get_per('accounts', self.name, 'name')
self._register_handlers(self.connection, 'tcp')
self.connection.auth(name, self.password, self.server_resource, 1,
self.__on_auth)
def _register_handlers(self, con, con_type): def _register_handlers(self, con, con_type):
self.peerhost = con.get_peerhost() self.peerhost = con.get_peerhost()

View file

@ -1657,8 +1657,10 @@ class AccountsWindow:
use_env_http_proxy) use_env_http_proxy)
self.xml.get_widget('proxy_hbox1').set_sensitive(not use_env_http_proxy) self.xml.get_widget('proxy_hbox1').set_sensitive(not use_env_http_proxy)
usessl = gajim.config.get_per('accounts', account, 'usessl') warn_when_insecure = gajim.config.get_per('accounts', account,
self.xml.get_widget('use_ssl_checkbutton1').set_active(usessl) 'warn_when_insecure_connection')
self.xml.get_widget('warn_when_insecure_connection_checkbutton1').\
set_active(warn_when_insecure)
self.xml.get_widget('send_keepalive_checkbutton1').set_active( self.xml.get_widget('send_keepalive_checkbutton1').set_active(
gajim.config.get_per('accounts', account, 'keep_alives_enabled')) gajim.config.get_per('accounts', account, 'keep_alives_enabled'))
@ -2015,20 +2017,11 @@ class AccountsWindow:
else: else:
gajim.interface.instances['manage_proxies'] = ManageProxiesWindow() gajim.interface.instances['manage_proxies'] = ManageProxiesWindow()
def on_use_ssl_checkbutton1_toggled(self, widget): def on_warn_when_insecure_connection_checkbutton1_toggled(self, widget):
if self.ignore_events: if self.ignore_events:
return return
if self.option_changed('usessl', widget.get_active()): self.on_checkbutton_toggled(widget, 'warn_when_insecure_connection',
self.need_relogin = True
isactive = widget.get_active()
if isactive:
self.xml.get_widget('custom_port_entry1').set_text('5223')
else:
self.xml.get_widget('custom_port_entry1').set_text('5222')
self.on_checkbutton_toggled(widget, 'usessl',
account=self.current_account) account=self.current_account)
def on_send_keepalive_checkbutton1_toggled(self, widget): def on_send_keepalive_checkbutton1_toggled(self, widget):

View file

@ -1220,8 +1220,8 @@ class ErrorDialog(HigDialog):
self.popup() self.popup()
class YesNoDialog(HigDialog): class YesNoDialog(HigDialog):
def __init__(self, pritext, sectext='', on_response_yes = None, def __init__(self, pritext, sectext='', checktext='', on_response_yes=None,
on_response_no = None): on_response_no=None):
'''HIG compliant YesNo dialog.''' '''HIG compliant YesNo dialog.'''
self.user_response_yes = on_response_yes self.user_response_yes = on_response_yes
self.user_response_no = on_response_no self.user_response_no = on_response_no
@ -1229,15 +1229,22 @@ class YesNoDialog(HigDialog):
gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, pritext, sectext, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, pritext, sectext,
on_response_yes=self.on_response_yes, on_response_yes=self.on_response_yes,
on_response_no=self.on_response_no) on_response_no=self.on_response_no)
if checktext:
self.checkbutton = gtk.CheckButton(checktext)
self.vbox.pack_start(self.checkbutton, expand=False, fill=True)
else:
self.checkbutton = None
self.set_modal(False) self.set_modal(False)
self.popup() self.popup()
def on_response_yes(self, widget): def on_response_yes(self, widget):
if self.user_response_yes: if self.user_response_yes:
if isinstance(self.user_response_yes, tuple): if isinstance(self.user_response_yes, tuple):
self.user_response_yes[0](*self.user_response_yes[1:]) self.user_response_yes[0](self.is_checked(),
*self.user_response_yes[1:])
else: else:
self.user_response_yes() self.user_response_yes(self.is_checked())
self.destroy() self.destroy()
def on_response_no(self, widget): def on_response_no(self, widget):
@ -1248,6 +1255,11 @@ class YesNoDialog(HigDialog):
self.user_response_no() self.user_response_no()
self.destroy() self.destroy()
def is_checked(self):
''' Get active state of the checkbutton '''
if not self.checkbutton:
return False
return self.checkbutton.get_active()
class ConfirmationDialogCheck(ConfirmationDialog): class ConfirmationDialogCheck(ConfirmationDialog):
'''HIG compliant confirmation dialog with checkbutton.''' '''HIG compliant confirmation dialog with checkbutton.'''

View file

@ -459,6 +459,9 @@ class Interface:
self.dialog.destroy() self.dialog.destroy()
gajim.connections[account].build_http_auth_answer(iq_obj, answer) gajim.connections[account].build_http_auth_answer(iq_obj, answer)
def on_yes(is_checked, account, iq_obj):
response(account, iq_obj, 'yes')
sec_msg = _('Do you accept this request?') sec_msg = _('Do you accept this request?')
if gajim.get_number_of_connected_accounts() > 1: if gajim.get_number_of_connected_accounts() > 1:
sec_msg = _('Do you accept this request on account %s?') % account sec_msg = _('Do you accept this request on account %s?') % account
@ -466,8 +469,8 @@ class Interface:
sec_msg = data[4] + '\n' + sec_msg sec_msg = data[4] + '\n' + sec_msg
self.dialog = dialogs.YesNoDialog(_('HTTP (%s) Authorization for %s (id: %s)') \ self.dialog = dialogs.YesNoDialog(_('HTTP (%s) Authorization for %s (id: %s)') \
% (data[0], data[1], data[2]), sec_msg, % (data[0], data[1], data[2]), sec_msg,
on_response_yes = (response, account, data[3], 'yes'), on_response_yes=(on_yes, account, data[3]),
on_response_no = (response, account, data[3], 'no')) on_response_no=(response, account, data[3], 'no'))
def handle_event_error_answer(self, account, array): def handle_event_error_answer(self, account, array):
#('ERROR_ANSWER', account, (id, jid_from, errmsg, errcode)) #('ERROR_ANSWER', account, (id, jid_from, errmsg, errcode))
@ -961,13 +964,13 @@ class Interface:
contact = gajim.contacts.get_first_contact_from_jid(account, jid) contact = gajim.contacts.get_first_contact_from_jid(account, jid)
if not contact: if not contact:
return return
def on_yes(list_): def on_yes(is_checked, list_):
self.roster.on_req_usub(None, list_) self.roster.on_req_usub(None, list_)
list_ = [(contact, account)] list_ = [(contact, account)]
dialogs.YesNoDialog( dialogs.YesNoDialog(
_('Contact "%s" removed subscription from you') % jid, _('Contact "%s" removed subscription from you') % jid,
_('You will always see him or her as offline.\nDo you want to remove him or her from your contact list?'), _('You will always see him or her as offline.\nDo you want to remove him or her from your contact list?'),
on_response_yes = (on_yes, list_)) on_response_yes=(on_yes, list_))
# FIXME: Per RFC 3921, we can "deny" ack as well, but the GUI does not show deny # FIXME: Per RFC 3921, we can "deny" ack as well, but the GUI does not show deny
def handle_event_agent_info_error(self, account, agent): def handle_event_agent_info_error(self, account, agent):
@ -1948,7 +1951,7 @@ class Interface:
negotiated, not_acceptable, ask_user = session.verify_options_bob(form) negotiated, not_acceptable, ask_user = session.verify_options_bob(form)
if ask_user: if ask_user:
def accept_nondefault_options(): def accept_nondefault_options(is_checked):
self.dialog.destroy() self.dialog.destroy()
negotiated.update(ask_user) negotiated.update(ask_user)
session.respond_e2e_bob(form, negotiated, not_acceptable) session.respond_e2e_bob(form, negotiated, not_acceptable)
@ -1965,8 +1968,8 @@ class Interface:
%s %s
Are these options acceptable?''') % (negotiation.describe_features(ask_user)), Are these options acceptable?''') % (negotiation.describe_features(ask_user)),
on_response_yes = accept_nondefault_options, on_response_yes=accept_nondefault_options,
on_response_no = reject_nondefault_options) on_response_no=reject_nondefault_options)
else: else:
session.respond_e2e_bob(form, negotiated, not_acceptable) session.respond_e2e_bob(form, negotiated, not_acceptable)
@ -1989,7 +1992,7 @@ class Interface:
session.check_identity = _cb session.check_identity = _cb
if ask_user: if ask_user:
def accept_nondefault_options(): def accept_nondefault_options(is_checked):
dialog.destroy() dialog.destroy()
negotiated.update(ask_user) negotiated.update(ask_user)
@ -2248,13 +2251,11 @@ class Interface:
def handle_event_fingerprint_error(self, account, data): def handle_event_fingerprint_error(self, account, data):
# ('FINGERPRINT_ERROR', account, (new_fingerprint,)) # ('FINGERPRINT_ERROR', account, (new_fingerprint,))
def on_yes(): def on_yes(is_checked):
dialog.destroy()
gajim.config.set_per('accounts', account, 'ssl_fingerprint_sha1', gajim.config.set_per('accounts', account, 'ssl_fingerprint_sha1',
data[0]) data[0])
gajim.connections[account].ssl_certificate_accepted() gajim.connections[account].ssl_certificate_accepted()
def on_no(): def on_no():
dialog.destroy()
gajim.connections[account].disconnect(on_purpose=True) gajim.connections[account].disconnect(on_purpose=True)
self.handle_event_status(account, 'offline') self.handle_event_status(account, 'offline')
pritext = _('SSL certificate error') pritext = _('SSL certificate error')
@ -2266,6 +2267,24 @@ class Interface:
dialog = dialogs.YesNoDialog(pritext, sectext, on_response_yes=on_yes, dialog = dialogs.YesNoDialog(pritext, sectext, on_response_yes=on_yes,
on_response_no=on_no) on_response_no=on_no)
def handle_event_plain_connection(self, account, data):
# ('PLAIN_CONNECTION', account, (connection))
server = gajim.config.get_per('accounts', account, 'hostname')
def on_yes(is_checked):
if is_checked:
gajim.config.set_per('accounts', account,
'warn_when_insecure_connection', False)
gajim.connections[account].connection_accepted(data[0], 'tcp')
def on_no():
gajim.connections[account].disconnect(on_purpose=True)
self.handle_event_status(account, 'offline')
pritext = _('Insecure connection')
sectext = _('You are about to send your password on an insecure '
'conection. Are you sure you want to do that?')
checktext = _('Do _not ask me again')
dialog = dialogs.YesNoDialog(pritext, sectext, checktext,
on_response_yes=on_yes, on_response_no=on_no)
def read_sleepy(self): def read_sleepy(self):
'''Check idle status and change that status if needed''' '''Check idle status and change that status if needed'''
if not self.sleeper.poll(): if not self.sleeper.poll():
@ -2606,6 +2625,7 @@ class Interface:
'GPG_PASSWORD_REQUIRED': self.handle_event_gpg_password_required, 'GPG_PASSWORD_REQUIRED': self.handle_event_gpg_password_required,
'SSL_ERROR': self.handle_event_ssl_error, 'SSL_ERROR': self.handle_event_ssl_error,
'FINGERPRINT_ERROR': self.handle_event_fingerprint_error, 'FINGERPRINT_ERROR': self.handle_event_fingerprint_error,
'PLAIN_CONNECTION': self.handle_event_plain_connection,
} }
gajim.handlers = self.handlers gajim.handlers = self.handlers