| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | enum { debug = 0 }; | - | ||||||||||||
| 10 | - | |||||||||||||
| 11 | static inline QByteArray detectDesktopEnvironment() | - | ||||||||||||
| 12 | { | - | ||||||||||||
| 13 | const QByteArray xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP"); | - | ||||||||||||
| 14 | if (!xdgCurrentDesktop.isEmpty()
| 0-33 | ||||||||||||
| 15 | return never executed: xdgCurrentDesktop.toUpper();return xdgCurrentDesktop.toUpper();never executed: return xdgCurrentDesktop.toUpper(); | 0 | ||||||||||||
| 16 | - | |||||||||||||
| 17 | - | |||||||||||||
| 18 | if (!qEnvironmentVariableIsEmpty("KDE_FULL_SESSION")
| 0-33 | ||||||||||||
| 19 | return never executed: ([]() -> QByteArray { enum { Size = sizeof("KDE") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "KDE" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("KDE") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "KDE" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());never executed: ba;return ba;never executed: }());return ba;never executed: return ([]() -> QByteArray { enum { Size = sizeof("KDE") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "KDE" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()); | 0 | ||||||||||||
| 20 | if (!qEnvironmentVariableIsEmpty("GNOME_DESKTOP_SESSION_ID")
| 0-33 | ||||||||||||
| 21 | return never executed: ([]() -> QByteArray { enum { Size = sizeof("GNOME") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GNOME" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("GNOME") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GNOME" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());never executed: ba;return ba;never executed: }());return ba;never executed: return ([]() -> QByteArray { enum { Size = sizeof("GNOME") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GNOME" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()); | 0 | ||||||||||||
| 22 | - | |||||||||||||
| 23 | - | |||||||||||||
| 24 | const QByteArray desktopSession = qgetenv("DESKTOP_SESSION"); | - | ||||||||||||
| 25 | if (desktopSession == "gnome"
| 0-33 | ||||||||||||
| 26 | return never executed: ([]() -> QByteArray { enum { Size = sizeof("GNOME") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GNOME" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("GNOME") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GNOME" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());never executed: ba;return ba;never executed: }());return ba;never executed: return ([]() -> QByteArray { enum { Size = sizeof("GNOME") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GNOME" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()); | 0 | ||||||||||||
| 27 | if (desktopSession == "xfce"
| 0-33 | ||||||||||||
| 28 | return never executed: ([]() -> QByteArray { enum { Size = sizeof("XFCE") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "XFCE" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("XFCE") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "XFCE" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());never executed: ba;return ba;never executed: }());return ba;never executed: return ([]() -> QByteArray { enum { Size = sizeof("XFCE") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "XFCE" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()); | 0 | ||||||||||||
| 29 | - | |||||||||||||
| 30 | return executed 33 times by 5 tests: ([]() -> QByteArray { enum { Size = sizeof("UNKNOWN") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "UNKNOWN" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("UNKNOWN") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "UNKNOWN" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
executed 33 times by 5 tests: ba;return ba;Executed by:
executed 33 times by 5 tests: }());return ba;Executed by:
executed 33 times by 5 tests: return ([]() -> QByteArray { enum { Size = sizeof("UNKNOWN") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "UNKNOWN" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
| 33 | ||||||||||||
| 31 | } | - | ||||||||||||
| 32 | - | |||||||||||||
| 33 | static inline bool checkExecutable(const QString &candidate, QString *result) | - | ||||||||||||
| 34 | { | - | ||||||||||||
| 35 | *result = QStandardPaths::findExecutable(candidate); | - | ||||||||||||
| 36 | return never executed: !result->isEmpty();return !result->isEmpty();never executed: return !result->isEmpty(); | 0 | ||||||||||||
| 37 | } | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | static inline bool detectWebBrowser(const QByteArray &desktop, | - | ||||||||||||
| 40 | bool checkBrowserVariable, | - | ||||||||||||
| 41 | QString *browser) | - | ||||||||||||
| 42 | { | - | ||||||||||||
| 43 | const char *browsers[] = {"google-chrome", "firefox", "mozilla", "opera"}; | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | browser->clear(); | - | ||||||||||||
| 46 | if (checkExecutable(([]() -> QString { enum { Size = sizeof(u"" "xdg-open")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "xdg-open" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), browser)
| 0 | ||||||||||||
| 47 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 48 | - | |||||||||||||
| 49 | if (checkBrowserVariable
| 0 | ||||||||||||
| 50 | QByteArray browserVariable = qgetenv("DEFAULT_BROWSER"); | - | ||||||||||||
| 51 | if (browserVariable.isEmpty()
| 0 | ||||||||||||
| 52 | browserVariable = qgetenv("BROWSER"); never executed: browserVariable = qgetenv("BROWSER"); | 0 | ||||||||||||
| 53 | if (!browserVariable.isEmpty()
| 0 | ||||||||||||
| 54 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 55 | } never executed: end of block | 0 | ||||||||||||
| 56 | - | |||||||||||||
| 57 | if (desktop == QByteArray("KDE")
| 0 | ||||||||||||
| 58 | - | |||||||||||||
| 59 | if (checkExecutable(([]() -> QString { enum { Size = sizeof(u"" "kfmclient")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "kfmclient" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), browser)
| 0 | ||||||||||||
| 60 | browser->append(QLatin1String(" exec")); | - | ||||||||||||
| 61 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 62 | } | - | ||||||||||||
| 63 | } never executed: else if (desktop == QByteArray("GNOME")end of block
| 0 | ||||||||||||
| 64 | if (checkExecutable(([]() -> QString { enum { Size = sizeof(u"" "gnome-open")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "gnome-open" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), browser)
| 0 | ||||||||||||
| 65 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 66 | } never executed: end of block | 0 | ||||||||||||
| 67 | - | |||||||||||||
| 68 | for (size_t i = 0; i < sizeof(browsers)/sizeof(char *)
| 0 | ||||||||||||
| 69 | if (checkExecutable(QLatin1String(browsers[i]), browser)
| 0 | ||||||||||||
| 70 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 71 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 72 | } | - | ||||||||||||
| 73 | - | |||||||||||||
| 74 | static inline bool launch(const QString &launcher, const QUrl &url) | - | ||||||||||||
| 75 | { | - | ||||||||||||
| 76 | const QString command = launcher + QLatin1Char(' ') + QLatin1String(url.toEncoded()); | - | ||||||||||||
| 77 | if (debug
| 0 | ||||||||||||
| 78 | QMessageLogger(__FILE__, 122, __PRETTY_FUNCTION__).debug("Launching %s", QString(command).toLocal8Bit().constData()); never executed: QMessageLogger(__FILE__, 122, __PRETTY_FUNCTION__).debug("Launching %s", QString(command).toLocal8Bit().constData()); | 0 | ||||||||||||
| 79 | - | |||||||||||||
| 80 | - | |||||||||||||
| 81 | - | |||||||||||||
| 82 | const bool ok = QProcess::startDetached(command); | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | if (!ok
| 0 | ||||||||||||
| 85 | QMessageLogger(__FILE__, 129, __PRETTY_FUNCTION__).warning("Launch failed (%s)", QString(command).toLocal8Bit().constData()); never executed: QMessageLogger(__FILE__, 129, __PRETTY_FUNCTION__).warning("Launch failed (%s)", QString(command).toLocal8Bit().constData()); | 0 | ||||||||||||
| 86 | return never executed: ok;return ok;never executed: return ok; | 0 | ||||||||||||
| 87 | } | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 | QByteArray QGenericUnixServices::desktopEnvironment() const | - | ||||||||||||
| 90 | { | - | ||||||||||||
| 91 | static const QByteArray result = detectDesktopEnvironment(); | - | ||||||||||||
| 92 | return executed 4200 times by 125 tests: result;return result;Executed by:
executed 4200 times by 125 tests: return result;Executed by:
| 4200 | ||||||||||||
| 93 | } | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | bool QGenericUnixServices::openUrl(const QUrl &url) | - | ||||||||||||
| 96 | { | - | ||||||||||||
| 97 | if (url.scheme() == QLatin1String("mailto")
| 0 | ||||||||||||
| 98 | return never executed: openDocument(url);return openDocument(url);never executed: return openDocument(url); | 0 | ||||||||||||
| 99 | - | |||||||||||||
| 100 | if (m_webBrowser.isEmpty()
| 0 | ||||||||||||
| 101 | QMessageLogger(__FILE__, 145, __PRETTY_FUNCTION__).warning("Unable to detect a web browser to launch '%s'", QString(url.toString()).toLocal8Bit().constData()); | - | ||||||||||||
| 102 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 103 | } | - | ||||||||||||
| 104 | return never executed: launch(m_webBrowser, url);return launch(m_webBrowser, url);never executed: return launch(m_webBrowser, url); | 0 | ||||||||||||
| 105 | } | - | ||||||||||||
| 106 | - | |||||||||||||
| 107 | bool QGenericUnixServices::openDocument(const QUrl &url) | - | ||||||||||||
| 108 | { | - | ||||||||||||
| 109 | if (m_documentLauncher.isEmpty()
| 0 | ||||||||||||
| 110 | QMessageLogger(__FILE__, 154, __PRETTY_FUNCTION__).warning("Unable to detect a launcher for '%s'", QString(url.toString()).toLocal8Bit().constData()); | - | ||||||||||||
| 111 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 112 | } | - | ||||||||||||
| 113 | return never executed: launch(m_documentLauncher, url);return launch(m_documentLauncher, url);never executed: return launch(m_documentLauncher, url); | 0 | ||||||||||||
| 114 | } | - | ||||||||||||
| 115 | - | |||||||||||||
| Switch to Source code | Preprocessed file |