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

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