Example #1
0
 def install(self):
     """
         Install missing plugins
     """
     try:
         context = GstPbutils.InstallPluginsContext.new()
         try:
             context.set_desktop_id('lollypop.desktop')
         except:
             pass  # Not supported by Ubuntu VIVID
         details = []
         for message in self._messages:
             detail = \
                 GstPbutils.missing_plugin_message_get_installer_detail(
                     message)
             details.append(detail)
         GstPbutils.install_plugins_async(
             details,
             context,
             self._null)
         if Lp.notify is not None:
             GLib.timeout_add(
                 10000,
                 Lp.notify.send,
                 _("Restart lollypop after installing codecs"))
     except Exception as e:
         print("Codecs::__init__(): %s" % e)
Example #2
0
 def on_gst_element(self, bus, message):
     if GstPbutils.is_missing_plugin_message(message):
         if GstPbutils.install_plugins_supported():
             details = GstPbutils.missing_plugin_message_get_installer_detail(message)
             GstPbutils.install_plugins_async([details,], None, self.on_gst_plugin_installed, None)
         else:
             self.error_dialog(_("Missing codec"), None,
                     submsg=_("GStreamer is missing a plugin and it could not be automatically installed. Either manually install it or try another quality setting."))
Example #3
0
 def on_gst_element(self, bus, message):
     if GstPbutils.is_missing_plugin_message(message):
         if GstPbutils.install_plugins_supported():
             details = GstPbutils.missing_plugin_message_get_installer_detail(message)
             GstPbutils.install_plugins_async([details,], None, self.on_gst_plugin_installed, None)
         else:
             self.error_dialog(_("Missing codec"), None,
                     submsg=_("GStreamer is missing a plugin and it could not be automatically installed. Either manually install it or try another quality setting."))
Example #4
0
 def _on_element(self, bus, message):
     if GstPbutils.is_missing_plugin_message(message):
         if GstPbutils.install_plugins_supported():
             details = (
                 GstPbutils.missing_plugin_message_get_installer_detail(
                     message))
             GstPbutils.install_plugins_async(
                 [details], None, self._plugin_installation_complete, None)
         else:
             self.emit("error", "Missing codec",
                       "GStreamer is missing a plugin and it could not be "
                       "automatically installed. Either manually install "
                       "it or try another quality setting.",
                       False)
Example #5
0
    def __handle_missing_plugin(self, message):
        get_installer_detail = \
            GstPbutils.missing_plugin_message_get_installer_detail
        get_description = GstPbutils.missing_plugin_message_get_description

        details = get_installer_detail(message)
        if details is None:
            return

        self.stop()

        format_desc = get_description(message)
        title = _(u"No GStreamer element found to handle media format")
        error_details = _(u"Media format: %(format-description)s") % {
            "format-description": format_desc.decode("utf-8")
        }

        def install_done_cb(plugins_return, *args):
            print_d("Gstreamer plugin install return: %r" % plugins_return)
            Gst.update_registry()

        context = GstPbutils.InstallPluginsContext.new()
        res = GstPbutils.install_plugins_async([details], context,
                                               install_done_cb, None)
        print_d("Gstreamer plugin install result: %r" % res)

        if res in (GstPbutils.InstallPluginsReturn.HELPER_MISSING,
                   GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE):
            self._error(PlayerError(title, error_details))
Example #6
0
    def __handle_missing_plugin(self, message):
        get_installer_detail = \
            GstPbutils.missing_plugin_message_get_installer_detail
        get_description = GstPbutils.missing_plugin_message_get_description

        details = get_installer_detail(message)
        if details is None:
            return

        self.stop()

        format_desc = get_description(message)
        title = _(u"No GStreamer element found to handle media format")
        error_details = _(u"Media format: %(format-description)s") % {
            "format-description": format_desc.decode("utf-8")}

        def install_done_cb(plugins_return, *args):
            print_d("Gstreamer plugin install return: %r" % plugins_return)
            Gst.update_registry()

        context = GstPbutils.InstallPluginsContext.new()
        res = GstPbutils.install_plugins_async(
            [details], context, install_done_cb, None)
        print_d("Gstreamer plugin install result: %r" % res)

        if res in (GstPbutils.InstallPluginsReturn.HELPER_MISSING,
                GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE):
            self._error(PlayerError(title, error_details))
Example #7
0
    def _installPlugins(self, details, missingPluginsCallback):
        context = GstPbutils.InstallPluginsContext()
        if self.app.system.has_x11():
            context.set_xid(self.window.xid)

        res = GstPbutils.install_plugins_async(details, context,
                                               missingPluginsCallback)
        return res
