component file sharing: don't initialise the plugin if not component use it
This commit is contained in:
parent
7000fcda34
commit
ca655f01a8
1 changed files with 26 additions and 15 deletions
|
|
@ -293,24 +293,34 @@ class FileSharingSite(server.Site):
|
||||||
class FileSharing:
|
class FileSharing:
|
||||||
|
|
||||||
def __init__(self, host):
|
def __init__(self, host):
|
||||||
log.info(_("File Sharing initialization"))
|
|
||||||
self.host = host
|
self.host = host
|
||||||
self._f = host.plugins["FILE"]
|
self.initialised = False
|
||||||
self._jf = host.plugins["XEP-0234"]
|
|
||||||
self._h = host.plugins["XEP-0300"]
|
def init(self):
|
||||||
self._t = host.plugins["XEP-0264"]
|
# we init once on first component connection,
|
||||||
host.plugins["XEP-0363"].registerHandler(self._onHTTPUpload)
|
# there is not need to init this plugin if not component use it
|
||||||
host.trigger.add("FILE_getDestDir", self._getDestDirTrigger)
|
# TODO: this plugin should not be loaded at all if no component uses it
|
||||||
host.trigger.add(
|
# and should be loaded dynamically as soon as a suitable profile is created
|
||||||
|
if self.initialised:
|
||||||
|
return
|
||||||
|
self.initialised = True
|
||||||
|
log.info(_("File Sharing initialization"))
|
||||||
|
self._f = self.host.plugins["FILE"]
|
||||||
|
self._jf = self.host.plugins["XEP-0234"]
|
||||||
|
self._h = self.host.plugins["XEP-0300"]
|
||||||
|
self._t = self.host.plugins["XEP-0264"]
|
||||||
|
self.host.plugins["XEP-0363"].registerHandler(self._onHTTPUpload)
|
||||||
|
self.host.trigger.add("FILE_getDestDir", self._getDestDirTrigger)
|
||||||
|
self.host.trigger.add(
|
||||||
"XEP-0234_fileSendingRequest", self._fileSendingRequestTrigger, priority=1000
|
"XEP-0234_fileSendingRequest", self._fileSendingRequestTrigger, priority=1000
|
||||||
)
|
)
|
||||||
host.trigger.add("XEP-0234_buildFileElement", self._addFileComments)
|
self.host.trigger.add("XEP-0234_buildFileElement", self._addFileComments)
|
||||||
host.trigger.add("XEP-0234_parseFileElement", self._getFileComments)
|
self.host.trigger.add("XEP-0234_parseFileElement", self._getFileComments)
|
||||||
host.trigger.add("XEP-0329_compGetFilesFromNode", self._addCommentsData)
|
self.host.trigger.add("XEP-0329_compGetFilesFromNode", self._addCommentsData)
|
||||||
self.files_path = host.getLocalPath(None, C.FILES_DIR, profile=False)
|
self.files_path = self.host.getLocalPath(None, C.FILES_DIR, profile=False)
|
||||||
self.http_port = host.memory.getConfig(
|
self.http_port = self.host.memory.getConfig(
|
||||||
'component file_sharing', 'http_upload_port', 8888)
|
'component file_sharing', 'http_upload_port', 8888)
|
||||||
connection_type = host.memory.getConfig(
|
connection_type = self.host.memory.getConfig(
|
||||||
'component file_sharing', 'http_upload_connection_type', 'https')
|
'component file_sharing', 'http_upload_connection_type', 'https')
|
||||||
if connection_type not in ('http', 'https'):
|
if connection_type not in ('http', 'https'):
|
||||||
raise exceptions.ConfigError(
|
raise exceptions.ConfigError(
|
||||||
|
|
@ -321,7 +331,7 @@ class FileSharing:
|
||||||
if connection_type == 'http':
|
if connection_type == 'http':
|
||||||
reactor.listenTCP(self.http_port, self.server)
|
reactor.listenTCP(self.http_port, self.server)
|
||||||
else:
|
else:
|
||||||
options = tls.getOptionsFromConfig(host.memory.config, "component file_sharing")
|
options = tls.getOptionsFromConfig(self.host.memory.config, "component file_sharing")
|
||||||
tls.TLSOptionsCheck(options)
|
tls.TLSOptionsCheck(options)
|
||||||
context_factory = tls.getTLSContextFactory(options)
|
context_factory = tls.getTLSContextFactory(options)
|
||||||
reactor.listenSSL(self.http_port, self.server, context_factory)
|
reactor.listenSSL(self.http_port, self.server, context_factory)
|
||||||
|
|
@ -331,6 +341,7 @@ class FileSharing:
|
||||||
return Comments_handler(self)
|
return Comments_handler(self)
|
||||||
|
|
||||||
def profileConnecting(self, client):
|
def profileConnecting(self, client):
|
||||||
|
self.init()
|
||||||
public_base_url = self.host.memory.getConfig(
|
public_base_url = self.host.memory.getConfig(
|
||||||
'component file_sharing', 'http_upload_public_facing_url')
|
'component file_sharing', 'http_upload_public_facing_url')
|
||||||
if public_base_url is None:
|
if public_base_url is None:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue