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

Proposed by Tim Bentley
Status: Merged
Merged at revision: not available
Proposed branch: lp:~trb143/openlp/bugfixes
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~trb143/openlp/bugfixes
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+10042@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

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.

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

I'll approve this, but there are two things I spotted:

1. I think the "sender" attribute should come _before_ the event type, then event_type can default to EventType.Default.

2. My idea was that the "sender" attribute would be a reference to an _object_, not a _string_ of the object name. This way the event receiver can interact with the event sender if necessary.

review: Approve
lp:~trb143/openlp/bugfixes updated
507. By Tim Bentley

Updates

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/lib/event.py'
2--- openlp/core/lib/event.py 2009-08-10 19:11:54 +0000
3+++ openlp/core/lib/event.py 2009-08-12 04:57:24 +0000
4@@ -45,7 +45,7 @@
5 """
6 Provides an Event class to encapsulate events within openlp.org.
7 """
8- def __init__(self, event_type=EventType.Default, payload=None, sender=None):
9+ def __init__(self, event_type, sender, payload=None):
10 self.event_type = event_type
11 self.payload = payload
12 self.sender = sender
13
14=== modified file 'openlp/core/lib/eventmanager.py'
15--- openlp/core/lib/eventmanager.py 2009-08-10 20:10:20 +0000
16+++ openlp/core/lib/eventmanager.py 2009-08-12 04:57:24 +0000
17@@ -57,13 +57,16 @@
18 The event type to be triggered
19
20 """
21- log.debug(u'post event called for event %s', event.event_type)
22+ log.debug(u'post event called for event %s (%s)', event.event_type, event.sender)
23 self.events.append(event)
24 if not self.processing:
25 self.processing = True
26 while len(self.events) > 0:
27 pEvent = self.events[0]
28 for point in self.endpoints:
29- point.handle_event(pEvent)
30+ status = point.handle_event(pEvent)
31+ #if call returns true message is finished with
32+ if status is not None and status :
33+ break
34 self.events.remove(pEvent)
35 self.processing = False
36
37=== modified file 'openlp/core/lib/plugin.py'
38--- openlp/core/lib/plugin.py 2009-08-10 20:10:20 +0000
39+++ openlp/core/lib/plugin.py 2009-08-12 04:57:24 +0000
40@@ -191,11 +191,14 @@
41 if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id:
42 log.debug(u'Load Service Item received')
43 self.media_item.onAddClick()
44+ return True
45 if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id:
46 log.debug(u'Load Preview Item received')
47 self.media_item.onPreviewClick()
48+ return True
49 if event.event_type == EventType.LiveShow and event.payload == self.dnd_id:
50 log.debug(u'Load Live Show Item received')
51+ return True
52 self.media_item.onLiveClick()
53
54 def about(self):
55
56=== modified file 'openlp/core/ui/maindisplay.py'
57--- openlp/core/ui/maindisplay.py 2009-08-10 20:10:20 +0000
58+++ openlp/core/ui/maindisplay.py 2009-08-12 04:57:24 +0000
59@@ -62,9 +62,14 @@
60 self.parent.EventManager.register(self)
61
62 def handle_event(self, event):
63+ """
64+ Accept Events for the system and If It's for Alert
65+ action it and Return true to stop futher processing
66+ """
67 log.debug(u'MainDisplay received event %s with payload %s'%(event.event_type, event.payload))
68 if event.event_type == EventType.TriggerAlert:
69 self.displayAlert(event.payload)
70+ return True
71
72 def setup(self, screenNumber):
73 """
74
75=== modified file 'openlp/core/ui/servicemanager.py'
76--- openlp/core/ui/servicemanager.py 2009-08-06 17:43:53 +0000
77+++ openlp/core/ui/servicemanager.py 2009-08-12 04:57:24 +0000
78@@ -488,7 +488,7 @@
79 link = event.mimeData()
80 if link.hasText():
81 plugin = event.mimeData().text()
82- self.parent.EventManager.post_event(Event(EventType.LoadServiceItem, plugin))
83+ self.parent.EventManager.post_event(Event(EventType.LoadServiceItem, u'ServiceManager', plugin))
84
85 def updateThemeList(self, theme_list):
86 """
87
88=== modified file 'openlp/core/ui/thememanager.py'
89--- openlp/core/ui/thememanager.py 2009-08-09 17:58:37 +0000
90+++ openlp/core/ui/thememanager.py 2009-08-12 04:57:24 +0000
91@@ -184,7 +184,7 @@
92 self.pushThemes()
93
94 def pushThemes(self):
95- self.parent.EventManager.post_event(Event(EventType.ThemeListChanged))
96+ self.parent.EventManager.post_event(Event(EventType.ThemeListChanged,u'ThemeManager'))
97
98 def getThemes(self):
99 return self.themelist
100
101=== modified file 'openlp/plugins/bibles/bibleplugin.py'
102--- openlp/plugins/bibles/bibleplugin.py 2009-07-03 20:32:33 +0000
103+++ openlp/plugins/bibles/bibleplugin.py 2009-08-12 04:57:24 +0000
104@@ -82,4 +82,4 @@
105 if event.event_type == EventType.ThemeListChanged:
106 log.debug(u'New Theme request received')
107 self.bibles_tab.updateThemeList(self.theme_manager.getThemes())
108- Plugin.handle_event(self, event)
109+ return Plugin.handle_event(self, event)
110
111=== modified file 'openlp/plugins/custom/customplugin.py'
112--- openlp/plugins/custom/customplugin.py 2009-06-26 17:51:43 +0000
113+++ openlp/plugins/custom/customplugin.py 2009-08-12 04:57:24 +0000
114@@ -58,4 +58,4 @@
115 if event.event_type == EventType.ThemeListChanged:
116 log.debug(u'New Theme request received')
117 self.edit_custom_form.loadThemes(self.theme_manager.getThemes())
118- Plugin.handle_event(self, event)
119+ return Plugin.handle_event(self, event)
120
121=== modified file 'openlp/plugins/presentations/lib/__init__.py'
122--- openlp/plugins/presentations/lib/__init__.py 2009-06-25 19:42:22 +0000
123+++ openlp/plugins/presentations/lib/__init__.py 2009-08-11 19:21:52 +0000
124@@ -17,10 +17,8 @@
125 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
126 Place, Suite 330, Boston, MA 02111-1307 USA
127 """
128-
129-from filelistdata import FileListData
130 from mediaitem import PresentationMediaItem
131 from presentationtab import PresentationTab
132-from impresscom import Openoffice
133+from impressslidecontroller import impressToolbar
134
135-__all__ = ['PresentationMediaItem', 'FileListData', 'PresentationTab', 'OpenOffice']
136+__all__ = ['PresentationMediaItem', 'PresentationTab', 'impressToolbar']
137
138=== removed file 'openlp/plugins/presentations/lib/filelistdata.py'
139--- openlp/plugins/presentations/lib/filelistdata.py 2009-06-16 18:21:24 +0000
140+++ openlp/plugins/presentations/lib/filelistdata.py 1970-01-01 00:00:00 +0000
141@@ -1,82 +0,0 @@
142-# -*- coding: utf-8 -*-
143-# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
144-"""
145-OpenLP - Open Source Lyrics Projection
146-Copyright (c) 2008 Raoul Snyman
147-Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
148-
149-This program is free software; you can redistribute it and/or modify it under
150-the terms of the GNU General Public License as published by the Free Software
151-Foundation; version 2 of the License.
152-
153-This program is distributed in the hope that it will be useful, but WITHOUT ANY
154-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
155-PARTICULAR PURPOSE. See the GNU General Public License for more details.
156-
157-You should have received a copy of the GNU General Public License along with
158-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
159-Place, Suite 330, Boston, MA 02111-1307 USA
160-"""
161-import os
162-import logging
163-from PyQt4.QtCore import *
164-from PyQt4.QtGui import *
165-
166-class FileListData(QAbstractListModel):
167- """
168- An abstract list of strings and the preview icon to go with them
169- """
170- global log
171- log=logging.getLogger(u'FileListData')
172- log.info(u'started')
173-
174- def __init__(self):
175- QAbstractListModel.__init__(self)
176- self.items=[] # will be a list of (full filename shortname) tuples
177-
178- def rowCount(self, parent):
179- return len(self.items)
180-
181- def insertRow(self, row, filename):
182- self.beginInsertRows(QModelIndex(),row,row)
183- log.info(u'insert row %d:%s'%(row,filename))
184- # get short filename to display next to image
185- (prefix, shortfilename) = os.path.split(unicode(filename))
186- log.info(u'shortfilename=%s'%(shortfilename))
187- # create a preview image
188- self.items.insert(row, (filename, shortfilename))
189- self.endInsertRows()
190-
191- def removeRow(self, row):
192- self.beginRemoveRows(QModelIndex(), row,row)
193- self.items.pop(row)
194- self.endRemoveRows()
195-
196- def addRow(self, filename):
197- self.insertRow(len(self.items), filename)
198-
199- def data(self, index, role):
200- row=index.row()
201- if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
202- return QVariant()
203- if role==Qt.DisplayRole:
204- retval= self.items[row][1]
205-# elif role == Qt.DecorationRole:
206-# retval= self.items[row][1]
207- elif role == Qt.ToolTipRole:
208- retval= self.items[row][0]
209- else:
210- retval= QVariant()
211-# log.info(u'Returning"+ unicode(retval))
212- if type(retval) is not type(QVariant):
213- return QVariant(retval)
214- else:
215- return retval
216-
217- def getFileList(self):
218- filelist = [item[0] for item in self.items];
219- return filelist
220-
221- def getFilename(self, index):
222- row = index.row()
223- return self.items[row][0]
224
225=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
226--- openlp/plugins/presentations/lib/mediaitem.py 2009-07-09 16:51:25 +0000
227+++ openlp/plugins/presentations/lib/mediaitem.py 2009-08-11 19:21:52 +0000
228@@ -21,25 +21,26 @@
229 import os
230
231 from PyQt4 import QtCore, QtGui
232-from openlp.plugins.presentations.lib import FileListData
233 from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD
234
235 # We have to explicitly create separate classes for each plugin
236 # in order for DnD to the Service manager to work correctly.
237 class PresentationListView(BaseListWithDnD):
238 def __init__(self, parent=None):
239- self.PluginName = u'Presentation'
240+ self.PluginName = u'Presentations'
241 BaseListWithDnD.__init__(self, parent)
242
243 class PresentationMediaItem(MediaManagerItem):
244 """
245- This is the custom media manager item for Custom Slides.
246+ This is the Presentation media manager item for Presentation Items.
247+ It can present files using Openoffice
248 """
249 global log
250 log=logging.getLogger(u'PresentationsMediaItem')
251 log.info(u'Presentations Media Item loaded')
252
253- def __init__(self, parent, icon, title):
254+ def __init__(self, parent, icon, title, controllers):
255+ self.controllers = controllers
256 self.TranslationContext = u'PresentationPlugin'
257 self.PluginTextShort = u'Presentation'
258 self.ConfigSection = u'presentation'
259@@ -76,10 +77,13 @@
260
261 def initialise(self):
262 list = self.parent.config.load_list(u'presentations')
263- self.loadPresentationList(list)
264- self.DisplayTypeComboBox.addItem(u'Impress')
265-# self.DisplayTypeComboBox.addItem(u'Powerpoint')
266-# self.DisplayTypeComboBox.addItem(u'Keynote')
267+ self.loadList(list)
268+ for item in self.controllers:
269+ #load the drop down selection
270+ self.DisplayTypeComboBox.addItem(item)
271+ #load the preview toolbars
272+ #self.parent.preview_controller.registerToolbar(item, self.controllers[item])
273+ #self.parent.live_controller.registerToolbar(item, self.controllers[item])
274
275 def loadList(self, list):
276 for file in list:
277@@ -88,14 +92,21 @@
278 item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
279 self.ListView.addItem(item_name)
280
281- def loadPresentationList(self, list):
282- pass
283-# for files in list:
284-# self.PresentationsListData.addRow(files)
285+ def onDeleteClick(self):
286+ item = self.ListView.currentItem()
287+ if item is not None:
288+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
289+ row = self.ListView.row(item)
290+ self.ListView.takeItem(row)
291+ self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList())
292
293- def onPresentationDeleteClick(self):
294- indexes = self.PresentationsListView.selectedIndexes()
295- for index in indexes:
296- current_row = int(index.row())
297- self.PresentationsListData.removeRow(current_row)
298- self.parent.config.set_list(u'Presentations', self.PresentationsListData.getFileList())
299+ def generateSlideData(self, service_item):
300+ items = self.ListView.selectedIndexes()
301+ service_item.title = self.DisplayTypeComboBox.currentText()
302+ service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
303+ for item in items:
304+ bitem = self.ListView.item(item.row())
305+ filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
306+ frame = QtGui.QImage(unicode(filename))
307+ (path, name) = os.path.split(filename)
308+ service_item.add_using_toolbar(path, name)
309
310=== modified file 'openlp/plugins/presentations/presentationplugin.py'
311--- openlp/plugins/presentations/presentationplugin.py 2009-07-09 16:51:25 +0000
312+++ openlp/plugins/presentations/presentationplugin.py 2009-08-11 19:21:52 +0000
313@@ -24,7 +24,7 @@
314 from PyQt4 import QtCore, QtGui
315
316 from openlp.core.lib import Plugin, MediaManagerItem
317-from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, Openoffice
318+from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, impressToolbar
319
320 class PresentationPlugin(Plugin):
321
322@@ -34,25 +34,49 @@
323 def __init__(self, plugin_helpers):
324 # Call the parent constructor
325 log.debug('Initialised')
326+ self.controllers = {}
327 Plugin.__init__(self, u'Presentations', u'1.9.0', plugin_helpers)
328 self.weight = -8
329 # Create the plugin icon
330 self.icon = QtGui.QIcon()
331 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'),
332 QtGui.QIcon.Normal, QtGui.QIcon.Off)
333+ self.dnd_id = u'Presentations'
334
335 def get_settings_tab(self):
336+ """
337+ Create the settings Tab
338+ """
339 self.presentation_tab = PresentationTab()
340 return self.presentation_tab
341
342 def get_media_manager_item(self):
343- # Create the MediaManagerItem object
344- self.media_item = PresentationMediaItem(self, self.icon, u'Presentations')
345+ """
346+ Create the Media Manager List
347+ """
348+ self.media_item = PresentationMediaItem(self, self.icon, u'Presentations', self.controllers)
349 return self.media_item
350
351+ def registerControllers(self, handle, controller):
352+ self.controllers[handle] = controller
353+
354 def check_pre_conditions(self):
355+ """
356+ Check to see if we have any presentation software available
357+ If Not do not install the plugin.
358+ """
359 log.debug('check_pre_conditions')
360- return True
361-# self.openoffice = Openoffice()
362+ impress = True
363+ try:
364+ #Check to see if we have uno installed
365+ import uno
366+ #openoffice = impressToolbar()
367+ self.registerControllers(u'Impress', None)
368+ except:
369+ pass
370+ #If we have no controllers disable plugin
371+ if len(self.controllers) > 0:
372+ return True
373+ else:
374+ return False
375 # return self.openoffice.checkOoPid()
376-
377
378=== modified file 'openlp/plugins/remotes/remoteclient-cli.py'
379--- openlp/plugins/remotes/remoteclient-cli.py 2009-08-10 18:20:46 +0000
380+++ openlp/plugins/remotes/remoteclient-cli.py 2009-08-12 16:29:00 +0000
381@@ -18,37 +18,54 @@
382 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
383 Place, Suite 330, Boston, MA 02111-1307 USA
384 """
385+import socket
386 import sys
387-import logging
388-from PyQt4 import QtNetwork, QtGui, QtCore
389-
390-logging.basicConfig(level=logging.DEBUG,
391- format=u'%(asctime)s:%(msecs)3d %(name)-15s %(levelname)-8s %(message)s',
392- datefmt=u'%m-%d %H:%M:%S', filename=u'openlp-cli.log', filemode=u'w')
393-
394-class OpenLPRemoteCli():
395- global log
396- log = logging.getLogger(u'OpenLP Remote Application')
397- log.info(u'Application Loaded')
398-
399- def __init__(self, argv):
400- log.debug(u'Initialising')
401- try:
402- self.tcpsocket = QtNetwork.QUdpSocket()
403- self.sendData()
404- except:
405- log.error(u'Errow thrown %s', sys.exc_info()[1])
406- print u'Errow thrown ', sys.exc_info()[1]
407-
408- def sendData(self):
409- text = "Alert:Wave to Zak, Superfly"
410- print self.tcpsocket
411- print self.tcpsocket.writeDatagram(text, QtNetwork.QHostAddress(QtNetwork.QHostAddress.Broadcast), 4316)
412-
413- def run(self):
414- pass
415+from optparse import OptionParser
416+
417+
418+def sendData(options, message):
419+ addr = (options.address, options.port)
420+ try:
421+ UDPSock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
422+ UDPSock.sendto(message, addr)
423+ print u'message sent ', message , addr
424+ except:
425+ print u'Errow thrown ', sys.exc_info()[1]
426+
427+def format_message(options):
428+ return u'%s:%s' % (options.event, options.message)
429+
430+def main():
431+ usage = "usage: %prog [options] arg1 arg2"
432+ parser = OptionParser(usage=usage)
433+ parser.add_option("-v", "--verbose",
434+ action="store_true", dest="verbose", default=True,
435+ help="make lots of noise [%default]")
436+ parser.add_option("-p", "--port",
437+ default=4316,
438+ help="IP Port number %default ")
439+ parser.add_option("-a", "--address",
440+ help="Recipient address ")
441+ parser.add_option("-e", "--event",
442+ default=u'Alert',
443+ help="Action to be undertaken")
444+ parser.add_option("-m", "--message",
445+ help="Message to be passed for the action")
446+
447+ (options, args) = parser.parse_args()
448+ if len(args) > 0:
449+ parser.print_help()
450+ parser.error("incorrect number of arguments")
451+ elif options.message is None:
452+ parser.print_help()
453+ parser.error("No message passed")
454+ elif options.address is None:
455+ parser.print_help()
456+ parser.error("IP address missing")
457+ else:
458+ text = format_message(options)
459+ sendData(options, text)
460
461 if __name__ == u'__main__':
462- app = OpenLPRemoteCli(sys.argv)
463- app.run()
464+ main()
465
466
467=== modified file 'openlp/plugins/remotes/remoteplugin.py'
468--- openlp/plugins/remotes/remoteplugin.py 2009-08-10 20:10:20 +0000
469+++ openlp/plugins/remotes/remoteplugin.py 2009-08-12 16:29:00 +0000
470@@ -40,16 +40,18 @@
471 QtCore.SIGNAL(u'readyRead()'), self.readData)
472
473 def readData(self):
474+ log.info(u'Remoted data has arrived')
475 while self.server.hasPendingDatagrams():
476 datagram, host, port = self.server.readDatagram(self.server.pendingDatagramSize())
477 self.handle_datagram(datagram)
478
479 def handle_datagram(self, datagram):
480+ log.info(u'Sending event %s ', datagram)
481 pos = datagram.find(u':')
482- event = unicode(datagram[:pos])
483- payyload = unicode(datagram[pos + 1:])
484- if event == u'Alert':
485- self.event_manager.post_event(Event(EventType.TriggerAlert, payyload))
486+ event = unicode(datagram[:pos].lower())
487+ payload = unicode(datagram[pos + 1:])
488+ if event == u'alert':
489+ self.event_manager.post_event(Event(EventType.TriggerAlert, u'RemotePlugin', payload))
490
491
492
493
494=== modified file 'openlp/plugins/songs/forms/editsongform.py'
495--- openlp/plugins/songs/forms/editsongform.py 2009-08-08 06:19:09 +0000
496+++ openlp/plugins/songs/forms/editsongform.py 2009-08-12 04:57:24 +0000
497@@ -356,7 +356,7 @@
498 self.processTitle()
499 self.songmanager.save_song(self.song)
500 if self.title_change:
501- self.eventmanager.post_event(Event(EventType.LoadSongList))
502+ self.eventmanager.post_event(Event(EventType.LoadSongList), u'EditSongForm')
503 self.close()
504
505 def processLyrics(self):
506
507=== modified file 'openlp/plugins/songs/songsplugin.py'
508--- openlp/plugins/songs/songsplugin.py 2009-08-06 21:30:14 +0000
509+++ openlp/plugins/songs/songsplugin.py 2009-08-12 04:57:24 +0000
510@@ -140,4 +140,4 @@
511 if event.event_type == EventType.LoadSongList :
512 log.debug(u'Load Load Song List Item received')
513 self.media_item.displayResultsSong(self.songmanager.get_songs())
514- Plugin.handle_event(self, event)
515+ return Plugin.handle_event(self, event)