#!/usr/bin/env python2 # -*- coding: utf-8 -*- # SAT plugin for managing xep-0249 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org) # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . from sat.core.i18n import _, D_ from sat.core.constants import Const as C from sat.core import exceptions from sat.core.log import getLogger log = getLogger(__name__) from sat.tools import xml_tools from twisted.words.xish import domish from twisted.words.protocols.jabber import jid from zope.interface import implements from wokkel import disco, iwokkel try: from twisted.words.protocols.xmlstream import XMPPHandler except ImportError: from wokkel.subprotocols import XMPPHandler MESSAGE = '/message' NS_DIRECT_MUC_INVITATION = 'jabber:x:conference' DIRECT_MUC_INVITATION_REQUEST = MESSAGE + '/x[@xmlns="' + NS_DIRECT_MUC_INVITATION + '"]' AUTOJOIN_KEY = "Misc" AUTOJOIN_NAME = "Auto-join MUC on invitation" AUTOJOIN_VALUES = ["ask", "always", "never"] PLUGIN_INFO = { C.PI_NAME: "XEP 0249 Plugin", C.PI_IMPORT_NAME: "XEP-0249", C.PI_TYPE: "XEP", C.PI_PROTOCOLS: ["XEP-0249"], C.PI_DEPENDENCIES: ["XEP-0045"], C.PI_RECOMMENDATIONS: [C.TEXT_CMDS], C.PI_MAIN: "XEP_0249", C.PI_HANDLER: "yes", C.PI_DESCRIPTION: _("""Implementation of Direct MUC Invitations""") } class XEP_0249(object): params = """ %(param_options)s """ % { 'category_name': AUTOJOIN_KEY, 'category_label': _("Misc"), 'param_name': AUTOJOIN_NAME, 'param_label': _("Auto-join MUC on invitation"), 'param_options': '\n'.join(['