← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bugfixes into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bugfixes into lp:openlp.

Requested reviews:
    openlp.org Core (openlp-core)

Clean up Eventing so events are labeled correctly
All Events to tell the manager the event is finished with so stop processing it.
Clean up Presentation Plugin a bit.
Clean up remote client cli to make pure python.
-- 
https://code.launchpad.net/~trb143/openlp/bugfixes/+merge/10042
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/event.py'
--- openlp/core/lib/event.py	2009-08-10 19:11:54 +0000
+++ openlp/core/lib/event.py	2009-08-12 04:57:24 +0000
@@ -45,7 +45,7 @@
     """
     Provides an Event class to encapsulate events within openlp.org.
     """
-    def __init__(self, event_type=EventType.Default, payload=None, sender=None):
+    def __init__(self, event_type, sender, payload=None):
         self.event_type = event_type
         self.payload = payload
         self.sender = sender

=== modified file 'openlp/core/lib/eventmanager.py'
--- openlp/core/lib/eventmanager.py	2009-08-10 20:10:20 +0000
+++ openlp/core/lib/eventmanager.py	2009-08-12 04:57:24 +0000
@@ -57,13 +57,16 @@
             The event type to be triggered
 
         """
-        log.debug(u'post event called for event %s', event.event_type)
+        log.debug(u'post event called for event %s (%s)', event.event_type, event.sender)
         self.events.append(event)
         if not self.processing:
             self.processing = True
             while len(self.events) > 0:
                 pEvent = self.events[0]
                 for point in self.endpoints:
-                    point.handle_event(pEvent)
+                    status = point.handle_event(pEvent)
+                    #if call returns true message is finished with
+                    if status is not None and status :
+                        break
                 self.events.remove(pEvent)
             self.processing = False

=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py	2009-08-10 20:10:20 +0000
+++ openlp/core/lib/plugin.py	2009-08-12 04:57:24 +0000
@@ -191,11 +191,14 @@
         if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id:
             log.debug(u'Load Service Item received')
             self.media_item.onAddClick()
+            return True
         if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id:
             log.debug(u'Load Preview Item received')
             self.media_item.onPreviewClick()
+            return True
         if event.event_type == EventType.LiveShow and event.payload == self.dnd_id:
             log.debug(u'Load Live Show Item received')
+            return True
             self.media_item.onLiveClick()
 
     def about(self):

=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2009-08-10 20:10:20 +0000
+++ openlp/core/ui/maindisplay.py	2009-08-12 04:57:24 +0000
@@ -62,9 +62,14 @@
         self.parent.EventManager.register(self)
 
     def handle_event(self, event):
+        """
+        Accept Events for the system and If It's for Alert
+        action it and Return true to stop futher processing
+        """
         log.debug(u'MainDisplay received event %s with payload %s'%(event.event_type, event.payload))
         if event.event_type == EventType.TriggerAlert:
             self.displayAlert(event.payload)
+            return True
 
     def setup(self, screenNumber):
         """

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2009-08-06 17:43:53 +0000
+++ openlp/core/ui/servicemanager.py	2009-08-12 04:57:24 +0000
@@ -488,7 +488,7 @@
         link = event.mimeData()
         if link.hasText():
             plugin = event.mimeData().text()
-            self.parent.EventManager.post_event(Event(EventType.LoadServiceItem, plugin))
+            self.parent.EventManager.post_event(Event(EventType.LoadServiceItem, u'ServiceManager', plugin))
 
     def updateThemeList(self, theme_list):
         """

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2009-08-09 17:58:37 +0000
+++ openlp/core/ui/thememanager.py	2009-08-12 04:57:24 +0000
@@ -184,7 +184,7 @@
         self.pushThemes()
 
     def pushThemes(self):
-        self.parent.EventManager.post_event(Event(EventType.ThemeListChanged))
+        self.parent.EventManager.post_event(Event(EventType.ThemeListChanged,u'ThemeManager'))
 
     def getThemes(self):
         return self.themelist

=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py	2009-07-03 20:32:33 +0000
+++ openlp/plugins/bibles/bibleplugin.py	2009-08-12 04:57:24 +0000
@@ -82,4 +82,4 @@
         if event.event_type == EventType.ThemeListChanged:
             log.debug(u'New Theme request received')
             self.bibles_tab.updateThemeList(self.theme_manager.getThemes())
-        Plugin.handle_event(self, event)
+        return Plugin.handle_event(self, event)

=== modified file 'openlp/plugins/custom/customplugin.py'
--- openlp/plugins/custom/customplugin.py	2009-06-26 17:51:43 +0000
+++ openlp/plugins/custom/customplugin.py	2009-08-12 04:57:24 +0000
@@ -58,4 +58,4 @@
         if event.event_type == EventType.ThemeListChanged:
             log.debug(u'New Theme request received')
             self.edit_custom_form.loadThemes(self.theme_manager.getThemes())
-        Plugin.handle_event(self, event)
+        return Plugin.handle_event(self, event)

=== modified file 'openlp/plugins/presentations/lib/__init__.py'
--- openlp/plugins/presentations/lib/__init__.py	2009-06-25 19:42:22 +0000
+++ openlp/plugins/presentations/lib/__init__.py	2009-08-11 19:21:52 +0000
@@ -17,10 +17,8 @@
 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 Place, Suite 330, Boston, MA 02111-1307 USA
 """
