From 858e615f1d1dabd1960068296a9f96fb6d9b7ce6 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Sun, 9 Oct 2016 11:48:27 +0200 Subject: Add support for httpuploadim message hint --- gajim-plugin/httpupload.py | 23 ++++++++++++++++++++++- gajim-plugin/manifest.ini | 5 +++-- 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), @@ -116,6 +120,20 @@ class HttpuploadPlugin(GajimPlugin): for base in self.controls: 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 @@ -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.
Your server must support XEP-0363: HTTP Upload.
Conversations supported this.
If the receiving side supports XEP-0071: XHTML-IM 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: authors: Thilo Molitor Philipp Hörist 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 -- cgit v1.2.3