diff --git a/MUtilities_VS2013.vcxproj b/MUtilities_VS2013.vcxproj index 9ea9e71..546411a 100644 --- a/MUtilities_VS2013.vcxproj +++ b/MUtilities_VS2013.vcxproj @@ -33,13 +33,13 @@ - StaticLibrary + DynamicLibrary true v120_xp Unicode - StaticLibrary + DynamicLibrary false v120_xp true @@ -86,7 +86,7 @@ Level3 Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions) MultiThreadedDebugDLL NoExtensions $(ProjectDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;%(AdditionalIncludeDirectories) @@ -94,6 +94,8 @@ Windows true + $(QTDIR)\lib + QtCored4.lib;QtGuid4.lib;Psapi.lib;Sensapi.lib;%(AdditionalDependencies) @@ -104,7 +106,7 @@ Full true true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;NDEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_NO_DEBUG;%(PreprocessorDefinitions) MultiThreadedDLL NoExtensions AnySuitable @@ -120,6 +122,8 @@ true true true + $(QTDIR)\lib + QtCore4.lib;QtGui4.lib;Psapi.lib;Sensapi.lib;%(AdditionalDependencies) @@ -130,7 +134,7 @@ Full true true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;NDEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_NODLL;QT_NO_DEBUG;%(PreprocessorDefinitions) MultiThreaded NoExtensions AnySuitable diff --git a/include/MUtils/OSSupport.h b/include/MUtils/OSSupport.h index c7f0f84..ac7a0a5 100644 --- a/include/MUtils/OSSupport.h +++ b/include/MUtils/OSSupport.h @@ -40,12 +40,24 @@ namespace MUtils } known_folder_t; + //Network connection types + typedef enum + { + NETWORK_TYPE_ERR = 0, /*unknown*/ + NETWORK_TYPE_NON = 1, /*not connected*/ + NETWORK_TYPE_YES = 2 /*connected*/ + } + network_type_t; + //Get known Folder const QString &known_folder(known_folder_t folder_id); //Current Date QDate current_date(void); + //Network Status + int network_status(void); + //Error handling void fatal_exit(const char* const errorMessage); } diff --git a/src/OSSupport_Win32.cpp b/src/OSSupport_Win32.cpp index 0cd6a13..265a1d5 100644 --- a/src/OSSupport_Win32.cpp +++ b/src/OSSupport_Win32.cpp @@ -31,6 +31,7 @@ #include #include #include +#include //Qt #include @@ -219,6 +220,21 @@ QDate MUtils::OS::current_date(void) return (currentDate >= processDate) ? currentDate : processDate; } +/////////////////////////////////////////////////////////////////////////////// +// NETWORK STATE +/////////////////////////////////////////////////////////////////////////////// + +int MUtils::OS::network_status(void) +{ + DWORD dwFlags; + const BOOL ret = IsNetworkAlive(&dwFlags); + if(GetLastError() == 0) + { + return (ret != FALSE) ? NETWORK_TYPE_YES : NETWORK_TYPE_NON; + } + return NETWORK_TYPE_ERR; +} + /////////////////////////////////////////////////////////////////////////////// // FATAL EXIT /////////////////////////////////////////////////////////////////////////////// diff --git a/src/UpdateChecker.cpp b/src/UpdateChecker.cpp index cff804f..2616361 100644 --- a/src/UpdateChecker.cpp +++ b/src/UpdateChecker.cpp @@ -253,8 +253,8 @@ void UpdateChecker::checkForUpdates(void) log("Checking internet connection..."); setStatus(UpdateStatus_CheckingConnection); - const int networkStatus = lamexp_network_status(); - if(networkStatus == lamexp_network_non) + const int networkStatus = OS::network_status(); + if(networkStatus == OS::NETWORK_TYPE_NON) { log("", "Operating system reports that the computer is currently offline !!!"); setProgress(m_maxProgress);