Make ownCloud work with service framework

- This allows firewall to manage ports automatically
This commit is contained in:
Sunil Mohan Adapa 2014-04-18 12:54:42 +05:30
parent 32144e96ef
commit f7dd63c0a6

View File

@ -5,6 +5,7 @@ from plugin_mount import PagePlugin, FormPlugin
from forms import Form
import actions
import cfg
import service
from util import Message
class Owncloud(PagePlugin, FormPlugin):
@ -15,13 +16,22 @@ class Owncloud(PagePlugin, FormPlugin):
self.register_page("apps.owncloud")
cfg.html_root.apps.menu.add_item("Owncloud", "icon-picture", "/apps/owncloud", 35)
self.service = service.Service('owncloud', _('ownCloud'),
['http', 'https'],
enabled=self.is_enabled)
def is_enabled(self):
"""Return whether ownCloud is enabled"""
output, error = actions.run('owncloud-setup', 'status')
if error:
raise Exception('Error getting ownCloud status: %s' % error)
return 'enable' in output.split()
@cherrypy.expose
@require()
def index(self, **kwargs):
output, error = actions.run("owncloud-setup", 'status')
if error:
raise Exception("something is wrong: " + error)
owncloud_enable = "enable" in output.split()
owncloud_enable = self.is_enabled()
if 'submitted' in kwargs:
owncloud_enable = self.process_form(kwargs)
@ -64,4 +74,8 @@ class Owncloud(PagePlugin, FormPlugin):
opts.append('no'+key)
actions.superuser_run("owncloud-setup", opts, async=True)
# Send a signal to other modules that the service is
# enabled/disabled
self.service.notify_enabled(self, checkedinfo['enable'])
return checkedinfo['enable']