| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/util/qdesktopservices.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | - | |||||||
| 8 | class QOpenUrlHandlerRegistry : public QObject | - | ||||||
| 9 | { | - | ||||||
| 10 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - | ||||||
| 11 | #pragma GCC diagnostic push | - | ||||||
| 12 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||
| 13 | #pragma GCC diagnostic pop | - | ||||||
| 14 | struct QPrivateSignal {}; | - | ||||||
| 15 | public: | - | ||||||
| 16 | inline QOpenUrlHandlerRegistry() : mutex(QMutex::Recursive) {} never executed: end of block | 0 | ||||||
| 17 | - | |||||||
| 18 | QMutex mutex; | - | ||||||
| 19 | - | |||||||
| 20 | struct Handler | - | ||||||
| 21 | { | - | ||||||
| 22 | QObject *receiver; | - | ||||||
| 23 | QByteArray name; | - | ||||||
| 24 | }; | - | ||||||
| 25 | typedef QHash<QString, Handler> HandlerHash; | - | ||||||
| 26 | HandlerHash handlers; | - | ||||||
| 27 | - | |||||||
| 28 | public : | - | ||||||
| 29 | void handlerDestroyed(QObject *handler); | - | ||||||
| 30 | - | |||||||
| 31 | }; | - | ||||||
| 32 | - | |||||||
| 33 | namespace { namespace Q_QGS_handlerRegistry { typedef QOpenUrlHandlerRegistry Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
never executed: }guard.store(QtGlobalStatic::Destroyed);never executed: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blocknever executed: &holder.value;return &holder.value;never executed: } } } static QGlobalStatic<QOpenUrlHandlerRegistry, Q_QGS_handlerRegistry::innerFunction, Q_QGS_handlerRegistry::guard> handlerRegistry;return &holder.value; | 0 | ||||||
| 34 | - | |||||||
| 35 | void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler) | - | ||||||
| 36 | { | - | ||||||
| 37 | HandlerHash::Iterator it = handlers.begin(); | - | ||||||
| 38 | while (it != handlers.end()
| 0 | ||||||
| 39 | if (it->receiver == handler
| 0 | ||||||
| 40 | it = handlers.erase(it); | - | ||||||
| 41 | } never executed: else {end of block | 0 | ||||||
| 42 | ++it; | - | ||||||
| 43 | } never executed: end of block | 0 | ||||||
| 44 | } | - | ||||||
| 45 | } never executed: end of block | 0 | ||||||
| 46 | bool QDesktopServices::openUrl(const QUrl &url) | - | ||||||
| 47 | { | - | ||||||
| 48 | QOpenUrlHandlerRegistry *registry = handlerRegistry(); | - | ||||||
| 49 | QMutexLocker locker(®istry->mutex); | - | ||||||
| 50 | static bool insideOpenUrlHandler = false; | - | ||||||
| 51 | - | |||||||
| 52 | if (!insideOpenUrlHandler
| 0 | ||||||
| 53 | QOpenUrlHandlerRegistry::HandlerHash::ConstIterator handler = registry->handlers.constFind(url.scheme()); | - | ||||||
| 54 | if (handler != registry->handlers.constEnd()
| 0 | ||||||
| 55 | insideOpenUrlHandler = true; | - | ||||||
| 56 | bool result = QMetaObject::invokeMethod(handler->receiver, handler->name.constData(), Qt::DirectConnection, QArgument<QUrl >("QUrl", url)); | - | ||||||
| 57 | insideOpenUrlHandler = false; | - | ||||||
| 58 | return never executed: result;return result;never executed: return result; | 0 | ||||||
| 59 | } | - | ||||||
| 60 | } never executed: end of block | 0 | ||||||
| 61 | if (!url.isValid()
| 0 | ||||||
| 62 | return never executed: false;return false;never executed: return false; | 0 | ||||||
| 63 | - | |||||||
| 64 | QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); | - | ||||||
| 65 | if (!platformIntegration
| 0 | ||||||
| 66 | return never executed: false;return false;never executed: return false; | 0 | ||||||
| 67 | - | |||||||
| 68 | QPlatformServices *platformServices = platformIntegration->services(); | - | ||||||
| 69 | if (!platformServices
| 0 | ||||||
| 70 | QMessageLogger(__FILE__, 200, __PRETTY_FUNCTION__).warning("The platform plugin does not support services."); | - | ||||||
| 71 | return never executed: false;return false;never executed: return false; | 0 | ||||||
| 72 | } | - | ||||||
| 73 | return never executed: url.scheme() == QLatin1String("file")return url.scheme() == QLatin1String("file") ? platformServices->openDocument(url) : platformServices->openUrl(url);
never executed: return url.scheme() == QLatin1String("file") ? platformServices->openDocument(url) : platformServices->openUrl(url); | 0 | ||||||
| 74 | platformServices->openDocument(url) : platformServices->openUrl(url); never executed: return url.scheme() == QLatin1String("file") ? platformServices->openDocument(url) : platformServices->openUrl(url); | 0 | ||||||
| 75 | } | - | ||||||
| 76 | void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, const char *method) | - | ||||||
| 77 | { | - | ||||||
| 78 | QOpenUrlHandlerRegistry *registry = handlerRegistry(); | - | ||||||
| 79 | QMutexLocker locker(®istry->mutex); | - | ||||||
| 80 | if (!receiver
| 0 | ||||||
| 81 | registry->handlers.remove(scheme.toLower()); | - | ||||||
| 82 | return; never executed: return; | 0 | ||||||
| 83 | } | - | ||||||
| 84 | QOpenUrlHandlerRegistry::Handler h; | - | ||||||
| 85 | h.receiver = receiver; | - | ||||||
| 86 | h.name = method; | - | ||||||
| 87 | registry->handlers.insert(scheme.toLower(), h); | - | ||||||
| 88 | QObject::connect(receiver, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "241"), | - | ||||||
| 89 | registry, qFlagLocation("1""handlerDestroyed(QObject*)" "\0" __FILE__ ":" "242")); | - | ||||||
| 90 | } never executed: end of block | 0 | ||||||
| 91 | - | |||||||
| 92 | - | |||||||
| 93 | - | |||||||
| 94 | - | |||||||
| 95 | - | |||||||
| 96 | - | |||||||
| 97 | void QDesktopServices::unsetUrlHandler(const QString &scheme) | - | ||||||
| 98 | { | - | ||||||
| 99 | setUrlHandler(scheme, 0, 0); | - | ||||||
| 100 | } never executed: end of block | 0 | ||||||
| 101 | extern __attribute__((visibility("default"))) QString qt_applicationName_noFallback(); | - | ||||||
| 102 | - | |||||||
| 103 | QString QDesktopServices::storageLocationImpl(QStandardPaths::StandardLocation type) | - | ||||||
| 104 | { | - | ||||||
| 105 | if (type == QStandardPaths::AppLocalDataLocation
| 0 | ||||||
| 106 | - | |||||||
| 107 | - | |||||||
| 108 | - | |||||||
| 109 | const QString compatAppName = qt_applicationName_noFallback(); | - | ||||||
| 110 | const QString baseDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); | - | ||||||
| 111 | return never executed: baseDir + QLatin1String("/data/")return baseDir + QLatin1String("/data/") + QCoreApplication::organizationName() + QLatin1Char('/') + compatAppName;never executed: return baseDir + QLatin1String("/data/") + QCoreApplication::organizationName() + QLatin1Char('/') + compatAppName; | 0 | ||||||
| 112 | + QCoreApplication::organizationName() + QLatin1Char('/') never executed: return baseDir + QLatin1String("/data/") + QCoreApplication::organizationName() + QLatin1Char('/') + compatAppName; | 0 | ||||||
| 113 | + compatAppName; never executed: return baseDir + QLatin1String("/data/") + QCoreApplication::organizationName() + QLatin1Char('/') + compatAppName; | 0 | ||||||
| 114 | - | |||||||
| 115 | } | - | ||||||
| 116 | return never executed: QStandardPaths::writableLocation(type);return QStandardPaths::writableLocation(type);never executed: return QStandardPaths::writableLocation(type); | 0 | ||||||
| 117 | } | - | ||||||
| 118 | - | |||||||
| 119 | - | |||||||
| 120 | - | |||||||
| Switch to Source code | Preprocessed file |