@@ -57,6 +57,10 @@ class UrlImagePreviewConfigDialog(OptionsDialog):
|
|||||||
props={'items': sizes,
|
props={'items': sizes,
|
||||||
'plugin': self.plugin}),
|
'plugin': self.plugin}),
|
||||||
|
|
||||||
|
Option(OptionKind.SWITCH, _('Preview all Image URLs'),
|
||||||
|
OptionType.VALUE, self.plugin.config['ALLOW_ALL_IMAGES'],
|
||||||
|
callback=self.on_option, data='ALLOW_ALL_IMAGES'),
|
||||||
|
|
||||||
Option('PreviewComboOption', _('Left click action'),
|
Option('PreviewComboOption', _('Left click action'),
|
||||||
OptionType.VALUE, self.plugin.config['LEFTCLICK_ACTION'],
|
OptionType.VALUE, self.plugin.config['LEFTCLICK_ACTION'],
|
||||||
callback=self.on_option, data='LEFTCLICK_ACTION',
|
callback=self.on_option, data='LEFTCLICK_ACTION',
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class UrlImagePreviewPlugin(GajimPlugin):
|
|||||||
self.config_default_values = {
|
self.config_default_values = {
|
||||||
'PREVIEW_SIZE': (150, 'Preview size(10-512)'),
|
'PREVIEW_SIZE': (150, 'Preview size(10-512)'),
|
||||||
'MAX_FILE_SIZE': (5242880, 'Max file size for image preview'),
|
'MAX_FILE_SIZE': (5242880, 'Max file size for image preview'),
|
||||||
|
'ALLOW_ALL_IMAGES': (False, ''),
|
||||||
'LEFTCLICK_ACTION': ('open_menuitem', 'Open'),
|
'LEFTCLICK_ACTION': ('open_menuitem', 'Open'),
|
||||||
'ANONYMOUS_MUC': (False, ''),
|
'ANONYMOUS_MUC': (False, ''),
|
||||||
'GEO_PREVIEW_PROVIDER': ('Google', 'Google Maps'),
|
'GEO_PREVIEW_PROVIDER': ('Google', 'Google Maps'),
|
||||||
@@ -177,14 +178,11 @@ class Base(object):
|
|||||||
except (KeyError, AttributeError):
|
except (KeyError, AttributeError):
|
||||||
oob_url = None
|
oob_url = None
|
||||||
|
|
||||||
# allow aesgcm uris without oob marker (aesgcm uris are always
|
if not self._accept_uri(urlparts, real_text, oob_url):
|
||||||
# httpupload filetransfers)
|
log.info("Not accepting URL for image preview "
|
||||||
if urlparts.scheme != "aesgcm" and real_text != oob_url:
|
"(wrong or no oob data): %s", real_text)
|
||||||
if urlparts.scheme != "geo":
|
log.debug("additional_data: %s", additional_data)
|
||||||
log.info("Not accepting URL for image preview "
|
return
|
||||||
"(wrong or no oob data): %s", real_text)
|
|
||||||
log.debug("additional_data: %s", additional_data)
|
|
||||||
return
|
|
||||||
|
|
||||||
# Don't print the URL in the message window (in the calling function)
|
# Don't print the URL in the message window (in the calling function)
|
||||||
self.textview.plugin_modified = True
|
self.textview.plugin_modified = True
|
||||||
@@ -316,6 +314,17 @@ class Base(object):
|
|||||||
repl_end, filepaths, key, iv,
|
repl_end, filepaths, key, iv,
|
||||||
encrypted])
|
encrypted])
|
||||||
|
|
||||||
|
def _accept_uri(self, urlparts, real_text, oob_url):
|
||||||
|
# allow aesgcm uris without oob marker (aesgcm uris are always
|
||||||
|
# httpupload filetransfers)
|
||||||
|
if urlparts.scheme in ('aesgcm', 'geo'):
|
||||||
|
return True
|
||||||
|
|
||||||
|
if real_text != oob_url:
|
||||||
|
if self.plugin.config['ALLOW_ALL_IMAGES']:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def _save_thumbnail(self, thumbpath, mem):
|
def _save_thumbnail(self, thumbpath, mem):
|
||||||
size = self.plugin.config['PREVIEW_SIZE']
|
size = self.plugin.config['PREVIEW_SIZE']
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user