diff --git a/openlp/core/lib/event.py b/openlp/core/lib/event.py index d6801654f..adb2fc527 100644 --- a/openlp/core/lib/event.py +++ b/openlp/core/lib/event.py @@ -45,7 +45,7 @@ class Event(object): """ 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 diff --git a/openlp/core/lib/eventmanager.py b/openlp/core/lib/eventmanager.py index 0cd12862b..15edf02d8 100644 --- a/openlp/core/lib/eventmanager.py +++ b/openlp/core/lib/eventmanager.py @@ -57,13 +57,16 @@ class EventManager(object): 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 diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 4eeec4123..e9b402085 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -191,11 +191,14 @@ class Plugin(object): 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): diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 0476d0d97..78f0caa2b 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -62,9 +62,14 @@ class MainDisplay(QtGui.QWidget): 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): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9f8f03959..75421e4ad 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -488,7 +488,7 @@ class ServiceManager(QtGui.QWidget): 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): """ diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 5b7e669c4..4d7312b38 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -184,7 +184,7 @@ class ThemeManager(QtGui.QWidget): 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 diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 4dd42b9e9..7c7591a42 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -82,4 +82,4 @@ class BiblePlugin(Plugin): 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) diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 2efa30f1e..209ef69bc 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -58,4 +58,4 @@ class CustomPlugin(Plugin): 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) diff --git a/openlp/plugins/presentations/lib/__init__.py b/openlp/plugins/presentations/lib/__init__.py index 767d922a0..627f40e36 100644 --- a/openlp/plugins/presentations/lib/__init__.py +++ b/openlp/plugins/presentations/lib/__init__.py @@ -17,10 +17,8 @@ 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 """ - -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'] diff --git a/openlp/plugins/presentations/lib/filelistdata.py b/openlp/plugins/presentations/lib/filelistdata.py deleted file mode 100644 index 465d3400e..000000000 --- a/openlp/plugins/presentations/lib/filelistdata.py +++ /dev/null @@ -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] diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 6506e5304..d65516e37 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -21,25 +21,26 @@ import logging 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 @@ class PresentationMediaItem(MediaManagerItem): 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 @@ class PresentationMediaItem(MediaManagerItem): 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) diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index f7f9f9903..8a03aa255 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -24,7 +24,7 @@ import logging 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 @@ class PresentationPlugin(Plugin): 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 check_pre_conditions(self): - log.debug('check_pre_conditions') - return True -# self.openoffice = Openoffice() -# return self.openoffice.checkOoPid() + 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') + 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() diff --git a/openlp/plugins/remotes/remoteclient-cli.py b/openlp/plugins/remotes/remoteclient-cli.py index ff4999b59..7228d1d0a 100755 --- a/openlp/plugins/remotes/remoteclient-cli.py +++ b/openlp/plugins/remotes/remoteclient-cli.py @@ -18,37 +18,54 @@ 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 socket import sys -import logging -from PyQt4 import QtNetwork, QtGui, QtCore +from optparse import OptionParser -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 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 __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 format_message(options): + return u'%s:%s' % (options.event, options.message) - def sendData(self): - text = "Alert:Wave to Zak, Superfly" - print self.tcpsocket - print self.tcpsocket.writeDatagram(text, QtNetwork.QHostAddress(QtNetwork.QHostAddress.Broadcast), 4316) +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") - def run(self): - pass + (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() diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index b0d546488..1c37c3c2c 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -40,16 +40,18 @@ class RemotesPlugin(Plugin): 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)) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0c4a1d6b2..8d5176f9e 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -356,7 +356,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 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): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index b79fce223..06bed8290 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -140,4 +140,4 @@ class SongsPlugin(Plugin): 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)