| Line | Source | Count | 
|---|
| 1 |  | - | 
| 2 |  | - | 
| 3 |  | - | 
| 4 |  | - | 
| 5 |  | - | 
| 6 |  | - | 
| 7 |  | - | 
| 8 |  | - | 
| 9 |  | - | 
| 10 |  | - | 
| 11 |  | - | 
| 12 |  | - | 
| 13 |  | - | 
| 14 |  | - | 
| 15 |  | - | 
| 16 |  | - | 
| 17 |  | - | 
| 18 |  | - | 
| 19 |  | - | 
| 20 |  | - | 
| 21 |  | - | 
| 22 |  | - | 
| 23 |  | - | 
| 24 |  | - | 
| 25 |  | - | 
| 26 |  | - | 
| 27 |  | - | 
| 28 |  | - | 
| 29 |  | - | 
| 30 |  | - | 
| 31 |  | - | 
| 32 |  | - | 
| 33 |  | - | 
| 34 |  | - | 
| 35 |  | - | 
| 36 |  | - | 
| 37 |  | - | 
| 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 |  | - | 
| 49 | extern "C" void dbus_shutdown(); | - | 
| 50 |  | - | 
| 51 | QT_BEGIN_NAMESPACE | - | 
| 52 |  | - | 
| 53 | void (*qdbus_resolve_me(const char *name))(); | - | 
| 54 |  | - | 
| 55 | #if !defined QT_LINKED_LIBDBUS | - | 
| 56 |  | - | 
| 57 | #ifndef QT_NO_LIBRARY | - | 
| 58 | static QLibrary *qdbus_libdbus = 0; | - | 
| 59 |  | - | 
| 60 | void 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 |  | - | 
| 72 | bool qdbus_loadLibDBus() | - | 
| 73 | { | - | 
| 74 | #ifndef QT_NO_LIBRARY | - | 
| 75 | #ifdef QT_BUILD_INTERNAL | - | 
| 76 |  | - | 
| 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); | - | 
| 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]); | - | 
| 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 | - | 
| 130 | void (*qdbus_resolve_conditionally(const char *name))() | - | 
| 131 | { | - | 
| 132 | if (qdbus_loadLibDBus()) | - | 
| 133 | return qdbus_libdbus->resolve(name); | - | 
| 134 | return 0; | - | 
| 135 | } | - | 
| 136 | #endif | - | 
| 137 |  | - | 
| 138 | void (*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 | - | 
| 156 | static void qdbus_unloadLibDBus() | - | 
| 157 | { | - | 
| 158 | if (qEnvironmentVariableIsSet("QDBUS_FORCE_SHUTDOWN")) | TRUE | never evaluated |  | FALSE | never 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) | - | 
| 165 | Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus) never executed: end of block | 0 | 
| 166 | #endif | - | 
| 167 |  | - | 
| 168 | QT_END_NAMESPACE | - | 
| 169 |  | - | 
| 170 | #endif // QT_NO_DBUS | - | 
|  |  |  |