Initial add of Remote Plugin

This commit is contained in:
Tim Bentley 2009-08-10 19:20:46 +01:00
parent dc05294be6
commit 6b7444ea97
6 changed files with 347 additions and 0 deletions

View File

@ -27,6 +27,7 @@ class EventType(object):
"""
# "Default" event - a non-event
Default = 0
TriggerAlert = 1
# General application events
# Service events
LoadServiceItem = 20

View File

View File

@ -0,0 +1,21 @@
# -*- 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-2009 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
"""
from mediaitem import RemoteMediaItem

View File

@ -0,0 +1,215 @@
# -*- 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-2009 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 logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, BaseListWithDnD
class RemoteListView(BaseListWithDnD):
def __init__(self, parent=None):
self.PluginName = u'Remote'
BaseListWithDnD.__init__(self, parent)
class RemoteMediaItem(MediaManagerItem):
"""
This is the custom media manager item for Custom Slides.
"""
global log
log=logging.getLogger(u'RemoteMediaItem')
log.info(u'Remote Media Item loaded')
def __init__(self, parent, icon, title):
MediaManagerItem.__init__(self, parent, icon, title)
self.parent = parent
self.TranslationContext = u'RemotesPlugin'
self.PluginTextShort = u'Remotes'
self.ConfigSection = u'Remotes'
self.ListViewWithDnD_class = RemoteListView
MediaManagerItem.__init__(self, parent, icon, title)
def initialise(self):
pass
def setupUi(self):
# Add a toolbar
self.addToolbar()
# # Create buttons for the toolbar
# ## New Custom Button ##
# self.addToolbarButton(
# translate(u'CustomMediaItem',u'New Custom Item'),
# translate(u'CustomMediaItem',u'Add a new Custom Item'),
# u':/custom/custom_new.png', self.onCustomNewClick, u'CustomNewItem')
# ## Edit Custom Button ##
# self.addToolbarButton(
# translate(u'CustomMediaItem',u'Edit Custom Item'),
# translate(u'CustomMediaItem',u'Edit the selected Custom Item'),
# u':/custom/custom_edit.png', self.onCustomEditClick, u'CustomEditItem')
# ## Delete Custom Button ##
# self.addToolbarButton(
# translate(u'CustomMediaItem',u'Delete Custom Item'),
# translate(u'CustomMediaItem',u'Delete the selected Custom Item'),
# u':/custom/custom_delete.png', self.onCustomDeleteClick, u'CustomDeleteItem')
# ## Separator Line ##
# self.addToolbarSeparator()
# ## Preview Custom Button ##
# self.addToolbarButton(
# translate(u'CustomMediaItem',u'Preview Custom Item'),
# translate(u'CustomMediaItem',u'Preview the selected Custom Item'),
# u':/system/system_preview.png', self.onCustomPreviewClick, u'CustomPreviewItem')
# ## Live Custom Button ##
# self.addToolbarButton(
# translate(u'CustomMediaItem',u'Go Live'),
# translate(u'CustomMediaItem', u'Send the selected Custom live'),
# u':/system/system_live.png', self.onCustomLiveClick, u'CustomLiveItem')
# ## Add Custom Button ##
# self.addToolbarButton(
# translate(u'CustomMediaItem',u'Add Custom To Service'),
# translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'),
# u':/system/system_add.png', self.onCustomAddClick, u'CustomAddItem')
# # Add the Customlist widget
# self.CustomWidget = QtGui.QWidget(self)
# sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
# sizePolicy.setHorizontalStretch(0)
# sizePolicy.setVerticalStretch(0)
# sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth())
# self.CustomWidget.setSizePolicy(sizePolicy)
# self.CustomWidget.setObjectName(u'CustomWidget')
# # Add the Custom widget to the page layout
# self.PageLayout.addWidget(self.CustomWidget)
# self.CustomListView = CustomList()
# self.CustomListView.setAlternatingRowColors(True)
# self.CustomListData = TextListData()
# self.CustomListView.setModel(self.CustomListData)
# self.CustomListView.setDragEnabled(True)
# self.PageLayout.addWidget(self.CustomListView)
# # Signals
# QtCore.QObject.connect(self.CustomListView,
# QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onCustomPreviewClick)
# #define and add the context menu
# self.CustomListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
# self.CustomListView.addAction(self.contextMenuAction(self.CustomListView,
# ':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'),
# self.onCustomEditClick))
# self.CustomListView.addAction(self.contextMenuSeparator(self.CustomListView))
# self.CustomListView.addAction(self.contextMenuAction(
# self.CustomListView, ':/system/system_preview.png',
# translate(u'CustomMediaItem',u'&Preview Custom'), self.onCustomPreviewClick))
# self.CustomListView.addAction(self.contextMenuAction(
# self.CustomListView, ':/system/system_live.png',
# translate(u'CustomMediaItem',u'&Show Live'), self.onCustomLiveClick))
# self.CustomListView.addAction(self.contextMenuAction(
# self.CustomListView, ':/system/system_add.png',
# translate(u'CustomMediaItem',u'&Add to Service'), self.onCustomAddClick))
# def retranslateUi(self):
# self.ClearTextButton.setText(translate(u'CustomMediaItem', u'Clear'))
# self.SearchTextButton.setText(translate(u'CustomMediaItem', u'Search'))
# def initialise(self):
# self.loadCustomList(self.parent.custommanager.get_all_slides())
#
# def loadCustomList(self, list):
# self.CustomListData.resetStore()
# for CustomSlide in list:
# self.CustomListData.addRow(CustomSlide.id,CustomSlide.title)
#
# def onClearTextButtonClick(self):
# """
# Clear the search text.
# """
# self.SearchTextEdit.clear()
#
# def onSearchTextEditChanged(self, text):
# # only search if > 3 characters
# if len(text) > 3:
# self.onSearchTextButtonClick()
#
# def onSearchTextButtonClick(self):
# search_keywords = str(self.SearchTextEdit.displayText())
# search_results = []
# search_type = self.SearchTypeComboBox.currentText()
# search_results = self.Custommanager.search_Custom_lyrics(search_keywords)
# self._display_results(search_results)
#
# def onCustomNewClick(self):
# self.parent.edit_custom_form.loadCustom(0)
# self.parent.edit_custom_form.exec_()
# self.initialise()
#
# def onCustomEditClick(self):
# indexes = self.CustomListView.selectedIndexes()
# for index in indexes:
# self.parent.edit_custom_form.loadCustom(self.CustomListData.getId(index))
# self.parent.edit_custom_form.exec_()
# self.initialise()
#
# def onCustomDeleteClick(self):
# indexes = self.CustomListView.selectedIndexes()
# for index in indexes:
# id = self.CustomListData.getId(index)
# self.parent.custommanager.delete_custom(id)
# self.CustomListData.deleteRow(index)
#
# def onCustomPreviewClick(self):
# log.debug(u'Custom Preview Requested')
# service_item = ServiceItem(self.parent)
# service_item.addIcon(u':/media/media_song.png')
# self.generateSlideData(service_item)
# self.parent.preview_controller.addServiceItem(service_item)
#
# def onCustomLiveClick(self):
# log.debug(u'Custom Live Requested')
# service_item = ServiceItem(self.parent)
# service_item.addIcon(u':/media/media_song.png')
# self.generateSlideData(service_item)
# self.parent.live_controller.addServiceItem(service_item)
#
# def onCustomAddClick(self):
# log.debug(u'Custom Add Requested')
# service_item = ServiceItem(self.parent)
# service_item.addIcon(u':/media/media_song.png')
# self.generateSlideData(service_item)
# self.parent.service_manager.addServiceItem(service_item)
#
# def generateSlideData(self, service_item):
# raw_slides =[]
# raw_footer = []
# slide = None
# theme = None
# indexes = self.CustomListView.selectedIndexes()
# for index in indexes:
# id = self.CustomListData.getId(index)
# customSlide = self.parent.custommanager.get_custom(id)
# title = customSlide.title
# credit = customSlide.credits
# theme = customSlide.theme_name
# if len(theme) is not 0 :
# service_item.theme = theme
# songXML=SongXMLParser(customSlide.text)
# verseList = songXML.get_verses()
# for verse in verseList:
# raw_slides.append(verse[1])
# raw_footer.append(title + u' '+ credit)
# if theme is not None:
# service_item.title = title
# for slide in raw_slides:
# service_item.add_from_text(slide[:30], slide)
# service_item.raw_footer = raw_footer

