def _make_command(command, attrs, dataform): command_node = Node('command', attrs=attrs) if dataform is not None: command_node.addChild(node=dataform) iq = Iq('set', to=command.jid) iq.addChild(node=command_node) return iq
def _make_search_query(jid, dataform, items_per_page=50, after=None): search = Node('search', attrs={'xmlns': Namespace.MUCLUMBUS}) search.addChild(node=dataform) rsm = search.addChild('set', namespace=Namespace.RSM) rsm.addChild('max').setData(items_per_page) if after is not None: rsm.addChild('after').setData(after) query = Iq(to=jid, typ='get') query.addChild(node=search) return query
def _make_node_configuration(node, form, jid): query = Iq('set', to=jid) pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB_OWNER) configure = pubsub.addChild('configure', {'node': node}) form.setAttr('type', 'submit') configure.addChild(node=form) return query
def _make_retract_request(node, id_, jid, notify): query = Iq('set', to=jid) pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB) attrs = {'node': node} if notify: attrs['notify'] = 'true' retract = pubsub.addChild('retract', attrs=attrs) retract.addChild('item', {'id': id_}) return query
def _make_pubsub_request(node, id_=None, max_items=None, jid=None): query = Iq('get', to=jid) pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB) items = pubsub.addChild('items', {'node': node}) if max_items is not None: items.setAttr('max_items', max_items) if id_ is not None: items.addChild('item', {'id': id_}) return query
def _make_publish_request(node, item, id_, options, jid): query = Iq('set', to=jid) pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB) publish = pubsub.addChild('publish', {'node': node}) attrs = {} if id_ is not None: attrs = {'id': id_} publish.addChild('item', attrs, [item]) if options: publish = pubsub.addChild('publish-options') publish.addChild(node=_make_publish_options(options)) return query
def _make_set_pref_request(default, always, never): iq = Iq(typ='set') prefs = iq.addChild(name='prefs', namespace=Namespace.MAM_2, attrs={'default': default}) always_node = prefs.addChild(name='always') never_node = prefs.addChild(name='never') for jid in always: always_node.addChild(name='jid').setData(jid) for jid in never: never_node.addChild(name='jid').setData(jid) return iq
def _make_delete_request(node, jid): query = Iq('set', to=jid) pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB_OWNER) pubsub.addChild('delete', attrs={'node': node}) return query
def _make_vcard_publish(jid, vcard): iq = Iq(typ='set', to=jid) iq.addChild(node=vcard.to_node()) return iq
def make_captcha_request(room_jid, form_node): iq = Iq(typ='set', to=room_jid) captcha = iq.addChild(name='captcha', namespace=Namespace.CAPTCHA) captcha.addChild(node=form_node) return iq
def get_private_request(): iq = Iq(typ='get') query = iq.addChild(name='query', namespace=Namespace.PRIVATE) query.addChild(name='storage', namespace=Namespace.BOOKMARKS) return iq
def _make_ping_request(jid): iq = Iq('get', to=jid) iq.addChild(name='ping', namespace=Namespace.PING) return iq
def _make_request(jid): iq = Iq('get', to=jid) iq.addChild('time', namespace=Namespace.TIME) return iq
def _make_parameter_request(jid): query = Iq(to=jid, typ='get') query.addChild(node=Node('search', attrs={'xmlns': Namespace.MUCLUMBUS})) return query
def _make_catalog_request(domain, jid): iq = Iq(typ='get', to=domain) iq.addChild(name='catalog', namespace=Namespace.SECLABEL_CATALOG, attrs={'to': jid}) return iq
def _make_node_configuration_request(node, jid): query = Iq('get', to=jid) pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB_OWNER) pubsub.addChild('configure', {'node': node}) return query
def _make_vcard_request(jid): iq = Iq(typ='get', to=jid) iq.addChild('vCard', namespace=Namespace.VCARD) return iq