Skip to content
Snippets Groups Projects
Commit 8553e05b authored by Juhász Bálint's avatar Juhász Bálint
Browse files

some tidying

parent 7780a6bf
No related branches found
No related tags found
No related merge requests found
# ignore everything
*
# allow these:
# git stuff
!.gitignore
# c/c++ stuff
!*.hpp
!*.cpp
!*.h
!*.c
# qt stuff
!*.pro
!*.qrc
# resources
!*.hqx
!*.ico
!*.gif
!*.svg
!*.html
# apply to subdirectories
!*/
# but ignore bin
bin/
\ No newline at end of file
...@@ -57,6 +57,7 @@ public slots: ...@@ -57,6 +57,7 @@ public slots:
void incrementTime(); void incrementTime();
void finishAction(); void finishAction();
void updateInfos(int, const QString); void updateInfos(int, const QString);
void show();
private: private:
void initStackedWindow(); void initStackedWindow();
void initWelcomePage(); void initWelcomePage();
......
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
#ifndef PRIVILEGES_HPP #ifndef PRIVILEGES_HPP
#define PRIVILEGES_HPP #define PRIVILEGES_HPP
class Privileges { namespace Privileges {
public: bool Check(const QString&, const QString&);
static bool enoughPrivileges(const QString&, const QString&);
static bool isRoot(); bool IsRoot();
};
}
#endif // PRIVILEGES_HPP #endif // PRIVILEGES_HPP
...@@ -15,7 +15,7 @@ extern QString TXT_LOG_GROUP[]; ...@@ -15,7 +15,7 @@ extern QString TXT_LOG_GROUP[];
extern QString TXT_CLIPB_BTN[]; extern QString TXT_CLIPB_BTN[];
extern QString TXT_SAVE_BTN[]; extern QString TXT_SAVE_BTN[];
extern QString TXT_SAVE_DIALOG[]; extern QString TXT_SAVE_DIALOG[];
extern QString TXT_ROOT_MSG_TITLE_WIN; extern QString TXT_ROOT_MSG_TITLE_WIN[];
extern QString TXT_ROOT_MSG_WIN; extern QString TXT_ROOT_MSG_WIN[];
#endif #endif
#include <QApplication> #include <QApplication>
#include <include/NetCheckerWindow.hpp> #include <include/NetCheckerWindow.hpp>
#include <include/Privileges.hpp>
#include <include/Translation.hpp>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
NetCheckerWindow ncw; NetCheckerWindow ncw;
if (Privileges::enoughPrivileges(TXT_ROOT_MSG_TITLE_WIN, TXT_ROOT_MSG_WIN) == true){
ncw.show(); ncw.show();
return app.exec(); return app.exec();
} }
return 1;
}
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.4.2, 2015-09-21T17:36:13. --> <!-- Written by QtCreator 3.6.0, 2016-02-07T15:29:27. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
<value type="QByteArray">{8a982672-9a47-4b9c-b231-1954ba5d7e5c}</value> <value type="QByteArray">{1eb0af89-fa91-4fbf-8709-87fdc4066d8f}</value>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
<data> <data>
<variable>ProjectExplorer.Project.Target.0</variable> <variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.5.0 MinGW 32bit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.5.1 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.5.0 MinGW 32bit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.5.1 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.55.win32_mingw492_kit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.55.win32_mingw492_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value> <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
...@@ -128,7 +127,6 @@ ...@@ -128,7 +127,6 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value> <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
...@@ -190,6 +188,10 @@ ...@@ -190,6 +188,10 @@
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
...@@ -227,8 +229,9 @@ ...@@ -227,8 +229,9 @@
<value type="int" key="PE.EnvironmentAspect.Base">2</value> <value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">netchecker</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">netchecker</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">netchecker2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/bebe/Documents/QtProjects/NetChecker/netchecker.pro</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/BME/kszk/NetChecker/netchecker.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">netchecker.pro</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">netchecker.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
......
...@@ -23,14 +23,16 @@ void Diagnostic::onStarted(){ ...@@ -23,14 +23,16 @@ void Diagnostic::onStarted(){
} }
Diagnostic::Diagnostic() Diagnostic::Diagnostic()
: func_vec({ :
func_vec({
&Diagnostic::getOsInfo, &Diagnostic::getOsInfo,
&Diagnostic::getInterfaceInfo, &Diagnostic::getInterfaceInfo,
&Diagnostic::getRoutingInfo, &Diagnostic::getRoutingInfo,
&Diagnostic::getDGPingOutput, &Diagnostic::getDGPingOutput,
&Diagnostic::getODPingOutput, &Diagnostic::getODPingOutput,
&Diagnostic::getDNSLookup &Diagnostic::getDNSLookup
}), tab(2, ' ') }),
tab(2, ' ')
{ {
INIT_GLOBALS(); INIT_GLOBALS();
} }
......
...@@ -328,3 +328,9 @@ void NetCheckerWindow::incrementTime(){ ...@@ -328,3 +328,9 @@ void NetCheckerWindow::incrementTime(){
} }
} }
} }
void NetCheckerWindow::show(){
if (Privileges::Check(TXT_ROOT_MSG_TITLE_WIN[0], TXT_ROOT_MSG_WIN[0]) == true){
QDialog::show();
}
}
...@@ -6,11 +6,8 @@ ...@@ -6,11 +6,8 @@
#include <include/ProcessHandler.hpp> #include <include/ProcessHandler.hpp>
#include <include/Privileges.hpp> #include <include/Privileges.hpp>
#ifndef PRIVILEGES_CPP bool Privileges::Check(const QString &title, const QString &msg){
#define PRIVILEGES_CPP if (Privileges::IsRoot() == false){
bool Privileges::enoughPrivileges(const QString &title, const QString &msg){
if (Privileges::isRoot() == false){
QMessageBox::critical(nullptr, title, msg, QMessageBox::Ok, QMessageBox::NoButton); QMessageBox::critical(nullptr, title, msg, QMessageBox::Ok, QMessageBox::NoButton);
return false; return false;
} }
...@@ -18,10 +15,12 @@ bool Privileges::enoughPrivileges(const QString &title, const QString &msg){ ...@@ -18,10 +15,12 @@ bool Privileges::enoughPrivileges(const QString &title, const QString &msg){
} }
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#include <windows.h> #include <windows.h>
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN #define WIN32_EXTRA_LEAN
bool Privileges::isRoot(){
bool Privileges::IsRoot(){
BOOL fRet = FALSE; BOOL fRet = FALSE;
HANDLE hToken = NULL; HANDLE hToken = NULL;
if( OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)){ if( OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)){
...@@ -36,14 +35,17 @@ bool Privileges::enoughPrivileges(const QString &title, const QString &msg){ ...@@ -36,14 +35,17 @@ bool Privileges::enoughPrivileges(const QString &title, const QString &msg){
} }
return fRet; return fRet;
} }
#elif (defined(Q_OS_LINUX) || defined(Q_OS_OSX)) #elif (defined(Q_OS_LINUX) || defined(Q_OS_OSX))
#include <unistd.h> #include <unistd.h>
bool Privileges::isRoot(){
bool Privileges::IsRoot(){
return !(getuid() && geteuid()); return !(getuid() && geteuid());
} }
#else #else
#error "This OS is not supported yet!"
#endif
#endif // PRIVILEGES_CPP #error "This OS is not supported yet!"
#endif
...@@ -15,9 +15,7 @@ QString ProcessHandler::exec(QString commands){ ...@@ -15,9 +15,7 @@ QString ProcessHandler::exec(QString commands){
if (!waitForFinished()){ if (!waitForFinished()){
return tr("Error occured. Command was: %1\n").arg(commands); return tr("Error occured. Command was: %1\n").arg(commands);
} }
QByteArray ba = readAllStandardOutput(); return readAllStandardOutput();
return ba;
} }
#endif #endif
...@@ -12,7 +12,8 @@ QString TXT_LOG_GROUP[] = { "Log", "Napló" }; ...@@ -12,7 +12,8 @@ QString TXT_LOG_GROUP[] = { "Log", "Napló" };
QString TXT_CLIPB_BTN[] = { "Copy to clipboard", "Másolás vágólapra" }; QString TXT_CLIPB_BTN[] = { "Copy to clipboard", "Másolás vágólapra" };
QString TXT_SAVE_BTN[] = { "Save to file...", "Mentés fájlba..." }; QString TXT_SAVE_BTN[] = { "Save to file...", "Mentés fájlba..." };
QString TXT_SAVE_DIALOG[] = { "Save to...", "Mentés helye..." }; QString TXT_SAVE_DIALOG[] = { "Save to...", "Mentés helye..." };
QString TXT_ROOT_MSG_TITLE_WIN ={ "Error" }; QString TXT_ROOT_MSG_TITLE_WIN[] = { "Error" };
QString TXT_ROOT_MSG_WIN = { QString TXT_ROOT_MSG_WIN[] = {
"Az alkalmazás futtatásához Rendszergazdai jogosultság szükséges!\n\nYou must have Administrator privileges to use this tool!" "Az alkalmazás futtatásához Rendszergazdai jogosultság szükséges!" "\n\n"
"You must have Administrator privileges to use this tool!"
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment