← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~j-corwin/openlp/remote into lp:openlp

 

Jonathan Corwin has proposed merging lp:~j-corwin/openlp/remote into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


Hoorah, launchpad finally finished updating branch after 14 hours! Glad I didn't wait up for it to finish.

Has a couple of web fixes, and allows a few more file types though in the hope it will entice someone to make the webpage look like it was written after 1993.

Attempts to implement presentation_hide signal. Works for powerpoint although a bit of a fight with maindisplay/videodisplay windows not going away. Impress is proving more troublesome, so I'll have to keep investigating.


-- 
https://code.launchpad.net/~j-corwin/openlp/remote/+merge/24663
Your team OpenLP Core is requested to review the proposed merge of lp:~j-corwin/openlp/remote into lp:openlp.
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2010-05-01 12:10:48 +0000
+++ openlp/core/ui/slidecontroller.py	2010-05-04 11:40:01 +0000
@@ -674,10 +674,10 @@
         self.themeButton.setChecked(False)
         if checked:
             Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
-            self.blankPlugin(True)
+            self.hidePlugin(True)
         else:
             Receiver.send_message(u'maindisplay_show')
-            self.blankPlugin(False)
+            self.hidePlugin(False)
 
     def blankPlugin(self, blank):
         """
@@ -693,6 +693,20 @@
                     % self.serviceItem.name.lower(),
                     [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):
         """
         Generate the preview when you click on a slide.

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2010-05-01 13:05:17 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2010-05-04 11:40:01 +0000
@@ -143,7 +143,7 @@
     def generateSlideData(self, service_item, item=None):
         items = self.ListView.selectedIndexes()
         if items:
-            service_item.title = self.trUtf8('Image(s)')
+            service_item.title = unicode(self.trUtf8('Image(s)'))
             service_item.add_capability(ItemCapabilities.AllowsMaintain)
             service_item.add_capability(ItemCapabilities.AllowsPreview)
             service_item.add_capability(ItemCapabilities.AllowsLoop)

=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py	2010-05-01 08:46:06 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py	2010-05-04 11:40:01 +0000
@@ -160,6 +160,16 @@
             return
         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):
         log.debug(u'Live = %s, unblank' % self.isLive)
         if not self.isLive:
@@ -191,6 +201,8 @@
         QtCore.QObject.connect(Receiver.get_receiver(),
             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.SIGNAL(u'presentations_first'), self.first)
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'presentations_previous'), self.previous)
@@ -279,6 +291,11 @@
         else:
             self.previewHandler.shutdown()
 
+    def hide(self, message):
+        isLive, item = self.decode_message(message)
+        if isLive:
+            self.liveHandler.stop()
+
     def blank(self, message):
         isLive, item = self.decode_message(message)
         if isLive:

=== modified file 'openlp/plugins/remotes/html/index.html'
--- openlp/plugins/remotes/html/index.html	2010-05-01 12:10:48 +0000
+++ openlp/plugins/remotes/html/index.html	2010-05-04 11:40:01 +0000
@@ -63,7 +63,7 @@
                     html += ' style="font-weight: bold"';
                 html += '>';
                 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 += '</table>';
@@ -105,10 +105,12 @@
     <hr>
     <input type='button' value='Order of service' 
         onclick='send_event("servicemanager_list_request");'>
+    <i>(Click service item to go live.)</i>
     <div id='service'></div>
     <hr>
     <input type='button' value='Current item' 
         onclick='send_event("slidecontroller_live_text_request");'>
+    <i>(Click verse to display.)</i>
     <div id='currentitem'></div>
     <hr>
     <a href="http://www.openlp.org/";>OpenLP website</a>

=== modified file 'openlp/plugins/remotes/lib/httpserver.py'
--- openlp/plugins/remotes/lib/httpserver.py	2010-05-01 12:10:48 +0000
+++ openlp/plugins/remotes/lib/httpserver.py	2010-05-04 11:40:01 +0000
@@ -152,43 +152,59 @@
             log.debug(u'received: ' + data)
             words = data.split(u' ')
             html = None
+            mimetype = None
             if words[0] == u'GET':
                 url = urlparse.urlparse(words[1])
                 params = self.load_params(url.query)
                 folders = url.path.split(u'/')
                 if folders[1] == u'':
-                    html = self.serve_file(u'')
+                    mimetype, html = self.serve_file(u'')
                 elif folders[1] == u'files':
-                    html = self.serve_file(folders[2])
+                    mimetype, html = self.serve_file(folders[2])
                 elif folders[1] == u'send':
                     html = self.process_event(folders[2], params)
                 elif folders[1] == u'request':
                     if self.process_request(folders[2], params):
                         return
             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:
-                html = self.get_404_not_found()
-            self.socket.write(html)
+                self.socket.write(self.get_404_not_found())
             self.close()
 
     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. 
         If subfolders requested return 404, easier for security for the present.
 
         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'
         """
-        log.debug(u'serve file request %s' % filename)
+        log.debug(u'serve file request %s' % filename)        
         if not filename:
             filename = u'index.html'
         if os.path.basename(filename) != filename:
             return None
         (fileroot, ext) = os.path.splitext(filename)
-        if ext != u'.html':
-            return None
+        if ext == u'.html':
+            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)
         try:
             f = open(path, u'rb')
@@ -198,12 +214,13 @@
         log.debug(u'Opened %s' % path)
         html = f.read()
         f.close()
-        return html
-                               
+        return (mimetype, html)
+
     def load_params(self, query):
         """
         Decode the query string parameters sent from the browser
         """
+        log.debug(u'loading params %s' % query)
         params = urlparse.parse_qs(query)
         if not params:
             return None
@@ -216,6 +233,7 @@
         Currently lets anything through. Later we should restrict and perform
         basic parameter checking, otherwise rogue clients could crash openlp
         """
+        log.debug(u'Processing event %s' % event)
         if params:
             Receiver.send_message(event, params)    
         else:                  
@@ -233,6 +251,7 @@
         is just waiting for slide change/song change activity. This can wait
         longer (one minute)
         """
+        log.debug(u'Processing request %s' % event)
         if not event.endswith(u'_request'):
             return False
         self.event = event
@@ -258,6 +277,7 @@
         The recipient of a _request signal has sent data. Convert this to 
         json and return it to client
         """
+        log.debug(u'Processing response for %s' % self.event)
         if not self.socket:
             return
         self.timer.stop()
@@ -266,13 +286,12 @@
         self.socket.write(html)
         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. 
         """
         return u'HTTP/1.1 200 OK\r\n' + \
-            u'Content-Type: text/html; charset="utf-8"\r\n' + \
-            u'\r\n'
+            u'Content-Type: %s\r\n\r\n' % mimetype
 
     def get_404_not_found(self):
         """


Follow ups