diff --git a/actions/xmpp b/actions/xmpp
index 459fda594..15bac053e 100755
--- a/actions/xmpp
+++ b/actions/xmpp
@@ -53,18 +53,6 @@ def parse_arguments():
# Setup jwchat apache conf
subparsers.add_parser('setup', help='Setup jwchat apache conf')
- # Get whether inband registration is enabled
- subparsers.add_parser('is-inband-enabled',
- help='Get whether inband registration is enabled')
-
- # Enable inband registration
- subparsers.add_parser('enable-inband',
- help='Enable inband registration')
-
- # Disable inband registration
- subparsers.add_parser('disable-inband',
- help='Disable inband registration')
-
# Prepare ejabberd for hostname change
pre_hostname_change = subparsers.add_parser(
'pre-change-hostname',
@@ -88,21 +76,6 @@ def parse_arguments():
help='Update ejabberd and jwchat with new domainname')
domainname_change.add_argument('--domainname', help='New domainname')
- # Get the list of all virtual hosts configured in ejabberd
- subparsers.add_parser(
- 'get-vhosts',
- help='Get the list of all virtual hosts configured in ejabberd')
-
- # Register a new user account
- register = subparsers.add_parser('register',
- help='Register a new user account')
- register.add_argument('--username',
- help='Username for the new user account')
- register.add_argument('--vhost',
- help='Virtual host to register the new user in')
- register.add_argument('--password',
- help='Password for the new user account')
-
return parser.parse_args()
@@ -150,49 +123,6 @@ def subcommand_setup(_):
webserver_change.enable('jwchat-plinth')
-def subcommand_is_inband_enabled(_):
- """Get whether inband registration is enabled"""
- conffile = open(EJABBERD_CONFIG, 'r')
- conf = yaml.safe_load(conffile)
- print('all' in conf['modules']['mod_register']['ip_access'])
-
-
-def subcommand_enable_inband(_):
- """Enable inband registration"""
- with open(EJABBERD_CONFIG, 'r') as conffile:
- lines = conffile.readlines()
-
- with open(EJABBERD_CONFIG, 'w') as conffile:
- for line in lines:
- if 'ip_access' in line:
- conffile.write(line.replace('trusted_network', 'all'))
- else:
- conffile.write(line)
-
- try:
- subprocess.check_output(['ejabberdctl', 'restart'])
- except subprocess.CalledProcessError as err:
- print('Failed to restart ejabberd with new configuration: %s', err)
-
-
-def subcommand_disable_inband(_):
- """Disable inband registration"""
- with open(EJABBERD_CONFIG, 'r') as conffile:
- lines = conffile.readlines()
-
- with open(EJABBERD_CONFIG, 'w') as conffile:
- for line in lines:
- if 'ip_access' in line:
- conffile.write(line.replace('all', 'trusted_network'))
- else:
- conffile.write(line)
-
- try:
- subprocess.check_output(['ejabberdctl', 'restart'])
- except subprocess.CalledProcessError as err:
- print('Failed to restart ejabberd with new configuration: %s', err)
-
-
def subcommand_pre_change_hostname(arguments):
"""Prepare ejabberd for hostname change"""
old_hostname = arguments.old_hostname
@@ -277,25 +207,6 @@ def subcommand_change_domainname(arguments):
action_utils.service_start('ejabberd')
-def subcommand_get_vhosts(_):
- """Get list of all virtual hosts configured in ejabbered."""
- subprocess.call(['ejabberdctl', 'registered_vhosts'])
-
-
-def subcommand_register(arguments):
- """Register a new user account."""
- username = arguments.username
- vhost = arguments.vhost
- password = arguments.password
-
- try:
- output = subprocess.check_output(['ejabberdctl', 'register',
- username, vhost, password])
- print(output.decode())
- except subprocess.CalledProcessError as e:
- print('Failed to register XMPP account:', e.output.decode())
-
-
def main():
"""Parse arguments and perform all duties"""
arguments = parse_arguments()
diff --git a/plinth/modules/xmpp/templates/xmpp_configure.html b/plinth/modules/xmpp/templates/xmpp_configure.html
deleted file mode 100644
index 06230657a..000000000
--- a/plinth/modules/xmpp/templates/xmpp_configure.html
+++ /dev/null
@@ -1,34 +0,0 @@
-{% extends "base.html" %}
-{% comment %}
-#
-# This file is part of Plinth.
-#
-# 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 .
-#
-{% endcomment %}
-
-{% load bootstrap %}
-
-{% block content %}
-
-
-
-{% endblock %}
diff --git a/plinth/modules/xmpp/templates/xmpp_register.html b/plinth/modules/xmpp/templates/xmpp_register.html
deleted file mode 100644
index 7bad2de5e..000000000
--- a/plinth/modules/xmpp/templates/xmpp_register.html
+++ /dev/null
@@ -1,43 +0,0 @@
-{% extends "base.html" %}
-{% comment %}
-#
-# This file is part of Plinth.
-#
-# 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 .
-#
-{% endcomment %}
-
-{% load bootstrap %}
-
-{% block content %}
-
-
-
-{% endblock %}
-
-{% block page_js %}
-
-{% endblock %}
diff --git a/plinth/modules/xmpp/urls.py b/plinth/modules/xmpp/urls.py
index ee7a651dd..b8f0fb608 100644
--- a/plinth/modules/xmpp/urls.py
+++ b/plinth/modules/xmpp/urls.py
@@ -25,6 +25,4 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( # pylint: disable-msg=C0103
'plinth.modules.xmpp.xmpp',
url(r'^apps/xmpp/$', 'index', name='index'),
- url(r'^apps/xmpp/configure/$', 'configure', name='configure'),
- url(r'^apps/xmpp/register/$', 'register', name='register')
)
diff --git a/plinth/modules/xmpp/xmpp.py b/plinth/modules/xmpp/xmpp.py
index f66164103..77bc5d215 100644
--- a/plinth/modules/xmpp/xmpp.py
+++ b/plinth/modules/xmpp/xmpp.py
@@ -17,7 +17,6 @@
from django import forms
from django.contrib import messages
-from django.core.urlresolvers import reverse_lazy
from django.template.response import TemplateResponse
from gettext import gettext as _
import logging
@@ -33,13 +32,6 @@ from plinth.signals import domainname_change
logger = logging.getLogger(__name__)
-subsubmenu = [{'url': reverse_lazy('xmpp:index'),
- 'text': _('About')},
- {'url': reverse_lazy('xmpp:configure'),
- 'text': _('Configure XMPP Server')},
- {'url': reverse_lazy('xmpp:register'),
- 'text': _('Register XMPP Account')}]
-
def init():
"""Initialize the XMPP module"""
@@ -80,129 +72,7 @@ def on_install():
def index(request):
"""Serve XMPP page"""
return TemplateResponse(request, 'xmpp.html',
- {'title': _('XMPP Server'),
- 'subsubmenu': subsubmenu})
-
-
-class ConfigureForm(forms.Form): # pylint: disable-msg=W0232
- """Configuration form"""
- inband_enabled = forms.BooleanField(
- label=_('Allow In-Band Registration'), required=False,
- help_text=_('When enabled, anyone who can reach this server will be \
-allowed to register an account through an XMPP client'))
-
-
-def configure(request):
- """Serve the configuration form"""
- status = get_status()
-
- form = None
-
- if request.method == 'POST':
- form = ConfigureForm(request.POST, prefix='xmpp')
- # pylint: disable-msg=E1101
- if form.is_valid():
- _apply_changes(request, status, form.cleaned_data)
- status = get_status()
- form = ConfigureForm(initial=status, prefix='xmpp')
- else:
- form = ConfigureForm(initial=status, prefix='xmpp')
-
- return TemplateResponse(request, 'xmpp_configure.html',
- {'title': _('Configure XMPP Server'),
- 'form': form,
- 'subsubmenu': subsubmenu})
-
-
-def get_status():
- """Return the current status"""
- output = actions.run('xmpp', ['is-inband-enabled'])
- inband_enabled = 'True' in output.split()
- return {'inband_enabled': inband_enabled}
-
-
-def _apply_changes(request, old_status, new_status):
- """Apply the form changes"""
- logger.info('Status - %s, %s', old_status, new_status)
-
- setting_changed = False
-
- if not old_status['inband_enabled'] and new_status['inband_enabled']:
- setting_changed = True
- output = actions.superuser_run('xmpp', ['enable-inband'])
- if 'Failed' in output:
- messages.error(request,
- _('Error when configuring XMPP server: %s') %
- output)
- else:
- messages.success(request, _('Inband registration enabled'))
- elif old_status['inband_enabled'] and not new_status['inband_enabled']:
- setting_changed = True
- output = actions.superuser_run('xmpp', ['disable-inband'])
- if 'Failed' in output:
- messages.error(request,
- _('Error when configuring XMPP server: %s') %
- output)
- else:
- messages.success(request, _('Inband registration disabled'))
-
- if not setting_changed:
- messages.info(request, _('Setting unchanged'))
-
-
-class RegisterForm(forms.Form): # pylint: disable-msg=W0232
- """Configuration form."""
- username = forms.CharField(label=_('Username'))
- vhost = forms.ChoiceField(
- label=_('Host'), choices=(),
- help_text=_('The new user will be able to login as: username@host'))
- password = forms.CharField(
- label=_('Password'), widget=forms.PasswordInput())
-
- def __init__(self, vhosts, *args, **kwargs):
- """Set the list of possible values for hosts."""
- super(RegisterForm, self).__init__(*args, **kwargs)
-
- self.fields['vhost'].choices = ((vhost, '@' + vhost)
- for vhost in vhosts)
-
-
-def register(request):
- """Serve the registration form."""
- form = None
- vhosts = actions.run('xmpp', ['get-vhosts']).split()
-
- if request.method == 'POST':
- form = RegisterForm(vhosts, request.POST, prefix='xmpp')
- # pylint: disable-msg=E1101
- if form.is_valid():
- _register_user(request, form.cleaned_data)
- form = RegisterForm(vhosts, prefix='xmpp')
- else:
- form = RegisterForm(vhosts, prefix='xmpp')
-
- return TemplateResponse(request, 'xmpp_register.html',
- {'title': _('Register XMPP Account'),
- 'form': form,
- 'subsubmenu': subsubmenu})
-
-
-def _register_user(request, data):
- """Register a new XMPP user"""
- output = actions.superuser_run(
- 'xmpp',
- ['register',
- '--username', data['username'],
- '--vhost', data['vhost'],
- '--password', data['password']])
-
- if 'successfully registered' in output:
- messages.success(request, _('Registered account %s@%s') %
- (data['username'], data['vhost']))
- else:
- messages.error(request,
- _('Failed to register account %s@%s: %s') %
- (data['username'], data['vhost'], output))
+ {'title': _('XMPP Server')})
def on_pre_hostname_change(sender, old_hostname, new_hostname, **kwargs):