View File

@ -0,0 +1,54 @@
#!/usr/bin/env python
# -*- 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-2009 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 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
if __name__ == u'__main__':
app = OpenLPRemoteCli(sys.argv)
app.run()

View File

@ -0,0 +1,56 @@
# -*- 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-2009 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 logging
import sys
from PyQt4 import QtNetwork, QtGui, QtCore
from openlp.core.lib import Plugin, Event, EventType
class RemotesPlugin(Plugin):
global log
log = logging.getLogger(u'RemotesPlugin')
log.info(u'Remote Plugin loaded')
def __init__(self, plugin_helpers):
# Call the parent constructor
Plugin.__init__(self, u'Remotes', u'1.9.0', plugin_helpers)
self.weight = -1
self.server = QtNetwork.QUdpSocket()
self.server.bind(4316)
QtCore.QObject.connect(self.server,
QtCore.SIGNAL(u'readyRead()'), self.readData)
def readData(self):
while self.server.hasPendingDatagrams():
datagram, host, port = self.server.readDatagram(self.server.pendingDatagramSize())
self.handle_datagram(datagram)
def handle_datagram(self, datagram):
pos = datagram.find(u':')
event = datagram[:pos]
payyload = datagram[pos + 1:]
if event == u'Alert':
self.event_manager.post_event(Event(EventType.TriggerAlert, payyload))