1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30#include "qwlclientbufferintegrationfactory_p.h"
31#include "qwlclientbufferintegrationplugin_p.h"
32#include "qwlclientbufferintegration_p.h"
33#include <QtCore/private/qfactoryloader_p.h>
34#include <QtCore/QCoreApplication>
35#include <QtCore/QDir>
36
37QT_BEGIN_NAMESPACE
38
39namespace QtWayland {
40
41#if QT_CONFIG(library)
42Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
43 (QtWaylandClientBufferIntegrationFactoryInterface_iid, QLatin1String("/wayland-graphics-integration-server"), Qt::CaseInsensitive))
44Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
45 (QtWaylandClientBufferIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
46#endif
47
48QStringList ClientBufferIntegrationFactory::keys(const QString &pluginPath)
49{
50#if QT_CONFIG(library)
51 QStringList list;
52 if (!pluginPath.isEmpty()) {
53 QCoreApplication::addLibraryPath(pluginPath);
54 list = directLoader()->keyMap().values();
55 if (!list.isEmpty()) {
56 const QString postFix = QStringLiteral(" (from ")
57 + QDir::toNativeSeparators(pathName: pluginPath)
58 + QLatin1Char(')');
59 const QStringList::iterator end = list.end();
60 for (QStringList::iterator it = list.begin(); it != end; ++it)
61 (*it).append(s: postFix);
62 }
63 }
64 list.append(t: loader()->keyMap().values());
65 return list;
66#else
67 return QStringList();
68#endif
69}
70
71ClientBufferIntegration *ClientBufferIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath)
72{
73#if QT_CONFIG(library)
74 // Try loading the plugin from platformPluginPath first:
75 if (!pluginPath.isEmpty()) {
76 QCoreApplication::addLibraryPath(pluginPath);
77 if (ClientBufferIntegration *ret = qLoadPlugin<ClientBufferIntegration, ClientBufferIntegrationPlugin>(loader: directLoader(), key: name, args))
78 return ret;
79 }
80 if (ClientBufferIntegration *ret = qLoadPlugin<ClientBufferIntegration, ClientBufferIntegrationPlugin>(loader: loader(), key: name, args))
81 return ret;
82#endif
83 return nullptr;
84}
85
86}
87
88QT_END_NAMESPACE
89

source code of qtwayland/src/compositor/hardware_integration/qwlclientbufferintegrationfactory.cpp