web fixes, allow more file types. Slidecontroller_hide event

This commit is contained in:
Jonathan Corwin 2010-05-03 22:49:42 +01:00
parent 456d35f2d4
commit 465ce8c7f7
4 changed files with 65 additions and 17 deletions

View File

@ -674,10 +674,10 @@ class SlideController(QtGui.QWidget):
self.themeButton.setChecked(False) self.themeButton.setChecked(False)
if checked: if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Screen) Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
self.blankPlugin(True) self.hidePlugin(True)
else: else:
Receiver.send_message(u'maindisplay_show') Receiver.send_message(u'maindisplay_show')
self.blankPlugin(False) self.hidePlugin(False)
def blankPlugin(self, blank): def blankPlugin(self, blank):
""" """
@ -693,6 +693,20 @@ class SlideController(QtGui.QWidget):
% self.serviceItem.name.lower(), % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive]) [self.serviceItem, self.isLive])
def hidePlugin(self, hide):
"""
Blank the display screen.
"""
if self.serviceItem is not None:
if hide:
Receiver.send_message(u'%s_hide'
% self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
else:
Receiver.send_message(u'%s_unblank'
% self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
def onSlideSelected(self): def onSlideSelected(self):
""" """
Generate the preview when you click on a slide. Generate the preview when you click on a slide.

View File

@ -160,6 +160,16 @@ class Controller(object):
return return
self.doc.blank_screen() self.doc.blank_screen()
def stop(self):
log.debug(u'Live = %s, stop' % self.isLive)
if not self.isLive:
return
if not self.doc.is_loaded():
return
if not self.doc.is_active():
return
self.doc.stop_presentation()
def unblank(self): def unblank(self):
log.debug(u'Live = %s, unblank' % self.isLive) log.debug(u'Live = %s, unblank' % self.isLive)
if not self.isLive: if not self.isLive:
@ -190,6 +200,8 @@ class MessageListener(object):
QtCore.SIGNAL(u'presentations_start'), self.startup) QtCore.SIGNAL(u'presentations_start'), self.startup)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_stop'), self.shutdown) QtCore.SIGNAL(u'presentations_stop'), self.shutdown)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_hide'), self.hide)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_first'), self.first) QtCore.SIGNAL(u'presentations_first'), self.first)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -279,6 +291,11 @@ class MessageListener(object):
else: else:
self.previewHandler.shutdown() self.previewHandler.shutdown()
def hide(self, message):
isLive, item = self.decode_message(message)
if isLive:
self.liveHandler.stop()
def blank(self, message): def blank(self, message):
isLive, item = self.decode_message(message) isLive, item = self.decode_message(message)
if isLive: if isLive:

View File

@ -63,7 +63,7 @@ function response(eventname, req){
html += ' style="font-weight: bold"'; html += ' style="font-weight: bold"';
html += '>'; html += '>';
html += '<td>' + data[row]['tag'] + '</td>'; html += '<td>' + data[row]['tag'] + '</td>';
html += '<td>' + data[row]['text'].replace(/\\n/g, '<br>'); html += '<td>' + data[row]['text'].replace(/\n/g, '<br>');
html += '</td></tr>'; html += '</td></tr>';
} }
html += '</table>'; html += '</table>';
@ -105,10 +105,12 @@ send_event("remotes_poll_request");
<hr> <hr>
<input type='button' value='Order of service' <input type='button' value='Order of service'
onclick='send_event("servicemanager_list_request");'> onclick='send_event("servicemanager_list_request");'>
<i>(Click service item to go live.)</i>
<div id='service'></div> <div id='service'></div>
<hr> <hr>
<input type='button' value='Current item' <input type='button' value='Current item'
onclick='send_event("slidecontroller_live_text_request");'> onclick='send_event("slidecontroller_live_text_request");'>
<i>(Click verse to display.)</i>
<div id='currentitem'></div> <div id='currentitem'></div>
<hr> <hr>
<a href="http://www.openlp.org/">OpenLP website</a> <a href="http://www.openlp.org/">OpenLP website</a>

