forked from openlp/openlp
Basic http support
This commit is contained in:
parent
a4a80a7b9e
commit
80e9f94a52
@ -24,3 +24,4 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
from remotetab import RemoteTab
|
from remotetab import RemoteTab
|
||||||
|
from httpserver import HttpServer
|
||||||
|
@ -28,7 +28,7 @@ import logging
|
|||||||
from PyQt4 import QtNetwork, QtCore
|
from PyQt4 import QtNetwork, QtCore
|
||||||
|
|
||||||
from openlp.core.lib import Plugin, Receiver
|
from openlp.core.lib import Plugin, Receiver
|
||||||
from openlp.plugins.remotes.lib import RemoteTab
|
from openlp.plugins.remotes.lib import RemoteTab, HttpServer
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -44,10 +44,7 @@ class RemotesPlugin(Plugin):
|
|||||||
log.debug(u'initialise')
|
log.debug(u'initialise')
|
||||||
Plugin.initialise(self)
|
Plugin.initialise(self)
|
||||||
self.insert_toolbox_item()
|
self.insert_toolbox_item()
|
||||||
self.server = QtNetwork.QUdpSocket()
|
self.server = HttpServer(self)
|
||||||
self.server.bind(int(self.config.get_config(u'remote port', 4316)))
|
|
||||||
QtCore.QObject.connect(self.server,
|
|
||||||
QtCore.SIGNAL(u'readyRead()'), self.readData)
|
|
||||||
|
|
||||||
def finalise(self):
|
def finalise(self):
|
||||||
log.debug(u'finalise')
|
log.debug(u'finalise')
|
||||||
@ -60,24 +57,6 @@ class RemotesPlugin(Plugin):
|
|||||||
Create the settings Tab
|
Create the settings Tab
|
||||||
"""
|
"""
|
||||||
return RemoteTab(self.name)
|
return RemoteTab(self.name)
|
||||||
|
|
||||||
def readData(self):
|
|
||||||
log.info(u'Remoted data has arrived')
|
|
||||||
while self.server.hasPendingDatagrams():
|
|
||||||
datagram, host, port = self.server.readDatagram(
|
|
||||||
self.server.pendingDatagramSize())
|
|
||||||
self.handle_datagram(datagram)
|
|
||||||
|
|
||||||
def handle_datagram(self, datagram):
|
|
||||||
log.info(u'Sending event %s ', datagram)
|
|
||||||
pos = datagram.find(u':')
|
|
||||||
event = unicode(datagram[:pos].lower())
|
|
||||||
if event == u'alert':
|
|
||||||
Receiver.send_message(u'alerts_text', unicode(datagram[pos + 1:]))
|
|
||||||
elif event == u'next_slide':
|
|
||||||
Receiver.send_message(u'slidecontroller_live_next')
|
|
||||||
else:
|
|
||||||
Receiver.send_message(event, unicode(datagram[pos + 1:]))
|
|
||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
about_text = self.trUtf8('<b>Remote Plugin</b><br>This plugin '
|
about_text = self.trUtf8('<b>Remote Plugin</b><br>This plugin '
|
||||||
|
Loading…
Reference in New Issue
Block a user