-
-from filelistdata import FileListData
 from mediaitem import PresentationMediaItem
 from presentationtab import PresentationTab
-from impresscom import Openoffice
+from impressslidecontroller import impressToolbar
 
-__all__ = ['PresentationMediaItem', 'FileListData', 'PresentationTab', 'OpenOffice']
+__all__ = ['PresentationMediaItem', 'PresentationTab', 'impressToolbar']

=== removed file 'openlp/plugins/presentations/lib/filelistdata.py'
--- openlp/plugins/presentations/lib/filelistdata.py	2009-06-16 18:21:24 +0000
+++ openlp/plugins/presentations/lib/filelistdata.py	1970-01-01 00:00:00 +0000
@@ -1,82 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
-"""
-OpenLP - Open Source Lyrics Projection
-Copyright (c) 2008 Raoul Snyman
-Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation; version 2 of the License.
-
-This program is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
-"""
-import os
-import logging
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-
-class FileListData(QAbstractListModel):
-    """
-    An abstract list of strings and the preview icon to go with them
-    """
-    global log
-    log=logging.getLogger(u'FileListData')
-    log.info(u'started')
-
-    def __init__(self):
-        QAbstractListModel.__init__(self)
-        self.items=[] # will be a list of (full filename shortname) tuples
-
-    def rowCount(self, parent):
-        return len(self.items)
-
-    def insertRow(self, row, filename):
-        self.beginInsertRows(QModelIndex(),row,row)
-        log.info(u'insert row %d:%s'%(row,filename))
-        # get short filename to display next to image
-        (prefix, shortfilename) = os.path.split(unicode(filename))
-        log.info(u'shortfilename=%s'%(shortfilename))
-        # create a preview image
-        self.items.insert(row, (filename, shortfilename))
-        self.endInsertRows()
-
-    def removeRow(self, row):
-        self.beginRemoveRows(QModelIndex(), row,row)
-        self.items.pop(row)
-        self.endRemoveRows()
-
-    def addRow(self, filename):
-        self.insertRow(len(self.items), filename)
-
-    def data(self, index, role):
-        row=index.row()
-        if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
-            return QVariant()
-        if role==Qt.DisplayRole:
-            retval= self.items[row][1]
-#        elif role == Qt.DecorationRole:
-#            retval= self.items[row][1]
-        elif role == Qt.ToolTipRole:
-            retval= self.items[row][0]
-        else:
-            retval= QVariant()
-#         log.info(u'Returning"+ unicode(retval))
-        if type(retval) is not type(QVariant):
-            return QVariant(retval)
-        else:
-            return retval
-
-    def getFileList(self):
-        filelist = [item[0] for item in self.items];
-        return filelist
-
-    def getFilename(self, index):
-        row = index.row()
-        return self.items[row][0]

=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py	2009-07-09 16:51:25 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py	2009-08-11 19:21:52 +0000
@@ -21,25 +21,26 @@
 import os
 
 from PyQt4 import QtCore, QtGui
-from openlp.plugins.presentations.lib import FileListData
 from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD
 
 # We have to explicitly create separate classes for each plugin
 # in order for DnD to the Service manager to work correctly.
 class PresentationListView(BaseListWithDnD):
     def __init__(self, parent=None):
-        self.PluginName = u'Presentation'
+        self.PluginName = u'Presentations'
         BaseListWithDnD.__init__(self, parent)
 
 class PresentationMediaItem(MediaManagerItem):
     """
-    This is the custom media manager item for Custom Slides.
+    This is the Presentation media manager item for Presentation Items.
+    It can present files using Openoffice
     """
     global log
     log=logging.getLogger(u'PresentationsMediaItem')
     log.info(u'Presentations Media Item loaded')
 
