Bypass message if requested from remote plugin

Fixes: https://launchpad.net/bugs/796195
This commit is contained in:
Tim Bentley 2011-09-06 18:53:43 +01:00
parent 7aafc658be
commit a328d1c7c7
8 changed files with 41 additions and 31 deletions

View File

@ -485,7 +485,8 @@ class MediaManagerItem(QtGui.QWidget):
"""
pass
def generateSlideData(self, serviceItem, item=None, xmlVersion=False):
def generateSlideData(self, serviceItem, item=None, xmlVersion=False,
remote=False):
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs '
u'to be defined by the plugin')
@ -539,12 +540,12 @@ class MediaManagerItem(QtGui.QWidget):
else:
self.goLive()
def goLive(self, item_id=None):
def goLive(self, item_id=None, remote=False):
log.debug(u'%s Live requested', self.plugin.name)
item = None
if item_id:
item = self.createItemFromId(item_id)
serviceItem = self.buildServiceItem(item)
serviceItem = self.buildServiceItem(item, remote=remote)
if serviceItem:
if not item_id:
serviceItem.from_plugin = True
@ -574,8 +575,8 @@ class MediaManagerItem(QtGui.QWidget):
for item in items:
self.addToService(item)
def addToService(self, item=None, replace=None):
serviceItem = self.buildServiceItem(item, True)
def addToService(self, item=None, replace=None, remote=False):
serviceItem = self.buildServiceItem(item, True, remote=remote)
if serviceItem:
serviceItem.from_plugin = False
self.plugin.serviceManager.addServiceItem(serviceItem,
@ -608,13 +609,13 @@ class MediaManagerItem(QtGui.QWidget):
unicode(translate('OpenLP.MediaManagerItem',
'You must select a %s service item.')) % self.title)
def buildServiceItem(self, item=None, xmlVersion=False):
def buildServiceItem(self, item=None, xmlVersion=False, remote=False):
"""
Common method for generating a service item
"""
serviceItem = ServiceItem(self.plugin)
serviceItem.add_icon(self.plugin.icon_path)
if self.generateSlideData(serviceItem, item, xmlVersion):
if self.generateSlideData(serviceItem, item, xmlVersion, remote):
return serviceItem
else:
return None

View File

@ -788,7 +788,8 @@ class BibleMediaItem(MediaManagerItem):
items.append(bible_verse)
return items
def generateSlideData(self, service_item, item=None, xmlVersion=False):
def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False):
"""
Generates and formats the slides for the service item as well as the
service item's title.

View File

@ -222,7 +222,8 @@ class CustomMediaItem(MediaManagerItem):
def onFocus(self):
self.searchTextEdit.setFocus()
def generateSlideData(self, service_item, item=None, xmlVersion=False):
def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False):
raw_footer = []
slide = None
theme = None

View File

@ -139,7 +139,8 @@ class ImageMediaItem(MediaManagerItem):
if not initialLoad:
self.plugin.formparent.finishedProgressBar()
def generateSlideData(self, service_item, item=None, xmlVersion=False):
def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False):
background = QtGui.QColor(QtCore.QSettings().value(self.settingsSection
+ u'/background color', QtCore.QVariant(u'#000000')))
if item:
@ -166,6 +167,7 @@ class ImageMediaItem(MediaManagerItem):
items.remove(item)
# We cannot continue, as all images do not exist.
if not items:
if not remote:
critical_error_message_box(
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
unicode(translate('ImagePlugin.MediaItem',

View File

@ -129,13 +129,15 @@ class MediaMediaItem(MediaManagerItem):
'There was a problem replacing your background, '
'the media file "%s" no longer exists.')) % filename)
def generateSlideData(self, service_item, item=None, xmlVersion=False):
def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False):
if item is None:
item = self.listView.currentItem()
if item is None:
return False
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
if not os.path.exists(filename):
if not remote:
# File is no longer present
critical_error_message_box(
translate('MediaPlugin.MediaItem', 'Missing Media File'),

View File

@ -233,7 +233,8 @@ class PresentationMediaItem(MediaManagerItem):
SettingsManager.set_list(self.settingsSection,
u'presentations', self.getFileList())
def generateSlideData(self, service_item, item=None, xmlVersion=False):
def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False):
"""
Load the relevant information for displaying the presentation
in the slidecontroller. In the case of powerpoints, an image
@ -275,6 +276,7 @@ class PresentationMediaItem(MediaManagerItem):
return True
else:
# File is no longer present
if not remote:
critical_error_message_box(
translate('PresentationPlugin.MediaItem',
'Missing Presentation'),

View File

@ -528,7 +528,7 @@ class HttpConnection(object):
id = json.loads(self.url_params[u'data'][0])[u'request'][u'id']
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
if plugin.status == PluginStatus.Active and plugin.mediaItem:
plugin.mediaItem.goLive(id)
plugin.mediaItem.goLive(id, remote=True)
def add_to_service(self, type):
"""
@ -538,7 +538,7 @@ class HttpConnection(object):
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
if plugin.status == PluginStatus.Active and plugin.mediaItem:
item_id = plugin.mediaItem.createItemFromId(id)
plugin.mediaItem.addToService(item_id)
plugin.mediaItem.addToService(item_id, remote=True)
def send_response(self, response):
http = u'HTTP/1.1 %s\r\n' % response.code

View File

@ -411,7 +411,8 @@ class SongMediaItem(MediaManagerItem):
self.plugin.manager.save_object(new_song)
self.onSongListLoad()
def generateSlideData(self, service_item, item=None, xmlVersion=False):
def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False):
log.debug(u'generateSlideData (%s:%s)' % (service_item, item))
item_id = self._getIdOfItemToGenerate(item, self.remoteSong)
service_item.add_capability(ItemCapabilities.CanEdit)