MediaInfoXP is based on MUtilities library now + massive code clean-up.

This commit is contained in:
LoRd_MuldeR 2015-05-02 18:54:39 +02:00
parent 990235ebcb
commit 85401025f0
9 changed files with 132 additions and 955 deletions

View File

@ -1,20 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MediaInfoXP", "MediaInfoXP.vcxproj", "{DCDCCABB-970A-4337-B5BB-7838EE72FE80}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MUtilities", "..\MUtilities\MUtilities_VS2013.vcxproj", "{55405FE1-149F-434C-9D72-4B64348D2A08}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release_Static|Win32 = Release_Static|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DCDCCABB-970A-4337-B5BB-7838EE72FE80}.Debug|Win32.ActiveCfg = Debug|Win32
{DCDCCABB-970A-4337-B5BB-7838EE72FE80}.Debug|Win32.Build.0 = Debug|Win32
{DCDCCABB-970A-4337-B5BB-7838EE72FE80}.Release|Win32.ActiveCfg = Release|Win32
{DCDCCABB-970A-4337-B5BB-7838EE72FE80}.Release|Win32.Build.0 = Release|Win32
{DCDCCABB-970A-4337-B5BB-7838EE72FE80}.Release_Static|Win32.ActiveCfg = Release_Static|Win32
{DCDCCABB-970A-4337-B5BB-7838EE72FE80}.Release_Static|Win32.Build.0 = Release_Static|Win32
{DCDCCABB-970A-4337-B5BB-7838EE72FE80}.Release|Win32.ActiveCfg = Release_Static|Win32
{55405FE1-149F-434C-9D72-4B64348D2A08}.Debug|Win32.ActiveCfg = Debug|Win32
{55405FE1-149F-434C-9D72-4B64348D2A08}.Debug|Win32.Build.0 = Debug|Win32
{55405FE1-149F-434C-9D72-4B64348D2A08}.Release_Static|Win32.ActiveCfg = Release_Static|Win32
{55405FE1-149F-434C-9D72-4B64348D2A08}.Release_Static|Win32.Build.0 = Release_Static|Win32
{55405FE1-149F-434C-9D72-4B64348D2A08}.Release|Win32.ActiveCfg = Release|Win32
{55405FE1-149F-434C-9D72-4B64348D2A08}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -5,8 +5,8 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<ProjectConfiguration Include="Release_Static|Win32">
<Configuration>Release_Static</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
@ -22,7 +22,7 @@
<PlatformToolset>v120_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120_xp</PlatformToolset>
@ -35,19 +35,19 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)\bin\$(PlatformName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)\tmp\$(PlatformName)\$(Configuration)\obj\</IntDir>
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)\bin\$(PlatformName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)\tmp\$(PlatformName)\$(Configuration)\obj\</IntDir>
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -56,23 +56,23 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)\include\QtCore;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\MUtilities\include;$(SolutionDir)\tmp\$(ProjectName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)..\LameXP_Qt\LameXP\etc\Prerequisites\qt4_static\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\Qt4\MSVC-2013\Debug\lib;$(SolutionDir)\..\Prerequisites\Qt4\MSVC-2013\Debug\plugins\imageformats;$(SolutionDir)\..\Prerequisites\EncodePointer\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_NO_DEBUG;QT_NODLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;MUTILS_STATIC_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_NO_DEBUG;QT_NODLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\MUtilities\include;$(SolutionDir)\tmp\$(ProjectName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
@ -91,8 +91,8 @@
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(QT_STATIC)\lib;$(QT_STATIC)\plugins\imageformats;$(SolutionDir)\..\EncodePointerLib\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>QtCore.lib;QtGui.lib;QtSvg.lib;qtmain.lib;qsvg.lib;qico.lib;qtga.lib;Winmm.lib;imm32.lib;ws2_32.lib;Shlwapi.lib;Wininet.lib;PowrProf.lib;psapi.lib;EncodePointer.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\Qt4\MSVC-2013\Static\lib;$(SolutionDir)\..\Prerequisites\Qt4\MSVC-2013\Static\plugins\imageformats;$(SolutionDir)\..\Prerequisites\EncodePointer\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>EncodePointer.lib;QtCore.lib;QtGui.lib;QtSvg.lib;qtmain.lib;qsvg.lib;qico.lib;qtga.lib;Winmm.lib;imm32.lib;ws2_32.lib;Shlwapi.lib;Wininet.lib;PowrProf.lib;psapi.lib;Sensapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<ShowProgress>LinkVerboseLib</ShowProgress>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
@ -104,23 +104,23 @@
<ItemGroup>
<CustomBuild Include="gui\Dialog.ui">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)\tmp\Common\uic\%(Filename).h" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)tmp\$(ProjectName)\UIC_%(Filename).h" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">UIC "$(SolutionDir)\tmp\Common\uic\%(Filename).h"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\tmp\Common\uic\%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)\tmp\Common\uic\%(Filename).h" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">UIC "$(SolutionDir)\tmp\Common\uic\%(Filename).h"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\tmp\Common\uic\%(Filename).h;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\$(ProjectName)\UIC_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">"$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)tmp\$(ProjectName)\UIC_%(Filename).h" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">UIC "$(SolutionDir)\tmp\Common\uic\%(Filename).h"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)tmp\$(ProjectName)\UIC_%(Filename).h;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="MediaInfoXP.qrc">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)\tmp\Common\rcc\RCC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)\tmp\Common\rcc\RCC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">RCC "$(SolutionDir)\tmp\Common\rcc\RCC_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">RCC "$(SolutionDir)\tmp\Common\rcc\RCC_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\tmp\Common\rcc\RCC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\tmp\Common\rcc\RCC_%(Filename).cpp;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">"$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">RCC "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">RCC "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp;%(Outputs)</Outputs>
<SubType>Designer</SubType>
</CustomBuild>
</ItemGroup>
@ -129,39 +129,48 @@
<ClCompile Include="src\Main.cpp" />
<ClCompile Include="src\MainWindow.cpp" />
<ClCompile Include="src\ShellExtension.cpp" />
<ClCompile Include="src\Utils.cpp" />
<ClCompile Include="tmp\Common\moc\MOC_IPC.cpp" />
<ClCompile Include="tmp\Common\moc\MOC_MainWindow.cpp" />
<ClCompile Include="tmp\Common\rcc\RCC_MediaInfoXP.cpp" />
<ClCompile Include="tmp\MediaInfoXP\MOC_IPC.cpp" />
<ClCompile Include="tmp\MediaInfoXP\MOC_MainWindow.cpp" />
<ClCompile Include="tmp\MediaInfoXP\QRC_MediaInfoXP.cpp" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="src\MainWindow.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MOC "$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MOC "$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MOC "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">MOC "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MOC "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(ProjectName)\moc\MOC_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Config.h" />
<CustomBuild Include="src\IPC.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MOC "$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MOC "$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\tmp\Common\moc\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MOC "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">MOC "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MOC "$(SolutionDir)\tmp\$(ProjectName)\MOC_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(ProjectName)\moc\MOC_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild>
<ClInclude Include="src\ShellExtension.h" />
<ClInclude Include="src\Utils.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="MediaInfoXP.rcx">
<FileType>Document</FileType>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MUtilities\MUtilities_VS2013.vcxproj">
<Project>{55405fe1-149f-434c-9d72-4b64348d2a08}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -42,22 +42,19 @@
<ClCompile Include="src\MainWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tmp\Common\moc\MOC_MainWindow.cpp">
<Filter>Source Files\Generated</Filter>
</ClCompile>
<ClCompile Include="tmp\Common\rcc\RCC_MediaInfoXP.cpp">
<Filter>Source Files\Generated</Filter>
</ClCompile>
<ClCompile Include="src\Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\ShellExtension.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\IPC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tmp\Common\moc\MOC_IPC.cpp">
<ClCompile Include="tmp\MediaInfoXP\MOC_IPC.cpp">
<Filter>Source Files\Generated</Filter>
</ClCompile>
<ClCompile Include="tmp\MediaInfoXP\MOC_MainWindow.cpp">
<Filter>Source Files\Generated</Filter>
</ClCompile>
<ClCompile Include="tmp\MediaInfoXP\QRC_MediaInfoXP.cpp">
<Filter>Source Files\Generated</Filter>
</ClCompile>
</ItemGroup>
@ -65,9 +62,6 @@
<ClInclude Include="src\Config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\Utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\ShellExtension.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -21,8 +21,10 @@
#include "IPC.h"
#include "Utils.h"
//MUtils
#include "MUtils/Global.h"
//Qt
#include <QSharedMemory>
#include <QSystemSemaphore>
@ -126,10 +128,10 @@ IPC::~IPC(void)
m_recvThread->wait();
}
MIXP_DELETE_OBJ(m_recvThread);
MIXP_DELETE_OBJ(m_sharedMemory);
MIXP_DELETE_OBJ(m_semaphoreWr);
MIXP_DELETE_OBJ(m_semaphoreRd);
MUTILS_DELETE(m_recvThread);
MUTILS_DELETE(m_sharedMemory);
MUTILS_DELETE(m_semaphoreWr);
MUTILS_DELETE(m_semaphoreRd);
}
int IPC::initialize(void)

