From 7c8fd955c717cf75c307b97a558dd2ad454a030d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Br=C3=B6tzmann?= Date: Sun, 26 Apr 2020 15:14:38 +0200 Subject: [PATCH] [image] Remove plugin Works only for very small images and if the chat is unencryped. --- image/__init__.py | 1 - image/image.png | Bin 666 -> 0 bytes image/image.py | 153 --------------------------------------------- image/manifest.ini | 11 ---- 4 files changed, 165 deletions(-) delete mode 100644 image/__init__.py delete mode 100644 image/image.png delete mode 100644 image/image.py delete mode 100644 image/manifest.ini diff --git a/image/__init__.py b/image/__init__.py deleted file mode 100644 index e003e38..0000000 --- a/image/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .image import ImagePlugin diff --git a/image/image.png b/image/image.png deleted file mode 100644 index 32dda528843e0e865c721be09f11b0f495f41394..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 666 zcmV;L0%iS)P)9Ff6=w>v<=1g3L9$3w^wT@sIFI$PNlKjdW2@HhOzwzkR2GqP%?vrBI?jWL8bt4UYgzeBVgOM6xwO#&}dWq z`k~5>tGrKV+@9Fg!qPo=+i7pmWufq2Ei2q#ODsI>?tUU0##L^X&MZJA)QW! z$YczpQVh>OwsE#-;>BtmBSuUJgbu17oSIe(09)$6gCEaTbD`F}3U)z>YQX0oWZ_*DEnct25T0OPY0So^e5B+1Fi1xeS< z|81LWUA!Raqd9SJce^N@KAAHQTd3Sys<|6)mPMZT6+;~6PB6-k*9xmaAWnVm?qx)i zhRgANr@fEm&%^0D?>^st;1NRZ$N`>+{BHpU0AFC@t1uRStpET307*qoM6N<$g4-%7 Aw*UYD diff --git a/image/image.py b/image/image.py deleted file mode 100644 index 9b47f24..0000000 --- a/image/image.py +++ /dev/null @@ -1,153 +0,0 @@ -import os -import base64 -import urllib - -from gi.repository import Gtk -from gi.repository import Gdk - -from gajim import chat_control -from gajim.plugins import GajimPlugin -from gajim.plugins.helpers import log_calls -from gajim.plugins.plugins_i18n import _ -from gajim.gtk.dialogs import ErrorDialog -from gajim.gtk.filechoosers import FileChooserDialog - - -NS_XHTML_IM = 'http://jabber.org/protocol/xhtml-im' - - -class ImagePlugin(GajimPlugin): - @log_calls('ImagePlugin') - def init(self): - self.description = _('This plugin is designed to send ' - 'a small(0 - 40 kb) graphic image to your contact.\n' - 'Client on the other side must support XEP-0071: XHTML-IM' - ' and maintain the scheme data: URI.\n' - 'Psi+ and Jabbim supported this.') - self.config_dialog = None # ImagePluginConfigDialog(self) - self.controls = [] - self.gui_extension_points = { - 'chat_control_base': (self.connect_with_chat_control, - self.disconnect_from_chat_control), - 'chat_control_base_update_toolbar': (self.update_button_state, - None)} - self.first_run = True - - @log_calls('ImagePlugin') - def connect_with_chat_control(self, control): - if not isinstance(control, chat_control.ChatControl): - return - self.chat_control = control - base = Base(self, self.chat_control) - self.controls.append(base) - - @log_calls('ImagePlugin') - def disconnect_from_chat_control(self, chat_control): - for control in self.controls: - control.disconnect_from_chat_control() - self.controls = [] - - @log_calls('ImagePlugin') - def update_button_state(self, chat_control): - for base in self.controls: - if base.chat_control == chat_control: - is_support_xhtml = chat_control.contact.supports(NS_XHTML_IM) - base.button.set_sensitive(is_support_xhtml and not \ - chat_control.encryption) - if not is_support_xhtml: - text = _('This contact does not support XHTML_IM') - else: - text = _('Send image (Alt+L)') - base.button.set_tooltip_text(text) - - -class Base(object): - def __init__(self, plugin, chat_control): - self.plugin = plugin - self.chat_control = chat_control - actions_hbox = chat_control.xml.get_object('hbox') - - self.button = Gtk.Button(label=None, stock=None, use_underline=True) - self.button.get_style_context().add_class( - 'chatcontrol-actionbar-button') - self.button.set_property('relief', Gtk.ReliefStyle.NONE) - self.button.set_property('can-focus', False) - img = Gtk.Image() - img.set_from_icon_name('image-x-generic-symbolic.symbolic', - Gtk.IconSize.MENU) - self.button.set_image(img) - self.button.set_tooltip_text('Send image (Alt+L)') - ag = Gtk.accel_groups_from_object(self.chat_control.parent_win.window)[0] - self.button.add_accelerator('activate', ag, Gdk.KEY_L, - Gdk.ModifierType.MOD1_MASK, Gtk.AccelFlags.VISIBLE) - - actions_hbox.pack_start(self.button, False, False , 0) - actions_hbox.reorder_child(self.button, - len(actions_hbox.get_children()) - 2) - id_ = self.button.connect('clicked', self.on_image_button_clicked) - self.button.show() - - def _on_message_textview_key_press_event(self, widget, event): - if event.get_state() & Gdk.ModifierType.MOD1_MASK and \ - event.keyval == Gdk.KEY_l: - if not self.chat_control.contact.supports(NS_XHTML_IM): - from dialogs import WarningDialog - WarningDialog('Warning', - _('This contact does not support XHTML_IM'), - self.chat_control.parent_win.window) - return True - self.on_image_button_clicked(widget) - return True - - def on_image_button_clicked(self, *args): - def on_ok(filename): - image = self._check_file(filename) - if image is None: - return - - self._send(image, filename) - - FileChooserDialog(on_ok, - select_multiple=False, - transient_for=self.chat_control.parent_win.window) - - def _check_file(self, filename): - filesize = os.path.getsize(filename) # in bytes - invalid_file = False - msg = '' - if os.path.isfile(filename): - stat = os.stat(filename) - if stat[6] == 0: - invalid_file = True - msg = _('File is empty') - else: - invalid_file = True - msg = _('File does not exist') - if filesize < 60000: - file_ = open(filename, "rb") - img = urllib.parse.quote(base64.standard_b64encode( - file_.read()), '') - if len(img) > 60000: - invalid_file = True - msg = _('File too big') - file_.close() - else: - invalid_file = True - msg = _('File too big') - if invalid_file: - ErrorDialog(_('Could not load image'), msg) - return - return img - - def _send(self, image, filename): - msg = 'HTML image' - extension = os.path.splitext(os.path.split(filename)[1])[1] \ - .lower()[1:] - xhtml = '
img \ - ' % (extension, image) - self.chat_control.send_message(message=msg, xhtml=xhtml) - self.chat_control.msg_textview.grab_focus() - - def disconnect_from_chat_control(self): - actions_hbox = self.chat_control.xml.get_object('hbox') - actions_hbox.remove(self.button) diff --git a/image/manifest.ini b/image/manifest.ini deleted file mode 100644 index 44646aa..0000000 --- a/image/manifest.ini +++ /dev/null @@ -1,11 +0,0 @@ -[info] -name: Image -short_name: image -version: 1.2.1 -description: This plugin is designed to send a small (0-40 KB) graphic image to your contact. - Client on the other side must support XEP-0071: XHTML-IM and maintain the scheme data: URI. - Psi+ and Jabbim supported this. -authors: Denis Fomin -homepage: https://dev.gajim.org/gajim/gajim-plugins/wikis/ImagePlugin -min_gajim_version: 1.1.91 -max_gajim_version: 1.2.90