kaffeine codecs autoinstallation patch

Anthony Mercatante tonio at ubuntu.com
Thu Nov 8 11:11:49 GMT 2007


Hi  !

Thanks for this, I'll test the patch tomorrow.

Cheers,
Tonio

Le Thursday 08 November 2007 11:59:44 Sergey Rudchenko, vous avez écrit :
> diff -ur
> base-kaffeine/kaffeine/src/player-parts/kaffeine-part/kaffeinepart.cpp
> kaffeine-0.8.5/kaffeine/src/player-parts/kaffeine-part/kaffeinepart.cpp
> ---
> base-kaffeine/kaffeine/src/player-parts/kaffeine-part/kaffeinepart.cpp
>  2007-07-28 19:45:37.000000000 +0300
> +++
> kaffeine-0.8.5/kaffeine/src/player-parts/kaffeine-part/kaffeinepart.cpp
>  2007-11-08 12:45:44.000000000 +0200
> @@ -19,6 +19,12 @@
>   */
>
>  #include "kaffeinepart.h"
> +#include <kapplication.h>
> +#include <kservice.h>
> +#include <ktrader.h>
> +#include <kmessagebox.h>
> +#include <krun.h>
> +#include <klocale.h>
>
>  #include "kaffeinepart.moc"
>
> @@ -30,3 +36,34 @@
>  KaffeinePart::~KaffeinePart()
>  {
>  }
> +
> +bool KaffeinePart::installDistroCodec(QWidget* parent, const QString&
> engine, const QString& codec)
> +{
> +    QString query = QString("[X-KDE-Kaffeine-codec] == '%1' and
> [X-KDE-Kaffeine-engine] == '%2'").arg(codec).arg(engine);
> +
> +    KService::Ptr service = KTrader::self()->query(
> "Kaffeine/CodecInstall", query).first();
> +
> +
> +    if (service)
> +    {
> +       QString installScript = service->exec();
> +
> +       if (!installScript.isNull()) //just a sanity check
> +       {
> +           KGuiItem installButton("Install Codecs");
> +
> +           if (KMessageBox::questionYesNo(parent,
> +                                          i18n("Kaffeine currently
> cannot play opened files."),
> +                                          i18n( "No codec Support" ),
> +                                          installButton,
> +                                          KStdGuiItem::no(),
> +                                          "codecInstallWarning" ) ==
> KMessageBox::Yes )
> +           {
> +               KRun::runCommand(installScript);
> +               return true;
> +           }
> +       }
> +    }
> +
> +    return false;
> +}
> diff -ur
> base-kaffeine/kaffeine/src/player-parts/kaffeine-part/kaffeinepart.h
> kaffeine-0.8.5/kaffeine/src/player-parts/kaffeine-part/kaffeinepart.h
> ---
> base-kaffeine/kaffeine/src/player-parts/kaffeine-part/kaffeinepart.h
>  2007-07-28 19:45:37.000000000 +0300
> +++
> kaffeine-0.8.5/kaffeine/src/player-parts/kaffeine-part/kaffeinepart.h
>  2007-11-08 12:47:14.000000000 +0200
> @@ -199,6 +199,11 @@
>      virtual void slotMute()
>      {}
>
> +        /*
> +         * Execute distro-dependent actions to install codecs
> +         */
> +        static bool installDistroCodec(QWidget* parent, const QString&
> engine, const QString& codec);
> +
>  private:
>      /*
>       * Don't reimplement this, a player should be able to stream media
> diff -ur
> base-kaffeine/kaffeine/src/player-parts/xine-part/kxinewidget.cpp
> kaffeine-0.8.5/kaffeine/src/player-parts/xine-part/kxinewidget.cpp
> --- base-kaffeine/kaffeine/src/player-parts/xine-part/kxinewidget.cpp
>  2007-11-08 11:48:23.000000000 +0200
> +++ kaffeine-0.8.5/kaffeine/src/player-parts/xine-part/kxinewidget.cpp
>  2007-11-07 22:54:17.000000000 +0200
> @@ -37,6 +37,7 @@
>  #include <cmath>
>
>  #include "kxinewidget.h"
> +#include "kaffeinepart.h"
>
>  #ifdef HAVE_XINERAMA
>  #include <X11/extensions/Xinerama.h>
> @@ -762,6 +763,12 @@
>              parentWidget()->resize(m_newParentSize);
>              break;
>          }
> +        case XINE_MSG_ENCRYPTED_SOURCE:
> +        {
> +            if (KaffeinePart::installDistroCodec(this, "xine-engine",
> "ffmpeg"))
> +                return;
> +
> +        }
>          default: break;
>      }
>  }
> @@ -1918,6 +1925,14 @@
>          return;
>      }
>
> +    if (!xine_get_stream_info(m_xineStream,
> XINE_STREAM_INFO_AUDIO_HANDLED) ||
> +        !xine_get_stream_info(m_xineStream,
> XINE_STREAM_INFO_VIDEO_HANDLED))
> +    {
> +       errorOut("No codecs to handle media");
> +       sendXineError();
> +       return;
> +    }
> +
>      /**** use visualization ? ****/
>  #ifndef USE_QT_ONLY
>      unwireAudioFilters();
> @@ -2136,6 +2151,9 @@
>          case XINE_ERROR_NO_INPUT_PLUGIN:
>          case XINE_ERROR_NO_DEMUX_PLUGIN:
>          {
> +            if (m_trackURL.startsWith("dvd:/") &&
> KaffeinePart::installDistroCodec(this, "xine-engine", "ffmpeg"))
> +                return;
> +
>              error = i18n("No plugin found to handle this resource") + "
> " + addInfo;
>              break;
>          }
> @@ -2156,6 +2174,13 @@
>          }
>          default:
>          {
> +                if (!xine_get_stream_info(m_xineStream,
> XINE_STREAM_INFO_AUDIO_HANDLED) ||
> +                !xine_get_stream_info(m_xineStream,
> XINE_STREAM_INFO_VIDEO_HANDLED))
> +            {
> +                if (KaffeinePart::installDistroCodec(this,
> "xine-engine", "ffmpeg"))
> +                    return;
> +            }
> +
>              error = i18n("Generic error") + " (" + m_trackURL + ")";
>              break;
>          }





More information about the kubuntu-devel mailing list