View File

@ -19,6 +19,10 @@
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
//MUTils
#include <MUtils/Startup.h>
#include <MUtils/Version.h>
//StdLib
#include <cstdio>
#include <iostream>
@ -48,7 +52,6 @@
#include "Config.h"
#include "MainWindow.h"
#include "IPC.h"
#include "Utils.h"
///////////////////////////////////////////////////////////////////////////////
// Debug Console
@ -86,27 +89,21 @@ static void init_console(void)
// MAIN function
///////////////////////////////////////////////////////////////////////////////
int mixp_main(int argc, char* argv[])
static int mixp_main(int &argc, char **argv)
{
//Show console?
bool bConsole = MIXP_CONSOLE;
for(int i = 1; i < argc; i++)
{
if(_stricmp(argv[i], "--console") == 0) bConsole = true;
if(_stricmp(argv[i], "--no-console") == 0) bConsole = false;
}
if(bConsole) init_console();
//Print the logo
qDebug("MediaInfoXP v%u.%02u, built on %s at %s.", mixp_versionMajor, mixp_versionMinor, mixp_buildDate, mixp_buildTime);
qDebug("Copyright (c) 2004-%s LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.", &mixp_buildDate[7]);
qDebug("Built with Qt v%s, running with Qt v%s.\n", QT_VERSION_STR, qVersion());
//Print library version
qDebug("This application is powerd by MUtils library v%u.%02u (%s, %s).\n", MUtils::Version::lib_version_major(), MUtils::Version::lib_version_minor(), MUTILS_UTF8(MUtils::Version::lib_build_date().toString(Qt::ISODate)), MUTILS_UTF8(MUtils::Version::lib_build_time().toString(Qt::ISODate)));
//Create application
QApplication *application = new QApplication(argc, argv);
QScopedPointer<QApplication> application(new QApplication(argc, argv));
//Create IPC
IPC *ipc = new IPC();
QScopedPointer<IPC> ipc(new IPC());
//Is this the *first* instance?
if(ipc->initialize() == 0)
@ -134,25 +131,16 @@ int mixp_main(int argc, char* argv[])
{
ipc->sendAsync("?");
}
MIXP_DELETE_OBJ(ipc);
MIXP_DELETE_OBJ(application);
return 42;
}
//Get temp folder
QFile *lockFile = NULL;
const QString tempFolder = mixp_getTempFolder(&lockFile);
if(tempFolder.isEmpty())
{
qFatal("Failed to determine TEMP folder!");
MIXP_DELETE_OBJ(ipc);
return 1;
}
const QString tempFolder = MUtils::temp_folder();
qDebug("TEMP folder is:\n%s\n", QDir::toNativeSeparators(tempFolder).toUtf8().constData());
//Create main window
CMainWindow *mainWindow = new CMainWindow(tempFolder, ipc);
QScopedPointer<CMainWindow> mainWindow(new CMainWindow(tempFolder, ipc.data()));
mainWindow->show();
//Run application
@ -162,184 +150,14 @@ int mixp_main(int argc, char* argv[])
//Stop IPC
ipc->stopListening();
//Clean up
MIXP_DELETE_OBJ(mainWindow);
MIXP_DELETE_OBJ(application);
if(lockFile) lockFile->remove();
MIXP_DELETE_OBJ(lockFile);
mixp_clean_folder(tempFolder);
MIXP_DELETE_OBJ(ipc);
return exit_code;
}
///////////////////////////////////////////////////////////////////////////////
// Error handlers
///////////////////////////////////////////////////////////////////////////////
void mixp_fatal_exit(const wchar_t *msg)
{
static volatile long s_lock = 0L;
if(_InterlockedExchange(&s_lock, 1L) == 0)
{
FatalAppExitW(0, msg);
TerminateProcess(GetCurrentProcess(), -1);
}
}
LONG WINAPI mixp_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInfo)
{
mixp_fatal_exit(L"Unhandeled exception handler invoked, application will exit!");
return LONG_MAX;
}
void mixp_invalid_param_handler(const wchar_t* exp, const wchar_t* fun, const wchar_t* fil, unsigned int, uintptr_t)
{
mixp_fatal_exit(L"Invalid parameter handler invoked, application will exit!");
}
static void mixp_signal_handler(int signal_num)
{
signal(signal_num, mixp_signal_handler);
mixp_fatal_exit(L"Signal handler invoked, application will exit!");
}
///////////////////////////////////////////////////////////////////////////////
// Message Handler
///////////////////////////////////////////////////////////////////////////////
static void mixp_console_color(FILE* file, WORD attributes)
{
const HANDLE hConsole = (HANDLE)(_get_osfhandle(_fileno(file)));
if((hConsole != NULL) && (hConsole != INVALID_HANDLE_VALUE))
{
SetConsoleTextAttribute(hConsole, attributes);
}
}
void mixp_message_handler(QtMsgType type, const char *msg)
{
if(g_bHaveConsole)
{
static const char *GURU_MEDITATION = "\n\nGURU MEDITATION !!!\n\n";
static volatile long s_lock = 0L;
while(_InterlockedExchange(&s_lock, 1L) != 0) __noop;
UINT oldOutputCP = GetConsoleOutputCP();
if(oldOutputCP != CP_UTF8) SetConsoleOutputCP(CP_UTF8);
switch(type)
{
case QtCriticalMsg:
case QtFatalMsg:
fflush(stdout);
fflush(stderr);
mixp_console_color(stderr, FOREGROUND_RED | FOREGROUND_INTENSITY);
fprintf(stderr, GURU_MEDITATION);
fprintf(stderr, "%s\n", msg);
fflush(stderr);
break;
case QtWarningMsg:
mixp_console_color(stderr, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
fprintf(stderr, "%s\n", msg);
fflush(stderr);
break;
default:
mixp_console_color(stderr, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
fprintf(stderr, "%s\n", msg);
fflush(stderr);
break;
}
mixp_console_color(stderr, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
if(oldOutputCP != CP_UTF8) SetConsoleOutputCP(oldOutputCP);
_InterlockedExchange(&s_lock, 0L);
}
if(type == QtCriticalMsg || type == QtFatalMsg)
{
mixp_fatal_exit(L"The application has encountered a critical error and will exit now!");
}
}
///////////////////////////////////////////////////////////////////////////////
// Applicaton entry point
///////////////////////////////////////////////////////////////////////////////
static int _main(int argc, char* argv[])
{
if(MIXP_DEBUG)
{
qInstallMsgHandler(mixp_message_handler);
return mixp_main(argc, argv);
}
else
{
int iResult = -1;
try
{
qInstallMsgHandler(mixp_message_handler);
iResult = mixp_main(argc, argv);
}
catch(char *error)
{
fflush(stdout);
fflush(stderr);
fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error message: %s\n", error);
mixp_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(int error)
{
fflush(stdout);
fflush(stderr);
fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error code: 0x%X\n", error);
mixp_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(...)
{
fflush(stdout);
fflush(stderr);
fprintf(stderr, "\nGURU MEDITATION !!!\n");
mixp_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
return iResult;
}
}
int main(int argc, char* argv[])
{
if(MIXP_DEBUG)
{
_mixp_global_init();
return _main(argc, argv);
}
else
{
__try
{
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
SetUnhandledExceptionFilter(mixp_exception_handler);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
_set_invalid_parameter_handler(mixp_invalid_param_handler);
static const int signal_num[6] = { SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM };
for(size_t i = 0; i < 6; i++)
{
signal(signal_num[i], mixp_signal_handler);
}
_mixp_global_init();
return _main(argc, argv);
}
__except(1)
{
fflush(stdout);
fflush(stderr);
fprintf(stderr, "\nGURU MEDITATION !!!\n\nUnhandeled structured exception error! [code: 0x%X]\n", GetExceptionCode());
mixp_fatal_exit(L"Unhandeled structured exception error, application will exit!");
}
}
MUtils::Startup::startup(argc, argv, mixp_main, "MediaInfoXP", false);
}

View File

@ -22,7 +22,13 @@
#include "MainWindow.h"
//UIC includes
#include "../tmp/Common/uic/Dialog.h"
#include "UIC_Dialog.h"
//MUtils
#include <MUtils/GUI.h>
#include <MUtils/OSSupport.h>
#include <MUtils/Sound.h>
#include <MUtils/Version.h>
//Qt includes
#include <QMessageBox>
@ -42,7 +48,6 @@
//Internal
#include "Config.h"
#include "Utils.h"
#include "ShellExtension.h"
#include "IPC.h"
@ -92,7 +97,7 @@ CMainWindow::CMainWindow(const QString &tempFolder, IPC *const ipc, QWidget *par
setMinimumSize(this->size());
//Setup Icon
m_icon = mixp_set_window_icon(this, QIcon(":/res/logo.png"), true);
MUtils::GUI::set_window_icon(this, QIcon(":/res/logo.png"), true);
//Setup links
ui->actionLink_MuldeR->setData(QVariant(QString::fromLatin1(LINK_MULDER)));
@ -145,12 +150,10 @@ CMainWindow::~CMainWindow(void)
if(m_mediaInfoHandle)
{
m_mediaInfoHandle->remove();
MIXP_DELETE_OBJ(m_mediaInfoHandle);
MUTILS_DELETE(m_mediaInfoHandle);
}
MIXP_DELETE_OBJ(m_process);
MIXP_DELETE_OBJ(m_floatingLabel);
mixp_free_window_icon(m_icon);
MUTILS_DELETE(m_process);
MUTILS_DELETE(m_floatingLabel);
}
////////////////////////////////////////////////////////////
@ -163,11 +166,11 @@ void CMainWindow::showEvent(QShowEvent *event)
resize(this->minimumSize());
//Init test
ui->versionLabel->setText(QString("v%1 / v%2 (%3)").arg(QString().sprintf("%u.%02u", mixp_versionMajor, mixp_versionMinor), QString().sprintf("%u.%u.%02u", mixp_miVersionMajor, mixp_miVersionMinor, mixp_miVersionPatch), mixp_get_build_date().toString(Qt::ISODate)));
ui->versionLabel->setText(QString("v%1 / v%2 (%3)").arg(QString().sprintf("%u.%02u", mixp_versionMajor, mixp_versionMinor), QString().sprintf("%u.%u.%02u", mixp_miVersionMajor, mixp_miVersionMinor, mixp_miVersionPatch), MUtils::Version::app_build_date().toString(Qt::ISODate)));
ui->updateLabel->setText(tr("This version is more than six month old and probably outdated. Please check <a href=\"%1\">%1</a> for updates!").arg(LINK_MULDER));
//Show update hint?
ui->updateLabel->setVisible(mixp_get_build_date().addMonths(6) < mixp_get_current_date());
ui->updateLabel->setVisible(MUtils::Version::app_build_date().addMonths(6) < MUtils::OS::current_date());
//Force resize event
resizeEvent(NULL);
@ -279,7 +282,7 @@ void CMainWindow::keyPressEvent(QKeyEvent *e)
{
if(m_process && (m_process->state() != QProcess::NotRunning))
{
mixp_beep(mixp_beep_error);
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
qWarning("Escape pressed, terminated process!");
m_process->kill();
}
@ -453,7 +456,7 @@ void CMainWindow::saveButtonClicked(void)
{
file.write(m_outputLines.join("\r\n").toUtf8());
file.close();
mixp_beep(mixp_beep_info);
MUtils::Sound::beep(MUtils::Sound::BEEP_NFO);
}
else
{
@ -473,7 +476,7 @@ void CMainWindow::copyToClipboardButtonClicked(void)
if(QClipboard *clipboard = QApplication::clipboard())
{
clipboard->setText(m_outputLines.join("\n"));
mixp_beep(mixp_beep_info);
MUtils::Sound::beep(MUtils::Sound::BEEP_NFO);
}
}
@ -624,8 +627,8 @@ void CMainWindow::showAboutScreen(void)
return;
}
const QDate buildDate = mixp_get_build_date();
const QDate curntDate = mixp_get_current_date();
const QDate buildDate = MUtils::Version::app_build_date();
const QDate curntDate = MUtils::OS::current_date();
QString text;
@ -685,7 +688,7 @@ void CMainWindow::updateSize(void)
void CMainWindow::fileReceived(const QString &str)
{
mixp_bring_to_front(this);
MUtils::GUI::bring_to_front(this);
if(str.compare("?") != 0)
{
@ -756,7 +759,7 @@ QString CMainWindow::getMediaInfoPath(void)
return m_mediaInfoHandle->fileName();
}
m_mediaInfoHandle->remove();
MIXP_DELETE_OBJ(m_mediaInfoHandle);
MUTILS_DELETE(m_mediaInfoHandle);
}
//Extract MediaInfo binary now!
@ -772,20 +775,20 @@ QString CMainWindow::getMediaInfoPath(void)
{
qWarning("Failed to open MediaInfo binary for reading!\n");
m_mediaInfoHandle->remove();
MIXP_DELETE_OBJ(m_mediaInfoHandle);
MUTILS_DELETE(m_mediaInfoHandle);
}
}
else
{
qWarning("Failed to write data to MediaInfo binary file!\n");
m_mediaInfoHandle->remove();
MIXP_DELETE_OBJ(m_mediaInfoHandle);
MUTILS_DELETE(m_mediaInfoHandle);
}
}
else
{
qWarning("Failed to open MediaInfo binary for writing!\n");
MIXP_DELETE_OBJ(m_mediaInfoHandle);
MUTILS_DELETE(m_mediaInfoHandle);
}
//Validate file content, after it has been extracted
@ -796,7 +799,7 @@ QString CMainWindow::getMediaInfoPath(void)
return m_mediaInfoHandle->fileName();
}
m_mediaInfoHandle->remove();
MIXP_DELETE_OBJ(m_mediaInfoHandle);
MUTILS_DELETE(m_mediaInfoHandle);
}
return QString();

View File

@ -22,8 +22,12 @@
#pragma once
#include "ShellExtension.h"
#include "Utils.h"
//MUtils
#include "MUtils/Registry.h"
#include "MUtils/OSSupport.h"
//Qt
#include <QApplication>
#include <QDir>
@ -33,7 +37,7 @@
bool ShellExtension::getEnabled(void)
{
quint32 value = 0;
if(mixp_reg_value_read(mixp_root_user, MIXP_REGISTRY_KEY, MIXP_REGISTRY_VAL, value))
if(MUtils::Registry::reg_value_read(MUtils::Registry::root_user, MIXP_REGISTRY_KEY, MIXP_REGISTRY_VAL, value))
{
return value;
}
@ -45,34 +49,34 @@ bool ShellExtension::setEnabled(bool enabled)
if(enabled)
{
qDebug("Installing the shell extension...");
if(mixp_reg_value_write(mixp_root_user, MIXP_REGISTRY_KEY, QString(), tr("Analyze file with MediaInfoXP")))
if(MUtils::Registry::reg_value_write(MUtils::Registry::root_user, MIXP_REGISTRY_KEY, QString(), tr("Analyze file with MediaInfoXP")))
{
const QString appPath = QDir::toNativeSeparators(QApplication::applicationFilePath());
const QString command = QString().sprintf("\"%ls\" --open \"%%1\"", appPath.utf16());
if(mixp_reg_value_write(mixp_root_user, MIXP_REGISTRY_KEY"\\command", QString(), command))
if(MUtils::Registry::reg_value_write(MUtils::Registry::root_user, MIXP_REGISTRY_KEY"\\command", QString(), command))
{
if(mixp_reg_value_write(mixp_root_user, MIXP_REGISTRY_KEY, MIXP_REGISTRY_VAL, 1))
if(MUtils::Registry::reg_value_write(MUtils::Registry::root_user, MIXP_REGISTRY_KEY, MIXP_REGISTRY_VAL, 1))
{
qDebug("Success.\n");
mixp_shell_change_notification();
MUtils::OS::shell_change_notification();
return true;
}
}
}
qWarning("Failed to install the shell extension!\n");
mixp_reg_key_delete(mixp_root_user, MIXP_REGISTRY_KEY);
MUtils::Registry::reg_key_delete(MUtils::Registry::root_user, MIXP_REGISTRY_KEY);
return false;
}
else
{
qDebug("Un-installing the shell extension...");
if(!mixp_reg_key_delete(mixp_root_user, MIXP_REGISTRY_KEY))
if(!MUtils::Registry::reg_key_delete(MUtils::Registry::root_user, MIXP_REGISTRY_KEY))
{
qWarning("Failed to un-install the shell extension!\n");
return false;
}
qDebug("Success.\n");
mixp_shell_change_notification();
MUtils::OS::shell_change_notification();
return true;
}
}

View File

@ -1,590 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// MediaInfoXP
// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#include "Utils.h"
#include "Config.h"
//Win32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <io.h>
#include <fcntl.h>
#include <Objbase.h>
#include <Psapi.h>
#include <Shlobj.h>
#include <Shlwapi.h>
//StdLib
#include <cstdio>
#include <iostream>
#include <fstream>
#include <ctime>
#pragma intrinsic(_InterlockedExchange)
//Qt
#include <QLibrary>
#include <QDir>
#include <QFileInfo>
#include <QUuid>
#include <QDate>
#include <QReadWriteLock>
#include <QMap>
#include <QIcon>
#include <QWidget>
//Function pointers
typedef HRESULT (WINAPI *SHGetKnownFolderPath_t)(const GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
typedef HRESULT (WINAPI *SHGetFolderPath_t)(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
//Known folders
typedef enum
{
mixp_folder_localappdata = 0,
mixp_folder_programfiles = 2,
mixp_folder_systemfolder = 3,
mixp_folder_systroot_dir = 4
}
mixp_known_folder_t;
//Known folder cache
static struct
{
bool initialized;
QMap<size_t, QString> knownFolders;
SHGetKnownFolderPath_t getKnownFolderPath;
SHGetFolderPath_t getFolderPath;
QReadWriteLock lock;
}
g_mixp_known_folder;
/*
* Try to lock folder
*/
static QString mixp_tryLockFolder(const QString &folderPath, QFile **lockfile)
{
const QByteArray WRITE_TEST_DATA = QByteArray("Lorem ipsum dolor sit amet, consetetur sadipscing elitr!");
for(int i = 0; i < 32; i++)
{
QDir folder(folderPath);
if(!folder.exists())
{
folder.mkdir(".");
}
if(folder.exists())
{
const QString SUB_FOLDER = QUuid::createUuid().toString().remove('{').remove('}').remove('-').right(16);
folder.mkdir(SUB_FOLDER);
if(folder.cd(SUB_FOLDER) && folder.exists())
{
QFile *testFile = new QFile(QString("%1/~lock.tmp").arg(folder.canonicalPath()));
if(testFile->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Unbuffered))
{
if(testFile->write(WRITE_TEST_DATA) >= WRITE_TEST_DATA.size())
{
*lockfile = testFile;
return folder.canonicalPath();
}
testFile->remove();
}
MIXP_DELETE_OBJ(testFile);
}
}
}
return QString();
}
/*
* Locate known folder on local system
*/
static const QString &mixp_known_folder(mixp_known_folder_t folder_id)
{
//static const int CSIDL_FLAG_CREATE = 0x8000;
//typedef enum { KF_FLAG_CREATE = 0x00008000 } kf_flags_t;
struct
{
const int csidl;
const GUID guid;
}
static s_folders[] =
{
{ 0x001c, {0xF1B32785,0x6FBA,0x4FCF,{0x9D,0x55,0x7B,0x8E,0x7F,0x15,0x70,0x91}} }, //CSIDL_LOCAL_APPDATA
{ 0x0026, {0x905e63b6,0xc1bf,0x494e,{0xb2,0x9c,0x65,0xb7,0x32,0xd3,0xd2,0x1a}} }, //CSIDL_PROGRAM_FILES
{ 0x0024, {0xF38BF404,0x1D43,0x42F2,{0x93,0x05,0x67,0xDE,0x0B,0x28,0xFC,0x23}} }, //CSIDL_WINDOWS_FOLDER
{ 0x0025, {0x1AC14E77,0x02E7,0x4E5D,{0xB7,0x44,0x2E,0xB1,0xAE,0x51,0x98,0xB7}} }, //CSIDL_SYSTEM_FOLDER
};
size_t folderId = size_t(-1);
switch(folder_id)
{
case mixp_folder_localappdata: folderId = 0; break;
case mixp_folder_programfiles: folderId = 1; break;
case mixp_folder_systroot_dir: folderId = 2; break;
case mixp_folder_systemfolder: folderId = 3; break;
}
if(folderId == size_t(-1))
{
qWarning("Invalid 'known' folder was requested!");
return *reinterpret_cast<QString*>(NULL);
}
QReadLocker readLock(&g_mixp_known_folder.lock);
//Already in cache?
if(g_mixp_known_folder.knownFolders.contains(folderId))
{
return g_mixp_known_folder.knownFolders[folderId];
}
//Obtain write lock to initialize
readLock.unlock();
QWriteLocker writeLock(&g_mixp_known_folder.lock);
//Still not in cache?
if(g_mixp_known_folder.knownFolders.contains(folderId))
{
return g_mixp_known_folder.knownFolders[folderId];
}
//Initialize on first call
if(!g_mixp_known_folder.initialized)
{
QLibrary shell32("shell32.dll");
if(shell32.load())
{
g_mixp_known_folder.getFolderPath = (SHGetFolderPath_t) shell32.resolve("SHGetFolderPathW");
g_mixp_known_folder.getKnownFolderPath = (SHGetKnownFolderPath_t) shell32.resolve("SHGetKnownFolderPath");
}
g_mixp_known_folder.initialized = true;
}
QString folderPath;
//Now try to get the folder path!
if(g_mixp_known_folder.getKnownFolderPath)
{
WCHAR *path = NULL;
if(g_mixp_known_folder.getKnownFolderPath(s_folders[folderId].guid, KF_FLAG_CREATE, NULL, &path) == S_OK)
{
//MessageBoxW(0, path, L"SHGetKnownFolderPath", MB_TOPMOST);
QDir folderTemp = QDir(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(path))));
if(folderTemp.exists())
{
folderPath = folderTemp.canonicalPath();
}
CoTaskMemFree(path);
}
}
else if(g_mixp_known_folder.getFolderPath)
{
WCHAR *path = new WCHAR[4096];
if(g_mixp_known_folder.getFolderPath(NULL, s_folders[folderId].csidl | CSIDL_FLAG_CREATE, NULL, NULL, path) == S_OK)
{
//MessageBoxW(0, path, L"SHGetFolderPathW", MB_TOPMOST);
QDir folderTemp = QDir(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(path))));
if(folderTemp.exists())
{
folderPath = folderTemp.canonicalPath();
}
}
MIXP_DELETE_ARR(path);
}
//Update cache
g_mixp_known_folder.knownFolders.insert(folderId, folderPath);
return g_mixp_known_folder.knownFolders[folderId];
}
/*
* Detect the TEMP folder
*/
QString mixp_getTempFolder(QFile **lockfile)
{
*lockfile = NULL;
//Try the %TMP% or %TEMP% directory first
QString tempPath = mixp_tryLockFolder(QDir::temp().absolutePath(), lockfile);
if(!tempPath.isEmpty())
{
return tempPath;
}
qWarning("Failed to init %%TEMP%%, falling back to %%LOCALAPPDATA%% or %%SYSTEMROOT%%\n");
//Create TEMP folder in %LOCALAPPDATA%
for(int i = 0; i < 2; i++)
{
static const mixp_known_folder_t folderId[2] = { mixp_folder_localappdata, mixp_folder_systroot_dir };
const QString &localAppDataPath = mixp_known_folder(folderId[i]);
if(!localAppDataPath.isEmpty())
{
if(QDir(localAppDataPath).exists())
{
tempPath = mixp_tryLockFolder(QString("%1/Temp").arg(localAppDataPath), lockfile);
if(!tempPath.isEmpty())
{
return tempPath;
}
}
}
}
return QString();
}
/*
* Safely remove a file
*/
static bool mixp_remove_file(const QString &filename)
{
if(!QFileInfo(filename).exists() || !QFileInfo(filename).isFile())
{
return true;
}
else
{
if(!QFile::remove(filename))
{
static const DWORD attrMask = FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM;
const DWORD attributes = GetFileAttributesW(QWCHAR(filename));
if(attributes & attrMask)
{
SetFileAttributesW(QWCHAR(filename), FILE_ATTRIBUTE_NORMAL);
}
if(!QFile::remove(filename))
{
qWarning("Could not delete \"%s\"", filename.toLatin1().constData());
return false;
}
else
{
return true;
}
}
else
{
return true;
}
}
}
/*
* Clean folder
*/
bool mixp_clean_folder(const QString &folderPath)
{
QDir tempFolder(folderPath);
if(tempFolder.exists())
{
QFileInfoList entryList = tempFolder.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden);
for(int i = 0; i < entryList.count(); i++)
{
if(entryList.at(i).isDir())
{
mixp_clean_folder(entryList.at(i).canonicalFilePath());
}
else
{
for(int j = 0; j < 3; j++)
{
if(mixp_remove_file(entryList.at(i).canonicalFilePath()))
{
break;
}
}
}
}
return tempFolder.rmdir(".");
}
return true;
}
/*
* Get build date
*/
QDate mixp_get_build_date(void)
{
QDate buildDate(2000, 1, 1);
static const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
int date[3] = {0, 0, 0}; char temp[12] = {'\0'};
strncpy_s(temp, 12, mixp_buildDate, _TRUNCATE);
if(strlen(temp) == 11)
{
temp[3] = temp[6] = '\0';
date[2] = atoi(&temp[4]);
date[0] = atoi(&temp[7]);
for(int j = 0; j < 12; j++)
{
if(!_strcmpi(&temp[0], months[j]))
{
date[1] = j+1;
break;
}
}
buildDate = QDate(date[0], date[1], date[2]);
}
return buildDate;
}
/*
* Get current date
*/
QDate mixp_get_current_date(void)
{
const DWORD MAX_PROC = 1024;
DWORD *processes = new DWORD[MAX_PROC];
DWORD bytesReturned = 0;
if(!EnumProcesses(processes, sizeof(DWORD) * MAX_PROC, &bytesReturned))
{
MIXP_DELETE_ARR(processes);
return QDate::currentDate();
}
const DWORD procCount = bytesReturned / sizeof(DWORD);
ULARGE_INTEGER lastStartTime;
memset(&lastStartTime, 0, sizeof(ULARGE_INTEGER));
for(DWORD i = 0; i < procCount; i++)
{
HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processes[i]);
if(hProc)
{
FILETIME processTime[4];
if(GetProcessTimes(hProc, &processTime[0], &processTime[1], &processTime[2], &processTime[3]))
{
ULARGE_INTEGER timeCreation;
timeCreation.LowPart = processTime[0].dwLowDateTime;
timeCreation.HighPart = processTime[0].dwHighDateTime;
if(timeCreation.QuadPart > lastStartTime.QuadPart)
{
lastStartTime.QuadPart = timeCreation.QuadPart;
}
}
CloseHandle(hProc);
}
}
MIXP_DELETE_ARR(processes);
FILETIME lastStartTime_fileTime;
lastStartTime_fileTime.dwHighDateTime = lastStartTime.HighPart;
lastStartTime_fileTime.dwLowDateTime = lastStartTime.LowPart;
FILETIME lastStartTime_localTime;
if(!FileTimeToLocalFileTime(&lastStartTime_fileTime, &lastStartTime_localTime))
{
memcpy(&lastStartTime_localTime, &lastStartTime_fileTime, sizeof(FILETIME));
}
SYSTEMTIME lastStartTime_system;
if(!FileTimeToSystemTime(&lastStartTime_localTime, &lastStartTime_system))
{
memset(&lastStartTime_system, 0, sizeof(SYSTEMTIME));
lastStartTime_system.wYear = 1970; lastStartTime_system.wMonth = lastStartTime_system.wDay = 1;
}
const QDate currentDate = QDate::currentDate();
const QDate processDate = QDate(lastStartTime_system.wYear, lastStartTime_system.wMonth, lastStartTime_system.wDay);
return (currentDate >= processDate) ? currentDate : processDate;
}
/*
* Convert QIcon to HICON -> caller is responsible for destroying the HICON!
*/
static HICON mixp_qicon2hicon(const QIcon &icon, const int w, const int h)
{
if(!icon.isNull())
{
QPixmap pixmap = icon.pixmap(w, h);
if(!pixmap.isNull())
{
return pixmap.toWinHICON();
}
}
return NULL;
}
/*
* Update the window icon
*/
mixp_icon_t *mixp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon)
{
if(!icon.isNull())
{
const int extend = (bIsBigIcon ? 32 : 16);
if(HICON hIcon = mixp_qicon2hicon(icon, extend, extend))
{
SendMessage(window->winId(), WM_SETICON, (bIsBigIcon ? ICON_BIG : ICON_SMALL), LPARAM(hIcon));
return reinterpret_cast<mixp_icon_t*>(hIcon);
}
}
return NULL;
}
/*
* Free window icon
*/
void mixp_free_window_icon(mixp_icon_t *icon)
{
if(HICON hIcon = reinterpret_cast<HICON>(icon))
{
DestroyIcon(hIcon);
}
}
/*
* Message Beep
*/
bool mixp_beep(int beepType)
{
switch(beepType)
{
case mixp_beep_info: return (MessageBeep(MB_ICONASTERISK) != FALSE); break;
case mixp_beep_warning: return (MessageBeep(MB_ICONEXCLAMATION) != FALSE); break;
case mixp_beep_error: return (MessageBeep(MB_ICONHAND) != FALSE); break;
default: return false;
}
}
/*
* Bring the specifed window to the front
*/
bool mixp_bring_to_front(const QWidget *window)
{
bool ret = false;
if(window)
{
for(int i = 0; (i < 5) && (!ret); i++)
{
ret = (SetForegroundWindow(window->winId()) != FALSE);
SwitchToThisWindow(window->winId(), TRUE);
}
LockSetForegroundWindow(LSFW_LOCK);
}
return ret;
}
/*
* Registry root key
*/
static HKEY mixp_reg_root(int rootKey)
{
switch(rootKey)
{
case mixp_root_classes: return HKEY_CLASSES_ROOT; break;
case mixp_root_user: return HKEY_CURRENT_USER; break;
case mixp_root_machine: return HKEY_LOCAL_MACHINE; break;
default: throw "Unknown root reg value was specified!";
}
}
/*
* Write registry value
*/
bool mixp_reg_value_write(int rootKey, const QString &keyName, const QString &valueName, const quint32 value)
{
bool success = false; HKEY hKey = NULL;
if(RegCreateKeyEx(mixp_reg_root(rootKey), QWCHAR(keyName), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
{
if(RegSetValueEx(hKey, valueName.isEmpty() ? NULL : QWCHAR(valueName), 0, REG_DWORD, reinterpret_cast<const BYTE*>(&value), sizeof(quint32)) == ERROR_SUCCESS)
{
success = true;
}
CloseHandle(hKey);
}
return success;
}
/*
* Write registry value
*/
bool mixp_reg_value_write(int rootKey, const QString &keyName, const QString &valueName, const QString &value)
{
bool success = false; HKEY hKey = NULL;
if(RegCreateKeyEx(mixp_reg_root(rootKey), QWCHAR(keyName), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
{
if(RegSetValueEx(hKey, valueName.isEmpty() ? NULL : QWCHAR(valueName), 0, REG_SZ, reinterpret_cast<const BYTE*>(value.utf16()), (value.length() + 1) * sizeof(wchar_t)) == ERROR_SUCCESS)
{
success = true;
}
CloseHandle(hKey);
}
return success;
}
/*
* Read registry value
*/
bool mixp_reg_value_read(int rootKey, const QString &keyName, const QString &valueName, quint32 &value)
{
bool success = false; HKEY hKey = NULL;
if(RegOpenKeyEx(mixp_reg_root(rootKey), QWCHAR(keyName), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
DWORD size = sizeof(quint32), type = -1;
if(RegQueryValueEx(hKey, valueName.isEmpty() ? NULL : QWCHAR(valueName), 0, &type, reinterpret_cast<BYTE*>(&value), &size) == ERROR_SUCCESS)
{
success = (type == REG_DWORD);
}
CloseHandle(hKey);
}
return success;
}
/*
* Delete registry key
*/
bool mixp_reg_key_delete(int rootKey, const QString &keyName)
{
return (SHDeleteKey( mixp_reg_root(rootKey), QWCHAR(keyName)) == ERROR_SUCCESS);
}
/*
* Shell notification
*/
void mixp_shell_change_notification(void)
{
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
}
/*
* Global init
*/
void _mixp_global_init(void)
{
g_mixp_known_folder.initialized = false;
}

View File

@ -1,73 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// MediaInfoXP
// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
#include <QFile>
class QDate;
class QWidget;
class QIcon;
class mixp_icon_t;
//Helper macros
#define MIXP_DELETE_OBJ(PTR) do { if((PTR)) { delete ((PTR)); (PTR) = NULL; } } while (0)
#define MIXP_DELETE_ARR(PTR) do { if((PTR)) { delete [] ((PTR)); (PTR) = NULL; } } while (0)
#define QWCHAR(STR) reinterpret_cast<const wchar_t*>(STR.utf16())
//Beep types
typedef enum
{
mixp_beep_info = 0,
mixp_beep_warning = 1,
mixp_beep_error = 2
}
mixp_beep_t;
//Regsitry root
typedef enum
{
mixp_root_classes = 0,
mixp_root_user = 1,
mixp_root_machine = 2,
}
mixp_reg_root_t;
//Utils
QString mixp_getTempFolder(QFile **lockfile);
bool mixp_clean_folder(const QString &folderPath);
QDate mixp_get_build_date(void);
QDate mixp_get_current_date(void);
mixp_icon_t *mixp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon);
void mixp_free_window_icon(mixp_icon_t *icon);
bool mixp_beep(int beepType);
bool mixp_bring_to_front(const QWidget *window);
void mixp_shell_change_notification(void);
//Regsitry
bool mixp_reg_value_write(int rootKey, const QString &keyName, const QString &valueName, const quint32 value);
bool mixp_reg_value_write(int rootKey, const QString &keyName, const QString &valueName, const QString &value);
bool mixp_reg_value_read(int rootKey, const QString &keyName, const QString &valueName, quint32 &value);
bool mixp_reg_key_delete(int rootKey, const QString &keyName);
//Init
void _mixp_global_init(void);