Skip to content
Snippets Groups Projects
Commit af7ce201 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

SubscriptionRequest: Refactor code

- Rename methods
- Make methods private
- Fix pylint errors
parent c948830e
No related branches found
No related tags found
No related merge requests found
......@@ -91,7 +91,7 @@
<property name="tooltip_text" translatable="yes">Contact Information</property>
<property name="valign">center</property>
<property name="image">image2</property>
<signal name="clicked" handler="on_contact_info_button_clicked" swapped="no"/>
<signal name="clicked" handler="_on_contact_info_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -106,7 +106,7 @@
<property name="tooltip_text" translatable="yes">Start Chat</property>
<property name="valign">center</property>
<property name="image">image1</property>
<signal name="clicked" handler="on_start_chat_button_clicked" swapped="no"/>
<signal name="clicked" handler="_on_start_chat_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -152,7 +152,7 @@
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Deny authorization from contact so the contact cannot know if you are connected</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_deny_button_clicked" swapped="no"/>
<signal name="clicked" handler="_on_deny_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
......@@ -170,7 +170,7 @@
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Authorize contact so the contact can know if you are connected</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_authorize_button_clicked" swapped="no"/>
<signal name="clicked" handler="_on_authorize_clicked" swapped="no"/>
<style>
<class name="suggested-action"/>
</style>
......
......@@ -52,41 +52,45 @@ def __init__(self, account, jid, text, user_nick=None):
self._ui.connect_signals(self)
self.show_all()
def on_authorize_button_clicked(self, widget):
def _on_authorize_clicked(self, _widget):
"""
Accept the request
"""
app.connections[self.account].get_module('Presence').subscribed(self.jid)
con = app.connections[self.account]
con.get_module('Presence').subscribed(self.jid)
self.destroy()
contact = app.contacts.get_contact(self.account, self.jid)
if not contact or _('Not in contact list') in contact.groups:
AddNewContactWindow(self.account, self.jid, self.user_nick)
def on_contact_info_button_clicked(self, widget):
def _on_contact_info_clicked(self, _widget):
"""
Ask for vCard
"""
if self.jid in app.interface.instances[self.account]['infos']:
app.interface.instances[self.account]['infos'][self.jid].window.present()
open_windows = app.interface.instances[self.account]['infos']
if self.jid in open_windows:
open_windows[self.jid].window.present()
else:
contact = app.contacts.create_contact(jid=self.jid, account=self.account)
contact = app.contacts.create_contact(jid=self.jid,
account=self.account)
app.interface.instances[self.account]['infos'][self.jid] = \
vcard.VcardWindow(contact, self.account)
# Remove xmpp page
app.interface.instances[self.account]['infos'][self.jid].xml.\
get_object('information_notebook').remove_page(0)
def on_start_chat_button_clicked(self, widget):
def _on_start_chat_clicked(self, _widget):
"""
Open chat
"""
app.interface.new_chat_from_jid(self.account, self.jid)
def on_deny_button_clicked(self, widget):
def _on_deny_clicked(self, _widget):
"""
Refuse the request
"""
app.connections[self.account].get_module('Presence').unsubscribed(self.jid)
con = app.connections[self.account]
con.get_module('Presence').unsubscribed(self.jid)
contact = app.contacts.get_contact(self.account, self.jid)
if contact and _('Not in contact list') in contact.get_shown_groups():
app.interface.roster.remove_contact(self.jid, self.account)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment