Add support for httpuploadim message hint
This commit is contained in:
parent
6816cd2435
commit
858e615f1d
2 changed files with 25 additions and 3 deletions
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
max_gajim_version: 0.16.9
|
||||
|
|
Loading…
Reference in a new issue