-    def __init__(self, parent, icon, title):
+    def __init__(self, parent, icon, title, controllers):
+        self.controllers = controllers
         self.TranslationContext = u'PresentationPlugin'
         self.PluginTextShort = u'Presentation'
         self.ConfigSection = u'presentation'
@@ -76,10 +77,13 @@
 
     def initialise(self):
         list = self.parent.config.load_list(u'presentations')
-        self.loadPresentationList(list)
-        self.DisplayTypeComboBox.addItem(u'Impress')
-#        self.DisplayTypeComboBox.addItem(u'Powerpoint')
-#        self.DisplayTypeComboBox.addItem(u'Keynote')
+        self.loadList(list)
+        for item in self.controllers:
+            #load the drop down selection
+            self.DisplayTypeComboBox.addItem(item)
+            #load the preview toolbars
+            #self.parent.preview_controller.registerToolbar(item,  self.controllers[item])
+            #self.parent.live_controller.registerToolbar(item,  self.controllers[item])
 
     def loadList(self, list):
         for file in list:
@@ -88,14 +92,21 @@
             item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
             self.ListView.addItem(item_name)
 
-    def loadPresentationList(self, list):
-        pass
-#        for files in list:
-#            self.PresentationsListData.addRow(files)
+    def onDeleteClick(self):
+        item = self.ListView.currentItem()
+        if item is not None:
+            item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
+            row = self.ListView.row(item)
+            self.ListView.takeItem(row)
+            self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList())
 
-    def onPresentationDeleteClick(self):
-        indexes = self.PresentationsListView.selectedIndexes()
-        for index in indexes:
-            current_row = int(index.row())
-            self.PresentationsListData.removeRow(current_row)
-        self.parent.config.set_list(u'Presentations', self.PresentationsListData.getFileList())
+    def generateSlideData(self, service_item):
+        items = self.ListView.selectedIndexes()
+        service_item.title = self.DisplayTypeComboBox.currentText()
+        service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
+        for item in items:
+            bitem =  self.ListView.item(item.row())
+            filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
+            frame = QtGui.QImage(unicode(filename))
+            (path, name) = os.path.split(filename)
+            service_item.add_using_toolbar(path, name)

=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py	2009-07-09 16:51:25 +0000
+++ openlp/plugins/presentations/presentationplugin.py	2009-08-11 19:21:52 +0000
@@ -24,7 +24,7 @@
 from PyQt4 import QtCore, QtGui
 
 from openlp.core.lib import Plugin,  MediaManagerItem
-from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab,  Openoffice
+from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab,  impressToolbar
 
 class PresentationPlugin(Plugin):
 
@@ -34,25 +34,49 @@
     def __init__(self, plugin_helpers):
         # Call the parent constructor
         log.debug('Initialised')
+        self.controllers = {}
         Plugin.__init__(self, u'Presentations', u'1.9.0', plugin_helpers)
         self.weight = -8
         # Create the plugin icon
         self.icon = QtGui.QIcon()
         self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'),
             QtGui.QIcon.Normal, QtGui.QIcon.Off)
+        self.dnd_id = u'Presentations'
 
     def get_settings_tab(self):
+        """
+        Create the settings Tab
+        """
         self.presentation_tab = PresentationTab()
         return self.presentation_tab
 
     def get_media_manager_item(self):
-        # Create the MediaManagerItem object
-        self.media_item = PresentationMediaItem(self, self.icon, u'Presentations')
+        """
+        Create the Media Manager List
+        """
+        self.media_item = PresentationMediaItem(self, self.icon, u'Presentations', self.controllers)
         return self.media_item
 
+    def registerControllers(self, handle, controller):
+        self.controllers[handle] = controller
+
     def check_pre_conditions(self):
+        """
+        Check to see if we have any presentation software available
+        If Not do not install the plugin.
+        """
         log.debug('check_pre_conditions')
-        return True
-#        self.openoffice = Openoffice()
+        impress = True
+        try:
+            #Check to see if we have uno installed
+            import uno
+            #openoffice = impressToolbar()
+            self.registerControllers(u'Impress', None)
+        except:
+            pass
+        #If we have no controllers disable plugin
+        if len(self.controllers) > 0:
+            return True
+        else:
+            return False
 #        return self.openoffice.checkOoPid()
-

