mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
This commit is contained in:
125
Plugins/PluginQuote/PluginQuote.dsp
Normal file
125
Plugins/PluginQuote/PluginQuote.dsp
Normal file
@ -0,0 +1,125 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginQuote" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginQuote - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "PluginQuote.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "PluginQuote.mak" CFG="PluginQuote - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginQuote - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginQuote - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginQuote - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginQuote"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginQuote - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x32/Release"
|
||||
# PROP Intermediate_Dir "x32/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PluginQuote_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginQuote_EXPORTS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 shlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../../TestBench/x32/Release/Plugins/QuotePlugin.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginQuote - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "x32/Debug"
|
||||
# PROP Intermediate_Dir "x32/Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PluginQuote_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginQuote_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "_DEBUG"
|
||||
# ADD RSC /l 0x40b /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 shlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../../TestBench/x32/Debug/Plugins/QuotePlugin.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginQuote - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginQuote___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginQuote___Win32_Release_64"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x64/Release"
|
||||
# PROP Intermediate_Dir "x64/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginQuote_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginQuote_EXPORTS" /FD /GL /EHsc /Wp64 /GA /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 shlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../../TestBench/x32/Release/Plugins/QuotePlugin.dll"
|
||||
# ADD LINK32 bufferoverflowU.lib shlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:IX86 /out:"../../TestBench/x64/Release/Plugins/QuotePlugin.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginQuote - Win32 Release"
|
||||
# Name "PluginQuote - Win32 Debug"
|
||||
# Name "PluginQuote - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Quote.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
234
Plugins/PluginQuote/PluginQuote.vcproj
Normal file
234
Plugins/PluginQuote/PluginQuote.vcproj
Normal file
@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginQuote"
|
||||
SccProjectName="PluginQuote"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release 64|Win32"
|
||||
OutputDirectory=".\x64/Release"
|
||||
IntermediateDirectory=".\x64/Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/GL /EHsc /Wp64 /GA "
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginQuote_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginQuote.pch"
|
||||
AssemblerListingLocation=".\x64/Release/"
|
||||
ObjectFile=".\x64/Release/"
|
||||
ProgramDataBaseFileName=".\x64/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/machine:AMD64 /LTCG "
|
||||
AdditionalDependencies="bufferoverflowU.lib shlwapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/QuotePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/QuotePlugin.pdb"
|
||||
ImportLibrary=".\x64/Release/QuotePlugin.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginQuote.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\x32/Release"
|
||||
IntermediateDirectory=".\x32/Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginQuote_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginQuote.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shlwapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/QuotePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/QuotePlugin.pdb"
|
||||
ImportLibrary=".\x32/Release/QuotePlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginQuote.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\x32/Debug"
|
||||
IntermediateDirectory=".\x32/Debug"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;UNICODE;_USRDLL;PluginQuote_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginQuote.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shlwapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/QuotePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/QuotePlugin.pdb"
|
||||
ImportLibrary=".\x32/Debug/QuotePlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginQuote.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="Quote.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginQuote_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginQuote_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginQuote_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
455
Plugins/PluginQuote/Quote.cpp
Normal file
455
Plugins/PluginQuote/Quote.cpp
Normal file
@ -0,0 +1,455 @@
|
||||
/*
|
||||
Copyright (C) 2005 Kimmo Pekkola
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginQuote/Quote.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Quote.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
#include <tchar.h>
|
||||
#include <shlwapi.h>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
/* The exported functions */
|
||||
extern "C"
|
||||
{
|
||||
__declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
|
||||
__declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
|
||||
__declspec( dllexport ) double Update2(UINT id);
|
||||
__declspec( dllexport ) LPCTSTR GetString(UINT id, UINT flags);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
struct quoteData
|
||||
{
|
||||
std::wstring pathname;
|
||||
std::wstring separator;
|
||||
std::vector<std::wstring> fileFilters;
|
||||
std::vector<std::wstring> files;
|
||||
std::wstring value;
|
||||
};
|
||||
|
||||
void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path);
|
||||
|
||||
static std::map<UINT, quoteData> g_Values;
|
||||
|
||||
std::string ConvertToAscii(LPCTSTR str)
|
||||
{
|
||||
std::string szAscii;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = (wcslen(str) + 1);
|
||||
char* tmpSz = new char[len * 2];
|
||||
WideCharToMultiByte(CP_ACP, 0, str, -1, tmpSz, (int)len * 2, NULL, FALSE);
|
||||
szAscii = tmpSz;
|
||||
delete tmpSz;
|
||||
}
|
||||
return szAscii;
|
||||
}
|
||||
|
||||
std::wstring ConvertToWide(LPCSTR str)
|
||||
{
|
||||
std::wstring szWide;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = strlen(str) + 1;
|
||||
WCHAR* wideSz = new WCHAR[len * 2];
|
||||
MultiByteToWideChar(CP_ACP, 0, str, (int)len, wideSz, (int)len * 2);
|
||||
szWide = wideSz;
|
||||
delete wideSz;
|
||||
}
|
||||
return szWide;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
The return value can also be 0, which means that Rainmeter will
|
||||
track the maximum value automatically. The parameters for this
|
||||
function are:
|
||||
|
||||
instance The instance of this DLL
|
||||
iniFile The name of the ini-file (usually Rainmeter.ini)
|
||||
section The name of the section in the ini-file for this measure
|
||||
id The identifier for the measure. This is used to identify the measures that use the same plugin.
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
quoteData qData;
|
||||
LPCTSTR data;
|
||||
bool bSubfolders = false;
|
||||
|
||||
data = ReadConfigString(section, L"Subfolders", L"0");
|
||||
if (data && _ttoi(data) == 1)
|
||||
{
|
||||
bSubfolders = true;
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"Separator", L"\n");
|
||||
if (data)
|
||||
{
|
||||
qData.separator = data;
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"FileFilter", L"");
|
||||
if (data && wcslen(data) > 0)
|
||||
{
|
||||
std::wstring ext = data;
|
||||
|
||||
size_t start = 0;
|
||||
size_t pos = ext.find(L';');
|
||||
while (pos != std::wstring::npos)
|
||||
{
|
||||
qData.fileFilters.push_back(ext.substr(start, pos - start));
|
||||
start = pos + 1;
|
||||
pos = ext.find(L';', pos + 1);
|
||||
}
|
||||
qData.fileFilters.push_back(ext.substr(start));
|
||||
|
||||
qData.separator = data;
|
||||
}
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
data = ReadConfigString(section, L"PathName", L"");
|
||||
if (data && wcslen(data) > 0)
|
||||
{
|
||||
qData.pathname = data;
|
||||
|
||||
if (qData.pathname.find(':') == -1) // Not found
|
||||
{
|
||||
std::wstring path = iniFile;
|
||||
size_t pos = path.rfind('\\');
|
||||
if (pos >= 0)
|
||||
{
|
||||
path.erase(pos + 1);
|
||||
qData.pathname = path + qData.pathname;
|
||||
}
|
||||
}
|
||||
|
||||
if (PathIsDirectory(qData.pathname.c_str()))
|
||||
{
|
||||
if (qData.pathname[qData.pathname.size() - 1] != L'\\')
|
||||
{
|
||||
qData.pathname += L"\\";
|
||||
}
|
||||
|
||||
// Scan files
|
||||
ScanFolder(qData, bSubfolders, qData.pathname);
|
||||
}
|
||||
}
|
||||
|
||||
if (!qData.pathname.empty())
|
||||
{
|
||||
g_Values[id] = qData;
|
||||
}
|
||||
|
||||
// TODO: Random=0, load stuff sequentially (store to somewhere)
|
||||
|
||||
srand( (unsigned)time( NULL ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
|
||||
{
|
||||
// Get folder listing
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
|
||||
std::wstring searchPath = path + L"*";
|
||||
|
||||
hSearch = FindFirstFile(searchPath.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
if (bSubfolders)
|
||||
{
|
||||
if (wcscmp(fileData.cFileName, L".") != 0 && wcscmp(fileData.cFileName, L"..") != 0)
|
||||
{
|
||||
ScanFolder(qData, bSubfolders, path + fileData.cFileName + L"\\");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!qData.fileFilters.empty())
|
||||
{
|
||||
for (int i = 0; i < qData.fileFilters.size(); i++)
|
||||
{
|
||||
if (!qData.fileFilters[i].empty() && PathMatchSpec(fileData.cFileName, qData.fileFilters[i].c_str()))
|
||||
{
|
||||
qData.files.push_back(path + fileData.cFileName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qData.files.push_back(path + fileData.cFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
while(FindNextFile(hSearch, &fileData));
|
||||
}
|
||||
|
||||
#define BUFFER_SIZE 4096
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
std::map<UINT, quoteData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
{
|
||||
quoteData& qData = (*i).second;
|
||||
|
||||
if (qData.files.empty())
|
||||
{
|
||||
BYTE buffer[BUFFER_SIZE + 2];
|
||||
buffer[BUFFER_SIZE] = 0;
|
||||
|
||||
// Read the file
|
||||
FILE* file = _wfopen(qData.pathname.c_str(), L"r");
|
||||
if (file)
|
||||
{
|
||||
// Check if the file is unicode or ascii
|
||||
fread(buffer, sizeof(WCHAR), 1, file);
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
int size = ftell(file);
|
||||
|
||||
// Go to a random place
|
||||
int pos = rand() % size;
|
||||
fseek(file, (pos / 2) * 2, SEEK_SET);
|
||||
|
||||
qData.value.erase();
|
||||
|
||||
if (0xFEFF == *(WCHAR*)buffer)
|
||||
{
|
||||
// It's unicode
|
||||
WCHAR* wBuffer = (WCHAR*)buffer;
|
||||
|
||||
// Read until we find the first separator
|
||||
WCHAR* sepPos1 = NULL;
|
||||
WCHAR* sepPos2 = NULL;
|
||||
do
|
||||
{
|
||||
size_t len = fread(buffer, sizeof(BYTE), BUFFER_SIZE, file);
|
||||
buffer[len] = 0;
|
||||
buffer[len + 1] = 0;
|
||||
|
||||
sepPos1 = wcsstr(wBuffer, qData.separator.c_str());
|
||||
if (sepPos1 == NULL)
|
||||
{
|
||||
// The separator wasn't found
|
||||
if (feof(file))
|
||||
{
|
||||
// End of file reached -> read from start
|
||||
fseek(file, 2, SEEK_SET);
|
||||
len = fread(buffer, sizeof(BYTE), BUFFER_SIZE, file);
|
||||
buffer[len] = 0;
|
||||
buffer[len + 1] = 0;
|
||||
sepPos1 = wBuffer;
|
||||
}
|
||||
// else continue reading
|
||||
}
|
||||
else
|
||||
{
|
||||
sepPos1 += qData.separator.size();
|
||||
}
|
||||
}
|
||||
while (sepPos1 == NULL);
|
||||
|
||||
// Find the second separator
|
||||
do
|
||||
{
|
||||
sepPos2 = wcsstr(sepPos1, qData.separator.c_str());
|
||||
if (sepPos2 == NULL)
|
||||
{
|
||||
// The separator wasn't found
|
||||
if (feof(file))
|
||||
{
|
||||
// End of file reached -> read the rest
|
||||
qData.value += sepPos1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
qData.value += sepPos1;
|
||||
|
||||
// else continue reading
|
||||
size_t len = fread(buffer, sizeof(BYTE), BUFFER_SIZE, file);
|
||||
buffer[len] = 0;
|
||||
buffer[len + 1] = 0;
|
||||
sepPos1 = wBuffer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sepPos2)
|
||||
{
|
||||
*sepPos2 = 0;
|
||||
}
|
||||
|
||||
// Read until we find the second separator
|
||||
qData.value += sepPos1;
|
||||
}
|
||||
}
|
||||
while (sepPos2 == NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
// It's ascii
|
||||
char* aBuffer = (char*)buffer;
|
||||
|
||||
// Read until we find the first separator
|
||||
char* sepPos1 = NULL;
|
||||
char* sepPos2 = NULL;
|
||||
do
|
||||
{
|
||||
size_t len = fread(buffer, sizeof(char), BUFFER_SIZE, file);
|
||||
aBuffer[len] = 0;
|
||||
|
||||
sepPos1 = strstr(aBuffer, ConvertToAscii(qData.separator.c_str()).c_str());
|
||||
if (sepPos1 == NULL)
|
||||
{
|
||||
// The separator wasn't found
|
||||
if (feof(file))
|
||||
{
|
||||
// End of file reached -> read from start
|
||||
fseek(file, 0, SEEK_SET);
|
||||
len = fread(buffer, sizeof(char), BUFFER_SIZE, file);
|
||||
aBuffer[len] = 0;
|
||||
sepPos1 = aBuffer;
|
||||
}
|
||||
// else continue reading
|
||||
}
|
||||
else
|
||||
{
|
||||
sepPos1 += qData.separator.size();
|
||||
}
|
||||
}
|
||||
while (sepPos1 == NULL);
|
||||
|
||||
// Find the second separator
|
||||
do
|
||||
{
|
||||
sepPos2 = strstr(sepPos1, ConvertToAscii(qData.separator.c_str()).c_str());
|
||||
if (sepPos2 == NULL)
|
||||
{
|
||||
// The separator wasn't found
|
||||
if (feof(file))
|
||||
{
|
||||
// End of file reached -> read the rest
|
||||
qData.value += ConvertToWide(sepPos1);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
qData.value += ConvertToWide(sepPos1);
|
||||
|
||||
// else continue reading
|
||||
size_t len = fread(buffer, sizeof(char), BUFFER_SIZE, file);
|
||||
aBuffer[len] = 0;
|
||||
sepPos1 = aBuffer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sepPos2)
|
||||
{
|
||||
*sepPos2 = 0;
|
||||
}
|
||||
|
||||
// Read until we find the second separator
|
||||
qData.value += ConvertToWide(sepPos1);
|
||||
}
|
||||
}
|
||||
while (sepPos2 == NULL);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the filename
|
||||
if (qData.files.size() > 0)
|
||||
{
|
||||
qData.value = qData.files[rand() % qData.files.size()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, quoteData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
{
|
||||
return ((*i).second).value.c_str();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
If the measure needs to free resources before quitting.
|
||||
The plugin can export Finalize function, which is called
|
||||
when Rainmeter quits (or refreshes).
|
||||
*/
|
||||
void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
std::map<UINT, quoteData>::iterator i1 = g_Values.find(id);
|
||||
if (i1 != g_Values.end())
|
||||
{
|
||||
g_Values.erase(i1);
|
||||
}
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1001;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
Reference in New Issue
Block a user