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