=== modified file 'openlp/plugins/remotes/remoteclient-cli.py'
--- openlp/plugins/remotes/remoteclient-cli.py	2009-08-10 18:20:46 +0000
+++ openlp/plugins/remotes/remoteclient-cli.py	2009-08-12 16:29:00 +0000
@@ -18,37 +18,54 @@
 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 Place, Suite 330, Boston, MA 02111-1307 USA
 """
+import socket
 import sys
-import logging
-from PyQt4 import QtNetwork, QtGui, QtCore
-
-logging.basicConfig(level=logging.DEBUG,
-    format=u'%(asctime)s:%(msecs)3d %(name)-15s %(levelname)-8s %(message)s',
-    datefmt=u'%m-%d %H:%M:%S', filename=u'openlp-cli.log', filemode=u'w')
-
-class OpenLPRemoteCli():
-    global log
-    log = logging.getLogger(u'OpenLP Remote Application')
-    log.info(u'Application Loaded')
-
-    def __init__(self, argv):
-        log.debug(u'Initialising')
-        try:
-            self.tcpsocket = QtNetwork.QUdpSocket()
-            self.sendData()
-        except:
-            log.error(u'Errow thrown %s', sys.exc_info()[1])
-            print u'Errow thrown ', sys.exc_info()[1]
-
-    def sendData(self):
-        text = "Alert:Wave to Zak, Superfly"
-        print self.tcpsocket
-        print self.tcpsocket.writeDatagram(text, QtNetwork.QHostAddress(QtNetwork.QHostAddress.Broadcast), 4316)
-
-    def run(self):
-        pass
+from optparse import OptionParser
+
+
+def sendData(options, message):
+    addr = (options.address, options.port)
+    try:
+        UDPSock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
+        UDPSock.sendto(message, addr)
+        print u'message sent ', message ,  addr
+    except:
+        print u'Errow thrown ', sys.exc_info()[1]
+
+def format_message(options):
+    return u'%s:%s' % (options.event,  options.message)
+
+def main():
+    usage = "usage: %prog [options] arg1 arg2"
+    parser = OptionParser(usage=usage)
+    parser.add_option("-v", "--verbose",
+                      action="store_true", dest="verbose", default=True,
+                      help="make lots of noise [%default]")
+    parser.add_option("-p", "--port",
+                      default=4316,
+                      help="IP Port number %default ")
+    parser.add_option("-a", "--address",
+                      help="Recipient address ")
+    parser.add_option("-e", "--event",
+                      default=u'Alert',
+                      help="Action to be undertaken")
+    parser.add_option("-m", "--message",
+                      help="Message to be passed for the action")
+
+    (options, args) = parser.parse_args()
+    if len(args) > 0:
+        parser.print_help()
+        parser.error("incorrect number of arguments")
+    elif options.message is None:
+        parser.print_help()
+        parser.error("No message passed")
+    elif options.address is None:
+        parser.print_help()
+        parser.error("IP address missing")
+    else:
+        text = format_message(options)
+        sendData(options, text)
 
 if __name__ == u'__main__':
-    app = OpenLPRemoteCli(sys.argv)
-    app.run()
+    main()
 

=== modified file 'openlp/plugins/remotes/remoteplugin.py'
--- openlp/plugins/remotes/remoteplugin.py	2009-08-10 20:10:20 +0000
+++ openlp/plugins/remotes/remoteplugin.py	2009-08-12 16:29:00 +0000
@@ -40,16 +40,18 @@
             QtCore.SIGNAL(u'readyRead()'), self.readData)
 
     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])
-        payyload = unicode(datagram[pos + 1:])
-        if event == u'Alert':
-            self.event_manager.post_event(Event(EventType.TriggerAlert, payyload))
+        event = unicode(datagram[:pos].lower())
+        payload = unicode(datagram[pos + 1:])
+        if event == u'alert':
+            self.event_manager.post_event(Event(EventType.TriggerAlert, u'RemotePlugin', payload))
 
 
 

=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2009-08-08 06:19:09 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2009-08-12 04:57:24 +0000
@@ -356,7 +356,7 @@
         self.processTitle()
         self.songmanager.save_song(self.song)
         if self.title_change:
-            self.eventmanager.post_event(Event(EventType.LoadSongList))
+            self.eventmanager.post_event(Event(EventType.LoadSongList), u'EditSongForm')
         self.close()
 
     def processLyrics(self):

=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py	2009-08-06 21:30:14 +0000
+++ openlp/plugins/songs/songsplugin.py	2009-08-12 04:57:24 +0000
@@ -140,4 +140,4 @@
         if event.event_type == EventType.LoadSongList :
             log.debug(u'Load Load Song List Item received')
             self.media_item.displayResultsSong(self.songmanager.get_songs())
-        Plugin.handle_event(self, event)
+        return Plugin.handle_event(self, event)


Follow ups