Example #8
0
    def _start_plugin_installation(self, missing_plugin_messages, confirm_search):
        install_ctx = GstPbutils.InstallPluginsContext.new()

        if self._gst_plugins_base_check_version(1, 5, 0):
            install_ctx.set_desktop_id('gnome-music.desktop')
            install_ctx.set_confirm_search(confirm_search)

            startup_id = '_TIME%u' % Gtk.get_current_event_time()
            install_ctx.set_startup_notification_id(startup_id)

        installer_details = []
        for message in missing_plugin_messages:
            installer_detail = GstPbutils.missing_plugin_message_get_installer_detail(message)
            installer_details.append(installer_detail)

        def on_install_done(res):
            # We get the callback too soon, before the installation has
            # actually finished. Do nothing for now.
            pass

        GstPbutils.install_plugins_async(installer_details, install_ctx, on_install_done)
Example #9
0
 def install(self):
     """
         Install missing plugins
     """
     if not GstPbutils.install_plugins_supported():
         return
     try:
         context = GstPbutils.InstallPluginsContext.new()
         try:
             context.set_desktop_id('org.gnome.Lollypop.desktop')
         except:
             pass  # Not supported by Ubuntu VIVID
         details = []
         for message in self._messages:
             detail = \
                 GstPbutils.missing_plugin_message_get_installer_detail(
                     message)
             details.append(detail)
         GstPbutils.install_plugins_async(details, context, self.__null)
     except Exception as e:
         print("Codecs::__init__(): %s" % e)
Example #10
0
    def _start_plugin_installation(self, missing_plugin_messages, confirm_search):
        install_ctx = GstPbutils.InstallPluginsContext.new()

        if self._gst_plugins_base_check_version(1, 5, 0):
            install_ctx.set_desktop_id('org.gnome.Music.desktop')
            install_ctx.set_confirm_search(confirm_search)

            startup_id = '_TIME%u' % Gtk.get_current_event_time()
            install_ctx.set_startup_notification_id(startup_id)

        installer_details = []
        for message in missing_plugin_messages:
            installer_detail = GstPbutils.missing_plugin_message_get_installer_detail(message)
            installer_details.append(installer_detail)

        def on_install_done(res):
            # We get the callback too soon, before the installation has
            # actually finished. Do nothing for now.
            pass

        GstPbutils.install_plugins_async(installer_details, install_ctx, on_install_done)
Example #11
0
 def install(self):
     """
         Install missing plugins
     """
     try:
         context = GstPbutils.InstallPluginsContext.new()
         try:
             context.set_desktop_id('lollypop.desktop')
         except:
             pass  # Not supported by Ubuntu VIVID
         details = []
         for message in self._messages:
             detail = \
                 GstPbutils.missing_plugin_message_get_installer_detail(
                     message)
             details.append(detail)
         GstPbutils.install_plugins_async(
             details,
             context,
             self._null)
     except Exception as e:
         print("Codecs::__init__(): %s" % e)
Example #12
0
    def _start_plugin_installation(
            self, missing_plugin_messages, confirm_search):
        install_ctx = GstPbutils.InstallPluginsContext.new()
        application_id = self._application.props.application_id
        install_ctx.set_desktop_id(application_id + '.desktop')
        install_ctx.set_confirm_search(confirm_search)

        startup_id = "_TIME{}".format(Gtk.get_current_event_time())
        install_ctx.set_startup_notification_id(startup_id)

        installer_details = []
        get_details = GstPbutils.missing_plugin_message_get_installer_detail
        for message in missing_plugin_messages:
            installer_detail = get_details(message)
            installer_details.append(installer_detail)

        def on_install_done(res):
            # We get the callback too soon, before the installation has
            # actually finished. Do nothing for now.
            pass

        GstPbutils.install_plugins_async(
            installer_details, install_ctx, on_install_done)
Example #13
0
    def _start_plugin_installation(
            self, missing_plugin_messages, confirm_search):
        install_ctx = GstPbutils.InstallPluginsContext.new()
        application_id = self._application.props.application_id
        install_ctx.set_desktop_id(application_id + '.desktop')
        install_ctx.set_confirm_search(confirm_search)

        startup_id = "_TIME{}".format(Gtk.get_current_event_time())
        install_ctx.set_startup_notification_id(startup_id)

        installer_details = []
        get_details = GstPbutils.missing_plugin_message_get_installer_detail
        for message in missing_plugin_messages:
            installer_detail = get_details(message)
            installer_details.append(installer_detail)

        def on_install_done(res):
            # We get the callback too soon, before the installation has
            # actually finished. Do nothing for now.
            pass

        GstPbutils.install_plugins_async(
            installer_details, install_ctx, on_install_done)
