diff options
author | Sangeeth Saravanaraj <sangeeth@riptideio.com> | 2015-01-28 14:52:15 +0530 |
---|---|---|
committer | Sangeeth Saravanaraj <sangeeth@riptideio.com> | 2015-01-28 14:52:15 +0530 |
commit | e1f25604ecbf5d6c196080cd8394191c7ea459c9 (patch) | |
tree | 8c57cf4dad8f1109e7502f029fd8ad573e5ca9d4 /sleekxmpp/plugins/xep_0332/http.py | |
parent | 0fe057b5c3f462275cf8dbf321c2ebec61de1bfe (diff) | |
download | slixmpp-e1f25604ecbf5d6c196080cd8394191c7ea459c9.tar.gz slixmpp-e1f25604ecbf5d6c196080cd8394191c7ea459c9.tar.bz2 slixmpp-e1f25604ecbf5d6c196080cd8394191c7ea459c9.tar.xz slixmpp-e1f25604ecbf5d6c196080cd8394191c7ea459c9.zip |
Added callbacks, registered stanzas, added features, etc.
Diffstat (limited to 'sleekxmpp/plugins/xep_0332/http.py')
-rw-r--r-- | sleekxmpp/plugins/xep_0332/http.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py index 7b9628e3..f91cc1ff 100644 --- a/sleekxmpp/plugins/xep_0332/http.py +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -10,8 +10,20 @@ import logging +from sleekxmpp import Iq + +from sleekxmpp.xmlstream import register_stanza_plugin +from sleekxmpp.xmlstream.handler import Callback +from sleekxmpp.xmlstream.matcher import StanzaPath + from sleekxmpp.plugins.base import BasePlugin +from sleekxmpp.plugins.xep_0332.stanza import NAMESPACE +from sleekxmpp.plugins.xep_0332.stanza.request import Request +from sleekxmpp.plugins.xep_0332.stanza.response import Response + +from sleekxmpp.plugins.xep_0131.stanza import Headers + log = logging.getLogger(__name__) @@ -29,9 +41,37 @@ class XEP_0332(BasePlugin): def plugin_init(self): log.debug("XEP_0332:: plugin_init()") + self.xmpp.register_handler(Callback( + 'HTTP Request', StanzaPath('iq/req'), self._handle_request + )) + self.xmpp.register_handler(Callback( + 'HTTP Response', StanzaPath('iq/resp'), self._handle_response + )) + + register_stanza_plugin(Iq, Request) + register_stanza_plugin(Iq, Response) + register_stanza_plugin(Request, Headers) + register_stanza_plugin(Response, Headers) + def plugin_end(self): log.debug("XEP_0332:: plugin_end()") + self.xmpp.remove_handler('HTTP Request') + self.xmpp.remove_handler('HTTP Response') + self.xmpp['xep_0030'].del_feature(NAMESPACE) def session_bind(self, jid): log.debug("XEP_0332:: session_bind()") + self.xmpp['xep_0030'].add_feature(NAMESPACE) + + def _handle_request(self): + log.debug("XEP_0332:: _handle_request()") + + def _handle_response(self): + log.debug("XEP_0332:: _handle_response()") + + def send_request(self, method=None, resource=None, headers=None, data=None, **kwargs): + log.debug("XEP_0332:: send_request()") + + def send_response(self, status_code=None, headers=None, data=None, **kwargs): + log.debug("XEP_0332:: send_response()") |