handle (un)subscription events as messages (don't force to popup a window) Fixes #2243
This commit is contained in:
parent
01bcfe2007
commit
95d7e157da
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
|
@ -32,7 +32,8 @@ class Event:
|
||||||
show_in_systray=True):
|
show_in_systray=True):
|
||||||
''' type_ in chat, normal, file-request, file-error, file-completed,
|
''' type_ in chat, normal, file-request, file-error, file-completed,
|
||||||
file-request-error, file-send-error, file-stopped, gc_msg, pm,
|
file-request-error, file-send-error, file-stopped, gc_msg, pm,
|
||||||
printed_chat, printed_gc_msg, printed_marked_gc_msg, printed_pm
|
printed_chat, printed_gc_msg, printed_marked_gc_msg, printed_pm,
|
||||||
|
gc-invitation, subscription_request, unsubscribed
|
||||||
parameters is (per type_):
|
parameters is (per type_):
|
||||||
chat, normal, pm: [message, subject, kind, time, encrypted, resource,
|
chat, normal, pm: [message, subject, kind, time, encrypted, resource,
|
||||||
msg_id]
|
msg_id]
|
||||||
|
@ -41,7 +42,11 @@ class Event:
|
||||||
gc_msg: None
|
gc_msg: None
|
||||||
printed_chat: control
|
printed_chat: control
|
||||||
printed_*: None
|
printed_*: None
|
||||||
messages that are already printed in chat, but not read'''
|
messages that are already printed in chat, but not read
|
||||||
|
gc-invitation: [room_jid, reason, password, is_continued]
|
||||||
|
subscription_request: [text, nick]
|
||||||
|
unsubscribed: contact
|
||||||
|
'''
|
||||||
self.type_ = type_
|
self.type_ = type_
|
||||||
self.time_ = time_
|
self.time_ = time_
|
||||||
self.parameters = parameters
|
self.parameters = parameters
|
||||||
|
|
|
@ -1644,6 +1644,9 @@ class SubscriptionRequestWindow:
|
||||||
def on_deny_button_clicked(self, widget):
|
def on_deny_button_clicked(self, widget):
|
||||||
'''refuse the request'''
|
'''refuse the request'''
|
||||||
gajim.connections[self.account].refuse_authorization(self.jid)
|
gajim.connections[self.account].refuse_authorization(self.jid)
|
||||||
|
contact = gajim.contacts.get_contact(self.account, self.jid)
|
||||||
|
if contact and _('Not in Roster') in contact.get_shown_groups():
|
||||||
|
gajim.interface.roster.remove_contact(self.jid, self.account)
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
def on_actions_button_clicked(self, widget):
|
def on_actions_button_clicked(self, widget):
|
||||||
|
|
64
src/gajim.py
64
src/gajim.py
|
@ -959,10 +959,26 @@ class Interface:
|
||||||
|
|
||||||
def handle_event_subscribe(self, account, array):
|
def handle_event_subscribe(self, account, array):
|
||||||
#('SUBSCRIBE', account, (jid, text, user_nick)) user_nick is JEP-0172
|
#('SUBSCRIBE', account, (jid, text, user_nick)) user_nick is JEP-0172
|
||||||
dialogs.SubscriptionRequestWindow(array[0], array[1], account, array[2])
|
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('Subscribe', (account, array))
|
self.remote_ctrl.raise_signal('Subscribe', (account, array))
|
||||||
|
|
||||||
|
jid = array[0]
|
||||||
|
text = array[1]
|
||||||
|
nick = array[2]
|
||||||
|
if helpers.allow_popup_window(account) or not self.systray_enabled:
|
||||||
|
dialogs.SubscriptionRequestWindow(jid, text, account, nick)
|
||||||
|
return
|
||||||
|
|
||||||
|
self.add_event(account, jid, 'subscription_request', (text, nick))
|
||||||
|
|
||||||
|
if helpers.allow_showing_notification(account):
|
||||||
|
path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
|
'subscription_request.png')
|
||||||
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(path)
|
||||||
|
event_type = _('Subscription request')
|
||||||
|
notify.popup(event_type, jid, account, 'subscription_request', path,
|
||||||
|
event_type, jid)
|
||||||
|
|
||||||
def handle_event_subscribed(self, account, array):
|
def handle_event_subscribed(self, account, array):
|
||||||
#('SUBSCRIBED', account, (jid, resource))
|
#('SUBSCRIBED', account, (jid, resource))
|
||||||
jid = array[0]
|
jid = array[0]
|
||||||
|
@ -992,7 +1008,20 @@ class Interface:
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('Subscribed', (account, array))
|
self.remote_ctrl.raise_signal('Subscribed', (account, array))
|
||||||
|
|
||||||
|
def show_unsubscribed_dialog(self, account, contact):
|
||||||
|
def on_yes(is_checked, list_):
|
||||||
|
self.roster.on_req_usub(None, list_)
|
||||||
|
list_ = [(contact, account)]
|
||||||
|
dialogs.YesNoDialog(
|
||||||
|
_('Contact "%s" removed subscription from you') % contact.jid,
|
||||||
|
_('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_))
|
||||||
|
# FIXME: Per RFC 3921, we can "deny" ack as well, but the GUI does
|
||||||
|
# not show deny
|
||||||
|
|
||||||
def handle_event_unsubscribed(self, account, jid):
|
def handle_event_unsubscribed(self, account, jid):
|
||||||
|
#('UNSUBSCRIBED', account, jid)
|
||||||
gajim.connections[account].ack_unsubscribed(jid)
|
gajim.connections[account].ack_unsubscribed(jid)
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('Unsubscribed', (account, jid))
|
self.remote_ctrl.raise_signal('Unsubscribed', (account, jid))
|
||||||
|
@ -1000,14 +1029,19 @@ 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(is_checked, list_):
|
|
||||||
self.roster.on_req_usub(None, list_)
|
if helpers.allow_popup_window(account) or not self.systray_enabled:
|
||||||
list_ = [(contact, account)]
|
self.show_unsubscribed_dialog(account, contact)
|
||||||
dialogs.YesNoDialog(
|
|
||||||
_('Contact "%s" removed subscription from you') % jid,
|
self.add_event(account, jid, 'unsubscribed', contact)
|
||||||
_('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_))
|
if helpers.allow_showing_notification(account):
|
||||||
# FIXME: Per RFC 3921, we can "deny" ack as well, but the GUI does not show deny
|
path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
|
'unsubscribed.png')
|
||||||
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(path)
|
||||||
|
event_type = _('Unsubscribed')
|
||||||
|
notify.popup(event_type, jid, account, 'unsubscribed', path,
|
||||||
|
event_type, jid)
|
||||||
|
|
||||||
def handle_event_agent_info_error(self, account, agent):
|
def handle_event_agent_info_error(self, account, agent):
|
||||||
#('AGENT_ERROR_INFO', account, (agent))
|
#('AGENT_ERROR_INFO', account, (agent))
|
||||||
|
@ -2389,6 +2423,18 @@ class Interface:
|
||||||
data[1], data[3])
|
data[1], data[3])
|
||||||
gajim.events.remove_events(account, jid, event)
|
gajim.events.remove_events(account, jid, event)
|
||||||
self.roster.draw_contact(jid, account)
|
self.roster.draw_contact(jid, account)
|
||||||
|
elif type_ == 'subscription_request':
|
||||||
|
event = gajim.events.get_first_event(account, jid, type_)
|
||||||
|
data = event.parameters
|
||||||
|
dialogs.SubscriptionRequestWindow(jid, data[0], account, data[1])
|
||||||
|
gajim.events.remove_events(account, jid, event)
|
||||||
|
self.roster.draw_contact(jid, account)
|
||||||
|
elif type_ == 'unsubscribed':
|
||||||
|
event = gajim.events.get_first_event(account, jid, type_)
|
||||||
|
contact = event.parameters
|
||||||
|
self.show_unsubscribed_dialog(account, contact)
|
||||||
|
gajim.events.remove_events(account, jid, event)
|
||||||
|
self.roster.draw_contact(jid, account)
|
||||||
if w:
|
if w:
|
||||||
w.set_active_tab(ctrl)
|
w.set_active_tab(ctrl)
|
||||||
w.window.window.focus()
|
w.window.window.focus()
|
||||||
|
|
|
@ -492,6 +492,10 @@ class DesktopNotification:
|
||||||
ntype = 'presence.status'
|
ntype = 'presence.status'
|
||||||
elif event_type == _('Connection Failed'):
|
elif event_type == _('Connection Failed'):
|
||||||
ntype = 'connection.failed'
|
ntype = 'connection.failed'
|
||||||
|
elif event_type == _('Subscription request'):
|
||||||
|
ntype = 'subscription.request'
|
||||||
|
elif event_type == _('Unsubscribed'):
|
||||||
|
ntype = 'unsubscribed'
|
||||||
else:
|
else:
|
||||||
# default failsafe values
|
# default failsafe values
|
||||||
self.path_to_image = os.path.abspath(
|
self.path_to_image = os.path.abspath(
|
||||||
|
|
|
@ -1832,6 +1832,14 @@ class RosterWindow:
|
||||||
data[1])
|
data[1])
|
||||||
gajim.events.remove_events(account, jid, event)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
|
elif event.type_ == 'subscription_request':
|
||||||
|
dialogs.SubscriptionRequestWindow(jid, data[0], account, data[1])
|
||||||
|
gajim.events.remove_events(account, jid, event)
|
||||||
|
return True
|
||||||
|
elif event.type_ == 'unsubscribed':
|
||||||
|
gajim.interface.show_unsubscribed_dialog(account, data)
|
||||||
|
gajim.events.remove_events(account, jid, event)
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Reference in New Issue