Example #14
0
 def __getMissingElement(self, message, window_id = 0):
     if gst.pygst_version < (0, 10, 10):
         print _("This version of gstreamer can't handle missing elements")
         return
     self.errors.append(str(message.structure["type"]))
     self.errors.append(str(message.structure["detail"]))
     self.errors.append(str(message.structure["name"]))
     detail = pbutils.missing_plugin_message_get_installer_detail(message)
     context = pbutils.InstallPluginsContext()
     
     if window_id:
         context.set_x_id(window_id)
         
     msg = pbutils.install_plugins_async([detail], context,self.__pbutils_plugin_installed_cb)
    def __message(self, bus, message, librarian):
        if message.type == Gst.MessageType.EOS:
            print_d("Stream EOS")
            if not self._in_gapless_transition:
                self._source.next_ended()
            self._end(False)
        elif message.type == Gst.MessageType.TAG:
            self.__tag(message.parse_tag(), librarian)
        elif message.type == Gst.MessageType.ERROR:
            err, debug = message.parse_error()
            err = str(err).decode(const.ENCODING, 'replace')
            self._error(err)
        elif message.type == Gst.MessageType.STREAM_START:
            if self._in_gapless_transition:
                print_d("Stream changed")
                self._end(False)
        elif message.type == Gst.MessageType.ASYNC_DONE:
            if self._active_seeks:
                song, pos = self._active_seeks.pop(0)
                if song is self.song:
                    self.emit("seek", song, pos)
        elif message.type == Gst.MessageType.ELEMENT:
            message_name = message.get_structure().get_name()

            if message_name == "missing-plugin":
                self.stop()
                details = \
                    GstPbutils.missing_plugin_message_get_installer_detail(
                        message)
                if details is not None:
                    message = (_(
                        "No GStreamer element found to handle the following "
                        "media format: %(format_details)r") %
                        {"format_details": details})
                    print_w(message)

                    context = GstPbutils.InstallPluginsContext.new()

                    # TODO: track success
                    def install_done_cb(*args):
                        Gst.update_registry()
                    res = GstPbutils.install_plugins_async(
                        [details], context, install_done_cb, None)
                    print_d("Gstreamer plugin install result: %r" % res)
                    if res in (GstPbutils.InstallPluginsReturn.HELPER_MISSING,
                            GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE):
                        self._error(message)

        return True
Example #16
0
    def __handle_missing_plugin(self, message):
        get_installer_detail = \
            GstPbutils.missing_plugin_message_get_installer_detail
        get_description = GstPbutils.missing_plugin_message_get_description

        details = get_installer_detail(message)
        if details is None:
            return

        self.stop()

        format_desc = get_description(message)
        title = _(u"No GStreamer element found to handle media format")
        error_details = _(u"Media format: %(format-description)s") % {
            "format-description": util.gdecode(format_desc)
        }

        def install_done_cb(plugins_return, *args):
            print_d("Gstreamer plugin install return: %r" % plugins_return)
            Gst.update_registry()

        context = GstPbutils.InstallPluginsContext.new()

        # new in 1.6
        if hasattr(context, "set_desktop_id"):
            from gi.repository import Gtk
            context.set_desktop_id(app.id)

        # new in 1.6
        if hasattr(context, "set_startup_notification_id"):
            current_time = Gtk.get_current_event_time()
            context.set_startup_notification_id("_TIME%d" % current_time)

        gdk_window = app.window.get_window()
        if gdk_window:
            try:
                xid = gdk_window.get_xid()
            except AttributeError:  # non X11
                pass
            else:
                context.set_xid(xid)

        res = GstPbutils.install_plugins_async([details], context,
                                               install_done_cb, None)
        print_d("Gstreamer plugin install result: %r" % res)

        if res in (GstPbutils.InstallPluginsReturn.HELPER_MISSING,
                   GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE):
            self._error(PlayerError(title, error_details))
Example #17
0
    def __getMissingElement(self, message, window_id=0):
        if gst.pygst_version < (0, 10, 10):
            print _("This version of gstreamer can't handle missing elements")
            return
        self.errors.append(str(message.structure["type"]))
        self.errors.append(str(message.structure["detail"]))
        self.errors.append(str(message.structure["name"]))
        detail = pbutils.missing_plugin_message_get_installer_detail(message)
        context = pbutils.InstallPluginsContext()

        if window_id:
            context.set_x_id(window_id)

        msg = pbutils.install_plugins_async([detail], context,
                                            self.__pbutils_plugin_installed_cb)
