forked from open-eid/qt-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiagnostics_unix.cpp
118 lines (105 loc) · 3.92 KB
/
Diagnostics_unix.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* QEstEidCommon
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "Diagnostics.h"
#include "Common.h"
#include <QtCore/QFile>
#include <QtCore/QTextStream>
#include <QtCore/QProcess>
#include <sys/utsname.h>
void Diagnostics::run()
{
QString info;
QTextStream s( &info );
QLocale::Language language = QLocale::system().language();
QString ctype = QProcessEnvironment::systemEnvironment().value( "LC_CTYPE",
QProcessEnvironment::systemEnvironment().value( "LANG" ) );
s << "<b>" << tr("Locale (time-, number format / codepage):") << "</b> "
<< (language == QLocale::C ? "English/United States" : QLocale::languageToString( language )) << " / "
<< ctype << "<br /><br />";
emit update( info );
info.clear();
#ifndef Q_OS_MAC
QStringList package = Common::packages( { "estonianidcard" }, false );
if( !package.isEmpty() )
s << "<b>" << tr("Base version:") << "</b> " << package.first() << "<br />";
#endif
s << "<b>" << tr("Application version:") << "</b> " << QCoreApplication::applicationVersion()
#ifdef INTERNATIONAL
<< " INTERNATIONAL"
#endif
<< "<br />";
emit update( info );
info.clear();
s << "<b>" << tr("OS:") << "</b> " << Common::applicationOs() << "<br />";
#ifndef Q_OS_MAC
s << "<b>" << tr("CPU:") << "</b> ";
QFile f( "/proc/cpuinfo" );
if( f.open( QFile::ReadOnly ) )
{
QRegExp rx( "model name.*\\: (.*)\n" );
rx.setMinimal( true );
if( rx.indexIn( QString::fromLocal8Bit( f.readAll() ) ) != -1 )
s << rx.cap( 1 );
}
s << "<br />";
#endif
struct utsname unameData;
uname(&unameData);
s << "<b>" << tr("Kernel:") << "</b> "
<< unameData.sysname << " " << unameData.release << " "
<< unameData.version << " " << unameData.machine << "<br /><br />";
emit update( info );
info.clear();
s << "<b>" << "URLs:" << "</b>";
const QHash<QString,QString> urls = qApp->urls();
for(auto i = urls.constBegin(); i != urls.constEnd(); ++i)
s << "<br />" << i.key() << ": " << i.value();
s << "<br /><br />";
s << "<b>" << tr("Arguments:") << "</b> " << qApp->arguments().join(" ") << "<br />";
s << "<b>" << tr("Library paths:") << "</b> " << QCoreApplication::libraryPaths().join( ";" ) << "<br />";
s << "<b>" << tr("Libraries") << ":</b><br />";
#ifdef Q_OS_MAC
s << Common::packages( { "libdigidoc", "digidocpp" } ).join( "<br />" ) << "<br />";
#else
s << Common::packages( { "libdigidoc2", "libdigidocpp0", "qdigidoc", "qesteidutil",
"esteidpkcs11loader", "esteidfirefoxplugin", "chrome-token-signing", "openssl",
"libpcsclite1", "pcsc-lite", "opensc", "esteid-pkcs11" } ).join( "<br />" ) << "<br />";
#endif
s << "QT (" << qVersion() << ")" << "<br /><br />";
emit update( info );
info.clear();
getReaderInfo( s );
emit update( info );
info.clear();
#ifndef Q_OS_MAC
QStringList browsers = Common::packages( { "chromium-browser", "firefox", "MozillaFirefox" } );
if( !browsers.isEmpty() )
s << "<br /><br /><b>" << tr("Browsers:") << "</b><br />" << browsers.join( "<br />" ) << "<br /><br />";
emit update( info );
info.clear();
QProcess p;
p.start( "lsusb" );
p.waitForFinished();
QString cmd = QString::fromLocal8Bit( p.readAll() );
if( !cmd.isEmpty() )
s << "<b>" << tr("USB info:") << "</b><br/> " << cmd.replace( "\n", "<br />" ) << "<br />";
emit update( info );
info.clear();
#endif
}