View File

@ -152,43 +152,59 @@ class HttpConnection(object):
log.debug(u'received: ' + data) log.debug(u'received: ' + data)
words = data.split(u' ') words = data.split(u' ')
html = None html = None
mimetype = None
if words[0] == u'GET': if words[0] == u'GET':
url = urlparse.urlparse(words[1]) url = urlparse.urlparse(words[1])
params = self.load_params(url.query) params = self.load_params(url.query)
folders = url.path.split(u'/') folders = url.path.split(u'/')
if folders[1] == u'': if folders[1] == u'':
html = self.serve_file(u'') mimetype, html = self.serve_file(u'')
elif folders[1] == u'files': elif folders[1] == u'files':
html = self.serve_file(folders[2]) mimetype, html = self.serve_file(folders[2])
elif folders[1] == u'send': elif folders[1] == u'send':
html = self.process_event(folders[2], params) html = self.process_event(folders[2], params)
elif folders[1] == u'request': elif folders[1] == u'request':
if self.process_request(folders[2], params): if self.process_request(folders[2], params):
return return
if html: if html:
html = self.get_200_ok() + html + u'\n' if mimetype:
self.socket.write(self.get_200_ok(mimetype))
else:
self.socket.write(self.get_200_ok())
self.socket.write(html)
else: else:
html = self.get_404_not_found() self.socket.write(self.get_404_not_found())
self.socket.write(html)
self.close() self.close()
def serve_file(self, filename): def serve_file(self, filename):
""" """
Send a file to the socket. For now, just .html files Send a file to the socket. For now, just a subset of file types
and must be top level inside the html folder. and must be top level inside the html folder.
If subfolders requested return 404, easier for security for the present. If subfolders requested return 404, easier for security for the present.
Ultimately for i18n, this could first look for xx/file.html before Ultimately for i18n, this could first look for xx/file.html before
falling back to file.html... where xx is the language, e.g. 'en' falling back to file.html... where xx is the language, e.g. 'en'
""" """
log.debug(u'serve file request %s' % filename) log.debug(u'serve file request %s' % filename)
if not filename: if not filename:
filename = u'index.html' filename = u'index.html'
if os.path.basename(filename) != filename: if os.path.basename(filename) != filename:
return None return None
(fileroot, ext) = os.path.splitext(filename) (fileroot, ext) = os.path.splitext(filename)
if ext != u'.html': if ext == u'.html':
return None mimetype = u'text/html'
elif ext == u'.css':
mimetype = u'text/css'
elif ext == u'.js':
mimetype = u'application/x-javascript'
elif ext == u'.jpg':
mimetype = u'image/jpeg'
elif ext == u'.gif':
mimetype = u'image/gif'
elif ext == u'.png':
mimetype = u'image/png'
else:
return (None, None)
path = os.path.join(self.parent.html_dir, filename) path = os.path.join(self.parent.html_dir, filename)
try: try:
f = open(path, u'rb') f = open(path, u'rb')
@ -198,8 +214,8 @@ class HttpConnection(object):
log.debug(u'Opened %s' % path) log.debug(u'Opened %s' % path)
html = f.read() html = f.read()
f.close() f.close()
return html return (mimetype, html)
def load_params(self, query): def load_params(self, query):
""" """
Decode the query string parameters sent from the browser Decode the query string parameters sent from the browser
@ -270,13 +286,12 @@ class HttpConnection(object):
self.socket.write(html) self.socket.write(html)
self.close() self.close()
def get_200_ok(self): def get_200_ok(self, mimetype='text/html; charset="utf-8"'):
""" """
Successful request. Send OK headers. Assume html for now. Successful request. Send OK headers. Assume html for now.
""" """
return u'HTTP/1.1 200 OK\r\n' + \ return u'HTTP/1.1 200 OK\r\n' + \
u'Content-Type: text/html; charset="utf-8"\r\n' + \ u'Content-Type: %s\r\n\r\n' % mimetype
u'\r\n'
def get_404_not_found(self): def get_404_not_found(self):
""" """