diff --git a/src/common/connection.py b/src/common/connection.py index c901317b4..de86af3e6 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -204,6 +204,7 @@ class Connection: HAS_IDLE = False self.on_connect_success = None self.retrycount = 0 + self.auto_auth = [] # list of jid to auto-authorize # END __init__ def get_full_jid(self, iq_obj): @@ -565,7 +566,8 @@ class Connection: if ptype == 'subscribe': gajim.log.debug('subscribe request from %s' % who) - if gajim.config.get('alwaysauth') or who.find("@") <= 0: + if gajim.config.get('alwaysauth') or who.find("@") <= 0 or \ + jid_stripped in self.auto_auth: if self.connection: p = common.xmpp.Presence(who, 'subscribed') p = self.add_sha(p) @@ -2198,10 +2200,13 @@ class Connection: p = common.xmpp.Presence(jid, 'unsubscribe') self.connection.send(p) - def request_subscription(self, jid, msg, name = '', groups = []): + def request_subscription(self, jid, msg, name = '', groups = [], + auto_auth = False): if not self.connection: return gajim.log.debug('subscription request for %s' % jid) + if auto_auth: + self.auto_auth.append(jid) # RFC 3921 section 8.2 infos = {'jid': jid} if name: diff --git a/src/dialogs.py b/src/dialogs.py index 914080479..b07d98a97 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -416,10 +416,9 @@ _('Please fill in the data of the contact you want to add in account %s') %accou end_iter = message_buffer.get_end_iter() message = message_buffer.get_text(start_iter, end_iter).decode('utf-8') group = self.group_comboboxentry.child.get_text().decode('utf-8') + auto_auth = self.xml.get_widget('auto_authorize_checkbutton').get_active() gajim.interface.roster.req_sub(self, jid, message, self.account, - group = group, pseudo = nickname) - if self.xml.get_widget('auto_authorize_checkbutton').get_active(): - gajim.connections[self.account].send_authorization(jid) + group = group, pseudo = nickname, auto_auth = auto_auth) self.window.destroy() def fill_jid(self): diff --git a/src/roster_window.py b/src/roster_window.py index 047a4e48d..2c6e1e2ec 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1398,13 +1398,15 @@ class RosterWindow: dialogs.InformationDialog(_('Authorization has been sent'), _('Now "%s" will know your status.') %jid) - def req_sub(self, widget, jid, txt, account, group=None, pseudo=None): + def req_sub(self, widget, jid, txt, account, group = None, pseudo = None, + auto_auth = False): '''Request subscription to a contact''' if group: group = [group] else: group = [] - gajim.connections[account].request_subscription(jid, txt, pseudo, group) + gajim.connections[account].request_subscription(jid, txt, pseudo, group, + auto_auth) contact = gajim.contacts.get_contact_with_highest_priority(account, jid) if not contact: keyID = ''