Implemented network_status() function + project file update.

This commit is contained in:
LoRd_MuldeR 2014-11-21 20:11:39 +01:00
parent b012aa0dbb
commit bfedb5b4b3
4 changed files with 39 additions and 7 deletions

View File

@ -33,13 +33,13 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
@ -86,7 +86,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<AdditionalIncludeDirectories>$(ProjectDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -94,6 +94,8 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(QTDIR)\lib</AdditionalLibraryDirectories>
<AdditionalDependencies>QtCored4.lib;QtGuid4.lib;Psapi.lib;Sensapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -104,7 +106,7 @@
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_NO_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
@ -120,6 +122,8 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(QTDIR)\lib</AdditionalLibraryDirectories>
<AdditionalDependencies>QtCore4.lib;QtGui4.lib;Psapi.lib;Sensapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
@ -130,7 +134,7 @@
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_NODLL;QT_NO_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>

View File

@ -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);
}

View File

@ -31,6 +31,7 @@
#include <Windows.h>
#include <Objbase.h>
#include <Psapi.h>
#include <Sensapi.h>
//Qt
#include <QMap>
@ -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
///////////////////////////////////////////////////////////////////////////////

View File

@ -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);