Example #18
0
    def __handle_missing_plugin(self, message):
        get_installer_detail = \
            GstPbutils.missing_plugin_message_get_installer_detail
        get_description = GstPbutils.missing_plugin_message_get_description

        details = get_installer_detail(message)
        if details is None:
            return

        self.stop()

        format_desc = get_description(message)
        title = _(u"No GStreamer element found to handle media format")
        error_details = _(u"Media format: %(format-description)s") % {
            "format-description": format_desc}

        def install_done_cb(plugins_return, *args):
            print_d("Gstreamer plugin install return: %r" % plugins_return)
            Gst.update_registry()

        context = GstPbutils.InstallPluginsContext.new()

        # new in 1.6
        if hasattr(context, "set_desktop_id"):
            from gi.repository import Gtk
            context.set_desktop_id(app.id)

        # new in 1.6
        if hasattr(context, "set_startup_notification_id"):
            current_time = Gtk.get_current_event_time()
            context.set_startup_notification_id("_TIME%d" % current_time)

        gdk_window = app.window.get_window()
        if gdk_window:
            try:
                xid = gdk_window.get_xid()
            except AttributeError:  # non X11
                pass
            else:
                context.set_xid(xid)

        res = GstPbutils.install_plugins_async(
            [details], context, install_done_cb, None)
        print_d("Gstreamer plugin install result: %r" % res)

        if res in (GstPbutils.InstallPluginsReturn.HELPER_MISSING,
                GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE):
            self._error(PlayerError(title, error_details))
Example #19
0
def __run_installer_helper(installer_details):
    """

        @return True if the helper might have run. False if did not run for
                    sure.
    """
    cntxt = __create_context()

    LOGGER.info("Prompting user to install missing codec(s): %s",
                installer_details)

    start_result = GstPbutils.install_plugins_async(
        [installer_details], cntxt, __installer_finished_callback)
    LOGGER.debug(
        "GstPbutils.install_plugins_async() return value: %s",
        GstPbutils.InstallPluginsReturn.get_name(start_result),
    )
    if start_result == GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE:
        # should only happen when there is a bug in Exaile or its libs:
        LOGGER.error(
            "Internal failure starting assisted GStreamer plugin installation")
        return False
    elif start_result == GstPbutils.InstallPluginsReturn.HELPER_MISSING:
        # we expect that to happen on some platforms
        LOGGER.warning(
            "Helper missing for assisted installation of Gstreamer plugins")
        return False
    elif start_result == GstPbutils.InstallPluginsReturn.INSTALL_IN_PROGRESS:
        LOGGER.warning(
            "Another assisted plugin installation is already in progress")
        return False
    elif start_result == GstPbutils.InstallPluginsReturn.STARTED_OK:
        LOGGER.info(
            "Successfully started assisted GStreamer plugin installation")
        return True
    else:
        LOGGER.error(
            "Code should not be reached. "
            "Unexpected return value from install_plugins_async: %s",
            GstPbutils.InstallPluginsReturn.get_name(start_result),
        )
        return False
Example #20
0
def __run_installer_helper(installer_details):
    """

        @return True if the helper might have run. False if did not run for
                    sure.
    """
    cntxt = __create_context()

    LOGGER.info("Prompting user to install missing codec(s): %s", installer_details)

    start_result = GstPbutils.install_plugins_async(
        [installer_details], cntxt, __installer_finished_callback
    )
    LOGGER.debug(
        "GstPbutils.install_plugins_async() return value: %s",
        GstPbutils.InstallPluginsReturn.get_name(start_result),
    )
    if start_result == GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE:
        # should only happen when there is a bug in Exaile or its libs:
        LOGGER.error("Internal failure starting assisted GStreamer plugin installation")
        return False
    elif start_result == GstPbutils.InstallPluginsReturn.HELPER_MISSING:
        # we expect that to happen on some platforms
        LOGGER.warn("Helper missing for assisted installation of Gstreamer plugins")
        return False
    elif start_result == GstPbutils.InstallPluginsReturn.INSTALL_IN_PROGRESS:
        LOGGER.warn("Another assisted plugin installation is already in progress")
        return False
    elif start_result == GstPbutils.InstallPluginsReturn.STARTED_OK:
        LOGGER.info("Successfully started assisted GStreamer plugin installation")
        return True
    else:
        LOGGER.error(
            "Code should not be reached. "
            "Unexpected return value from install_plugins_async: %s",
            GstPbutils.InstallPluginsReturn.get_name(start_result),
        )
        return False