summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0009
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/plugins/xep_0009')
-rw-r--r--sleekxmpp/plugins/xep_0009/__init__.py11
-rw-r--r--sleekxmpp/plugins/xep_0009/binding.py10
-rw-r--r--sleekxmpp/plugins/xep_0009/rpc.py31
3 files changed, 31 insertions, 21 deletions
diff --git a/sleekxmpp/plugins/xep_0009/__init__.py b/sleekxmpp/plugins/xep_0009/__init__.py
index 2cd14170..0ce3cf2c 100644
--- a/sleekxmpp/plugins/xep_0009/__init__.py
+++ b/sleekxmpp/plugins/xep_0009/__init__.py
@@ -6,6 +6,15 @@
See the file LICENSE for copying permission.
"""
+from sleekxmpp.plugins.base import register_plugin
+
from sleekxmpp.plugins.xep_0009 import stanza
-from sleekxmpp.plugins.xep_0009.rpc import xep_0009
+from sleekxmpp.plugins.xep_0009.rpc import XEP_0009
from sleekxmpp.plugins.xep_0009.stanza import RPCQuery, MethodCall, MethodResponse
+
+
+register_plugin(XEP_0009)
+
+
+# Retain some backwards compatibility
+xep_0009 = XEP_0009
diff --git a/sleekxmpp/plugins/xep_0009/binding.py b/sleekxmpp/plugins/xep_0009/binding.py
index b4395707..a55993ad 100644
--- a/sleekxmpp/plugins/xep_0009/binding.py
+++ b/sleekxmpp/plugins/xep_0009/binding.py
@@ -6,10 +6,14 @@
See the file LICENSE for copying permission.
"""
-from xml.etree import cElementTree as ET
+from sleekxmpp.xmlstream import ET
import base64
import logging
import time
+import sys
+
+if sys.version_info > (3, 0):
+ unicode = str
log = logging.getLogger(__name__)
@@ -54,7 +58,7 @@ def _py2xml(*args):
boolean = ET.Element("{%s}boolean" % _namespace)
boolean.text = str(int(x))
val.append(boolean)
- elif type(x) is str:
+ elif type(x) in (str, unicode):
string = ET.Element("{%s}string" % _namespace)
string.text = x
val.append(string)
@@ -152,7 +156,7 @@ class rpctime(object):
def __init__(self,data=None):
#assume string data is in iso format YYYYMMDDTHH:MM:SS
- if type(data) is str:
+ if type(data) in (str, unicode):
self.timestamp = time.strptime(data,"%Y%m%dT%H:%M:%S")
elif type(data) is time.struct_time:
self.timestamp = data
diff --git a/sleekxmpp/plugins/xep_0009/rpc.py b/sleekxmpp/plugins/xep_0009/rpc.py
index 4f749f30..4e1c538b 100644
--- a/sleekxmpp/plugins/xep_0009/rpc.py
+++ b/sleekxmpp/plugins/xep_0009/rpc.py
@@ -6,28 +6,28 @@
See the file LICENSE for copying permission.
"""
-from sleekxmpp.plugins import base
-from sleekxmpp.plugins.xep_0009.stanza.RPC import RPCQuery, MethodCall, MethodResponse
-from sleekxmpp.stanza.iq import Iq
-from sleekxmpp.xmlstream.handler.callback import Callback
-from sleekxmpp.xmlstream.matcher.xpath import MatchXPath
-from sleekxmpp.xmlstream.stanzabase import register_stanza_plugin
-from xml.etree import cElementTree as ET
import logging
+from sleekxmpp import Iq
+from sleekxmpp.xmlstream import ET, register_stanza_plugin
+from sleekxmpp.xmlstream.handler import Callback
+from sleekxmpp.xmlstream.matcher import MatchXPath
+from sleekxmpp.plugins import BasePlugin
+from sleekxmpp.plugins.xep_0009 import stanza
+from sleekxmpp.plugins.xep_0009.stanza.RPC import RPCQuery, MethodCall, MethodResponse
log = logging.getLogger(__name__)
+class XEP_0009(BasePlugin):
-class xep_0009(base.base_plugin):
+ name = 'xep_0009'
+ description = 'XEP-0009: Jabber-RPC'
+ dependencies = set(['xep_0030'])
+ stanza = stanza
def plugin_init(self):
- self.xep = '0009'
- self.description = 'Jabber-RPC'
- #self.stanza = sleekxmpp.plugins.xep_0009.stanza
-
register_stanza_plugin(Iq, RPCQuery)
register_stanza_plugin(RPCQuery, MethodCall)
register_stanza_plugin(RPCQuery, MethodResponse)
@@ -51,10 +51,8 @@ class xep_0009(base.base_plugin):
self.xmpp.add_event_handler('error', self._handle_error)
#self.activeCalls = []
- def post_init(self):
- base.base_plugin.post_init(self)
- self.xmpp.plugin['xep_0030'].add_feature('jabber:iq:rpc')
- self.xmpp.plugin['xep_0030'].add_identity('automation','rpc')
+ self.xmpp['xep_0030'].add_feature('jabber:iq:rpc')
+ self.xmpp['xep_0030'].add_identity('automation','rpc')
def make_iq_method_call(self, pto, pmethod, params):
iq = self.xmpp.makeIqSet()
@@ -218,4 +216,3 @@ class xep_0009(base.base_plugin):
def _extract_method(self, stanza):
xml = ET.fromstring("%s" % stanza)
return xml.find("./methodCall/methodName").text
-