2 Slixmpp: The Slick XMPP Library
3 Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout
4 This file is part of Slixmpp.
6 See the file LICENSE for copying permission.
9 from slixmpp
import Message
10 from slixmpp
.xmlstream
import register_stanza_plugin
11 from slixmpp
.xmlstream
.handler
import Callback
12 from slixmpp
.xmlstream
.matcher
import StanzaPath
13 from slixmpp
.plugins
import BasePlugin
14 from slixmpp
.plugins
.xep_0004
import stanza
15 from slixmpp
.plugins
.xep_0004
.stanza
import Form
, FormField
, FieldOption
18 class XEP_0004(BasePlugin
):
25 description
= 'XEP-0004: Data Forms'
26 dependencies
= set(['xep_0030'])
29 def plugin_init(self
):
30 self
.xmpp
.register_handler(
32 StanzaPath('message/form'),
35 register_stanza_plugin(FormField
, FieldOption
, iterable
=True)
36 register_stanza_plugin(Form
, FormField
, iterable
=True)
37 register_stanza_plugin(Message
, Form
)
40 self
.xmpp
.remove_handler('Data Form')
41 self
.xmpp
['xep_0030'].del_feature(feature
='jabber:x:data')
43 def session_bind(self
, jid
):
44 self
.xmpp
['xep_0030'].add_feature('jabber:x:data')
46 def make_form(self
, ftype
='form', title
='', instructions
=''):
50 f
['instructions'] = instructions
53 def handle_form(self
, message
):
54 self
.xmpp
.event("message_xform", message
)
56 def build_form(self
, xml
):