OpenCoverage

qdbus_symbols.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/dbus/qdbus_symbols.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2016 Intel Corporation.-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtDBus module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include <QtCore/qglobal.h>-
42#ifndef QT_BOOTSTRAPPED-
43#include <QtCore/qlibrary.h>-
44#endif-
45#include <QtCore/qmutex.h>-
46-
47#ifndef QT_NO_DBUS-
48-
49extern "C" void dbus_shutdown();-
50-
51QT_BEGIN_NAMESPACE-
52-
53void (*qdbus_resolve_me(const char *name))();-
54-
55#if !defined QT_LINKED_LIBDBUS-
56-
57#ifndef QT_NO_LIBRARY-
58static QLibrary *qdbus_libdbus = 0;-
59-
60void qdbus_unloadLibDBus()-
61{-
62 if (qdbus_libdbus) {-
63 if (qEnvironmentVariableIsSet("QDBUS_FORCE_SHUTDOWN"))-
64 qdbus_libdbus->resolve("dbus_shutdown")();-
65 qdbus_libdbus->unload();-
66 }-
67 delete qdbus_libdbus;-
68 qdbus_libdbus = 0;-
69}-
70#endif-
71-
72bool qdbus_loadLibDBus()-
73{-
74#ifndef QT_NO_LIBRARY-
75#ifdef QT_BUILD_INTERNAL-
76 // this is to simulate a library load failure for our autotest suite.-
77 if (!qEnvironmentVariableIsEmpty("QT_SIMULATE_DBUS_LIBFAIL"))-
78 return false;-
79#endif-
80-
81 static bool triedToLoadLibrary = false;-
82#ifndef QT_NO_THREAD-
83 static QBasicMutex mutex;-
84 QMutexLocker locker(&mutex);-
85#endif-
86-
87 QLibrary *&lib = qdbus_libdbus;-
88 if (triedToLoadLibrary)-
89 return lib && lib->isLoaded();-
90-
91 lib = new QLibrary;-
92 lib->setLoadHints(QLibrary::ExportExternalSymbolsHint); // make libdbus symbols available for apps that need more advanced control over the dbus-
93 triedToLoadLibrary = true;-
94-
95 static int majorversions[] = { 3, 2, -1 };-
96 const QString baseNames[] = {-
97#ifdef Q_OS_WIN-
98 QLatin1String("dbus-1"),-
99#endif-
100 QLatin1String("libdbus-1")-
101 };-
102-
103 lib->unload();-
104 for (uint i = 0; i < sizeof(majorversions) / sizeof(majorversions[0]); ++i) {-
105 for (uint j = 0; j < sizeof(baseNames) / sizeof(baseNames[0]); ++j) {-
106#ifdef Q_OS_WIN-
107 QString suffix;-
108 if (majorversions[i] != -1)-
109 suffix = QString::number(- majorversions[i]); // negative so it prepends the dash-
110 lib->setFileName(baseNames[j] + suffix);-
111#else-
112 lib->setFileNameAndVersion(baseNames[j], majorversions[i]);-
113#endif-
114 if (lib->load() && lib->resolve("dbus_connection_open_private"))-
115 return true;-
116-
117 lib->unload();-
118 }-
119 }-
120-
121 delete lib;-
122 lib = 0;-
123 return false;-
124#else-
125 return true;-
126#endif-
127}-
128-
129#ifndef QT_NO_LIBRARY-
130void (*qdbus_resolve_conditionally(const char *name))()-
131{-
132 if (qdbus_loadLibDBus())-
133 return qdbus_libdbus->resolve(name);-
134 return 0;-
135}-
136#endif-
137-
138void (*qdbus_resolve_me(const char *name))()-
139{-
140#ifndef QT_NO_LIBRARY-
141 if (Q_UNLIKELY(!qdbus_loadLibDBus()))-
142 qFatal("Cannot find libdbus-1 in your system to resolve symbol '%s'.", name);-
143-
144 QFunctionPointer ptr = qdbus_libdbus->resolve(name);-
145 if (Q_UNLIKELY(!ptr))-
146 qFatal("Cannot resolve '%s' in your libdbus-1.", name);-
147-
148 return ptr;-
149#else-
150 Q_UNUSED(name);-
151 return 0;-
152#endif-
153}-
154-
155#else-
156static void qdbus_unloadLibDBus()-
157{-
158 if (qEnvironmentVariableIsSet("QDBUS_FORCE_SHUTDOWN"))
qEnvironmentVa...RCE_SHUTDOWN")Description
TRUEnever evaluated
FALSEnever evaluated
0
159 dbus_shutdown();
never executed: dbus_shutdown();
0
160}
never executed: end of block
0
161-
162#endif // !QT_LINKED_LIBDBUS-
163-
164#if defined(QT_LINKED_LIBDBUS) || !defined(QT_NO_LIBRARY)-
165Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus)
never executed: end of block
0
166#endif-
167-
168QT_END_NAMESPACE-
169-
170#endif // QT_NO_DBUS-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9