qgenericunixservices.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9enum { debug = 0 };-
10-
11static inline QByteArray detectDesktopEnvironment()-
12{-
13 const QByteArray xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP");-
14 if (!xdgCurrentDesktop.isEmpty()
!xdgCurrentDesktop.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 33 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_QGuiApplication
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
)
0-33
15 return
never executed: return xdgCurrentDesktop.toUpper();
xdgCurrentDesktop.toUpper();
never executed: return xdgCurrentDesktop.toUpper();
0
16-
17-
18 if (!qEnvironmentVariableIsEmpty("KDE_FULL_SESSION")
!qEnvironmentV...FULL_SESSION")Description
TRUEnever evaluated
FALSEevaluated 33 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_QGuiApplication
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
)
0-33
19 return
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; }());
([]() -> 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
never executed: return ba;
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")
!qEnvironmentV...P_SESSION_ID")Description
TRUEnever evaluated
FALSEevaluated 33 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_QGuiApplication
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
)
0-33
21 return
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; }());
([]() -> 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
never executed: return ba;
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"
desktopSession == "gnome"Description
TRUEnever evaluated
FALSEevaluated 33 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_QGuiApplication
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
)
0-33
26 return
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; }());
([]() -> 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
never executed: return ba;
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"
desktopSession == "xfce"Description
TRUEnever evaluated
FALSEevaluated 33 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_QGuiApplication
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
)
0-33
28 return
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; }());
([]() -> 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
never executed: return ba;
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: 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:
  • tst_QApplication
  • tst_QGuiApplication
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
([]() -> 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
executed 33 times by 5 tests: return ba;
Executed by:
  • tst_QApplication
  • tst_QGuiApplication
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
ba;
executed 33 times by 5 tests: return ba;
Executed by:
  • tst_QApplication
  • tst_QGuiApplication
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
}());
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:
  • tst_QApplication
  • tst_QGuiApplication
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
33
31}-
32-
33static inline bool checkExecutable(const QString &candidate, QString *result)-
34{-
35 *result = QStandardPaths::findExecutable(candidate);-
36 return
never executed: return !result->isEmpty();
!result->isEmpty();
never executed: return !result->isEmpty();
0
37}-
38-
39static 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)
checkExecutabl...}()), browser)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
47 return
never executed: return true;
true;
never executed: return true;
0
48-
49 if (checkBrowserVariable
checkBrowserVariableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
50 QByteArray browserVariable = qgetenv("DEFAULT_BROWSER");-
51 if (browserVariable.isEmpty()
browserVariable.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
52 browserVariable = qgetenv("BROWSER");
never executed: browserVariable = qgetenv("BROWSER");
0
53 if (!browserVariable.isEmpty()
!browserVariable.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& checkExecutable(QString::fromLocal8Bit(browserVariable), browser)
checkExecutabl...ble), browser)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
54 return
never executed: return true;
true;
never executed: return true;
0
55 }
never executed: end of block
0
56-
57 if (desktop == QByteArray("KDE")
desktop == QByteArray("KDE")Description
TRUEnever evaluated
FALSEnever evaluated
) {
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)
checkExecutabl...}()), browser)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
60 browser->append(QLatin1String(" exec"));-
61 return
never executed: return true;
true;
never executed: return true;
0
62 }-
63 }
never executed: end of block
else if (desktop == QByteArray("GNOME")
desktop == QByteArray("GNOME")Description
TRUEnever evaluated
FALSEnever evaluated
) {
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)
checkExecutabl...}()), browser)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
65 return
never executed: return true;
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 *)
i < sizeof(bro...sizeof(char *)Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
69 if (checkExecutable(QLatin1String(browsers[i]), browser)
checkExecutabl...[i]), browser)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
70 return
never executed: return true;
true;
never executed: return true;
0
71 return
never executed: return false;
false;
never executed: return false;
0
72}-
73-
74static inline bool launch(const QString &launcher, const QUrl &url)-
75{-
76 const QString command = launcher + QLatin1Char(' ') + QLatin1String(url.toEncoded());-
77 if (debug
debugDescription
TRUEnever evaluated
FALSEnever evaluated
)
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
!okDescription
TRUEnever evaluated
FALSEnever evaluated
)
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: return ok;
ok;
never executed: return ok;
0
87}-
88-
89QByteArray QGenericUnixServices::desktopEnvironment() const-
90{-
91 static const QByteArray result = detectDesktopEnvironment();-
92 return
executed 4200 times by 125 tests: return result;
Executed by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • ...
result;
executed 4200 times by 125 tests: return result;
Executed by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • ...
4200
93}-
94-
95bool QGenericUnixServices::openUrl(const QUrl &url)-
96{-
97 if (url.scheme() == QLatin1String("mailto")
url.scheme() =...ring("mailto")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
98 return
never executed: return openDocument(url);
openDocument(url);
never executed: return openDocument(url);
0
99-
100 if (m_webBrowser.isEmpty()
m_webBrowser.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& !detectWebBrowser(desktopEnvironment(), true, &m_webBrowser)
!detectWebBrow...&m_webBrowser)Description
TRUEnever evaluated
FALSEnever evaluated
) {
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: return false;
false;
never executed: return false;
0
103 }-
104 return
never executed: return launch(m_webBrowser, url);
launch(m_webBrowser, url);
never executed: return launch(m_webBrowser, url);
0
105}-
106-
107bool QGenericUnixServices::openDocument(const QUrl &url)-
108{-
109 if (m_documentLauncher.isEmpty()
m_documentLauncher.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& !detectWebBrowser(desktopEnvironment(), false, &m_documentLauncher)
!detectWebBrow...umentLauncher)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
110 QMessageLogger(__FILE__, 154, __PRETTY_FUNCTION__).warning("Unable to detect a launcher for '%s'", QString(url.toString()).toLocal8Bit().constData());-
111 return
never executed: return false;
false;
never executed: return false;
0
112 }-
113 return
never executed: return launch(m_documentLauncher, url);
launch(m_documentLauncher, url);
never executed: return launch(m_documentLauncher, url);
0
114}-
115-
Switch to Source codePreprocessed file

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