aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gajim-plugin/httpupload.py23
-rw-r--r--gajim-plugin/manifest.ini5
2 files changed, 25 insertions, 3 deletions
diff --git a/gajim-plugin/httpupload.py b/gajim-plugin/httpupload.py
index e845e3d..b2bb3fc 100644
--- a/gajim-plugin/httpupload.py
+++ b/gajim-plugin/httpupload.py
@@ -64,6 +64,7 @@ except Exception as e:
log.info('Decryption/Encryption disabled due to errors')
encryption_available = False
+NS_HINTS = 'urn:xmpp:hints'
# XEP-0363 (http://xmpp.org/extensions/xep-0363.html)
NS_HTTPUPLOAD = 'urn:xmpp:http:upload'
TAGSIZE = 16
@@ -73,6 +74,7 @@ iq_ids_to_callbacks = {}
last_info_query = {}
max_thumbnail_size = 2048
max_thumbnail_dimension = 160
+httpuploadurls = {}
class HttpuploadPlugin(GajimPlugin):
@@ -88,6 +90,8 @@ class HttpuploadPlugin(GajimPlugin):
self.handle_agent_info_received)
self.events_handlers['raw-iq-received'] = (ged.PRECORE,
self.handle_iq_received)
+ self.events_handlers['stanza-message-outgoing'] = (ged.PRECORE,
+ self.handle_message_stanza_out)
self.gui_extension_points = {
'chat_control_base': (self.connect_with_chat_control,
self.disconnect_from_chat_control),
@@ -117,6 +121,20 @@ class HttpuploadPlugin(GajimPlugin):
self.update_button_state(base.chat_control)
@log_calls('HttpuploadPlugin')
+ def handle_message_stanza_out(self, event):
+ try:
+ global httpuploadurls
+ if not event.msg_iq.getTag('body'):
+ return
+ url = event.msg_iq.getBody()
+ if url in httpuploadurls:
+ # httpupload Hint
+ event.msg_iq.addChild('httpupload', namespace=NS_HINTS)
+ del httpuploadurls[url]
+ except Exception as e:
+ log.error(e)
+
+ @log_calls('HttpuploadPlugin')
def connect_with_chat_control(self, control):
self.chat_control = control
base = Base(self, self.chat_control)
@@ -458,7 +476,10 @@ class Base(object):
keyAndIv = '#' + binascii.hexlify(iv) + binascii.hexlify(key)
self.chat_control.send_message(message=get.getData() + keyAndIv, xhtml=None)
else:
- self.chat_control.send_message(message=get.getData(), xhtml=xhtml)
+ global httpuploadurls
+ url = get.getData()
+ httpuploadurls[url] = True
+ self.chat_control.send_message(message=url, xhtml=xhtml)
self.chat_control.msg_textview.grab_focus()
else:
progress_window.close_dialog()
diff --git a/gajim-plugin/manifest.ini b/gajim-plugin/manifest.ini
index 57f5d37..fa21628 100644
--- a/gajim-plugin/manifest.ini
+++ b/gajim-plugin/manifest.ini
@@ -1,15 +1,16 @@
[info]
name: HttpUpload
short_name: httpupload
-version: 0.4.1
+version: 0.4.1-thedevstack
description: This plugin is designed to send a file to a contact or muc by using httpupload.<br/>
Your server must support <a href="http://xmpp.org/extensions/xep-0363.html">XEP-0363: HTTP Upload</a>.<br/>
Conversations supported this.<br/>
If the receiving side supports <a href="http://xmpp.org/extensions/xep-0071.html">XEP-0071: XHTML-IM</a>
and maintains the scheme data: URI, a thumbnail image is send along the link to the full size image.
If the receiving side doesn't support this, only a text message containing the link to the image is send.
+ This plugin adds additionally to this a hint for processing: <httpupload xmlns="urn:xmpp:hints"/>
authors: Thilo Molitor <thilo@eightysoft.de>
Philipp Hörist <philipp@hoerist.com>
homepage: https://trac-plugins.gajim.org/wiki/HttpUploadPlugin
min_gajim_version: 0.16.5
-max_gajim_version: 0.16.9 \ No newline at end of file
+max_gajim_version: 0.16.9