summaryrefslogtreecommitdiff
path: root/slixmpp/plugins/xep_0009/stanza/RPC.py
blob: f8cec481d031ef188b2a878eb988b7217b79056e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
    Slixmpp: The Slick XMPP Library
    Copyright (C) 2011 Nathanael C. Fritz, Dann Martens (TOMOTON).
    This file is part of Slixmpp.

    See the file LICENSE for copying permission.
"""

from slixmpp.xmlstream.stanzabase import ElementBase
from xml.etree import cElementTree as ET


class RPCQuery(ElementBase):
    name = 'query'
    namespace = 'jabber:iq:rpc'
    plugin_attrib = 'rpc_query'
    interfaces = {}
    subinterfaces = {}
    plugin_attrib_map = {}
    plugin_tag_map = {}


class MethodCall(ElementBase):
    name = 'methodCall'
    namespace = 'jabber:iq:rpc'
    plugin_attrib = 'method_call'
    interfaces = {'method_name', 'params'}
    subinterfaces = {}
    plugin_attrib_map = {}
    plugin_tag_map = {}

    def get_method_name(self):
        return self._get_sub_text('methodName')

    def set_method_name(self, value):
        return self._set_sub_text('methodName', value)

    def get_params(self):
        return self.xml.find('{%s}params' % self.namespace)

    def set_params(self, params):
        self.append(params)


class MethodResponse(ElementBase):
    name = 'methodResponse'
    namespace = 'jabber:iq:rpc'
    plugin_attrib = 'method_response'
    interfaces = {'params', 'fault'}
    subinterfaces = {}
    plugin_attrib_map = {}
    plugin_tag_map = {}

    def get_params(self):
        return self.xml.find('{%s}params' % self.namespace)

    def set_params(self, params):
        self.append(params)

    def get_fault(self):
        return self.xml.find('{%s}fault' % self.namespace)

    def set_fault(self, fault):
        self.append(fault)