Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jens Korte
gajim-plugins
Commits
9c917844
Commit
9c917844
authored
May 07, 2018
by
Philipp Hörist
Browse files
[preview] Add setting to allow all image urls
Fixes #301
parent
6b98cdbc
Changes
2
Hide whitespace changes
Inline
Side-by-side
url_image_preview/config_dialog.py
View file @
9c917844
...
...
@@ -57,6 +57,10 @@ class UrlImagePreviewConfigDialog(OptionsDialog):
props
=
{
'items'
:
sizes
,
'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'
),
OptionType
.
VALUE
,
self
.
plugin
.
config
[
'LEFTCLICK_ACTION'
],
callback
=
self
.
on_option
,
data
=
'LEFTCLICK_ACTION'
,
...
...
url_image_preview/url_image_preview.py
View file @
9c917844
...
...
@@ -82,6 +82,7 @@ class UrlImagePreviewPlugin(GajimPlugin):
self
.
config_default_values
=
{
'PREVIEW_SIZE'
:
(
150
,
'Preview size(10-512)'
),
'MAX_FILE_SIZE'
:
(
5242880
,
'Max file size for image preview'
),
'ALLOW_ALL_IMAGES'
:
(
False
,
''
),
'LEFTCLICK_ACTION'
:
(
'open_menuitem'
,
'Open'
),
'ANONYMOUS_MUC'
:
(
False
,
''
),
'GEO_PREVIEW_PROVIDER'
:
(
'Google'
,
'Google Maps'
),
...
...
@@ -177,14 +178,11 @@ class Base(object):
except
(
KeyError
,
AttributeError
):
oob_url
=
None
# allow aesgcm uris without oob marker (aesgcm uris are always
# httpupload filetransfers)
if
urlparts
.
scheme
!=
"aesgcm"
and
real_text
!=
oob_url
:
if
urlparts
.
scheme
!=
"geo"
:
log
.
info
(
"Not accepting URL for image preview "
"(wrong or no oob data): %s"
,
real_text
)
log
.
debug
(
"additional_data: %s"
,
additional_data
)
return
if
not
self
.
_accept_uri
(
urlparts
,
real_text
,
oob_url
):
log
.
info
(
"Not accepting URL for image preview "
"(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)
self
.
textview
.
plugin_modified
=
True
...
...
@@ -316,6 +314,17 @@ class Base(object):
repl_end
,
filepaths
,
key
,
iv
,
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
):
size
=
self
.
plugin
.
config
[
'PREVIEW_SIZE'
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment