From ea1321ef202a174335bbcc01ff207cbcb5a22914 Mon Sep 17 00:00:00 2001 From: rimach Date: Wed, 15 Sep 2010 22:51:01 +0200 Subject: [PATCH 1/4] add pipe using for soffice --- .../plugins/presentations/lib/impresscontroller.py | 14 +++++++++++--- openlp/plugins/songs/lib/oooimport.py | 12 +++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 9ada43a5a..582368a4e 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -98,7 +98,12 @@ class ImpressController(PresentationController): self.manager._FlagAsMethod(u'Bridge_GetValueObject') else: # -headless - cmd = u'openoffice.org -nologo -norestore -minimized -invisible -nofirststartwizard -accept="socket,host=localhost,port=2002;urp;"' + #connection_type = u'socket' + connection_type = u'pipe,name=openlp_pipe:' + cmd = u'openoffice.org -nologo -norestore -minimized ' \ + + u'-invisible -nofirststartwizard ' \ + + '-accept="' + connection_type \ + + u'socket,host=localhost,port=2002;urp;"' self.process = QtCore.QProcess() self.process.startDetached(cmd) self.process.waitForStarted() @@ -117,11 +122,14 @@ class ImpressController(PresentationController): u'UnoUrlResolver') resolver = context.ServiceManager.createInstanceWithContext( u'com.sun.star.bridge.UnoUrlResolver', context) + #connection_type = u'socket' + connection_type = u'pipe,name=openlp_pipe:' while ctx is None and loop < 3: try: log.debug(u'get UNO Desktop Openoffice - resolve') - ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;' - u'urp;StarOffice.ComponentContext') + ctx = resolver.resolve(u'uno:' + connection_type \ + + u',host=localhost,' \ + + u'port=2002;urp;StarOffice.ComponentContext') except: log.exception(u'Unable to find running instance ') self.start_process() diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index e8c723c0e..b092d2962 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -94,6 +94,8 @@ class OooImport(SongImport): Start OpenOffice.org process TODO: The presentation/Impress plugin may already have it running """ + #connection_type = u'socket' + connection_type = u'pipe,name=openlp_pipe:' if os.name == u'nt': self.start_ooo_process() self.desktop = self.manager.createInstance( @@ -106,8 +108,9 @@ class OooImport(SongImport): loop = 0 while ctx is None and loop < 5: try: - ctx = resolver.resolve(u'uno:socket,host=localhost,' \ - + 'port=2002;urp;StarOffice.ComponentContext') + ctx = resolver.resolve(u'uno:' + connection_type \ + + u',host=localhost,' \ + + u'port=2002;urp;StarOffice.ComponentContext') except: pass self.start_ooo_process() @@ -117,6 +120,8 @@ class OooImport(SongImport): "com.sun.star.frame.Desktop", ctx) def start_ooo_process(self): + #connection_type = u'socket' + connection_type = u'pipe,name=openlp_pipe:' try: if os.name == u'nt': self.manager = Dispatch(u'com.sun.star.ServiceManager') @@ -125,7 +130,8 @@ class OooImport(SongImport): else: cmd = u'openoffice.org -nologo -norestore -minimized ' \ + u'-invisible -nofirststartwizard ' \ - + '-accept="socket,host=localhost,port=2002;urp;"' + + '-accept="' + connection_type \ + + u'socket,host=localhost,port=2002;urp;"' process = QtCore.QProcess() process.startDetached(cmd) process.waitForStarted() From d2bf1fedae06f58c554252726c0d022b354e57f1 Mon Sep 17 00:00:00 2001 From: rimach Date: Thu, 16 Sep 2010 23:01:44 +0200 Subject: [PATCH 2/4] correct piped soffice start, fix Python2.5 problem with unicode strings in optparse --- openlp.pyw | 22 +++++++------- .../presentations/lib/impresscontroller.py | 28 +++++++++++------- openlp/plugins/songs/lib/oooimport.py | 28 +++++++++++------- resources/images/about-new.bmp | Bin resources/openlp.desktop | 17 +++++++++-- 5 files changed, 60 insertions(+), 35 deletions(-) mode change 100755 => 100644 resources/images/about-new.bmp mode change 100644 => 100755 resources/openlp.desktop diff --git a/openlp.pyw b/openlp.pyw index 9327a1168..80b49321e 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -162,18 +162,18 @@ def main(): the PyQt4 Application. """ # Set up command line options. - usage = u'Usage: %prog [options] [qt-options]' + usage = 'Usage: %prog [options] [qt-options]' parser = OptionParser(usage=usage) - parser.add_option(u'-e', u'--no-error-form', dest=u'no_error_form', - action=u'store_true', help=u'Disable the error notification form.') - parser.add_option(u'-l', u'--log-level', dest=u'loglevel', - default=u'warning', metavar=u'LEVEL', help=u'Set logging to LEVEL ' - u'level. Valid values are "debug", "info", "warning".') - parser.add_option(u'-p', u'--portable', dest=u'portable', - action=u'store_true', help=u'Specify if this should be run as a ' - u'portable app, off a USB flash drive (not implemented).') - parser.add_option(u'-s', u'--style', dest=u'style', - help=u'Set the Qt4 style (passed directly to Qt4).') + parser.add_option('-e', '--no-error-form', dest='no_error_form', + action='store_true', help='Disable the error notification form.') + parser.add_option('-l', '--log-level', dest='loglevel', + default='warning', metavar='LEVEL', help='Set logging to LEVEL ' + 'level. Valid values are "debug", "info", "warning".') + parser.add_option('-p', '--portable', dest='portable', + action='store_true', help='Specify if this should be run as a ' + 'portable app, off a USB flash drive (not implemented).') + parser.add_option('-s', '--style', dest='style', + help='Set the Qt4 style (passed directly to Qt4).') # Set up logging log_path = AppLocation.get_directory(AppLocation.CacheDir) if not os.path.exists(log_path): diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 582368a4e..8d2f8e76e 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -74,6 +74,7 @@ class ImpressController(PresentationController): self.process = None self.desktop = None self.manager = None + self.uno_connection_type = u'pipe' #u'socket' def check_available(self): """ @@ -98,12 +99,14 @@ class ImpressController(PresentationController): self.manager._FlagAsMethod(u'Bridge_GetValueObject') else: # -headless - #connection_type = u'socket' - connection_type = u'pipe,name=openlp_pipe:' - cmd = u'openoffice.org -nologo -norestore -minimized ' \ - + u'-invisible -nofirststartwizard ' \ - + '-accept="' + connection_type \ - + u'socket,host=localhost,port=2002;urp;"' + if self.uno_connection_type == u'pipe': + cmd = u'openoffice.org -nologo -norestore -minimized ' \ + + u'-invisible -nofirststartwizard ' \ + + u'-accept=pipe,name=openlp_pipe;urp;' + else: + cmd = u'openoffice.org -nologo -norestore -minimized ' \ + + u'-invisible -nofirststartwizard ' \ + + u'-accept=socket,host=localhost,port=2002;urp;' self.process = QtCore.QProcess() self.process.startDetached(cmd) self.process.waitForStarted() @@ -123,13 +126,18 @@ class ImpressController(PresentationController): resolver = context.ServiceManager.createInstanceWithContext( u'com.sun.star.bridge.UnoUrlResolver', context) #connection_type = u'socket' - connection_type = u'pipe,name=openlp_pipe:' + connection_type = u'pipe,name=openlp_pipe' while ctx is None and loop < 3: try: log.debug(u'get UNO Desktop Openoffice - resolve') - ctx = resolver.resolve(u'uno:' + connection_type \ - + u',host=localhost,' \ - + u'port=2002;urp;StarOffice.ComponentContext') + if self.uno_connection_type == u'pipe': + ctx = resolver.resolve(u'uno:' \ + + u'pipe,name=openlp_pipe;' \ + + u'urp;StarOffice.ComponentContext') + else: + ctx = resolver.resolve(u'uno:' \ + + u'socket,host=localhost,port=2002;' \ + + u'urp;StarOffice.ComponentContext') except: log.exception(u'Unable to find running instance ') self.start_process() diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index b092d2962..26a0abfcc 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -59,6 +59,7 @@ class OooImport(SongImport): self.document = None self.process_started = False self.filenames = kwargs[u'filenames'] + self.uno_connection_type = u'pipe' #u'socket' QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'song_stop_import'), self.stop_import) @@ -94,8 +95,6 @@ class OooImport(SongImport): Start OpenOffice.org process TODO: The presentation/Impress plugin may already have it running """ - #connection_type = u'socket' - connection_type = u'pipe,name=openlp_pipe:' if os.name == u'nt': self.start_ooo_process() self.desktop = self.manager.createInstance( @@ -108,9 +107,14 @@ class OooImport(SongImport): loop = 0 while ctx is None and loop < 5: try: - ctx = resolver.resolve(u'uno:' + connection_type \ - + u',host=localhost,' \ - + u'port=2002;urp;StarOffice.ComponentContext') + if self.uno_connection_type == u'pipe': + ctx = resolver.resolve(u'uno:' \ + + u'pipe,name=openlp_pipe;' \ + + u'urp;StarOffice.ComponentContext') + else: + ctx = resolver.resolve(u'uno:' \ + + u'socket,host=localhost,port=2002;' \ + + u'urp;StarOffice.ComponentContext') except: pass self.start_ooo_process() @@ -120,18 +124,20 @@ class OooImport(SongImport): "com.sun.star.frame.Desktop", ctx) def start_ooo_process(self): - #connection_type = u'socket' - connection_type = u'pipe,name=openlp_pipe:' try: if os.name == u'nt': self.manager = Dispatch(u'com.sun.star.ServiceManager') self.manager._FlagAsMethod(u'Bridge_GetStruct') self.manager._FlagAsMethod(u'Bridge_GetValueObject') else: - cmd = u'openoffice.org -nologo -norestore -minimized ' \ - + u'-invisible -nofirststartwizard ' \ - + '-accept="' + connection_type \ - + u'socket,host=localhost,port=2002;urp;"' + if self.uno_connection_type == u'pipe': + cmd = u'openoffice.org -nologo -norestore -minimized ' \ + + u'-invisible -nofirststartwizard ' \ + + u'-accept=pipe,name=openlp_pipe;urp;' + else: + cmd = u'openoffice.org -nologo -norestore -minimized ' \ + + u'-invisible -nofirststartwizard ' \ + + u'-accept=socket,host=localhost,port=2002;urp;' process = QtCore.QProcess() process.startDetached(cmd) process.waitForStarted() diff --git a/resources/images/about-new.bmp b/resources/images/about-new.bmp old mode 100755 new mode 100644 diff --git a/resources/openlp.desktop b/resources/openlp.desktop old mode 100644 new mode 100755 index 0c843bd69..684119773 --- a/resources/openlp.desktop +++ b/resources/openlp.desktop @@ -1,10 +1,21 @@ [Desktop Entry] +Categories=AudioVideo; +Comment[de]= +Comment= Encoding=UTF-8 -Name=OpenLP -GenericName=Church lyrics projection Exec=openlp +GenericName[de]=Church lyrics projection +GenericName=Church lyrics projection Icon=openlp +MimeType= +Name[de]=OpenLP +Name=OpenLP +Path= StartupNotify=true Terminal=false +TerminalOptions= Type=Application -Categories=AudioVideo; +X-DBUS-ServiceName= +X-DBUS-StartupType= +X-KDE-SubstituteUID=false +X-KDE-Username= From ba346502e44da0470ae86d37c42c9819386beb1c Mon Sep 17 00:00:00 2001 From: rimach Date: Thu, 16 Sep 2010 23:04:02 +0200 Subject: [PATCH 3/4] Head --- resources/openlp.desktop | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/resources/openlp.desktop b/resources/openlp.desktop index 684119773..d84f69297 100755 --- a/resources/openlp.desktop +++ b/resources/openlp.desktop @@ -1,21 +1,11 @@ +#!/usr/bin/env xdg-open [Desktop Entry] -Categories=AudioVideo; -Comment[de]= -Comment= Encoding=UTF-8 -Exec=openlp -GenericName[de]=Church lyrics projection -GenericName=Church lyrics projection -Icon=openlp -MimeType= -Name[de]=OpenLP Name=OpenLP -Path= +GenericName=Church lyrics projection +Exec=openlp +Icon=openlp StartupNotify=true Terminal=false -TerminalOptions= Type=Application -X-DBUS-ServiceName= -X-DBUS-StartupType= -X-KDE-SubstituteUID=false -X-KDE-Username= +Categories=AudioVideo; From 86bed937f5983171e1e688f119a73c31524f2a3d Mon Sep 17 00:00:00 2001 From: rimach Date: Sat, 18 Sep 2010 20:56:57 +0200 Subject: [PATCH 4/4] Remove unused lines --- openlp/plugins/presentations/lib/impresscontroller.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 8d2f8e76e..d054c3e9c 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -125,8 +125,6 @@ class ImpressController(PresentationController): u'UnoUrlResolver') resolver = context.ServiceManager.createInstanceWithContext( u'com.sun.star.bridge.UnoUrlResolver', context) - #connection_type = u'socket' - connection_type = u'pipe,name=openlp_pipe' while ctx is None and loop < 3: try: log.debug(u'get UNO Desktop Openoffice - resolve')