Add new extension point method
This commit is contained in:
parent
1a2d32fca5
commit
55889d045f
|
@ -851,7 +851,7 @@ class ChatControl(ChatControlBase):
|
||||||
'authenticated': False}
|
'authenticated': False}
|
||||||
|
|
||||||
if self.encryption:
|
if self.encryption:
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'encryption_state' + self.encryption, self, encryption_state)
|
'encryption_state' + self.encryption, self, encryption_state)
|
||||||
|
|
||||||
self._show_lock_image(**encryption_state)
|
self._show_lock_image(**encryption_state)
|
||||||
|
@ -877,7 +877,7 @@ class ChatControl(ChatControlBase):
|
||||||
|
|
||||||
def _on_authentication_button_clicked(self, widget):
|
def _on_authentication_button_clicked(self, widget):
|
||||||
if self.encryption:
|
if self.encryption:
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'encryption_dialog' + self.encryption, self)
|
'encryption_dialog' + self.encryption, self)
|
||||||
|
|
||||||
def send_message(self, message, keyID='', chatstate=None, xhtml=None,
|
def send_message(self, message, keyID='', chatstate=None, xhtml=None,
|
||||||
|
@ -888,7 +888,7 @@ class ChatControl(ChatControlBase):
|
||||||
|
|
||||||
if self.encryption:
|
if self.encryption:
|
||||||
self.sendmessage = True
|
self.sendmessage = True
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'send_message' + self.encryption, self)
|
'send_message' + self.encryption, self)
|
||||||
if not self.sendmessage:
|
if not self.sendmessage:
|
||||||
return
|
return
|
||||||
|
@ -1399,7 +1399,7 @@ class ChatControl(ChatControlBase):
|
||||||
def _on_message_tv_buffer_changed(self, textbuffer):
|
def _on_message_tv_buffer_changed(self, textbuffer):
|
||||||
super()._on_message_tv_buffer_changed(textbuffer)
|
super()._on_message_tv_buffer_changed(textbuffer)
|
||||||
if textbuffer.get_char_count() and self.encryption:
|
if textbuffer.get_char_count() and self.encryption:
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'typing' + self.encryption, self)
|
'typing' + self.encryption, self)
|
||||||
if (not self.session or not self.session.status) and \
|
if (not self.session or not self.session.status) and \
|
||||||
gajim.connections[self.account].archiving_136_supported:
|
gajim.connections[self.account].archiving_136_supported:
|
||||||
|
|
|
@ -527,8 +527,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
|
||||||
self)
|
self)
|
||||||
gajim.plugin_manager.remove_gui_extension_point(
|
gajim.plugin_manager.remove_gui_extension_point(
|
||||||
'chat_control_base_draw_banner', self)
|
'chat_control_base_draw_banner', self)
|
||||||
gajim.plugin_manager.remove_gui_extension_point('print_special_text',
|
|
||||||
self)
|
|
||||||
gajim.ged.remove_event_handler('our-show', ged.GUI1,
|
gajim.ged.remove_event_handler('our-show', ged.GUI1,
|
||||||
self._nec_our_status)
|
self._nec_our_status)
|
||||||
|
|
||||||
|
|
|
@ -2039,7 +2039,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
config_key = '%s-%s' % (self.name, obj.jid)
|
config_key = '%s-%s' % (self.name, obj.jid)
|
||||||
encryption = gajim.config.get_per('encryption', config_key, 'encryption')
|
encryption = gajim.config.get_per('encryption', config_key, 'encryption')
|
||||||
if encryption:
|
if encryption:
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'encrypt' + encryption, self, obj, self.send_message)
|
'encrypt' + encryption, self, obj, self.send_message)
|
||||||
else:
|
else:
|
||||||
self.send_message(obj)
|
self.send_message(obj)
|
||||||
|
@ -2646,7 +2646,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
config_key = '%s-%s' % (self.name, obj.jid)
|
config_key = '%s-%s' % (self.name, obj.jid)
|
||||||
encryption = gajim.config.get_per('encryption', config_key, 'encryption')
|
encryption = gajim.config.get_per('encryption', config_key, 'encryption')
|
||||||
if encryption:
|
if encryption:
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'gc_encrypt' + encryption, self, obj, self.send_gc_message)
|
'gc_encrypt' + encryption, self, obj, self.send_gc_message)
|
||||||
else:
|
else:
|
||||||
self.send_gc_message(obj)
|
self.send_gc_message(obj)
|
||||||
|
|
|
@ -1084,7 +1084,7 @@ class ConnectionHandlersBase:
|
||||||
if obj.conn.name != self.name:
|
if obj.conn.name != self.name:
|
||||||
return
|
return
|
||||||
|
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'decrypt', self, obj, self._on_message_received)
|
'decrypt', self, obj, self._on_message_received)
|
||||||
if not obj.encrypted:
|
if not obj.encrypted:
|
||||||
self._on_message_received(obj)
|
self._on_message_received(obj)
|
||||||
|
|
|
@ -822,7 +822,7 @@ class ConversationTextview(GObject.GObject):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
self.plugin_modified = False
|
self.plugin_modified = False
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'hyperlink_handler', word, kind, self,
|
'hyperlink_handler', word, kind, self,
|
||||||
self.tv.get_toplevel())
|
self.tv.get_toplevel())
|
||||||
if self.plugin_modified:
|
if self.plugin_modified:
|
||||||
|
@ -920,7 +920,7 @@ class ConversationTextview(GObject.GObject):
|
||||||
|
|
||||||
# PluginSystem: adding GUI extension point for ConversationTextview
|
# PluginSystem: adding GUI extension point for ConversationTextview
|
||||||
self.plugin_modified = False
|
self.plugin_modified = False
|
||||||
gajim.plugin_manager.gui_extension_point('print_special_text', self,
|
gajim.plugin_manager.extension_point('print_special_text', self,
|
||||||
special_text, other_tags, graphics, additional_data)
|
special_text, other_tags, graphics, additional_data)
|
||||||
if self.plugin_modified:
|
if self.plugin_modified:
|
||||||
return
|
return
|
||||||
|
@ -1397,7 +1397,7 @@ class ConversationTextview(GObject.GObject):
|
||||||
|
|
||||||
# PluginSystem: adding GUI extension point for ConversationTextview
|
# PluginSystem: adding GUI extension point for ConversationTextview
|
||||||
self.plugin_modified = False
|
self.plugin_modified = False
|
||||||
gajim.plugin_manager.gui_extension_point('print_real_text', self,
|
gajim.plugin_manager.extension_point('print_real_text', self,
|
||||||
text, text_tags, graphics, iter_, additional_data)
|
text, text_tags, graphics, iter_, additional_data)
|
||||||
|
|
||||||
if self.plugin_modified:
|
if self.plugin_modified:
|
||||||
|
|
|
@ -776,7 +776,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
'authenticated': False}
|
'authenticated': False}
|
||||||
|
|
||||||
if self.encryption:
|
if self.encryption:
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'encryption_state' + self.encryption, self, encryption_state)
|
'encryption_state' + self.encryption, self, encryption_state)
|
||||||
|
|
||||||
self._show_lock_image(**encryption_state)
|
self._show_lock_image(**encryption_state)
|
||||||
|
@ -802,7 +802,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.lock_image.set_sensitive(visible)
|
self.lock_image.set_sensitive(visible)
|
||||||
|
|
||||||
def _on_authentication_button_clicked(self, widget):
|
def _on_authentication_button_clicked(self, widget):
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'encryption_dialog' + self.encryption, self)
|
'encryption_dialog' + self.encryption, self)
|
||||||
|
|
||||||
def _change_style(self, model, path, iter_, option):
|
def _change_style(self, model, path, iter_, option):
|
||||||
|
@ -2022,7 +2022,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
if self.encryption:
|
if self.encryption:
|
||||||
self.sendmessage = True
|
self.sendmessage = True
|
||||||
gajim.plugin_manager.gui_extension_point(
|
gajim.plugin_manager.extension_point(
|
||||||
'send_message' + self.encryption, self)
|
'send_message' + self.encryption, self)
|
||||||
if not self.sendmessage:
|
if not self.sendmessage:
|
||||||
return
|
return
|
||||||
|
|
|
@ -157,6 +157,26 @@ class PluginManager(metaclass=Singleton):
|
||||||
return plugin
|
return plugin
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@log_calls('PluginManager')
|
||||||
|
def extension_point(self, gui_extpoint_name, *args):
|
||||||
|
'''
|
||||||
|
Invokes all handlers (from plugins) for a particular extension point, but
|
||||||
|
doesnt add it to collection for further processing.
|
||||||
|
For example if you pass a message for encryption via extension point to a
|
||||||
|
plugin, its undesired that the call is stored and replayed on activating the
|
||||||
|
plugin. For example after an update.
|
||||||
|
|
||||||
|
:param gui_extpoint_name: name of GUI extension point.
|
||||||
|
:type gui_extpoint_name: str
|
||||||
|
:param args: parameters to be passed to extension point handlers
|
||||||
|
(typically and object that invokes `gui_extension_point`;
|
||||||
|
however, this can be practically anything)
|
||||||
|
:type args: tuple
|
||||||
|
'''
|
||||||
|
|
||||||
|
self._execute_all_handlers_of_gui_extension_point(gui_extpoint_name,
|
||||||
|
*args)
|
||||||
|
|
||||||
@log_calls('PluginManager')
|
@log_calls('PluginManager')
|
||||||
def gui_extension_point(self, gui_extpoint_name, *args):
|
def gui_extension_point(self, gui_extpoint_name, *args):
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in New Issue