Review Request 125830: Read protocol info from plugin metadata

Alex Richardson arichardson.kde at gmail.com
Wed Oct 28 00:09:39 UTC 2015


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/125830/#review87561
-----------------------------------------------------------


Looks good to me if it still works. 

I don't really like all the code being duplicated with config.readEntry() changing to value().toFoo() but I don't see an easy way to avoid the duplication.


src/core/kprotocolinfo.cpp (line 126)
<https://git.reviewboard.kde.org/r/125830/#comment60120>

    toBool() has has bool defaultValue parameter which could be used instead



src/core/kprotocolinfofactory.cpp (line 87)
<https://git.reviewboard.kde.org/r/125830/#comment60119>

    Probably easier to use KPluginLoader::findPlugins() instead, it only returns plugins with metadata:
    
    Something like this should work (untested)
    
    ```
    foreach (const KPluginMetaData& md : KPluginLoader::findPlugins("kf5/kio")) {
            const QString slavePath = md.fileName()
            const QJsonObject protocols(md.rawData().value(QStringLiteral("KDE-KIO-Protocols")).toObject());
            // add all protocols, does nothing if object invalid
    
            for (auto it = protocols.begin(); it != protocols.end(); ++it) {
                // skip empty objects
                const QJsonObject protocol(it.value().toObject());
                if (protocol.isEmpty()) {
                    continue;
                }
    
                // add to cache, skip double entries
                if (!m_cache.contains(it.key())) {
                    m_cache.insert(it.key(), new KProtocolInfoPrivate(it.key(), slavePath, protocol));
                }
    
    }
    ```


- Alex Richardson


On Oct. 27, 2015, 10:31 p.m., Christoph Cullmann wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/125830/
> -----------------------------------------------------------
> 
> (Updated Oct. 27, 2015, 10:31 p.m.)
> 
> 
> Review request for KDE Frameworks, Alex Richardson and David Faure.
> 
> 
> Repository: kio
> 
> 
> Description
> -------
> 
> Extends the protocol factory and co. to allow reading of protocol data from embedded json.
> Allows to deploy io slaves without anything else than the io slave itself in librarypath kf5/kio.
> 
> I changed to factory to ALWAYS fill its cache for any request, as now the determination which protocols are around is more expensive than just some directory traversal.
> 
> If this preview is ok, I will do that for all other shipped slaves and update this request.
> 
> 
> Diffs
> -----
> 
>   src/core/kprotocolinfo.cpp 8a02f7a 
>   src/core/kprotocolinfo_p.h c3dea6b 
>   src/core/kprotocolinfofactory.cpp 29ba8f4 
>   src/core/kprotocolinfofactory_p.h aa79fc5 
>   src/ioslaves/http/http.cpp 1727d41 
>   src/ioslaves/http/http.json PRE-CREATION 
> 
> Diff: https://git.reviewboard.kde.org/r/125830/diff/
> 
> 
> Testing
> -------
> 
> http slave still seems to be found and work.
> 
> 
> Thanks,
> 
> Christoph Cullmann
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20151028/cdbfa4b0/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list