[PATCH] Phonon Gstreamer backend

Matthias Kretz kretz at kde.org
Mon Jan 21 18:04:40 GMT 2008


The kde4_phonon_kdepluginfactory.cpp looks good, but I'd like to avoid the 
makeLibName function. One way to achieve that would be a, IMHO, sane 
QPluginLoader which does the correct thing itself. Brad, after our last chat 
about QPluginLoader, will Qt4.4 be able to just take a library name without 
lib prefix and without extension like QLibrary does?

If it won't work in Qt 4.4 (or if we need to stay compatible with 4.3) I 
suggest to use
cData.dirs()->findAllResources("module", newService->library + 
QLatin1String(".\*"));
And then iterate over those to find one that works (like it does in 
factory.cpp).

On Monday 21 January 2008, Andre Magalhaes wrote:
> +// KService::library should not contain extension, neither
> +// lib prefix. This function takes this into account.
> +static inline QString makeLibName(const QString &libname)
> +{
> +#ifdef Q_OS_WIN
> +    return libname + ".dll";
> +#else
> +    const char* const extList[] = { ".so", ".dylib", ".bundle", ".sl" };
> +    for (uint i = 0; i < sizeof(extList) / sizeof(*extList); ++i) {
> +        if (QLibrary::isLibrary(libname + extList[i])) {
> +            return libname + extList[i];
> +        }
> +    }
> +    return QString();
> +#endif
> +}
> +
>  QObject *KdePlatformPlugin::createBackend(KService::Ptr newService)
>  {
>      QString errorReason;
> @@ -137,6 +155,19 @@
>      }
>  #else
>      QObject *backend = newService->createInstance<QObject>(0,
> QVariantList(), &errorReason); +
> +    if (0 == backend) {
> +        QString libName = makeLibName(newService->library());
> +        if (!libName.isEmpty()) {
> +            const KComponentData cData = KGlobal::mainComponent();
> +            QString libFile = cData.dirs()->findResource("module",
> libName); +            if (!libFile.isEmpty()) {
> +                QPluginLoader pluginLoader(libFile);
> +                if (pluginLoader.load())
> +                    backend = pluginLoader.instance();
> +            }
> +        }
> +    }



-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080121/dc8dad8b/attachment.sig>


More information about the kde-core-devel mailing list