mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Cosmetic changes to code.
This commit is contained in:
parent
5882f12c49
commit
a92bdd9b18
@ -61,7 +61,7 @@ enum RetValue
|
||||
RetError = 1
|
||||
};
|
||||
|
||||
/*
|
||||
/*
|
||||
** WinMain
|
||||
**
|
||||
** The Main-function
|
||||
@ -94,22 +94,22 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
||||
return RetSuccess;
|
||||
}
|
||||
|
||||
if(!hPrevInstance)
|
||||
if (!hPrevInstance)
|
||||
{
|
||||
if (!InitApplication(hInstance, WinClass)) return RetError;
|
||||
}
|
||||
|
||||
hWnd=InitInstance(hInstance, WinClass, WinName);
|
||||
if(!hWnd) return RetError;
|
||||
if (!hWnd) return RetError;
|
||||
|
||||
// Remove quotes from the commandline
|
||||
WCHAR Path[MAX_PATH+1] = {0};
|
||||
if(lpCmdLine)
|
||||
if (lpCmdLine)
|
||||
{
|
||||
size_t Pos = 0;
|
||||
for(size_t i = 0, len = wcslen(lpCmdLine); i <= len && Pos < MAX_PATH; ++i)
|
||||
for (size_t i = 0, len = wcslen(lpCmdLine); i <= len && Pos < MAX_PATH; ++i)
|
||||
{
|
||||
if(lpCmdLine[i] != L'\"') Path[Pos++] = lpCmdLine[i];
|
||||
if (lpCmdLine[i] != L'\"') Path[Pos++] = lpCmdLine[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
||||
|
||||
// Check that the DLL is available
|
||||
HMODULE module = GetModuleHandle(L"Rainmeter.dll");
|
||||
if(module == NULL)
|
||||
if (module == NULL)
|
||||
{
|
||||
MessageBox(NULL, L"Unable to load Rainmeter.dll", L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONERROR);
|
||||
DestroyWindow(hWnd);
|
||||
@ -134,7 +134,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
||||
}
|
||||
|
||||
// Run the standard window message loop
|
||||
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
|
||||
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
|
||||
{
|
||||
if (bRet == -1) // error
|
||||
{
|
||||
@ -144,15 +144,15 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
||||
else
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hMutex) ReleaseMutex(hMutex);
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** InitApplication
|
||||
**
|
||||
** Creates the windowclass
|
||||
@ -169,14 +169,14 @@ BOOL InitApplication(HINSTANCE hInstance, const WCHAR* WinClass)
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_RAINMETER));
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = WinClass;
|
||||
|
||||
return RegisterClass(&wc);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** InitInstance
|
||||
**
|
||||
** Creates the window. This is just an invisible window. The real window
|
||||
@ -201,7 +201,7 @@ HWND InitInstance(HINSTANCE hInstance, const WCHAR* WinClass, const WCHAR* WinNa
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** Bang
|
||||
**
|
||||
** Sends bangs to the DLL
|
||||
@ -231,7 +231,7 @@ void Bang(const WCHAR* command)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** RmLoadSystemLibrary
|
||||
**
|
||||
** Loads a system dll from system32 directory.
|
||||
@ -254,7 +254,7 @@ HMODULE RmLoadSystemLibrary(LPCWSTR lpLibFileName)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** IsRunning
|
||||
**
|
||||
** Checks whether Rainmeter.exe is running.
|
||||
@ -330,7 +330,7 @@ BOOL IsRunning(HANDLE* hMutex)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** MainWndProc
|
||||
**
|
||||
** The main window procedure
|
||||
|
@ -127,7 +127,7 @@ void UpdateAboutDialog()
|
||||
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); ++iter)
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
if (_wcsicmp(selectedItemName, (*iter).first.c_str()) == 0)
|
||||
{
|
||||
@ -200,7 +200,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
|
||||
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); ++iter)
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
if (current == selected)
|
||||
{
|
||||
@ -213,7 +213,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
|
||||
|
||||
int index = 0;
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
const WCHAR* name = (*i)->GetName();
|
||||
const WCHAR* val = (*i)->GetStats();
|
||||
@ -229,7 +229,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
|
||||
|
||||
if (name && *name)
|
||||
{
|
||||
if (index < count)
|
||||
if (index < count)
|
||||
{
|
||||
ListView_SetItemText(widget, index, 0, (WCHAR*)name);
|
||||
}
|
||||
@ -237,7 +237,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
|
||||
{
|
||||
LVITEM vitem;
|
||||
vitem.mask = LVIF_TEXT;
|
||||
vitem.iItem = index;
|
||||
vitem.iItem = index;
|
||||
vitem.iSubItem = 0;
|
||||
vitem.pszText = (WCHAR*)name;
|
||||
ListView_InsertItem(widget, &vitem);
|
||||
@ -273,7 +273,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgets()
|
||||
void UpdateWidgets()
|
||||
{
|
||||
HWND widget;
|
||||
widget = GetDlgItem(g_DialogWin, IDC_ABOUT_ENTRIES);
|
||||
@ -284,8 +284,8 @@ void UpdateWidgets()
|
||||
|
||||
if (selected == 0)
|
||||
{
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = L"Time";
|
||||
ListView_SetColumn(widget, 0, &lvc);
|
||||
lvc.pszText = L"Type";
|
||||
@ -295,8 +295,8 @@ void UpdateWidgets()
|
||||
}
|
||||
else if (selected == 1)
|
||||
{
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = L"Plugin";
|
||||
ListView_SetColumn(widget, 0, &lvc);
|
||||
lvc.pszText = L"Version";
|
||||
@ -344,8 +344,8 @@ void UpdateWidgets()
|
||||
}
|
||||
else
|
||||
{
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = L"Measure";
|
||||
ListView_SetColumn(widget, 0, &lvc);
|
||||
lvc.pszText = L"Range";
|
||||
@ -390,7 +390,7 @@ void ScanPlugins()
|
||||
info.author = author;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GETPLUGINVERSION GetVersionFunc = (GETPLUGINVERSION)GetProcAddress(dll, "GetPluginVersion");
|
||||
if (GetVersionFunc)
|
||||
{
|
||||
@ -444,13 +444,13 @@ void RepositionControls(HWND hwndDlg)
|
||||
widget = GetDlgItem(hwndDlg, IDC_STATISTICS);
|
||||
SetWindowPos(widget, NULL, (r.right < 800) ? (18 + ((r.right - 28) / 3)) : 275, 130, (r.right < 800) ? (2 * ((r.right - 28) / 3)) : (r.right - 287), r.bottom - 170, SWP_NOZORDER);
|
||||
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_WIDTH;
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_WIDTH;
|
||||
lvc.cx = ((r.right < 800) ? (2 * ((r.right - 28) / 3)) : (r.right - 287)) - 200;
|
||||
ListView_SetColumn(widget, 2, &lvc);
|
||||
}
|
||||
|
||||
BOOL OnInitAboutDialog(HWND window)
|
||||
BOOL OnInitAboutDialog(HWND window)
|
||||
{
|
||||
WCHAR tmpSz[256];
|
||||
HWND widget;
|
||||
@ -477,7 +477,7 @@ BOOL OnInitAboutDialog(HWND window)
|
||||
size_t namelength = skinName.length();
|
||||
|
||||
int currwidth = (int)SendMessage(widget, LB_GETHORIZONTALEXTENT, NULL, NULL);
|
||||
if(6 * (int)namelength > currwidth)
|
||||
if (6 * (int)namelength > currwidth)
|
||||
{
|
||||
SendMessage(widget, LB_SETHORIZONTALEXTENT, 6 * namelength, NULL);
|
||||
}
|
||||
@ -498,8 +498,8 @@ BOOL OnInitAboutDialog(HWND window)
|
||||
//ListView_SetExtendedListViewStyleEx(widget, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
|
||||
ListView_SetExtendedListViewStyleEx(widget, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
|
||||
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
|
||||
lvc.iSubItem = 0;
|
||||
lvc.pszText = L"Time";
|
||||
lvc.cx = 110;
|
||||
@ -521,7 +521,7 @@ BOOL OnInitAboutDialog(HWND window)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
@ -551,7 +551,7 @@ INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa
|
||||
case IDC_DISABLE_VERSION_CHECK:
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_DISABLE_VERSION_CHECK))
|
||||
{
|
||||
Rainmeter->SetDisableVersionCheck(TRUE);
|
||||
Rainmeter->SetDisableVersionCheck(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -580,7 +580,7 @@ INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa
|
||||
UpdateWidgets();
|
||||
UpdateAboutStatistics();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -96,7 +96,7 @@ void CConfigParser::SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* me
|
||||
SetBuiltInVariable(L"PLUGINSPATH", pRainmeter->GetPluginPath());
|
||||
SetBuiltInVariable(L"CURRENTPATH", CRainmeter::ExtractPath(m_Filename));
|
||||
SetBuiltInVariable(L"ADDONSPATH", pRainmeter->GetAddonPath());
|
||||
SetBuiltInVariable(L"CRLF", L"\n");
|
||||
SetBuiltInVariable(L"CRLF", L"\n");
|
||||
|
||||
if (meterWindow)
|
||||
{
|
||||
@ -141,7 +141,7 @@ void CConfigParser::ReadVariables()
|
||||
/**
|
||||
** Sets a new value for the variable. The DynamicVariables must be set to 1 in the
|
||||
** meter/measure for the changes to be applied.
|
||||
**
|
||||
**
|
||||
** \param variables
|
||||
** \param strVariable
|
||||
** \param strValue
|
||||
@ -155,7 +155,7 @@ void CConfigParser::SetVariable(std::unordered_map<std::wstring, std::wstring>&
|
||||
|
||||
/**
|
||||
** Gets a value for the variable.
|
||||
**
|
||||
**
|
||||
** \param strVariable
|
||||
** \param strValue
|
||||
** \return true if variable is found
|
||||
@ -216,7 +216,7 @@ void CConfigParser::ResetMonitorVariables(CMeterWindow* meterWindow)
|
||||
** SetMultiMonitorVariables
|
||||
**
|
||||
** Sets new values for the SCREENAREA/WORKAREA variables.
|
||||
**
|
||||
**
|
||||
*/
|
||||
void CConfigParser::SetMultiMonitorVariables(bool reset)
|
||||
{
|
||||
@ -322,7 +322,7 @@ void CConfigParser::SetMultiMonitorVariables(bool reset)
|
||||
** SetAutoSelectedMonitorVariables
|
||||
**
|
||||
** Sets new SCREENAREA/WORKAREA variables for present monitor.
|
||||
**
|
||||
**
|
||||
*/
|
||||
void CConfigParser::SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow)
|
||||
{
|
||||
@ -440,7 +440,7 @@ void CConfigParser::SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow)
|
||||
|
||||
/**
|
||||
** Replaces environment and internal variables in the given string.
|
||||
**
|
||||
**
|
||||
** \param result The string where the variables are returned. The string is modified.
|
||||
*/
|
||||
bool CConfigParser::ReplaceVariables(std::wstring& result)
|
||||
@ -460,7 +460,7 @@ bool CConfigParser::ReplaceVariables(std::wstring& result)
|
||||
size_t pos = std::wstring::npos;
|
||||
bool loop = true;
|
||||
|
||||
do
|
||||
do
|
||||
{
|
||||
pos = result.find(L'#', start);
|
||||
if (pos != std::wstring::npos)
|
||||
@ -499,7 +499,7 @@ bool CConfigParser::ReplaceVariables(std::wstring& result)
|
||||
|
||||
/**
|
||||
** Replaces measures in the given string.
|
||||
**
|
||||
**
|
||||
** \param result The string where the measure values are returned. The string is modified.
|
||||
*/
|
||||
bool CConfigParser::ReplaceMeasures(std::wstring& result)
|
||||
@ -514,7 +514,7 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result)
|
||||
size_t pos = std::wstring::npos;
|
||||
size_t pos2 = std::wstring::npos;
|
||||
bool loop = true;
|
||||
do
|
||||
do
|
||||
{
|
||||
pos = result.find(L'[', start);
|
||||
if (pos != std::wstring::npos)
|
||||
@ -764,7 +764,7 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue)
|
||||
return (m_LastDefaultUsed) ? defValue : ParseDouble(result, defValue);
|
||||
}
|
||||
|
||||
// Returns an int if the formula was read successfully, -1 for failure.
|
||||
// Returns 1 if the formula was read successfully, -1 for failure.
|
||||
// Pass a pointer to a double.
|
||||
int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue)
|
||||
{
|
||||
@ -772,7 +772,7 @@ int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue)
|
||||
if (result.size() > 0 && result[0] == L'(' && result[result.size() - 1] == L')')
|
||||
{
|
||||
char* errMsg = MathParser_Parse(m_Parser, ConvertToAscii(result.substr(1, result.size() - 2).c_str()).c_str(), resultValue);
|
||||
|
||||
|
||||
if (errMsg != NULL)
|
||||
{
|
||||
Log(LOG_ERROR, ConvertToWide(errMsg).c_str());
|
||||
@ -816,15 +816,15 @@ RECT CConfigParser::ReadRECT(LPCTSTR section, LPCTSTR key, const RECT& defValue)
|
||||
std::vector<std::wstring> CConfigParser::Tokenize(const std::wstring& str, const std::wstring& delimiters)
|
||||
{
|
||||
std::vector<std::wstring> tokens;
|
||||
|
||||
|
||||
std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0); // skip delimiters at beginning.
|
||||
std::wstring::size_type pos = str.find_first_of(delimiters, lastPos); // find first "non-delimiter".
|
||||
|
||||
while (std::wstring::npos != pos || std::wstring::npos != lastPos)
|
||||
{
|
||||
tokens.push_back(str.substr(lastPos, pos - lastPos)); // found a token, add it to the vector.
|
||||
lastPos = str.find_first_not_of(delimiters, pos); // skip delimiters. Note the "not_of"
|
||||
pos = str.find_first_of(delimiters, lastPos); // find next "non-delimiter"
|
||||
tokens.push_back(str.substr(lastPos, pos - lastPos)); // found a token, add it to the vector.
|
||||
lastPos = str.find_first_not_of(delimiters, pos); // skip delimiters. Note the "not_of"
|
||||
pos = str.find_first_of(delimiters, lastPos); // find next "non-delimiter"
|
||||
}
|
||||
|
||||
return tokens;
|
||||
@ -840,7 +840,7 @@ std::vector<std::wstring> CConfigParser::Tokenize(const std::wstring& str, const
|
||||
double CConfigParser::ParseDouble(const std::wstring& string, double defValue, bool rejectExp)
|
||||
{
|
||||
std::wstring::size_type pos;
|
||||
|
||||
|
||||
// Ignore inline comments which start with ';'
|
||||
if ((pos = string.find_first_of(L';')) != std::wstring::npos)
|
||||
{
|
||||
@ -878,7 +878,7 @@ double CConfigParser::ParseDouble(const std::wstring& string, double defValue, b
|
||||
** ParseColor
|
||||
**
|
||||
** This is a helper method that parses the color values from the given string.
|
||||
** The color can be supplied as three/four comma separated values or as one
|
||||
** The color can be supplied as three/four comma separated values or as one
|
||||
** hex-value.
|
||||
**
|
||||
*/
|
||||
@ -886,7 +886,7 @@ Color CConfigParser::ParseColor(LPCTSTR string)
|
||||
{
|
||||
int R, G, B, A;
|
||||
|
||||
if(wcschr(string, L',') != NULL)
|
||||
if (wcschr(string, L',') != NULL)
|
||||
{
|
||||
WCHAR* parseSz = _wcsdup(string);
|
||||
WCHAR* token;
|
||||
@ -936,7 +936,7 @@ Color CConfigParser::ParseColor(LPCTSTR string)
|
||||
A = 255;
|
||||
}
|
||||
free(parseSz);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const WCHAR* start = string;
|
||||
@ -949,8 +949,8 @@ Color CConfigParser::ParseColor(LPCTSTR string)
|
||||
if (wcslen(string) > 6 && !iswspace(string[6]))
|
||||
{
|
||||
swscanf(string, L"%02x%02x%02x%02x", &R, &G, &B, &A);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
swscanf(string, L"%02x%02x%02x", &R, &G, &B);
|
||||
A = 255; // Opaque
|
||||
@ -1029,7 +1029,7 @@ RECT CConfigParser::ParseRECT(LPCTSTR string)
|
||||
//==============================================================================
|
||||
/**
|
||||
** Reads the given ini file and fills the m_Values and m_Keys maps.
|
||||
**
|
||||
**
|
||||
** \param iniFile The ini file to be read.
|
||||
*/
|
||||
void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings, const std::wstring& iniFile, int depth)
|
||||
@ -1067,7 +1067,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
|
||||
WCHAR* epos = NULL;
|
||||
|
||||
// Get all the sections
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
items[0] = 0;
|
||||
int res = GetPrivateProfileString( NULL, NULL, NULL, items, size, iniRead.c_str());
|
||||
@ -1117,7 +1117,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
|
||||
std::list<std::wstring>::const_iterator iter = sections.begin();
|
||||
for ( ; iter != sections.end(); ++iter)
|
||||
{
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
items[0] = 0;
|
||||
int res = GetPrivateProfileString((*iter).c_str(), NULL, NULL, items, size, iniRead.c_str());
|
||||
@ -1139,7 +1139,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
|
||||
{
|
||||
std::wstring strKey = pos;
|
||||
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
buffer[0] = 0;
|
||||
int res = GetPrivateProfileString((*iter).c_str(), strKey.c_str(), L"", buffer, bufferSize, iniRead.c_str());
|
||||
@ -1184,7 +1184,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
|
||||
//==============================================================================
|
||||
/**
|
||||
** Sets the value for the key under the given section.
|
||||
**
|
||||
**
|
||||
** \param strSection The name of the section.
|
||||
** \param strKey The name of the key.
|
||||
** \param strValue The value for the key.
|
||||
@ -1211,7 +1211,7 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring&
|
||||
//==============================================================================
|
||||
/**
|
||||
** Returns the value for the key under the given section.
|
||||
**
|
||||
**
|
||||
** \param strSection The name of the section.
|
||||
** \param strKey The name of the key.
|
||||
** \param strDefault The default value for the key.
|
||||
@ -1234,7 +1234,7 @@ const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, cons
|
||||
//==============================================================================
|
||||
/**
|
||||
** Returns a list of keys under the given section.
|
||||
**
|
||||
**
|
||||
** \param strSection The name of the section.
|
||||
** \return A list of keys under the given section.
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Error.h"
|
||||
|
||||
const WCHAR* CError::c_ErrorStrings[] =
|
||||
const WCHAR* CError::c_ErrorStrings[] =
|
||||
{
|
||||
L"User defined error",
|
||||
L"Out of memory",
|
||||
@ -28,7 +28,7 @@ const WCHAR* CError::c_ErrorStrings[] =
|
||||
L"Unable to create window"
|
||||
};
|
||||
|
||||
/*
|
||||
/*
|
||||
** GetString
|
||||
**
|
||||
** Returns the error string
|
||||
@ -38,10 +38,10 @@ const std::wstring& CError::GetString()
|
||||
{
|
||||
// static WCHAR Buffer[16];
|
||||
|
||||
if (m_Error != ERROR_USER)
|
||||
if (m_Error != ERROR_USER)
|
||||
{
|
||||
m_String = c_ErrorStrings[m_Error];
|
||||
// if (m_File)
|
||||
// if (m_File)
|
||||
// {
|
||||
// _snwprintf_s(Buffer, _TRUNCATE, L"%i", m_Line);
|
||||
//
|
||||
@ -53,5 +53,5 @@ const std::wstring& CError::GetString()
|
||||
// }
|
||||
}
|
||||
|
||||
return m_String;
|
||||
return m_String;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ BOOL GetRCString(LPCSTR lpKeyName, LPSTR value, LPCSTR defStr, int maxLen)
|
||||
void VarExpansion(LPSTR buffer, LPCSTR value)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpVarExpansion)
|
||||
if (fpVarExpansion)
|
||||
{
|
||||
fpVarExpansion(buffer, value);
|
||||
}
|
||||
@ -281,7 +281,7 @@ HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
|
||||
PSID AdministratorsGroup;
|
||||
// Initialize SID.
|
||||
if( !AllocateAndInitializeSid( &NtAuthority,
|
||||
if (!AllocateAndInitializeSid( &NtAuthority,
|
||||
2,
|
||||
SECURITY_BUILTIN_DOMAIN_RID,
|
||||
DOMAIN_ALIAS_RID_ADMINS,
|
||||
@ -294,7 +294,7 @@ HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
else
|
||||
{
|
||||
// Check whether the token is present in admin group.
|
||||
if( !CheckTokenMembership( NULL,
|
||||
if (!CheckTokenMembership( NULL,
|
||||
AdministratorsGroup,
|
||||
&IsInAdminGroup ))
|
||||
{
|
||||
@ -318,7 +318,7 @@ HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpLSExecute)
|
||||
if (fpLSExecute)
|
||||
{
|
||||
std::string asc = ConvertToAscii(szCommand);
|
||||
return fpLSExecute(Owner, asc.c_str(), nShowCmd);
|
||||
@ -386,7 +386,7 @@ HINSTANCE ExecuteCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, LPCTSTR sz
|
||||
//void TransparentBltLS(HDC hdcDst, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, COLORREF colorTransparent)
|
||||
//{
|
||||
// // Use the lsapi.dll version of the method if possible
|
||||
// if (fpTransparentBltLS)
|
||||
// if (fpTransparentBltLS)
|
||||
// {
|
||||
// fpTransparentBltLS(hdcDst, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, colorTransparent);
|
||||
// }
|
||||
@ -506,9 +506,9 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage)
|
||||
|
||||
// Add timestamp
|
||||
static DWORD startTime = 0;
|
||||
|
||||
|
||||
DWORD time = GetTickCount();
|
||||
if (startTime == 0)
|
||||
if (startTime == 0)
|
||||
{
|
||||
startTime = time;
|
||||
}
|
||||
@ -516,7 +516,7 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage)
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"(%02i:%02i:%02i.%03i) ", (time - startTime) / (1000 * 60* 60), ((time - startTime) / (1000 * 60)) % 60, ((time - startTime) / 1000) % 60, (time - startTime) % 1000);
|
||||
|
||||
std::wstring message(buffer);
|
||||
logInfo.timestamp = message;
|
||||
logInfo.timestamp = message;
|
||||
message += pszMessage;
|
||||
|
||||
#ifdef _DEBUG
|
||||
@ -546,7 +546,7 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage)
|
||||
}
|
||||
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpLSLog)
|
||||
if (fpLSLog)
|
||||
{
|
||||
std::string asc = ConvertToAscii(message.c_str());
|
||||
std::string mod = ConvertToAscii(pszModule);
|
||||
@ -612,7 +612,7 @@ void LogWithArgs(int nLevel, const WCHAR* format, ... )
|
||||
{
|
||||
WCHAR* buffer = new WCHAR[4096];
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
va_start( args, format );
|
||||
|
||||
_invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(RmNullCRTInvalidParameterHandler);
|
||||
_CrtSetReportMode(_CRT_ASSERT, 0);
|
||||
|
@ -116,7 +116,7 @@ void CMeasure::Initialize()
|
||||
**
|
||||
** Reads the common configs for all Measures. The inherited classes
|
||||
** must call the base implementation if they overwrite this method.
|
||||
**
|
||||
**
|
||||
*/
|
||||
void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
@ -185,7 +185,7 @@ void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
/*
|
||||
** CheckSubstitute
|
||||
**
|
||||
**
|
||||
** Substitutes part of the text
|
||||
*/
|
||||
const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
|
||||
@ -208,7 +208,7 @@ const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
|
||||
size_t start = 0;
|
||||
size_t pos = std::wstring::npos;
|
||||
|
||||
do
|
||||
do
|
||||
{
|
||||
pos = str.find(m_Substitute[i], start);
|
||||
if (pos != std::wstring::npos)
|
||||
@ -221,7 +221,7 @@ const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
|
||||
}
|
||||
|
||||
return str.c_str();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return buffer;
|
||||
@ -230,19 +230,19 @@ const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
|
||||
|
||||
/*
|
||||
** ParseSubstitute
|
||||
**
|
||||
**
|
||||
** Reads the buffer for "Name":"Value"-pairs separated with comma and
|
||||
** fills the map with the parsed data.
|
||||
*/
|
||||
bool CMeasure::ParseSubstitute(std::wstring buffer)
|
||||
{
|
||||
if (buffer.empty()) return true;
|
||||
if (buffer.empty()) return true;
|
||||
|
||||
while (!buffer.empty())
|
||||
{
|
||||
std::wstring word1 = ExtractWord(buffer);
|
||||
std::wstring sep = ExtractWord(buffer);
|
||||
if (sep != L":") return false;
|
||||
if (sep != L":") return false;
|
||||
std::wstring word2 = ExtractWord(buffer);
|
||||
|
||||
if (word1 != word2)
|
||||
@ -252,7 +252,7 @@ bool CMeasure::ParseSubstitute(std::wstring buffer)
|
||||
}
|
||||
|
||||
sep = ExtractWord(buffer);
|
||||
if (!sep.empty() && sep != L",") return false;
|
||||
if (!sep.empty() && sep != L",") return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -262,7 +262,7 @@ bool CMeasure::ParseSubstitute(std::wstring buffer)
|
||||
** ExtractWord
|
||||
**
|
||||
** Returns the first word from the buffer. The word can be inside quotes.
|
||||
** If not, the separators are ' ', '\t', ',' and ':'. Whitespaces are removed
|
||||
** If not, the separators are ' ', '\t', ',' and ':'. Whitespaces are removed
|
||||
** and buffer _will_ be modified.
|
||||
*/
|
||||
std::wstring CMeasure::ExtractWord(std::wstring& buffer)
|
||||
@ -270,7 +270,7 @@ std::wstring CMeasure::ExtractWord(std::wstring& buffer)
|
||||
std::wstring::size_type end, len;
|
||||
std::wstring ret;
|
||||
|
||||
if (buffer.empty()) return ret;
|
||||
if (buffer.empty()) return ret;
|
||||
|
||||
len = buffer.size();
|
||||
|
||||
@ -334,28 +334,28 @@ std::wstring CMeasure::ExtractWord(std::wstring& buffer)
|
||||
** PreUpdate
|
||||
**
|
||||
** The base implementation of the update method. This includes the code
|
||||
** that is common for all measures. This is called every time the measure
|
||||
** is updated. The inherited classes must call the base implementation if
|
||||
** that is common for all measures. This is called every time the measure
|
||||
** is updated. The inherited classes must call the base implementation if
|
||||
** they overwrite this method. If this method returns false, the update
|
||||
** needs not to be done.
|
||||
**
|
||||
**
|
||||
*/
|
||||
bool CMeasure::PreUpdate()
|
||||
{
|
||||
if (IsDisabled())
|
||||
if (IsDisabled())
|
||||
{
|
||||
m_Value = 0.0; // Disable measures return 0 as value
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only update the counter if the divider
|
||||
|
||||
// Only update the counter if the divider
|
||||
++m_UpdateCounter;
|
||||
if (m_UpdateCounter < m_UpdateDivider) return false;
|
||||
m_UpdateCounter = 0;
|
||||
|
||||
// If we're logging the maximum value of the measure, check if
|
||||
// the new value is greater than the old one, and update if necessary.
|
||||
if(m_LogMaxValue)
|
||||
if (m_LogMaxValue)
|
||||
{
|
||||
if (m_MedianMaxValues.empty())
|
||||
{
|
||||
@ -369,7 +369,7 @@ bool CMeasure::PreUpdate()
|
||||
m_MedianPos %= MEDIAN_SIZE;
|
||||
|
||||
std::vector<double> medianArray;
|
||||
|
||||
|
||||
medianArray = m_MedianMaxValues;
|
||||
std::sort(medianArray.begin(), medianArray.end());
|
||||
m_MaxValue = max(m_MaxValue, medianArray[MEDIAN_SIZE / 2]);
|
||||
@ -382,11 +382,11 @@ bool CMeasure::PreUpdate()
|
||||
if (m_MeterWindow)
|
||||
{
|
||||
// Check the IfEqualValue
|
||||
if(!m_IfEqualAction.empty())
|
||||
if (!m_IfEqualAction.empty())
|
||||
{
|
||||
if((int)m_Value == (int)m_IfEqualValue)
|
||||
if ((int)m_Value == (int)m_IfEqualValue)
|
||||
{
|
||||
if(!m_IfEqualCommited)
|
||||
if (!m_IfEqualCommited)
|
||||
{
|
||||
m_IfEqualCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop
|
||||
Rainmeter->ExecuteCommand(m_IfEqualAction.c_str(), m_MeterWindow);
|
||||
@ -399,11 +399,11 @@ bool CMeasure::PreUpdate()
|
||||
}
|
||||
|
||||
// Check the IfAboveValue
|
||||
if(!m_IfAboveAction.empty())
|
||||
if (!m_IfAboveAction.empty())
|
||||
{
|
||||
if(m_Value > m_IfAboveValue)
|
||||
if (m_Value > m_IfAboveValue)
|
||||
{
|
||||
if(!m_IfAboveCommited)
|
||||
if (!m_IfAboveCommited)
|
||||
{
|
||||
m_IfAboveCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop
|
||||
Rainmeter->ExecuteCommand(m_IfAboveAction.c_str(), m_MeterWindow);
|
||||
@ -416,11 +416,11 @@ bool CMeasure::PreUpdate()
|
||||
}
|
||||
|
||||
// Check the IfBelowValue
|
||||
if(!m_IfBelowAction.empty())
|
||||
if (!m_IfBelowAction.empty())
|
||||
{
|
||||
if(m_Value < m_IfBelowValue)
|
||||
if (m_Value < m_IfBelowValue)
|
||||
{
|
||||
if(!m_IfBelowCommited)
|
||||
if (!m_IfBelowCommited)
|
||||
{
|
||||
m_IfBelowCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop
|
||||
Rainmeter->ExecuteCommand(m_IfBelowAction.c_str(), m_MeterWindow);
|
||||
@ -441,7 +441,7 @@ bool CMeasure::PreUpdate()
|
||||
**
|
||||
** Does post measuring things to the value. All measures must call this
|
||||
** after they have set the m_Value.
|
||||
**
|
||||
**
|
||||
*/
|
||||
bool CMeasure::PostUpdate()
|
||||
{
|
||||
@ -474,8 +474,8 @@ bool CMeasure::PostUpdate()
|
||||
/*
|
||||
** GetValue
|
||||
**
|
||||
** Returns the value of the measure.
|
||||
**
|
||||
** Returns the value of the measure.
|
||||
**
|
||||
*/
|
||||
double CMeasure::GetValue()
|
||||
{
|
||||
@ -491,8 +491,8 @@ double CMeasure::GetValue()
|
||||
/*
|
||||
** GetRelativeValue
|
||||
**
|
||||
** Returns the relative value of the measure (0.0 - 1.0).
|
||||
**
|
||||
** Returns the relative value of the measure (0.0 - 1.0).
|
||||
**
|
||||
*/
|
||||
double CMeasure::GetRelativeValue()
|
||||
{
|
||||
@ -516,8 +516,8 @@ double CMeasure::GetRelativeValue()
|
||||
/*
|
||||
** GetValueRange
|
||||
**
|
||||
** Returns the value range.
|
||||
**
|
||||
** Returns the value range.
|
||||
**
|
||||
*/
|
||||
double CMeasure::GetValueRange()
|
||||
{
|
||||
@ -529,7 +529,7 @@ double CMeasure::GetValueRange()
|
||||
**
|
||||
** This method returns the value as text string. The actual value is
|
||||
** get with GetValue() so we don't have to worry about m_Invert.
|
||||
**
|
||||
**
|
||||
** autoScale If true, scale the value automatically to some sensible range.
|
||||
** scale The scale to use if autoScale is false.
|
||||
** decimals Number of decimals used in the value. If -1, get rid of ".00000" for dynamic variables.
|
||||
@ -540,29 +540,29 @@ const WCHAR* CMeasure::GetStringValue(AUTOSCALE autoScale, double scale, int dec
|
||||
static WCHAR buffer[MAX_LINE_LENGTH];
|
||||
WCHAR format[32];
|
||||
|
||||
if(percentual)
|
||||
if (percentual)
|
||||
{
|
||||
double val = 100.0 * GetRelativeValue();
|
||||
|
||||
if (decimals == 0)
|
||||
{
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"%i", (int)val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_snwprintf_s(format, _TRUNCATE, L"%%.%if", decimals);
|
||||
_snwprintf_s(buffer, _TRUNCATE, format, val);
|
||||
}
|
||||
}
|
||||
else if(autoScale != AUTOSCALE_OFF)
|
||||
}
|
||||
else if (autoScale != AUTOSCALE_OFF)
|
||||
{
|
||||
GetScaledValue(autoScale, decimals, GetValue(), buffer, _countof(buffer));
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
double val = GetValue() / scale;
|
||||
|
||||
if(decimals == 0)
|
||||
if (decimals == 0)
|
||||
{
|
||||
val += (val >= 0) ? 0.5 : -0.5;
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"%lli", (LONGLONG)val);
|
||||
@ -592,7 +592,7 @@ void CMeasure::GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue
|
||||
WCHAR format[32];
|
||||
double value = 0;
|
||||
|
||||
if(decimals == 0)
|
||||
if (decimals == 0)
|
||||
{
|
||||
wcsncpy_s(format, L"%.0f", _TRUNCATE);
|
||||
}
|
||||
@ -603,22 +603,22 @@ void CMeasure::GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue
|
||||
|
||||
int index = (autoScale == AUTOSCALE_1000 || autoScale == AUTOSCALE_1000K) ? AUTOSCALE_INDEX_1000 : AUTOSCALE_INDEX_1024;
|
||||
|
||||
if(theValue > (g_TblScale[index][0] * 0.99))
|
||||
if (theValue > (g_TblScale[index][0] * 0.99))
|
||||
{
|
||||
wcsncat_s(format, L" T", _TRUNCATE);
|
||||
value = theValue / g_TblScale[index][0];
|
||||
}
|
||||
else if(theValue > (g_TblScale[index][1] * 0.99))
|
||||
else if (theValue > (g_TblScale[index][1] * 0.99))
|
||||
{
|
||||
wcsncat_s(format, L" G", _TRUNCATE);
|
||||
value = theValue / g_TblScale[index][1];
|
||||
}
|
||||
else if(theValue > (g_TblScale[index][2] * 0.99))
|
||||
else if (theValue > (g_TblScale[index][2] * 0.99))
|
||||
{
|
||||
wcsncat_s(format, L" M", _TRUNCATE);
|
||||
value = theValue / g_TblScale[index][2];
|
||||
}
|
||||
else if(autoScale == AUTOSCALE_1024K || autoScale == AUTOSCALE_1000K || theValue > (g_TblScale[index][3] * 0.99))
|
||||
else if (autoScale == AUTOSCALE_1024K || autoScale == AUTOSCALE_1000K || theValue > (g_TblScale[index][3] * 0.99))
|
||||
{
|
||||
wcsncat_s(format, L" k", _TRUNCATE);
|
||||
value = theValue / g_TblScale[index][3];
|
||||
@ -651,69 +651,69 @@ const WCHAR* CMeasure::GetStats()
|
||||
**
|
||||
** Creates the given measure. This is the factory method for the measures.
|
||||
** If new measures are implemented this method needs to be updated.
|
||||
**
|
||||
**
|
||||
*/
|
||||
CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name)
|
||||
{
|
||||
// Comparison is caseinsensitive
|
||||
|
||||
if(*measure == L'\0')
|
||||
if (*measure == L'\0')
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else if(_wcsicmp(L"CPU", measure) == 0)
|
||||
else if (_wcsicmp(L"CPU", measure) == 0)
|
||||
{
|
||||
return new CMeasureCPU(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Memory", measure) == 0)
|
||||
}
|
||||
else if (_wcsicmp(L"Memory", measure) == 0)
|
||||
{
|
||||
return new CMeasureMemory(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"NetIn", measure) == 0)
|
||||
else if (_wcsicmp(L"NetIn", measure) == 0)
|
||||
{
|
||||
return new CMeasureNetIn(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"NetOut", measure) == 0)
|
||||
else if (_wcsicmp(L"NetOut", measure) == 0)
|
||||
{
|
||||
return new CMeasureNetOut(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"NetTotal", measure) == 0)
|
||||
else if (_wcsicmp(L"NetTotal", measure) == 0)
|
||||
{
|
||||
return new CMeasureNetTotal(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"PhysicalMemory", measure) == 0)
|
||||
else if (_wcsicmp(L"PhysicalMemory", measure) == 0)
|
||||
{
|
||||
return new CMeasurePhysicalMemory(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"SwapMemory", measure) == 0)
|
||||
else if (_wcsicmp(L"SwapMemory", measure) == 0)
|
||||
{
|
||||
return new CMeasureVirtualMemory(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"FreeDiskSpace", measure) == 0)
|
||||
else if (_wcsicmp(L"FreeDiskSpace", measure) == 0)
|
||||
{
|
||||
return new CMeasureDiskSpace(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Uptime", measure) == 0)
|
||||
else if (_wcsicmp(L"Uptime", measure) == 0)
|
||||
{
|
||||
return new CMeasureUptime(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Time", measure) == 0)
|
||||
else if (_wcsicmp(L"Time", measure) == 0)
|
||||
{
|
||||
return new CMeasureTime(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Plugin", measure) == 0)
|
||||
else if (_wcsicmp(L"Plugin", measure) == 0)
|
||||
{
|
||||
return new CMeasurePlugin(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Registry", measure) == 0)
|
||||
else if (_wcsicmp(L"Registry", measure) == 0)
|
||||
{
|
||||
return new CMeasureRegistry(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Calc", measure) == 0)
|
||||
else if (_wcsicmp(L"Calc", measure) == 0)
|
||||
{
|
||||
return new CMeasureCalc(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"script", measure) == 0)
|
||||
else if (_wcsicmp(L"script", measure) == 0)
|
||||
{
|
||||
return new CMeasureScript(meterWindow, name);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ ULONG CMeasureCPU::c_BufferSize = 0;
|
||||
// OUT PULONG ReturnLength OPTIONAL // pointer to a 32-bit
|
||||
// // variable that receives
|
||||
// // the number of bytes
|
||||
// // written to the buffer
|
||||
// // written to the buffer
|
||||
// );
|
||||
|
||||
/*
|
||||
|
@ -37,10 +37,10 @@ CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow, const WCHAR* name) : CMeas
|
||||
m_HighBound(100),
|
||||
m_UpdateRandom(false)
|
||||
{
|
||||
if(!c_RandSeeded)
|
||||
if (!c_RandSeeded)
|
||||
{
|
||||
c_RandSeeded = true;
|
||||
srand((unsigned)time(0));
|
||||
srand((unsigned)time(0));
|
||||
}
|
||||
|
||||
rand();
|
||||
@ -98,12 +98,12 @@ void CMeasureCalc::UpdateVariableMap(CMeterWindow& meterWindow)
|
||||
}
|
||||
|
||||
// Create the variable map
|
||||
c_VarMap = Strmap_Create(sizeof(double), 0);
|
||||
c_VarMap = Strmap_Create(sizeof(double), 0);
|
||||
|
||||
const std::list<CMeasure*>& measures = meterWindow.GetMeasures();
|
||||
|
||||
std::list<CMeasure*>::const_iterator iter = measures.begin();
|
||||
for( ; iter != measures.end(); ++iter)
|
||||
for ( ; iter != measures.end(); ++iter)
|
||||
{
|
||||
const char* name = (*iter)->GetANSIName();
|
||||
double val = (*iter)->GetValue();
|
||||
@ -172,9 +172,9 @@ void CMeasureCalc::FormulaReplace()
|
||||
(loc == 0 || IsDelimiter(*(m_Formula.c_str() + loc - 1))) &&
|
||||
(loc == (m_Formula.length() - 6) || IsDelimiter(*(m_Formula.c_str() + loc + 6))))
|
||||
{
|
||||
int range = (m_HighBound - m_LowBound) + 1;
|
||||
srand((unsigned) rand());
|
||||
int randNumber = m_LowBound + (int)(range * rand()/(RAND_MAX + 1.0));
|
||||
int range = (m_HighBound - m_LowBound) + 1;
|
||||
srand((unsigned) rand());
|
||||
int randNumber = m_LowBound + (int)(range * rand()/(RAND_MAX + 1.0));
|
||||
|
||||
WCHAR buffer[32];
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"%i", randNumber);
|
||||
|
@ -47,7 +47,7 @@ CMeasureDiskSpace::~CMeasureDiskSpace()
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current disk free space value.
|
||||
** Updates the current disk free space value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureDiskSpace::Update()
|
||||
@ -127,7 +127,7 @@ bool CMeasureDiskSpace::Update()
|
||||
*/
|
||||
const WCHAR* CMeasureDiskSpace::GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual)
|
||||
{
|
||||
if (m_Label)
|
||||
if (m_Label)
|
||||
{
|
||||
return CheckSubstitute(m_LabelName.c_str());
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ CMeasureMemory::~CMeasureMemory()
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current total memory value.
|
||||
** Updates the current total memory value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureMemory::Update()
|
||||
|
@ -35,7 +35,7 @@ extern CRainmeter* Rainmeter;
|
||||
/*
|
||||
** CMeasureNet
|
||||
**
|
||||
** The constructor. This is the base class for the net-meters.
|
||||
** The constructor. This is the base class for the net-meters.
|
||||
**
|
||||
*/
|
||||
CMeasureNet::CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
||||
@ -394,7 +394,7 @@ ULONG64 CMeasureNet::GetNetStatsValue(NET net)
|
||||
if (m_Interface == 0)
|
||||
{
|
||||
// Get all interfaces
|
||||
for(size_t i = 0; i < statsSize; ++i)
|
||||
for (size_t i = 0; i < statsSize; ++i)
|
||||
{
|
||||
// Ignore the loopback and filter interfaces
|
||||
if (c_NumOfTables == statsSize)
|
||||
@ -482,15 +482,15 @@ void CMeasureNet::ReadConfig(CConfigParser& parser, const WCHAR* section, NET ne
|
||||
}
|
||||
|
||||
double maxValue = parser.ReadFloat(section, L"MaxValue", -1);
|
||||
if (maxValue == -1)
|
||||
if (maxValue == -1)
|
||||
{
|
||||
maxValue = parser.ReadFloat(section, netName, -1);
|
||||
if (maxValue == -1)
|
||||
if (maxValue == -1)
|
||||
{
|
||||
maxValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_Interface = parser.ReadInt(section, L"Interface", 0);
|
||||
m_Cumulative = 0!=parser.ReadInt(section, L"Cumulative", 0);
|
||||
|
||||
@ -527,7 +527,7 @@ void CMeasureNet::UpdateStats()
|
||||
}
|
||||
|
||||
while (c_OldStatValues.size() < statsSize)
|
||||
{
|
||||
{
|
||||
c_OldStatValues.push_back(0);
|
||||
}
|
||||
|
||||
@ -622,7 +622,7 @@ void CMeasureNet::WriteStats(const std::wstring& iniFile)
|
||||
WCHAR buffer2[64];
|
||||
|
||||
size_t statsSize = c_StatValues.size() / 2;
|
||||
|
||||
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"%i", (int)statsSize);
|
||||
WritePrivateProfileString(L"Statistics", L"NetStatsCount", buffer, iniFile.c_str());
|
||||
|
||||
|
@ -44,14 +44,14 @@ CMeasureNetIn::~CMeasureNetIn()
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current net in value.
|
||||
** Updates the current net in value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureNetIn::Update()
|
||||
{
|
||||
if (!CMeasureNet::PreUpdate()) return false;
|
||||
|
||||
if(c_Table == NULL) return false;
|
||||
if (c_Table == NULL) return false;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
@ -61,7 +61,7 @@ bool CMeasureNetIn::Update()
|
||||
{
|
||||
ULONG64 value = 0;
|
||||
|
||||
if (!m_FirstTime)
|
||||
if (!m_FirstTime)
|
||||
{
|
||||
value = GetNetOctets(NET_IN);
|
||||
if (value > m_InOctets)
|
||||
|
@ -44,14 +44,14 @@ CMeasureNetOut::~CMeasureNetOut()
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current net out value.
|
||||
** Updates the current net out value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureNetOut::Update()
|
||||
{
|
||||
if (!CMeasureNet::PreUpdate()) return false;
|
||||
|
||||
if(c_Table == NULL) return false;
|
||||
if (c_Table == NULL) return false;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
@ -61,7 +61,7 @@ bool CMeasureNetOut::Update()
|
||||
{
|
||||
ULONG64 value = 0;
|
||||
|
||||
if (!m_FirstTime)
|
||||
if (!m_FirstTime)
|
||||
{
|
||||
value = GetNetOctets(NET_OUT);
|
||||
if (value > m_OutOctets)
|
||||
|
@ -44,14 +44,14 @@ CMeasureNetTotal::~CMeasureNetTotal()
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current net total value.
|
||||
** Updates the current net total value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureNetTotal::Update()
|
||||
{
|
||||
if (!CMeasureNet::PreUpdate()) return false;
|
||||
|
||||
if(c_Table == NULL) return false;
|
||||
if (c_Table == NULL) return false;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
@ -61,7 +61,7 @@ bool CMeasureNetTotal::Update()
|
||||
{
|
||||
ULONG64 value = 0;
|
||||
|
||||
if (!m_FirstTime)
|
||||
if (!m_FirstTime)
|
||||
{
|
||||
value = GetNetOctets(NET_TOTAL);
|
||||
if (value > m_TotalOctets)
|
||||
|
@ -44,7 +44,7 @@ CMeasurePhysicalMemory::~CMeasurePhysicalMemory()
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current physical memory value.
|
||||
** Updates the current physical memory value.
|
||||
**
|
||||
*/
|
||||
bool CMeasurePhysicalMemory::Update()
|
||||
|
@ -49,11 +49,11 @@ CMeasurePlugin::CMeasurePlugin(CMeterWindow* meterWindow, const WCHAR* name) : C
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasurePlugin::~CMeasurePlugin()
|
||||
CMeasurePlugin::~CMeasurePlugin()
|
||||
{
|
||||
if (m_Plugin)
|
||||
{
|
||||
if(FinalizeFunc) FinalizeFunc(m_Plugin, m_ID);
|
||||
if (FinalizeFunc) FinalizeFunc(m_Plugin, m_ID);
|
||||
FreeLibrary(m_Plugin);
|
||||
}
|
||||
}
|
||||
@ -78,12 +78,12 @@ bool CMeasurePlugin::Update()
|
||||
}
|
||||
SetCurrentDirectory(dir.c_str());
|
||||
|
||||
if(UpdateFunc)
|
||||
if (UpdateFunc)
|
||||
{
|
||||
// Update the plugin
|
||||
m_Value = UpdateFunc(m_ID);
|
||||
}
|
||||
else if(UpdateFunc2)
|
||||
else if (UpdateFunc2)
|
||||
{
|
||||
// Update the plugin
|
||||
m_Value = UpdateFunc2(m_ID);
|
||||
@ -113,13 +113,13 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
m_PluginName = parser.ReadString(section, L"Plugin", L"");
|
||||
|
||||
size_t pos = m_PluginName.rfind(L".");
|
||||
if (pos == std::wstring::npos)
|
||||
if (pos == std::wstring::npos)
|
||||
{
|
||||
m_PluginName += L".dll";
|
||||
}
|
||||
|
||||
pos = m_PluginName.rfind(L'\\');
|
||||
if (pos != std::wstring::npos)
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
m_PluginName.insert(0, L"..\\");
|
||||
}
|
||||
@ -127,8 +127,8 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
DWORD err = 0;
|
||||
m_Plugin = CSystem::RmLoadLibrary(m_PluginName.c_str(), &err);
|
||||
|
||||
if(m_Plugin == NULL)
|
||||
|
||||
if (m_Plugin == NULL)
|
||||
{
|
||||
if (CRainmeter::GetDebug())
|
||||
{
|
||||
@ -137,7 +137,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
// Try to load from Rainmeter's folder
|
||||
pos = m_PluginName.rfind(L'\\');
|
||||
if (pos != std::wstring::npos)
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
std::wstring pluginName = Rainmeter->GetPath() + m_PluginName.substr(pos + 1);
|
||||
|
||||
@ -160,7 +160,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
throw CError(error, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InitializeFunc = (INITIALIZE)GetProcAddress(m_Plugin, "Initialize");
|
||||
FinalizeFunc = (FINALIZE)GetProcAddress(m_Plugin, "Finalize");
|
||||
UpdateFunc = (UPDATE)GetProcAddress(m_Plugin, "Update");
|
||||
@ -179,7 +179,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
// Initialize the plugin
|
||||
m_ID = id++;
|
||||
if(InitializeFunc)
|
||||
if (InitializeFunc)
|
||||
{
|
||||
WCHAR buffer[MAX_PATH];
|
||||
GetCurrentDirectory(MAX_PATH, buffer);
|
||||
@ -200,13 +200,13 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
SetCurrentDirectory(buffer);
|
||||
|
||||
std::wstring szMaxValue = parser.ReadString(section, L"MaxValue", L"NotSet");
|
||||
if (szMaxValue == L"NotSet")
|
||||
if (szMaxValue == L"NotSet")
|
||||
{
|
||||
m_MaxValue = maxValue;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_MaxValue == 0)
|
||||
if (m_MaxValue == 0)
|
||||
{
|
||||
m_MaxValue = 1;
|
||||
m_LogMaxValue = true;
|
||||
@ -221,7 +221,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
*/
|
||||
const WCHAR* CMeasurePlugin::GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual)
|
||||
{
|
||||
if(GetStringFunc)
|
||||
if (GetStringFunc)
|
||||
{
|
||||
const WCHAR* ret = GetStringFunc(m_ID, 0);
|
||||
if (ret) return CheckSubstitute(ret);
|
||||
|
@ -42,7 +42,7 @@ CMeasureRegistry::CMeasureRegistry(CMeterWindow* meterWindow, const WCHAR* name)
|
||||
*/
|
||||
CMeasureRegistry::~CMeasureRegistry()
|
||||
{
|
||||
if(m_RegKey) RegCloseKey(m_RegKey);
|
||||
if (m_RegKey) RegCloseKey(m_RegKey);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -55,13 +55,13 @@ bool CMeasureRegistry::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
if(m_RegKey != NULL)
|
||||
if (m_RegKey != NULL)
|
||||
{
|
||||
DWORD size = 4096;
|
||||
WCHAR* data = new WCHAR[size];
|
||||
DWORD type = 0;
|
||||
|
||||
if(RegQueryValueEx(m_RegKey,
|
||||
if (RegQueryValueEx(m_RegKey,
|
||||
m_RegValueName.c_str(),
|
||||
NULL,
|
||||
(LPDWORD)&type,
|
||||
@ -120,31 +120,31 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
const std::wstring& keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER");
|
||||
if(_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
if (_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CLASSES_ROOT;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_CONFIG") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_CONFIG") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CURRENT_CONFIG;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_USER") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_USER") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CURRENT_USER;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_LOCAL_MACHINE") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_LOCAL_MACHINE") == 0)
|
||||
{
|
||||
m_HKey = HKEY_LOCAL_MACHINE;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CLASSES_ROOT;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_PERFORMANCE_DATA") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_PERFORMANCE_DATA") == 0)
|
||||
{
|
||||
m_HKey = HKEY_PERFORMANCE_DATA;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_DYN_DATA") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_DYN_DATA") == 0)
|
||||
{
|
||||
m_HKey = HKEY_DYN_DATA;
|
||||
}
|
||||
@ -167,8 +167,8 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
// Try to open the key
|
||||
if(m_RegKey) RegCloseKey(m_RegKey);
|
||||
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
|
||||
if (m_RegKey) RegCloseKey(m_RegKey);
|
||||
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -13,7 +13,7 @@ CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : C
|
||||
m_pLuaScript(),
|
||||
m_bUpdateDefined(false),
|
||||
m_bGetValueDefined(false),
|
||||
m_bGetStringValueDefined(false),
|
||||
m_bGetStringValueDefined(false),
|
||||
m_bInitializeDefined(false)
|
||||
{
|
||||
LuaManager::Init();
|
||||
@ -84,7 +84,7 @@ void CMeasureScript::SetValue(double d)
|
||||
**
|
||||
** This method returns the value as text string. The actual value is
|
||||
** get with GetValue() so we don't have to worry about m_Invert.
|
||||
**
|
||||
**
|
||||
** autoScale If true, scale the value automatically to some sensible range.
|
||||
** scale The scale to use if autoScale is false.
|
||||
** decimals Number of decimals used in the value.
|
||||
@ -95,7 +95,7 @@ const WCHAR* CMeasureScript::GetStringValue(AUTOSCALE autoScale, double scale, i
|
||||
if (m_bGetStringValueDefined && m_pLuaScript && m_pLuaScript->IsInitialized())
|
||||
{
|
||||
m_strValue = m_pLuaScript->RunFunctionString(g_strGetStringValueFunction);
|
||||
|
||||
|
||||
return CheckSubstitute(m_strValue.c_str());
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ static void stackDump(lua_State *L)
|
||||
{
|
||||
int i = lua_gettop(L);
|
||||
LuaManager::LuaLog(LOG_DEBUG, " ---------------- Stack Dump ----------------" );
|
||||
while(i)
|
||||
while (i)
|
||||
{
|
||||
int t = lua_type(L, i);
|
||||
switch (t)
|
||||
@ -194,7 +194,7 @@ void CMeasureScript::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
|
||||
while(lua_next(L, -2))
|
||||
while (lua_next(L, -2))
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
|
||||
|
@ -25,7 +25,7 @@ int GetYearDay(int year, int month, int day)
|
||||
int yearDay = 0;
|
||||
UINT dates[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
for (int i = 0; i < month - 1; ++i)
|
||||
for (int i = 0; i < month - 1; ++i)
|
||||
{
|
||||
yearDay += dates[i];
|
||||
}
|
||||
@ -51,8 +51,8 @@ CMeasureTime::CMeasureTime(CMeterWindow* meterWindow, const WCHAR* name) : CMeas
|
||||
m_Time()
|
||||
{
|
||||
/* Set time zone from TZ environment variable. If TZ is not set,
|
||||
* the operating system is queried to obtain the default value
|
||||
* for the variable.
|
||||
* the operating system is queried to obtain the default value
|
||||
* for the variable.
|
||||
*/
|
||||
_tzset();
|
||||
}
|
||||
@ -174,7 +174,7 @@ const WCHAR* CMeasureTime::GetStringValue(AUTOSCALE autoScale, double scale, int
|
||||
{
|
||||
static WCHAR tmpSz[MAX_LINE_LENGTH];
|
||||
struct tm today;
|
||||
|
||||
|
||||
tmpSz[0] = 0;
|
||||
|
||||
SYSTEMTIME sysToday;
|
||||
|
@ -44,7 +44,7 @@ CMeasureVirtualMemory::~CMeasureVirtualMemory()
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current virtual memory value.
|
||||
** Updates the current virtual memory value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureVirtualMemory::Update()
|
||||
|
@ -139,7 +139,7 @@ int CMeter::GetX(bool abs)
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_X;
|
||||
return m_X;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -187,7 +187,7 @@ int CMeter::GetY(bool abs)
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_Y;
|
||||
return m_Y;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -262,7 +262,7 @@ void CMeter::Hide()
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the meter-specific configs from the ini-file. The base implementation
|
||||
** reads the common settings for all meters. The inherited classes must call
|
||||
** reads the common settings for all meters. The inherited classes must call
|
||||
** the base implementation if they overwrite this method.
|
||||
**
|
||||
*/
|
||||
@ -453,9 +453,9 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
|
||||
// Go through the list and check it there is a measure for us
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), m_MeasureName.c_str()) == 0)
|
||||
if (_wcsicmp((*i)->GetName(), m_MeasureName.c_str()) == 0)
|
||||
{
|
||||
m_Measure = (*i);
|
||||
return;
|
||||
@ -479,42 +479,42 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
*/
|
||||
CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHAR* name)
|
||||
{
|
||||
if(_wcsicmp(L"HISTOGRAM", meter) == 0)
|
||||
if (_wcsicmp(L"HISTOGRAM", meter) == 0)
|
||||
{
|
||||
return new CMeterHistogram(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"STRING", meter) == 0)
|
||||
}
|
||||
else if (_wcsicmp(L"STRING", meter) == 0)
|
||||
{
|
||||
return new CMeterString(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"BAR", meter) == 0)
|
||||
}
|
||||
else if (_wcsicmp(L"BAR", meter) == 0)
|
||||
{
|
||||
return new CMeterBar(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"BITMAP", meter) == 0)
|
||||
}
|
||||
else if (_wcsicmp(L"BITMAP", meter) == 0)
|
||||
{
|
||||
return new CMeterBitmap(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"IMAGE", meter) == 0)
|
||||
}
|
||||
else if (_wcsicmp(L"IMAGE", meter) == 0)
|
||||
{
|
||||
return new CMeterImage(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"LINE", meter) == 0)
|
||||
}
|
||||
else if (_wcsicmp(L"LINE", meter) == 0)
|
||||
{
|
||||
return new CMeterLine(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"ROUNDLINE", meter) == 0)
|
||||
}
|
||||
else if (_wcsicmp(L"ROUNDLINE", meter) == 0)
|
||||
{
|
||||
return new CMeterRoundLine(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"ROTATOR", meter) == 0)
|
||||
}
|
||||
else if (_wcsicmp(L"ROTATOR", meter) == 0)
|
||||
{
|
||||
return new CMeterRotator(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"BUTTON", meter) == 0)
|
||||
}
|
||||
else if (_wcsicmp(L"BUTTON", meter) == 0)
|
||||
{
|
||||
return new CMeterButton(meterWindow, name);
|
||||
}
|
||||
}
|
||||
|
||||
// Error
|
||||
std::wstring error = L"Meter=";
|
||||
@ -566,7 +566,7 @@ void CMeter::SetAllMeasures(const std::vector<CMeasure*>& measures)
|
||||
m_AllMeasures.push_back(m_Measure);
|
||||
|
||||
std::vector<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
m_AllMeasures.push_back(*i);
|
||||
}
|
||||
@ -583,7 +583,7 @@ void CMeter::ReadMeasureNames(CConfigParser& parser, const WCHAR* section, std::
|
||||
|
||||
int i = 2;
|
||||
bool loop = true;
|
||||
do
|
||||
do
|
||||
{
|
||||
_snwprintf_s(tmpName, _TRUNCATE, L"MeasureName%i", i);
|
||||
const std::wstring& measure = parser.ReadString(section, tmpName, L"");
|
||||
@ -620,7 +620,7 @@ bool CMeter::ReplaceMeasures(const std::vector<std::wstring>& stringValues, std:
|
||||
size_t start = 0;
|
||||
size_t pos = std::wstring::npos;
|
||||
|
||||
do
|
||||
do
|
||||
{
|
||||
pos = str.find(buffer, start);
|
||||
if (pos != std::wstring::npos)
|
||||
@ -646,7 +646,7 @@ void CMeter::ReplaceToolTipMeasures(std::wstring& str)
|
||||
std::vector<std::wstring> stringValues;
|
||||
|
||||
if (!m_AllMeasures.empty())
|
||||
{
|
||||
{
|
||||
// Get the values for the measures
|
||||
for (size_t i = 0, isize = m_AllMeasures.size(); i < isize; ++i)
|
||||
{
|
||||
@ -683,7 +683,7 @@ void CMeter::CreateToolTip(CMeterWindow* meterWindow)
|
||||
}
|
||||
|
||||
HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST,
|
||||
TOOLTIPS_CLASS,
|
||||
TOOLTIPS_CLASS,
|
||||
NULL,
|
||||
style,
|
||||
CW_USEDEFAULT,
|
||||
@ -732,7 +732,7 @@ void CMeter::UpdateToolTip()
|
||||
ti.lpszText = (PTSTR) text.c_str();
|
||||
ti.rect = GetMeterRect();
|
||||
|
||||
SendMessage(hwndTT, TTM_SETTOOLINFO, NULL, (LPARAM) (LPTOOLINFO) &ti);
|
||||
SendMessage(hwndTT, TTM_SETTOOLINFO, NULL, (LPARAM) (LPTOOLINFO) &ti);
|
||||
SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, NULL, m_ToolTipWidth);
|
||||
|
||||
if (!m_ToolTipTitle.empty())
|
||||
@ -861,7 +861,7 @@ bool CMeter::Draw(Graphics& graphics)
|
||||
Pen dark(darkColor);
|
||||
|
||||
// The bevel is drawn outside the meter
|
||||
Rect rect(x - 2, y - 2, m_W + 4, m_H + 4);
|
||||
Rect rect(x - 2, y - 2, m_W + 4, m_H + 4);
|
||||
DrawBevel(graphics, rect, light, dark);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ void CMeterBar::Initialize()
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
if (!m_ImageName.empty())
|
||||
{
|
||||
m_Image.LoadImage(m_ImageName, m_NeedsReload);
|
||||
|
||||
@ -120,11 +120,11 @@ void CMeterBar::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
m_Flip = parser.ReadInt(section, L"Flip", 0) == 1;
|
||||
|
||||
const std::wstring& orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL");
|
||||
if(_wcsicmp(L"VERTICAL", orientation.c_str()) == 0)
|
||||
if (_wcsicmp(L"VERTICAL", orientation.c_str()) == 0)
|
||||
{
|
||||
m_Orientation = VERTICAL;
|
||||
}
|
||||
else if(_wcsicmp(L"HORIZONTAL", orientation.c_str()) == 0)
|
||||
}
|
||||
else if (_wcsicmp(L"HORIZONTAL", orientation.c_str()) == 0)
|
||||
{
|
||||
m_Orientation = HORIZONTAL;
|
||||
}
|
||||
@ -179,23 +179,23 @@ bool CMeterBar::Update()
|
||||
*/
|
||||
bool CMeterBar::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
Bitmap* drawBitmap = m_Image.GetImage();
|
||||
|
||||
if(m_Orientation == VERTICAL)
|
||||
if (m_Orientation == VERTICAL)
|
||||
{
|
||||
int barSize = m_H - 2 * m_Border;
|
||||
int size = (int)(barSize * m_Value);
|
||||
size = min(barSize, size);
|
||||
size = max(0, size);
|
||||
|
||||
|
||||
if (drawBitmap)
|
||||
{
|
||||
if (m_Flip)
|
||||
if (m_Flip)
|
||||
{
|
||||
if (m_Border > 0)
|
||||
{
|
||||
@ -227,7 +227,7 @@ bool CMeterBar::Draw(Graphics& graphics)
|
||||
else
|
||||
{
|
||||
SolidBrush brush(m_Color);
|
||||
if (m_Flip)
|
||||
if (m_Flip)
|
||||
{
|
||||
Rect r(x, y, m_W, size);
|
||||
graphics.FillRectangle(&brush, r);
|
||||
@ -248,7 +248,7 @@ bool CMeterBar::Draw(Graphics& graphics)
|
||||
|
||||
if (drawBitmap)
|
||||
{
|
||||
if (m_Flip)
|
||||
if (m_Flip)
|
||||
{
|
||||
if (m_Border > 0)
|
||||
{
|
||||
@ -280,7 +280,7 @@ bool CMeterBar::Draw(Graphics& graphics)
|
||||
else
|
||||
{
|
||||
SolidBrush brush(m_Color);
|
||||
if (m_Flip)
|
||||
if (m_Flip)
|
||||
{
|
||||
Rect r(x + m_W - size, y, size, m_H);
|
||||
graphics.FillRectangle(&brush, r);
|
||||
|
@ -69,7 +69,7 @@ void CMeterBitmap::Initialize()
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
if (!m_ImageName.empty())
|
||||
{
|
||||
m_Image.LoadImage(m_ImageName, m_NeedsReload);
|
||||
|
||||
@ -80,7 +80,7 @@ void CMeterBitmap::Initialize()
|
||||
m_W = bitmap->GetWidth();
|
||||
m_H = bitmap->GetHeight();
|
||||
|
||||
if(m_H > m_W)
|
||||
if (m_H > m_W)
|
||||
{
|
||||
m_H = m_H / m_FrameCount;
|
||||
}
|
||||
@ -195,15 +195,15 @@ void CMeterBitmap::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0);
|
||||
|
||||
const std::wstring& align = parser.ReadString(section, L"BitmapAlign", L"LEFT");
|
||||
if(_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
if (_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_LEFT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"RIGHT") == 0)
|
||||
else if (_wcsicmp(align.c_str(), L"RIGHT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_RIGHT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"CENTER") == 0)
|
||||
else if (_wcsicmp(align.c_str(), L"CENTER") == 0)
|
||||
{
|
||||
m_Align = ALIGN_CENTER;
|
||||
}
|
||||
@ -290,11 +290,11 @@ bool CMeterBitmap::HasActiveTransition()
|
||||
*/
|
||||
bool CMeterBitmap::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
int newY, newX;
|
||||
|
||||
if(m_FrameCount == 0 || !m_Image.IsLoaded()) return false; // Unable to continue
|
||||
if (m_FrameCount == 0 || !m_Image.IsLoaded()) return false; // Unable to continue
|
||||
|
||||
Bitmap* bitmap = m_Image.GetImage();
|
||||
|
||||
@ -383,7 +383,7 @@ bool CMeterBitmap::Draw(Graphics& graphics)
|
||||
|
||||
// LogWithArgs(LOG_DEBUG, L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");
|
||||
|
||||
if(bitmap->GetHeight() > bitmap->GetWidth())
|
||||
if (bitmap->GetHeight() > bitmap->GetWidth())
|
||||
{
|
||||
newX = 0;
|
||||
newY = m_H * frame;
|
||||
@ -449,7 +449,7 @@ bool CMeterBitmap::Draw(Graphics& graphics)
|
||||
|
||||
// LogWithArgs(LOG_DEBUG, L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");
|
||||
|
||||
if(bitmap->GetHeight() > bitmap->GetWidth())
|
||||
if (bitmap->GetHeight() > bitmap->GetWidth())
|
||||
{
|
||||
newX = 0;
|
||||
newY = frame * m_H;
|
||||
|
@ -83,7 +83,7 @@ void CMeterButton::Initialize()
|
||||
}
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
if (!m_ImageName.empty())
|
||||
{
|
||||
m_Image.LoadImage(m_ImageName, m_NeedsReload);
|
||||
|
||||
@ -94,7 +94,7 @@ void CMeterButton::Initialize()
|
||||
m_W = bitmap->GetWidth();
|
||||
m_H = bitmap->GetHeight();
|
||||
|
||||
if(m_H > m_W)
|
||||
if (m_H > m_W)
|
||||
{
|
||||
m_H = m_H / BUTTON_FRAMES;
|
||||
}
|
||||
@ -112,7 +112,7 @@ void CMeterButton::Initialize()
|
||||
Graphics graphics(&bitmapPart);
|
||||
Rect r(0, 0, m_W, m_H);
|
||||
|
||||
if(bitmap->GetHeight() > bitmap->GetWidth())
|
||||
if (bitmap->GetHeight() > bitmap->GetWidth())
|
||||
{
|
||||
graphics.DrawImage(bitmap, r, 0, m_H * i, m_W, m_H, UnitPixel);
|
||||
}
|
||||
@ -198,7 +198,7 @@ bool CMeterButton::Update()
|
||||
*/
|
||||
bool CMeterButton::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
if (m_Bitmaps[m_State] == NULL) return false; // Unable to continue
|
||||
|
||||
@ -207,7 +207,7 @@ bool CMeterButton::Draw(Graphics& graphics)
|
||||
|
||||
// Blit the image
|
||||
graphics.DrawCachedBitmap(m_Bitmaps[m_State], x, y);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ void CMeterHistogram::Initialize()
|
||||
// A sanity check
|
||||
if (m_SecondaryMeasure && !m_PrimaryImageName.empty() && (m_BothImageName.empty() || m_SecondaryImageName.empty()))
|
||||
{
|
||||
Log(LOG_WARNING, L"You need to define SecondaryImage and BothImage also!");
|
||||
Log(LOG_WARNING, L"You need to define SecondaryImage and BothImage also!");
|
||||
|
||||
m_PrimaryImage.DisposeImage();
|
||||
m_SecondaryImage.DisposeImage();
|
||||
@ -385,7 +385,7 @@ bool CMeterHistogram::Update()
|
||||
*/
|
||||
bool CMeterHistogram::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics) ||
|
||||
if (!CMeter::Draw(graphics) ||
|
||||
(m_Measure && !m_PrimaryValues) ||
|
||||
(m_SecondaryMeasure && !m_SecondaryValues)) return false;
|
||||
|
||||
@ -517,13 +517,13 @@ void CMeterHistogram::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
{
|
||||
CMeter::BindMeasure(measures);
|
||||
|
||||
if(!m_SecondaryMeasureName.empty())
|
||||
if (!m_SecondaryMeasureName.empty())
|
||||
{
|
||||
// Go through the list and check it there is a secondary measure for us
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), m_SecondaryMeasureName.c_str()) == 0)
|
||||
if (_wcsicmp((*i)->GetName(), m_SecondaryMeasureName.c_str()) == 0)
|
||||
{
|
||||
m_SecondaryMeasure = (*i);
|
||||
CMeter::SetAllMeasures(m_SecondaryMeasure);
|
||||
@ -535,6 +535,6 @@ void CMeterHistogram::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
error += L"] cannot be bound with [";
|
||||
error += m_SecondaryMeasureName;
|
||||
error += L"]!";
|
||||
throw CError(error, __LINE__, __FILE__);
|
||||
throw CError(error, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ bool CMeterImage::Update()
|
||||
*/
|
||||
bool CMeterImage::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
if (m_Image.IsLoaded())
|
||||
{
|
||||
@ -284,9 +284,9 @@ bool CMeterImage::Draw(Graphics& graphics)
|
||||
{
|
||||
const RECT m = m_ScaleMargins;
|
||||
|
||||
if (m.top > 0)
|
||||
if (m.top > 0)
|
||||
{
|
||||
if (m.left > 0)
|
||||
if (m.left > 0)
|
||||
{
|
||||
// Top-Left
|
||||
Rect r(x, y, m.left, m.top);
|
||||
@ -297,7 +297,7 @@ bool CMeterImage::Draw(Graphics& graphics)
|
||||
Rect r(x + m.left, y, drawW - m.left - m.right, m.top);
|
||||
graphics.DrawImage(drawBitmap, r, m.left, 0, imageW - m.left - m.right, m.top, UnitPixel);
|
||||
|
||||
if (m.right > 0)
|
||||
if (m.right > 0)
|
||||
{
|
||||
// Top-Right
|
||||
Rect r(x + drawW - m.right, y, m.right, m.top);
|
||||
@ -305,7 +305,7 @@ bool CMeterImage::Draw(Graphics& graphics)
|
||||
}
|
||||
}
|
||||
|
||||
if (m.left > 0)
|
||||
if (m.left > 0)
|
||||
{
|
||||
// Left
|
||||
Rect r(x, y + m.top, m.left, drawH - m.top - m.bottom);
|
||||
@ -316,16 +316,16 @@ bool CMeterImage::Draw(Graphics& graphics)
|
||||
Rect r(x + m.left, y + m.top, drawW - m.left - m.right, drawH - m.top - m.bottom);
|
||||
graphics.DrawImage(drawBitmap, r, m.left, m.top, imageW - m.left - m.right, imageH - m.top - m.bottom, UnitPixel);
|
||||
|
||||
if (m.right > 0)
|
||||
if (m.right > 0)
|
||||
{
|
||||
// Right
|
||||
Rect r(x + drawW - m.right, y + m.top, m.right, drawH - m.top - m.bottom);
|
||||
graphics.DrawImage(drawBitmap, r, imageW - m.right, m.top, m.right, imageH - m.top - m.bottom, UnitPixel);
|
||||
}
|
||||
|
||||
if (m.bottom > 0)
|
||||
|
||||
if (m.bottom > 0)
|
||||
{
|
||||
if (m.left > 0)
|
||||
if (m.left > 0)
|
||||
{
|
||||
// Bottom-Left
|
||||
Rect r(x, y + drawH - m.bottom, m.left, m.bottom);
|
||||
@ -336,7 +336,7 @@ bool CMeterImage::Draw(Graphics& graphics)
|
||||
Rect r(x + m.left, y + drawH - m.bottom, drawW - m.left - m.right, m.bottom);
|
||||
graphics.DrawImage(drawBitmap, r, m.left, imageH - m.bottom, imageW - m.left - m.right, m.bottom, UnitPixel);
|
||||
|
||||
if (m.right > 0)
|
||||
if (m.right > 0)
|
||||
{
|
||||
// Bottom-Right
|
||||
Rect r(x + drawW - m.right, y + drawH - m.bottom, m.right, m.bottom);
|
||||
@ -366,9 +366,9 @@ void CMeterImage::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
{
|
||||
// Go through the list and check it there is a secondary measures for us
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
{
|
||||
m_Measures.push_back(*i);
|
||||
break;
|
||||
|
@ -208,7 +208,7 @@ bool CMeterLine::Update()
|
||||
*/
|
||||
bool CMeterLine::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics) || m_W == 0) return false;
|
||||
if (!CMeter::Draw(graphics) || m_W == 0) return false;
|
||||
|
||||
double maxValue = 0.0;
|
||||
int counter = 0;
|
||||
@ -264,7 +264,7 @@ bool CMeterLine::Draw(Graphics& graphics)
|
||||
maxValue = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
@ -277,7 +277,7 @@ bool CMeterLine::Draw(Graphics& graphics)
|
||||
|
||||
// Check the highest power of 2 that fits in maxLines
|
||||
int power = 2;
|
||||
while(power < maxLines)
|
||||
while (power < maxLines)
|
||||
{
|
||||
power *= 2;
|
||||
}
|
||||
@ -362,22 +362,22 @@ void CMeterLine::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
{
|
||||
// Go through the list and check it there is a secondary measure for us
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
{
|
||||
m_Measures.push_back(*i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (i == measures.end())
|
||||
{
|
||||
std::wstring error = L"The meter [" + m_Name;
|
||||
error += L"] cannot be bound with [";
|
||||
error += (*j);
|
||||
error += L"]!";
|
||||
throw CError(error, __LINE__, __FILE__);
|
||||
throw CError(error, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
CMeter::SetAllMeasures(m_Measures);
|
||||
|
@ -65,7 +65,7 @@ void CMeterRotator::Initialize()
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
if (!m_ImageName.empty())
|
||||
{
|
||||
m_Image.LoadImage(m_ImageName, m_NeedsReload);
|
||||
}
|
||||
@ -157,7 +157,7 @@ bool CMeterRotator::Update()
|
||||
*/
|
||||
bool CMeterRotator::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
if (m_Image.IsLoaded())
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ void CMeterRoundLine::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0);
|
||||
m_LineLength = parser.ReadFloat(section, L"LineLength", 20.0);
|
||||
m_LineStart = parser.ReadFloat(section, L"LineStart", -1.0);
|
||||
m_LineStart = parser.ReadFormula(section, L"LineStart", -1.0);
|
||||
m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0);
|
||||
m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832);
|
||||
m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo
|
||||
@ -123,7 +123,7 @@ bool CMeterRoundLine::Update()
|
||||
*/
|
||||
bool CMeterRoundLine::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
// Calculate the center of for the line
|
||||
int x = GetX();
|
||||
@ -154,14 +154,14 @@ bool CMeterRoundLine::Draw(Graphics& graphics)
|
||||
REAL s_sin = (REAL)sin(m_StartAngle);
|
||||
REAL e_cos = (REAL)cos(angle);
|
||||
REAL e_sin = (REAL)sin(angle);
|
||||
|
||||
|
||||
//Create a path to surround the arc
|
||||
GraphicsPath path;
|
||||
path.AddArc((REAL)(cx - lineStart), (REAL)(cy - lineStart), (REAL)(lineStart * 2.0), (REAL)(lineStart * 2.0), startAngle, sweepAngle);
|
||||
path.AddLine((REAL)lineStart * s_cos + cx, (REAL)lineStart * s_sin + cy, (REAL)lineLength * s_cos + cx, (REAL)lineLength * s_sin + cy);
|
||||
path.AddArc((REAL)(cx - lineLength), (REAL)(cy - lineLength), (REAL)(lineLength * 2.0), (REAL)(lineLength * 2.0), startAngle, sweepAngle);
|
||||
path.AddLine((REAL)lineLength * e_cos + cx, (REAL)lineLength * e_sin + cy, (REAL)lineStart * e_cos + cx, (REAL)lineStart * e_sin + cy);
|
||||
|
||||
|
||||
graphics.FillPath(&solidBrush, &path);
|
||||
}
|
||||
else
|
||||
|
@ -107,7 +107,7 @@ int CMeterString::GetX(bool abs)
|
||||
{
|
||||
int x = CMeter::GetX();
|
||||
|
||||
if (!abs)
|
||||
if (!abs)
|
||||
{
|
||||
switch(m_Align)
|
||||
{
|
||||
@ -199,7 +199,7 @@ void CMeterString::Initialize()
|
||||
|
||||
// It couldn't find the font family: Log it.
|
||||
if (Ok != status)
|
||||
{
|
||||
{
|
||||
std::wstring error = L"Unable to load font family: " + m_FontFace;
|
||||
Log(LOG_ERROR, error.c_str());
|
||||
|
||||
@ -259,7 +259,7 @@ void CMeterString::Initialize()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Font = new Gdiplus::Font(FontFamily::GenericSansSerif(), size, style);
|
||||
m_Font = new Gdiplus::Font(FontFamily::GenericSansSerif (), size, style);
|
||||
}
|
||||
|
||||
Status status = m_Font->GetLastStatus();
|
||||
@ -361,15 +361,15 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
m_Scale = wcstod(scale.c_str(), NULL);
|
||||
|
||||
const std::wstring& align = parser.ReadString(section, L"StringAlign", L"LEFT");
|
||||
if(_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
if (_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_LEFT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"RIGHT") == 0)
|
||||
else if (_wcsicmp(align.c_str(), L"RIGHT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_RIGHT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"CENTER") == 0)
|
||||
else if (_wcsicmp(align.c_str(), L"CENTER") == 0)
|
||||
{
|
||||
m_Align = ALIGN_CENTER;
|
||||
}
|
||||
@ -383,19 +383,19 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
const std::wstring& stringCase = parser.ReadString(section, L"StringCase", L"NONE");
|
||||
if(_wcsicmp(stringCase.c_str(), L"NONE") == 0)
|
||||
if (_wcsicmp(stringCase.c_str(), L"NONE") == 0)
|
||||
{
|
||||
m_textCase = TEXTCASE_NONE;
|
||||
}
|
||||
else if(_wcsicmp(stringCase.c_str(), L"UPPER") == 0)
|
||||
else if (_wcsicmp(stringCase.c_str(), L"UPPER") == 0)
|
||||
{
|
||||
m_textCase = TEXTCASE_UPPER;
|
||||
}
|
||||
else if(_wcsicmp(stringCase.c_str(), L"LOWER") == 0)
|
||||
else if (_wcsicmp(stringCase.c_str(), L"LOWER") == 0)
|
||||
{
|
||||
m_textCase = TEXTCASE_LOWER;
|
||||
}
|
||||
else if(_wcsicmp(stringCase.c_str(), L"PROPER") == 0)
|
||||
else if (_wcsicmp(stringCase.c_str(), L"PROPER") == 0)
|
||||
{
|
||||
m_textCase = TEXTCASE_PROPER;
|
||||
}
|
||||
@ -409,19 +409,19 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
const std::wstring& style = parser.ReadString(section, L"StringStyle", L"NORMAL");
|
||||
if(_wcsicmp(style.c_str(), L"NORMAL") == 0)
|
||||
if (_wcsicmp(style.c_str(), L"NORMAL") == 0)
|
||||
{
|
||||
m_Style = NORMAL;
|
||||
}
|
||||
else if(_wcsicmp(style.c_str(), L"BOLD") == 0)
|
||||
else if (_wcsicmp(style.c_str(), L"BOLD") == 0)
|
||||
{
|
||||
m_Style = BOLD;
|
||||
}
|
||||
else if(_wcsicmp(style.c_str(), L"ITALIC") == 0)
|
||||
else if (_wcsicmp(style.c_str(), L"ITALIC") == 0)
|
||||
{
|
||||
m_Style = ITALIC;
|
||||
}
|
||||
else if(_wcsicmp(style.c_str(), L"BOLDITALIC") == 0)
|
||||
else if (_wcsicmp(style.c_str(), L"BOLDITALIC") == 0)
|
||||
{
|
||||
m_Style = BOLDITALIC;
|
||||
}
|
||||
@ -435,15 +435,15 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
const std::wstring& effect = parser.ReadString(section, L"StringEffect", L"NONE");
|
||||
if(_wcsicmp(effect.c_str(), L"NONE") == 0)
|
||||
if (_wcsicmp(effect.c_str(), L"NONE") == 0)
|
||||
{
|
||||
m_Effect = EFFECT_NONE;
|
||||
}
|
||||
else if(_wcsicmp(effect.c_str(), L"SHADOW") == 0)
|
||||
else if (_wcsicmp(effect.c_str(), L"SHADOW") == 0)
|
||||
{
|
||||
m_Effect = EFFECT_SHADOW;
|
||||
}
|
||||
else if(_wcsicmp(effect.c_str(), L"BORDER") == 0)
|
||||
else if (_wcsicmp(effect.c_str(), L"BORDER") == 0)
|
||||
{
|
||||
m_Effect = EFFECT_BORDER;
|
||||
}
|
||||
@ -498,7 +498,7 @@ bool CMeterString::Update()
|
||||
{
|
||||
if (!stringValues.empty())
|
||||
{
|
||||
m_String += stringValues[0];
|
||||
m_String += stringValues[0];
|
||||
}
|
||||
}
|
||||
else if (!stringValues.empty())
|
||||
@ -556,7 +556,7 @@ bool CMeterString::Update()
|
||||
*/
|
||||
bool CMeterString::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
return DrawString(graphics, NULL);
|
||||
}
|
||||
@ -572,7 +572,7 @@ bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
|
||||
if (m_Font == NULL) return false;
|
||||
|
||||
StringFormat stringFormat;
|
||||
|
||||
|
||||
if (m_AntiAlias)
|
||||
{
|
||||
graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
|
||||
@ -650,7 +650,7 @@ bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
|
||||
rcEffect.Offset(-1, 1);
|
||||
graphics.DrawString(m_String.c_str(), (int)m_String.length(), m_Font, rcEffect, &stringFormat, &solidBrush);
|
||||
}
|
||||
|
||||
|
||||
SolidBrush solidBrush(m_Color);
|
||||
graphics.DrawString(m_String.c_str(), (int)m_String.length(), m_Font, m_Rect, &stringFormat, &solidBrush);
|
||||
|
||||
@ -680,9 +680,9 @@ void CMeterString::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
{
|
||||
// Go through the list and check it there is a secondary measures for us
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
{
|
||||
m_Measures.push_back(*i);
|
||||
break;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -74,7 +74,7 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
|
||||
endPos = spacePos;
|
||||
}
|
||||
|
||||
std::wstring newStr = arg.substr(0, endPos);
|
||||
std::wstring newStr = arg.substr(0, endPos);
|
||||
arg.erase(0, endPos + 1);
|
||||
|
||||
if (newStr.size() > 0 || quotePos == 0)
|
||||
@ -105,7 +105,7 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** initModuleEx
|
||||
**
|
||||
@ -115,18 +115,18 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
|
||||
int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
|
||||
{
|
||||
int Result=1;
|
||||
|
||||
try
|
||||
|
||||
try
|
||||
{
|
||||
Rainmeter=new CRainmeter;
|
||||
|
||||
if(Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
Result=Rainmeter->Initialize(ParentWnd, dllInst, szPath);
|
||||
}
|
||||
|
||||
}
|
||||
catch(CError& error)
|
||||
catch(CError& error)
|
||||
{
|
||||
MessageBox(ParentWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
@ -142,7 +142,7 @@ int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
|
||||
*/
|
||||
void quitModule(HINSTANCE dllInst)
|
||||
{
|
||||
if(Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
Rainmeter->Quit(dllInst);
|
||||
delete Rainmeter;
|
||||
@ -162,7 +162,7 @@ void Initialize(bool DummyLS, LPCTSTR CmdLine)
|
||||
CRainmeter::SetCommandLine(CmdLine);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** ExecuteBang
|
||||
**
|
||||
** Runs a bang command. This is called from the main application
|
||||
@ -188,14 +188,14 @@ void ExecuteBang(LPCTSTR szBang)
|
||||
*/
|
||||
LPCTSTR ReadConfigString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue)
|
||||
{
|
||||
if (Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
CConfigParser* parser = Rainmeter->GetCurrentParser();
|
||||
if (parser)
|
||||
{
|
||||
return parser->ReadString(section, key, defValue, false).c_str();
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ LPCTSTR ReadConfigString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue)
|
||||
*/
|
||||
LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
|
||||
{
|
||||
if (Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
static std::wstring result;
|
||||
|
||||
@ -359,7 +359,7 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
|
||||
}
|
||||
|
||||
return L"noop";
|
||||
}
|
||||
}
|
||||
|
||||
return L"error:no rainmeter!";
|
||||
}
|
||||
@ -372,7 +372,7 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
|
||||
*/
|
||||
void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs)
|
||||
{
|
||||
if(Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
std::vector<std::wstring> subStrings = CRainmeter::ParseString(arg);
|
||||
size_t subStringsSize = subStrings.size();
|
||||
@ -1397,7 +1397,7 @@ void RainmeterTrayMenuWide()
|
||||
*/
|
||||
void RainmeterResetStatsWide()
|
||||
{
|
||||
if (Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
Rainmeter->ResetStats();
|
||||
}
|
||||
@ -1486,7 +1486,7 @@ void RainmeterWriteKeyValueWide(const WCHAR* arg)
|
||||
{
|
||||
double value;
|
||||
formula = mw->GetParser().ReadFormula(strValue, &value);
|
||||
|
||||
|
||||
// Formula read fine
|
||||
if (formula != -1)
|
||||
{
|
||||
@ -1565,7 +1565,7 @@ void RainmeterQuitWide()
|
||||
GlobalConfig CRainmeter::c_GlobalConfig = {0};
|
||||
bool CRainmeter::c_Debug = false;
|
||||
|
||||
/*
|
||||
/*
|
||||
** CRainmeter
|
||||
**
|
||||
** Constructor
|
||||
@ -1593,12 +1593,12 @@ CRainmeter::CRainmeter() :
|
||||
INITCOMMONCONTROLSEX initCtrls = {sizeof(INITCOMMONCONTROLSEX), ICC_LISTVIEW_CLASSES};
|
||||
InitCommonControlsEx(&initCtrls);
|
||||
|
||||
// Initialize GDI+.
|
||||
GdiplusStartupInput gdiplusStartupInput;
|
||||
GdiplusStartup(&m_GDIplusToken, &gdiplusStartupInput, NULL);
|
||||
// Initialize GDI+.
|
||||
GdiplusStartupInput gdiplusStartupInput;
|
||||
GdiplusStartup(&m_GDIplusToken, &gdiplusStartupInput, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** ~CRainmeter
|
||||
**
|
||||
** Destructor
|
||||
@ -1633,7 +1633,7 @@ CRainmeter::~CRainmeter()
|
||||
GdiplusShutdown(m_GDIplusToken);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
** The main initialization function for the module.
|
||||
@ -1644,10 +1644,10 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
{
|
||||
int Result=0;
|
||||
|
||||
if(Parent==NULL || Instance==NULL)
|
||||
if (Parent==NULL || Instance==NULL)
|
||||
{
|
||||
throw CError(CError::ERROR_NULL_PARAMETER, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
m_Instance = Instance;
|
||||
|
||||
@ -1656,18 +1656,18 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
|
||||
// Remove the module's name from the path
|
||||
WCHAR* pos = wcsrchr(tmpSzPath, L'\\');
|
||||
if(pos)
|
||||
if (pos)
|
||||
{
|
||||
*(pos + 1) = L'\0';
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpSzPath[0] = L'\0';
|
||||
}
|
||||
|
||||
m_Path = tmpSzPath;
|
||||
|
||||
if(!c_DummyLitestep) InitalizeLitestep();
|
||||
if (!c_DummyLitestep) InitalizeLitestep();
|
||||
|
||||
bool bDefaultIniLocation = false;
|
||||
|
||||
@ -1761,7 +1761,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
|
||||
// Read the skin folder from the ini file
|
||||
tmpSzPath[0] = L'\0';
|
||||
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSzPath, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
||||
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSzPath, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
||||
{
|
||||
m_SkinPath = tmpSzPath;
|
||||
ExpandEnvironmentVariables(m_SkinPath);
|
||||
@ -1901,7 +1901,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
ScanForConfigs(m_SkinPath);
|
||||
ScanForThemes(GetSettingsPath() + L"Themes");
|
||||
|
||||
if(m_ConfigStrings.empty())
|
||||
if (m_ConfigStrings.empty())
|
||||
{
|
||||
std::wstring error = L"There are no available skins at:\n" + m_SkinPath;
|
||||
MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR);
|
||||
@ -1926,7 +1926,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
}
|
||||
|
||||
// If we're running as Litestep's plugin, register the !bangs
|
||||
if(!c_DummyLitestep)
|
||||
if (!c_DummyLitestep)
|
||||
{
|
||||
int Msgs[] = { LM_GETREVID, 0 };
|
||||
// Register RevID message to Litestep
|
||||
@ -2013,7 +2013,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
return Result; // Alles OK
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** CheckSkinVersions
|
||||
**
|
||||
** Checks if any of the skins in the program folder are newer than in the skin folder.
|
||||
@ -2143,7 +2143,7 @@ void CRainmeter::CheckSkinVersions()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** CompareVersions
|
||||
**
|
||||
** Compares two version strings. Returns 0 if they are equal, 1 if A > B and -1 if A < B.
|
||||
@ -2159,7 +2159,7 @@ int CRainmeter::CompareVersions(const std::wstring& strA, const std::wstring& st
|
||||
std::vector<std::wstring> arrayB = CConfigParser::Tokenize(strB, L".");
|
||||
size_t arrayASize = arrayA.size();
|
||||
size_t arrayBSize = arrayB.size();
|
||||
|
||||
|
||||
size_t len = max(arrayASize, arrayBSize);
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
{
|
||||
@ -2181,7 +2181,7 @@ int CRainmeter::CompareVersions(const std::wstring& strA, const std::wstring& st
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** CreateDefaultConfigFile
|
||||
**
|
||||
** Creates the default Rainmeter.ini file.
|
||||
@ -2202,7 +2202,7 @@ void CRainmeter::CreateDefaultConfigFile(const std::wstring& strFile)
|
||||
{
|
||||
// The default.ini wasn't found -> create new
|
||||
std::ofstream out(strFile.c_str(), std::ios::out);
|
||||
if (out)
|
||||
if (out)
|
||||
{
|
||||
out << std::string("[Rainmeter]\n\n[illustro\\System]\nActive=1\n");
|
||||
out.close();
|
||||
@ -2264,11 +2264,11 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex)
|
||||
m_ConfigStrings[configIndex].active = iniIndex + 1;
|
||||
WriteActive(skinConfig, iniIndex);
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
CreateMeterWindow(skinPath, skinConfig, skinIniFile);
|
||||
}
|
||||
catch(CError& error)
|
||||
}
|
||||
catch(CError& error)
|
||||
{
|
||||
MessageBox(NULL, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
@ -2375,7 +2375,7 @@ bool CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater)
|
||||
{
|
||||
// Delete all meter windows
|
||||
delete (*iter).second;
|
||||
}
|
||||
}
|
||||
else if ((*iter).second == meterWindow)
|
||||
{
|
||||
m_Meters.erase(iter);
|
||||
@ -2525,7 +2525,7 @@ int CRainmeter::GetLoadOrder(const std::wstring& config)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** Quit
|
||||
**
|
||||
** Called when the module quits
|
||||
@ -2534,7 +2534,7 @@ int CRainmeter::GetLoadOrder(const std::wstring& config)
|
||||
void CRainmeter::Quit(HINSTANCE dllInst)
|
||||
{
|
||||
// If we're running as Litestep's plugin, unregister the !bangs
|
||||
if(!c_DummyLitestep)
|
||||
if (!c_DummyLitestep)
|
||||
{
|
||||
int Msgs[] = { LM_GETREVID, 0 };
|
||||
// Unregister RevID message
|
||||
@ -2608,7 +2608,7 @@ void CRainmeter::Quit(HINSTANCE dllInst)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** ScanForConfigs
|
||||
**
|
||||
** Scans all the subfolders and locates the ini-files.
|
||||
@ -2624,10 +2624,10 @@ void CRainmeter::ScanForConfigs(const std::wstring& path)
|
||||
|
||||
int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse)
|
||||
{
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
WIN32_FIND_DATA fileDataIni; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
HANDLE hSearchIni; // Search handle returned by FindFirstFile
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
WIN32_FIND_DATA fileDataIni; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
HANDLE hSearchIni; // Search handle returned by FindFirstFile
|
||||
|
||||
if (!base.empty())
|
||||
{
|
||||
@ -2644,7 +2644,7 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
|
||||
|
||||
do
|
||||
{
|
||||
if(hSearchIni == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
if (hSearchIni == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
// Check whether the extension is ".ini"
|
||||
std::wstring ext = fileDataIni.cFileName;
|
||||
@ -2673,12 +2673,12 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
|
||||
// Scan for folders
|
||||
std::wstring files = path + base;
|
||||
files += L"*";
|
||||
hSearch = FindFirstFile(files.c_str(), &fileData);
|
||||
hSearch = FindFirstFile(files.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
if(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
|
||||
!(wcscmp(L"Backup", fileData.cFileName) == 0 && base.empty()) && // Skip the backup folder
|
||||
wcscmp(L".", fileData.cFileName) != 0 &&
|
||||
wcscmp(L"..", fileData.cFileName) != 0)
|
||||
@ -2702,12 +2702,12 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
|
||||
}
|
||||
} while(FindNextFile(hSearch, &fileData));
|
||||
|
||||
FindClose(hSearch);
|
||||
FindClose(hSearch);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** ScanForThemes
|
||||
**
|
||||
** Scans the given folder for themes
|
||||
@ -2717,16 +2717,16 @@ void CRainmeter::ScanForThemes(const std::wstring& path)
|
||||
m_Themes.clear();
|
||||
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
|
||||
// Scan for folders
|
||||
std::wstring folders = path + L"\\*";
|
||||
hSearch = FindFirstFile(folders.c_str(), &fileData);
|
||||
hSearch = FindFirstFile(folders.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
if(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
|
||||
wcscmp(L".", fileData.cFileName) != 0 &&
|
||||
wcscmp(L"..", fileData.cFileName) != 0)
|
||||
{
|
||||
@ -2734,7 +2734,7 @@ void CRainmeter::ScanForThemes(const std::wstring& path)
|
||||
}
|
||||
} while(FindNextFile(hSearch, &fileData));
|
||||
|
||||
FindClose(hSearch);
|
||||
FindClose(hSearch);
|
||||
}
|
||||
|
||||
void CRainmeter::SaveSettings()
|
||||
@ -3076,11 +3076,11 @@ std::wstring CRainmeter::ParseCommand(const WCHAR* command, CMeterWindow* meterW
|
||||
}
|
||||
else
|
||||
{
|
||||
if (meterWindow)
|
||||
if (meterWindow)
|
||||
{
|
||||
const std::list<CMeasure*>& measures = meterWindow->GetMeasures();
|
||||
std::list<CMeasure*>::const_iterator iter = measures.begin();
|
||||
for( ; iter != measures.end(); ++iter)
|
||||
for ( ; iter != measures.end(); ++iter)
|
||||
{
|
||||
if (_wcsicmp((*iter)->GetName(), measureName.c_str()) == 0)
|
||||
{
|
||||
@ -3111,7 +3111,7 @@ std::wstring CRainmeter::ParseCommand(const WCHAR* command, CMeterWindow* meterW
|
||||
** Runs the given command or bang
|
||||
**
|
||||
*/
|
||||
void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
|
||||
void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
|
||||
{
|
||||
if (command == NULL) return;
|
||||
|
||||
@ -3151,11 +3151,11 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
|
||||
PlaySound(NULL, NULL, SND_PURGE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Run the command
|
||||
if(strCommand.c_str()[0] == L'!' && Rainmeter->GetDummyLitestep())
|
||||
if (strCommand.c_str()[0] == L'!' && Rainmeter->GetDummyLitestep())
|
||||
{
|
||||
if (meterWindow)
|
||||
if (meterWindow)
|
||||
{
|
||||
// Fake WM_COPY to deliver bangs
|
||||
COPYDATASTRUCT CopyDataStruct;
|
||||
@ -3168,7 +3168,7 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
|
||||
{
|
||||
std::wstring bang, arg;
|
||||
size_t pos = strCommand.find(L' ');
|
||||
if (pos != std::wstring::npos)
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
bang = strCommand.substr(0, pos);
|
||||
strCommand.erase(0, pos + 1);
|
||||
@ -3191,7 +3191,7 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
|
||||
|
||||
/*
|
||||
** ReadGeneralSettings
|
||||
**
|
||||
**
|
||||
** Reads the general settings from the Rainmeter.ini file
|
||||
**
|
||||
*/
|
||||
@ -3326,7 +3326,7 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
||||
}
|
||||
|
||||
delete [] tmpSz;
|
||||
|
||||
|
||||
if (!skinName.empty())
|
||||
{
|
||||
if (!SetActiveConfig(skinName, skinIni))
|
||||
@ -3355,7 +3355,7 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** SetActiveConfig
|
||||
**
|
||||
** Makes the given config active. If the config cannot be found this returns false.
|
||||
@ -3382,7 +3382,7 @@ bool CRainmeter::SetActiveConfig(const std::wstring& skinName, const std::wstrin
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** RefreshAll
|
||||
**
|
||||
** Refreshes all active meter windows.
|
||||
@ -3479,7 +3479,7 @@ void CRainmeter::RefreshAll()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** UpdateDesktopWorkArea
|
||||
**
|
||||
** Applies given DesktopWorkArea and DesktopWorkArea@n.
|
||||
@ -3603,7 +3603,7 @@ void CRainmeter::ReadStats()
|
||||
{
|
||||
WCHAR* tmpSz = new WCHAR[MAX_LINE_LENGTH];
|
||||
|
||||
if(GetPrivateProfileString(L"Statistics", L"Since", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
||||
if (GetPrivateProfileString(L"Statistics", L"Since", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
||||
{
|
||||
m_StatsDate = tmpSz;
|
||||
}
|
||||
@ -3648,12 +3648,12 @@ void CRainmeter::ResetStats()
|
||||
{
|
||||
// Set the stats-date string
|
||||
struct tm *newtime;
|
||||
time_t long_time;
|
||||
time(&long_time);
|
||||
newtime = localtime(&long_time);
|
||||
time_t long_time;
|
||||
time(&long_time);
|
||||
newtime = localtime(&long_time);
|
||||
m_StatsDate = _wasctime(newtime);
|
||||
m_StatsDate.resize(m_StatsDate.size() - 1);
|
||||
|
||||
|
||||
// Only Net measure has stats at the moment
|
||||
CMeasureNet::ResetStats();
|
||||
}
|
||||
@ -3664,7 +3664,7 @@ void CRainmeter::ResetStats()
|
||||
** Opens the context menu in given coordinates.
|
||||
**
|
||||
*/
|
||||
void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
|
||||
void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
|
||||
{
|
||||
if (!m_MenuActive)
|
||||
{
|
||||
@ -3673,10 +3673,10 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
|
||||
// Show context menu, if no actions were executed
|
||||
HMENU menu = LoadMenu(m_Instance, MAKEINTRESOURCE(IDR_CONTEXT_MENU));
|
||||
|
||||
if(menu)
|
||||
if (menu)
|
||||
{
|
||||
HMENU subMenu = GetSubMenu(menu, 0);
|
||||
if(subMenu)
|
||||
if (subMenu)
|
||||
{
|
||||
if (!GetDummyLitestep())
|
||||
{
|
||||
@ -3798,7 +3798,7 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
|
||||
// Show context menu
|
||||
TrackPopupMenu(
|
||||
subMenu,
|
||||
TPM_RIGHTBUTTON | TPM_LEFTALIGN,
|
||||
TPM_RIGHTBUTTON | TPM_LEFTALIGN,
|
||||
pos.x,
|
||||
pos.y,
|
||||
0,
|
||||
@ -3893,7 +3893,7 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
|
||||
HMENU posMenu = GetSubMenu(settingsMenu, 0);
|
||||
if (posMenu)
|
||||
{
|
||||
switch(meterWindow->GetWindowZPosition())
|
||||
switch(meterWindow->GetWindowZPosition())
|
||||
{
|
||||
case ZPOSITION_ONDESKTOP:
|
||||
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_ONDESKTOP, MF_BYCOMMAND | MF_CHECKED);
|
||||
@ -3915,10 +3915,10 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
|
||||
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_NORMAL, MF_BYCOMMAND | MF_CHECKED);
|
||||
}
|
||||
|
||||
if(meterWindow->GetXFromRight()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMRIGHT, MF_BYCOMMAND | MF_CHECKED);
|
||||
if(meterWindow->GetYFromBottom()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMBOTTOM, MF_BYCOMMAND | MF_CHECKED);
|
||||
if(meterWindow->GetXPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_XPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
|
||||
if(meterWindow->GetYPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_YPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
|
||||
if (meterWindow->GetXFromRight()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMRIGHT, MF_BYCOMMAND | MF_CHECKED);
|
||||
if (meterWindow->GetYFromBottom()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMBOTTOM, MF_BYCOMMAND | MF_CHECKED);
|
||||
if (meterWindow->GetXPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_XPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
|
||||
if (meterWindow->GetYPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_YPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
|
||||
|
||||
if (!c_DummyLitestep)
|
||||
{
|
||||
@ -3949,17 +3949,17 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
|
||||
value = max(0, value);
|
||||
CheckMenuItem(alphaMenu, value, MF_BYPOSITION | MF_CHECKED);
|
||||
|
||||
if (meterWindow->GetWindowHide() == HIDEMODE_FADEIN)
|
||||
if (meterWindow->GetWindowHide() == HIDEMODE_FADEIN)
|
||||
{
|
||||
CheckMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_CHECKED);
|
||||
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED);
|
||||
}
|
||||
else if (meterWindow->GetWindowHide() == HIDEMODE_FADEOUT)
|
||||
else if (meterWindow->GetWindowHide() == HIDEMODE_FADEOUT)
|
||||
{
|
||||
CheckMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_CHECKED);
|
||||
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED);
|
||||
}
|
||||
else if (meterWindow->GetWindowHide() == HIDEMODE_HIDE)
|
||||
else if (meterWindow->GetWindowHide() == HIDEMODE_HIDE)
|
||||
{
|
||||
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED);
|
||||
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED);
|
||||
@ -4011,7 +4011,7 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
|
||||
InsertMenu(skinMenu, 0, MF_BYPOSITION, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, skinName.c_str());
|
||||
InsertMenu(skinMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
|
||||
SetMenuDefaultItem(skinMenu, 0, MF_BYPOSITION);
|
||||
|
||||
|
||||
ChangeSkinIndex(skinMenu, index);
|
||||
|
||||
// Add the variants menu
|
||||
@ -4247,7 +4247,7 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
|
||||
if (bSuccess)
|
||||
{
|
||||
bSuccess = (wcscmp(L"TRUE", tmpSz) == 0);
|
||||
WritePrivateProfileString(L"Rainmeter", L"WriteTest", NULL, m_IniFile.c_str());
|
||||
WritePrivateProfileString(L"Rainmeter", L"WriteTest", NULL, m_IniFile.c_str());
|
||||
}
|
||||
if (!bSuccess)
|
||||
{
|
||||
|
@ -573,7 +573,7 @@ HWND CSystem::GetDefaultShellWindow()
|
||||
**
|
||||
** Finds the Shell's desktop window or WorkerW window.
|
||||
** If the window is not found, this function returns NULL.
|
||||
**
|
||||
**
|
||||
** Note for WorkerW:
|
||||
**
|
||||
** In Earlier Windows / 7 (without Aero):
|
||||
@ -982,7 +982,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
||||
// Deliver WM_DISPLAYCHANGE / WM_SETTINGCHANGE message to all meter windows
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); ++iter)
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
PostMessage((*iter).second->GetWindow(), WM_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0);
|
||||
}
|
||||
@ -1118,7 +1118,7 @@ HMODULE CSystem::RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError, bool ignor
|
||||
// return fEnabled;
|
||||
//}
|
||||
|
||||
/*
|
||||
/*
|
||||
** CopyFiles
|
||||
**
|
||||
** Copies files and folders from one location to another.
|
||||
@ -1149,7 +1149,7 @@ bool CSystem::CopyFiles(const std::wstring& strFrom, const std::wstring& strTo,
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** RemoveFile
|
||||
**
|
||||
** Removes a file even if a file is read-only.
|
||||
@ -1167,7 +1167,7 @@ bool CSystem::RemoveFile(const std::wstring& file)
|
||||
return (DeleteFile(file.c_str()) != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** GetIniFileMappingList
|
||||
**
|
||||
** Retrieves the "IniFileMapping" entries from Registry.
|
||||
@ -1199,7 +1199,7 @@ void CSystem::GetIniFileMappingList(std::vector<std::wstring>& iniFileMappings)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** GetTemporaryFile
|
||||
**
|
||||
** Prepares a temporary file if iniFile is included in the "IniFileMapping" entries.
|
||||
|
@ -600,7 +600,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
WCHAR* parseSz = _wcsdup(crop.c_str());
|
||||
WCHAR* token;
|
||||
|
||||
|
||||
token = wcstok(parseSz, L",");
|
||||
if (token)
|
||||
{
|
||||
@ -673,7 +673,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
std::vector<Gdiplus::REAL> matrix2 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix2]);
|
||||
if (matrix2.size() == 5)
|
||||
{
|
||||
for(int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
for (int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
{
|
||||
m_ColorMatrix->m[1][i] = matrix2[i];
|
||||
}
|
||||
@ -686,7 +686,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
std::vector<Gdiplus::REAL> matrix3 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix3]);
|
||||
if (matrix3.size() == 5)
|
||||
{
|
||||
for(int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
for (int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
{
|
||||
m_ColorMatrix->m[2][i] = matrix3[i];
|
||||
}
|
||||
@ -699,7 +699,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
std::vector<Gdiplus::REAL> matrix4 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix4]);
|
||||
if (matrix4.size() == 5)
|
||||
{
|
||||
for(int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
for (int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
{
|
||||
m_ColorMatrix->m[3][i] = matrix4[i];
|
||||
}
|
||||
@ -712,7 +712,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
std::vector<Gdiplus::REAL> matrix5 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix5]);
|
||||
if (matrix5.size() == 5)
|
||||
{
|
||||
for(int i = 0; i < 4; ++i) // The fifth column must be 1.
|
||||
for (int i = 0; i < 4; ++i) // The fifth column must be 1.
|
||||
{
|
||||
m_ColorMatrix->m[4][i] = matrix5[i];
|
||||
}
|
||||
@ -721,19 +721,19 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
m_NeedsTinting = (oldGreyScale != m_GreyScale || !CompareColorMatrix(&oldColorMatrix, m_ColorMatrix));
|
||||
|
||||
std::wstring flip = parser.ReadString(section, m_ConfigArray[ConfigIndexImageFlip], L"NONE");
|
||||
if(_wcsicmp(flip.c_str(), L"NONE") == 0)
|
||||
if (_wcsicmp(flip.c_str(), L"NONE") == 0)
|
||||
{
|
||||
m_Flip = RotateNoneFlipNone;
|
||||
}
|
||||
else if(_wcsicmp(flip.c_str(), L"HORIZONTAL") == 0)
|
||||
else if (_wcsicmp(flip.c_str(), L"HORIZONTAL") == 0)
|
||||
{
|
||||
m_Flip = RotateNoneFlipX;
|
||||
}
|
||||
else if(_wcsicmp(flip.c_str(), L"VERTICAL") == 0)
|
||||
else if (_wcsicmp(flip.c_str(), L"VERTICAL") == 0)
|
||||
{
|
||||
m_Flip = RotateNoneFlipY;
|
||||
}
|
||||
else if(_wcsicmp(flip.c_str(), L"BOTH") == 0)
|
||||
else if (_wcsicmp(flip.c_str(), L"BOTH") == 0)
|
||||
{
|
||||
m_Flip = RotateNoneFlipXY;
|
||||
}
|
||||
|
@ -57,12 +57,12 @@ CTrayWindow::CTrayWindow(HINSTANCE instance) : m_Instance(instance),
|
||||
wc.hInstance = instance;
|
||||
wc.hIcon = LoadIcon(instance, MAKEINTRESOURCE(IDI_WINDOW));
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = L"RainmeterTrayClass";
|
||||
|
||||
RegisterClass(&wc);
|
||||
|
||||
|
||||
m_Window = CreateWindowEx(
|
||||
WS_EX_TOOLWINDOW,
|
||||
L"RainmeterTrayClass",
|
||||
@ -92,7 +92,7 @@ CTrayWindow::~CTrayWindow()
|
||||
delete m_Bitmap;
|
||||
delete m_Measure;
|
||||
|
||||
for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i)
|
||||
for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i)
|
||||
{
|
||||
DestroyIcon(m_TrayIcons[i]);
|
||||
}
|
||||
@ -101,10 +101,10 @@ CTrayWindow::~CTrayWindow()
|
||||
if (m_Window) DestroyWindow(m_Window);
|
||||
}
|
||||
|
||||
BOOL CTrayWindow::AddTrayIcon()
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
|
||||
BOOL CTrayWindow::AddTrayIcon()
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
|
||||
if (m_TrayIcon)
|
||||
{
|
||||
DestroyIcon(m_TrayIcon);
|
||||
@ -116,41 +116,41 @@ BOOL CTrayWindow::AddTrayIcon()
|
||||
if (m_TrayIcon)
|
||||
{
|
||||
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
|
||||
tnid.hWnd = m_Window;
|
||||
tnid.hWnd = m_Window;
|
||||
tnid.uID = IDI_TRAY;
|
||||
tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
||||
tnid.uCallbackMessage = WM_TRAY_NOTIFYICON;
|
||||
tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
||||
tnid.uCallbackMessage = WM_TRAY_NOTIFYICON;
|
||||
tnid.hIcon = m_TrayIcon;
|
||||
wcsncpy_s(tnid.szTip, L"Rainmeter", _TRUNCATE);
|
||||
|
||||
res = Shell_NotifyIcon(NIM_ADD, &tnid);
|
||||
wcsncpy_s(tnid.szTip, L"Rainmeter", _TRUNCATE);
|
||||
|
||||
res = Shell_NotifyIcon(NIM_ADD, &tnid);
|
||||
}
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
BOOL CTrayWindow::RemoveTrayIcon()
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
|
||||
BOOL CTrayWindow::RemoveTrayIcon()
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
|
||||
if (m_TrayIcon)
|
||||
{
|
||||
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
|
||||
tnid.hWnd = m_Window;
|
||||
tnid.uID = IDI_TRAY;
|
||||
tnid.uFlags = 0;
|
||||
|
||||
tnid.hWnd = m_Window;
|
||||
tnid.uID = IDI_TRAY;
|
||||
tnid.uFlags = 0;
|
||||
|
||||
res = Shell_NotifyIcon(NIM_DELETE, &tnid);
|
||||
|
||||
DestroyIcon(m_TrayIcon);
|
||||
m_TrayIcon = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
BOOL CTrayWindow::ModifyTrayIcon(double value)
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
BOOL CTrayWindow::ModifyTrayIcon(double value)
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
|
||||
if (m_TrayIcon)
|
||||
{
|
||||
@ -159,22 +159,22 @@ BOOL CTrayWindow::ModifyTrayIcon(double value)
|
||||
}
|
||||
|
||||
m_TrayIcon = CreateTrayIcon(value);
|
||||
|
||||
|
||||
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
|
||||
tnid.hWnd = m_Window;
|
||||
tnid.hWnd = m_Window;
|
||||
tnid.uID = IDI_TRAY;
|
||||
tnid.uFlags = NIF_ICON;
|
||||
tnid.uFlags = NIF_ICON;
|
||||
tnid.hIcon = m_TrayIcon;
|
||||
|
||||
res = Shell_NotifyIcon(NIM_MODIFY, &tnid);
|
||||
return res;
|
||||
res = Shell_NotifyIcon(NIM_MODIFY, &tnid);
|
||||
return res;
|
||||
}
|
||||
|
||||
HICON CTrayWindow::CreateTrayIcon(double value)
|
||||
{
|
||||
if (m_Measure != NULL)
|
||||
{
|
||||
if (m_MeterType == TRAY_METER_TYPE_HISTOGRAM)
|
||||
if (m_MeterType == TRAY_METER_TYPE_HISTOGRAM)
|
||||
{
|
||||
m_TrayValues[m_TrayPos] = value;
|
||||
m_TrayPos = (m_TrayPos + 1) % TRAYICON_SIZE;
|
||||
@ -205,9 +205,9 @@ HICON CTrayWindow::CreateTrayIcon(double value)
|
||||
trayBitmap.GetHICON(&icon);
|
||||
return icon;
|
||||
}
|
||||
else if (m_MeterType == TRAY_METER_TYPE_BITMAP && (m_Bitmap || m_TrayIcons.size() > 0))
|
||||
else if (m_MeterType == TRAY_METER_TYPE_BITMAP && (m_Bitmap || m_TrayIcons.size() > 0))
|
||||
{
|
||||
if (m_TrayIcons.size() > 0)
|
||||
if (m_TrayIcons.size() > 0)
|
||||
{
|
||||
size_t frame = 0;
|
||||
size_t frameCount = m_TrayIcons.size();
|
||||
@ -224,7 +224,7 @@ HICON CTrayWindow::CreateTrayIcon(double value)
|
||||
int frameCount = 0;
|
||||
int newX, newY;
|
||||
|
||||
if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight())
|
||||
if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight())
|
||||
{
|
||||
frameCount = m_Bitmap->GetWidth() / TRAYICON_SIZE;
|
||||
}
|
||||
@ -237,7 +237,7 @@ HICON CTrayWindow::CreateTrayIcon(double value)
|
||||
frame = (int)(value * frameCount);
|
||||
frame = min((frameCount - 1), frame);
|
||||
|
||||
if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight())
|
||||
if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight())
|
||||
{
|
||||
newX = frame * TRAYICON_SIZE;
|
||||
newY = 0;
|
||||
@ -255,7 +255,7 @@ HICON CTrayWindow::CreateTrayIcon(double value)
|
||||
// Blit the image
|
||||
Rect r(0, 0, TRAYICON_SIZE, TRAYICON_SIZE);
|
||||
graphics.DrawImage(m_Bitmap, r, newX, newY, TRAYICON_SIZE, TRAYICON_SIZE, UnitPixel);
|
||||
|
||||
|
||||
HICON icon;
|
||||
trayBitmap.GetHICON(&icon);
|
||||
return icon;
|
||||
@ -274,7 +274,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
|
||||
delete m_Measure;
|
||||
m_Measure = NULL;
|
||||
|
||||
for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i)
|
||||
for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i)
|
||||
{
|
||||
DestroyIcon(m_TrayIcons[i]);
|
||||
}
|
||||
@ -308,13 +308,13 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
|
||||
m_MeterType = TRAY_METER_TYPE_NONE;
|
||||
|
||||
std::wstring type = parser.ReadString(L"TrayMeasure", L"TrayMeter", L"HISTOGRAM");
|
||||
if (_wcsicmp(type.c_str(), L"HISTOGRAM") == 0)
|
||||
if (_wcsicmp(type.c_str(), L"HISTOGRAM") == 0)
|
||||
{
|
||||
m_MeterType = TRAY_METER_TYPE_HISTOGRAM;
|
||||
m_TrayColor1 = parser.ReadColor(L"TrayMeasure", L"TrayColor1", Color(0, 100, 0));
|
||||
m_TrayColor2 = parser.ReadColor(L"TrayMeasure", L"TrayColor2", Color(0, 255, 0));
|
||||
}
|
||||
else if (_wcsicmp(type.c_str(), L"BITMAP") == 0)
|
||||
else if (_wcsicmp(type.c_str(), L"BITMAP") == 0)
|
||||
{
|
||||
m_MeterType = TRAY_METER_TYPE_BITMAP;
|
||||
|
||||
@ -324,16 +324,16 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
|
||||
if (!imageName.empty())
|
||||
{
|
||||
imageName.insert(0, Rainmeter->GetSkinPath());
|
||||
if (imageName.size() > 3)
|
||||
if (imageName.size() > 3)
|
||||
{
|
||||
std::wstring extension = imageName.substr(imageName.size() - 3);
|
||||
if (extension == L"ico" || extension == L"ICO")
|
||||
if (extension == L"ico" || extension == L"ICO")
|
||||
{
|
||||
int count = 1;
|
||||
HICON hIcon = NULL;
|
||||
|
||||
// Load the icons
|
||||
do
|
||||
do
|
||||
{
|
||||
WCHAR buffer[MAX_PATH];
|
||||
_snwprintf_s(buffer, _TRUNCATE, imageName.c_str(), count++);
|
||||
@ -345,13 +345,13 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_TrayIcons.empty())
|
||||
if (m_TrayIcons.empty())
|
||||
{
|
||||
// No icons found so load as bitmap
|
||||
delete m_Bitmap;
|
||||
m_Bitmap = new Bitmap(imageName.c_str());
|
||||
Status status = m_Bitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
if (Ok != status)
|
||||
{
|
||||
LogWithArgs(LOG_WARNING, L"Bitmap image not found: %s", imageName.c_str());
|
||||
delete m_Bitmap;
|
||||
@ -382,12 +382,12 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
{
|
||||
static CTrayWindow* tray = NULL;
|
||||
|
||||
if(uMsg == WM_CREATE)
|
||||
if (uMsg == WM_CREATE)
|
||||
{
|
||||
tray=(CTrayWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams;
|
||||
}
|
||||
|
||||
switch(uMsg)
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
if (Rainmeter && tray)
|
||||
@ -395,24 +395,24 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
if (wParam == ID_CONTEXT_ABOUT)
|
||||
{
|
||||
OpenAboutDialog(tray->GetWindow(), Rainmeter->GetInstance());
|
||||
}
|
||||
}
|
||||
else if (wParam == ID_CONTEXT_DOWNLOADS)
|
||||
{
|
||||
LSExecute(NULL, RAINMETER_DOWNLOADS, SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SHOW_HELP)
|
||||
else if (wParam == ID_CONTEXT_SHOW_HELP)
|
||||
{
|
||||
LSExecute(NULL, revision_beta ? RAINMETER_MANUALBETA : RAINMETER_MANUAL, SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_NEW_VERSION)
|
||||
else if (wParam == ID_CONTEXT_NEW_VERSION)
|
||||
{
|
||||
LSExecute(NULL, RAINMETER_OFFICIAL, SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_REFRESH)
|
||||
else if (wParam == ID_CONTEXT_REFRESH)
|
||||
{
|
||||
PostMessage(tray->GetWindow(), WM_TRAY_DELAYED_REFRESH_ALL, (WPARAM)NULL, (LPARAM)NULL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SHOWLOGFILE)
|
||||
}
|
||||
else if (wParam == ID_CONTEXT_SHOWLOGFILE)
|
||||
{
|
||||
// Check if the file exists
|
||||
const std::wstring& log = Rainmeter->GetLogFile();
|
||||
@ -423,57 +423,57 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_STARTLOG)
|
||||
else if (wParam == ID_CONTEXT_STARTLOG)
|
||||
{
|
||||
Rainmeter->StartLogging();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_STOPLOG)
|
||||
else if (wParam == ID_CONTEXT_STOPLOG)
|
||||
{
|
||||
Rainmeter->StopLogging();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_DELETELOGFILE)
|
||||
else if (wParam == ID_CONTEXT_DELETELOGFILE)
|
||||
{
|
||||
Rainmeter->DeleteLogFile();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_DEBUGLOG)
|
||||
else if (wParam == ID_CONTEXT_DEBUGLOG)
|
||||
{
|
||||
Rainmeter->SetDebug(!CRainmeter::GetDebug());
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_DISABLEDRAG)
|
||||
else if (wParam == ID_CONTEXT_DISABLEDRAG)
|
||||
{
|
||||
Rainmeter->SetDisableDragging(!Rainmeter->GetDisableDragging());
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_EDITCONFIG)
|
||||
else if (wParam == ID_CONTEXT_EDITCONFIG)
|
||||
{
|
||||
std::wstring command = Rainmeter->GetConfigEditor() + L" \"";
|
||||
command += Rainmeter->GetIniFile();
|
||||
command += L"\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_MANAGETHEMES)
|
||||
else if (wParam == ID_CONTEXT_MANAGETHEMES)
|
||||
{
|
||||
std::wstring command = L"\"" + Rainmeter->GetAddonPath();
|
||||
command += L"RainThemes\\RainThemes.exe\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_MANAGESKINS)
|
||||
else if (wParam == ID_CONTEXT_MANAGESKINS)
|
||||
{
|
||||
std::wstring command = L"\"" + Rainmeter->GetAddonPath();
|
||||
command += L"RainBrowser\\RainBrowser.exe\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_QUIT)
|
||||
else if (wParam == ID_CONTEXT_QUIT)
|
||||
{
|
||||
if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0);
|
||||
quitModule(Rainmeter->GetInstance());
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_OPENSKINSFOLDER)
|
||||
else if (wParam == ID_CONTEXT_OPENSKINSFOLDER)
|
||||
{
|
||||
std::wstring command = L"\"" + Rainmeter->GetSkinPath();
|
||||
command += L"\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if((wParam & 0x0ffff) >= ID_THEME_FIRST && (wParam & 0x0ffff) <= ID_THEME_LAST)
|
||||
else if ((wParam & 0x0ffff) >= ID_THEME_FIRST && (wParam & 0x0ffff) <= ID_THEME_LAST)
|
||||
{
|
||||
int pos = (wParam & 0x0ffff) - ID_THEME_FIRST;
|
||||
|
||||
@ -487,7 +487,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
else if((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST)
|
||||
else if ((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST)
|
||||
{
|
||||
wParam = wParam & 0x0ffff;
|
||||
|
||||
@ -523,7 +523,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
if (index < (int)windows.size())
|
||||
{
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); ++iter)
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
--index;
|
||||
if (index < 0)
|
||||
@ -540,11 +540,11 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
case WM_TRAY_NOTIFYICON:
|
||||
{
|
||||
UINT uMouseMsg = (UINT)lParam;
|
||||
UINT uMouseMsg = (UINT)lParam;
|
||||
|
||||
std::wstring bang;
|
||||
|
||||
switch(uMouseMsg)
|
||||
switch(uMouseMsg)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
bang = Rainmeter->GetTrayExecuteL();
|
||||
@ -589,7 +589,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
{
|
||||
COPYDATASTRUCT cds;
|
||||
|
||||
if(wParam == RAINMETER_QUERY_ID_SKINS_PATH)
|
||||
if (wParam == RAINMETER_QUERY_ID_SKINS_PATH)
|
||||
{
|
||||
const std::wstring& path = Rainmeter->GetSkinPath();
|
||||
|
||||
@ -598,10 +598,10 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
cds.lpData = (LPVOID) path.c_str();
|
||||
|
||||
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_SETTINGS_PATH)
|
||||
else if (wParam == RAINMETER_QUERY_ID_SETTINGS_PATH)
|
||||
{
|
||||
std::wstring path = Rainmeter->GetSettingsPath();
|
||||
|
||||
@ -613,7 +613,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_PLUGINS_PATH)
|
||||
else if (wParam == RAINMETER_QUERY_ID_PLUGINS_PATH)
|
||||
{
|
||||
const std::wstring& path = Rainmeter->GetPluginPath();
|
||||
|
||||
@ -625,7 +625,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_PROGRAM_PATH)
|
||||
else if (wParam == RAINMETER_QUERY_ID_PROGRAM_PATH)
|
||||
{
|
||||
const std::wstring& path = Rainmeter->GetPath();
|
||||
|
||||
@ -637,7 +637,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_LOG_PATH)
|
||||
else if (wParam == RAINMETER_QUERY_ID_LOG_PATH)
|
||||
{
|
||||
const std::wstring& path = Rainmeter->GetLogFile();
|
||||
|
||||
@ -649,7 +649,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR)
|
||||
else if (wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR)
|
||||
{
|
||||
const std::wstring& editor = Rainmeter->GetConfigEditor();
|
||||
|
||||
@ -661,7 +661,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_COMMAND_LINE)
|
||||
else if (wParam == RAINMETER_QUERY_ID_COMMAND_LINE)
|
||||
{
|
||||
std::wstring commandline = Rainmeter->GetCommandLine();
|
||||
|
||||
@ -673,15 +673,15 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_VERSION_CHECK)
|
||||
else if (wParam == RAINMETER_QUERY_ID_VERSION_CHECK)
|
||||
{
|
||||
UINT versioncheck = (Rainmeter->GetDisableVersionCheck() * (Rainmeter->GetDisableVersionCheck() + Rainmeter->GetNewVersion()));
|
||||
|
||||
|
||||
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM) versioncheck);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_IS_DEBUGGING)
|
||||
else if (wParam == RAINMETER_QUERY_ID_IS_DEBUGGING)
|
||||
{
|
||||
BOOL debug = Rainmeter->GetDebug();
|
||||
|
||||
@ -689,7 +689,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_STATS_DATE)
|
||||
else if (wParam == RAINMETER_QUERY_ID_STATS_DATE)
|
||||
{
|
||||
const std::wstring& date = Rainmeter->GetStatsDate();
|
||||
|
||||
@ -701,7 +701,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_L)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_L)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteL();
|
||||
|
||||
@ -713,7 +713,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_R)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_R)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteR();
|
||||
|
||||
@ -725,7 +725,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_M)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_M)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteM();
|
||||
|
||||
@ -737,7 +737,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DL)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DL)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteDL();
|
||||
|
||||
@ -749,7 +749,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DR)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DR)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteDR();
|
||||
|
||||
@ -761,7 +761,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DM)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DM)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteDM();
|
||||
|
||||
@ -773,7 +773,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_IS_LITESTEP)
|
||||
else if (wParam == RAINMETER_QUERY_ID_IS_LITESTEP)
|
||||
{
|
||||
BOOL islitestep = !Rainmeter->GetDummyLitestep();
|
||||
|
||||
@ -785,19 +785,19 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
return 1;
|
||||
|
||||
case WM_COPYDATA:
|
||||
if(Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam;
|
||||
if(cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE)
|
||||
if (cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE)
|
||||
{
|
||||
std::wstring SkinName((LPTSTR) cds->lpData);
|
||||
std::map<std::wstring, CMeterWindow*> MeterWindows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = MeterWindows.find(SkinName);
|
||||
if(iter != MeterWindows.end())
|
||||
if (iter != MeterWindows.end())
|
||||
{
|
||||
return (LRESULT) iter->second->GetWindow();
|
||||
}
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -833,17 +833,17 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
break;
|
||||
|
||||
case LM_GETREVID:
|
||||
if(lParam != NULL)
|
||||
if (lParam != NULL)
|
||||
{
|
||||
char* Buffer=(char*)lParam;
|
||||
if(wParam==0)
|
||||
if (wParam==0)
|
||||
{
|
||||
sprintf(Buffer, "Rainmeter.dll: %s", APPVERSION);
|
||||
}
|
||||
else if(wParam==1)
|
||||
}
|
||||
else if (wParam==1)
|
||||
{
|
||||
sprintf(Buffer, "Rainmeter.dll: %s %s, Rainy", APPVERSION, __DATE__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer[0] = 0;
|
||||
|
@ -68,7 +68,7 @@ void CheckVersion(void* dummy)
|
||||
version += atoi(verMinor.c_str()) * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (version > RAINMETER_VERSION)
|
||||
{
|
||||
Rainmeter->SetNewVersion(TRUE);
|
||||
|
@ -19,7 +19,7 @@ void LuaManager::Init()
|
||||
{
|
||||
if (c_pState == 0)
|
||||
{
|
||||
// initialize Lua
|
||||
// initialize Lua
|
||||
c_pState = lua_open();
|
||||
|
||||
//load Lua base libraries
|
||||
@ -57,7 +57,7 @@ void LuaManager::ReportErrors(lua_State * L)
|
||||
{
|
||||
LuaLog(LOG_ERROR, "Script: %s", lua_tostring(L, -1));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void LuaManager::LuaLog(int nLevel, const char* format, ... )
|
||||
{
|
||||
|
@ -21,14 +21,14 @@ std::wstring to_wstring(lua_State* L, int arg, void* type)
|
||||
|
||||
const wchar_t* to_wchar (lua_State* L, int arg, void* type)
|
||||
{
|
||||
// We have a static wstring here so we can keep a copy of the string
|
||||
// We have a static wstring here so we can keep a copy of the string
|
||||
// passed in alive while its being passed around.
|
||||
// This isn't exactly safe, but we shouldn't really have to worry as
|
||||
// Rainmeter isn't threaded.
|
||||
static std::wstring str;
|
||||
|
||||
str = ConvertToWide(lua_tostring(L,arg));
|
||||
|
||||
|
||||
return str.c_str();
|
||||
}
|
||||
|
||||
|
@ -16,11 +16,11 @@ LuaScript::LuaScript(lua_State* p_pState, const char* p_strFile) : m_pState(p_pS
|
||||
lua_newtable(m_pState);
|
||||
|
||||
// Create the metatable that will store the global table
|
||||
lua_createtable(m_pState, 0, 1);
|
||||
|
||||
lua_createtable(m_pState, 0, 1);
|
||||
|
||||
// Push the global teble
|
||||
lua_pushvalue(m_pState, LUA_GLOBALSINDEX);
|
||||
|
||||
|
||||
// Set the __index of the table to be the global table
|
||||
lua_setfield(m_pState, -2, "__index");
|
||||
|
||||
@ -102,7 +102,7 @@ double LuaScript::RunFunctionDouble(const char* p_strFuncName)
|
||||
// Push the function onto the stack
|
||||
lua_getfield(m_pState, -1, p_strFuncName);
|
||||
|
||||
if(lua_pcall(m_pState, 0, 1, 0))
|
||||
if (lua_pcall(m_pState, 0, 1, 0))
|
||||
{
|
||||
LuaManager::ReportErrors(m_pState);
|
||||
}
|
||||
@ -188,7 +188,7 @@ bool LuaScript::FunctionExists(const char* p_strFuncName)
|
||||
// Push the function onto the stack
|
||||
lua_getfield(m_pState, -1, p_strFuncName);
|
||||
|
||||
if (lua_isfunction( m_pState, -1))
|
||||
if (lua_isfunction( m_pState, -1))
|
||||
{
|
||||
bExists = true;
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ static std::map<UINT, CPUMeasure*> g_CPUMeasures;
|
||||
void SplitName(WCHAR* names, std::vector< std::wstring >& splittedNames)
|
||||
{
|
||||
WCHAR* token;
|
||||
|
||||
|
||||
token = wcstok(names, L";");
|
||||
while(token != NULL)
|
||||
while (token != NULL)
|
||||
{
|
||||
splittedNames.push_back(token);
|
||||
token = wcstok(NULL, L";");
|
||||
@ -63,7 +63,7 @@ void SplitName(WCHAR* names, std::vector< std::wstring >& splittedNames)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -110,7 +110,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
|
||||
bool CheckProcess(CPUMeasure* measure, const std::wstring& name)
|
||||
{
|
||||
if (measure->includes.empty())
|
||||
if (measure->includes.empty())
|
||||
{
|
||||
for (size_t i = 0; i < measure->excludes.size(); i++)
|
||||
{
|
||||
@ -141,7 +141,7 @@ bool CheckProcess(CPUMeasure* measure, const std::wstring& name)
|
||||
double Update2(UINT id)
|
||||
{
|
||||
static DWORD oldTime = 0;
|
||||
|
||||
|
||||
// Only update twice per second
|
||||
DWORD time = GetTickCount();
|
||||
if (oldTime == 0 || time - oldTime > 500)
|
||||
@ -153,25 +153,25 @@ double Update2(UINT id)
|
||||
LONGLONG newValue = 0;
|
||||
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
if (i != g_CPUMeasures.end())
|
||||
{
|
||||
CPUMeasure* measure = (*i).second;
|
||||
|
||||
if(measure)
|
||||
if (measure)
|
||||
{
|
||||
for (size_t i = 0; i < g_Processes.size(); i++)
|
||||
for (size_t i = 0; i < g_Processes.size(); i++)
|
||||
{
|
||||
// Check process include/exclude
|
||||
if (CheckProcess(measure, g_Processes[i].name))
|
||||
if (CheckProcess(measure, g_Processes[i].name))
|
||||
{
|
||||
if (g_Processes[i].oldValue != 0)
|
||||
if (g_Processes[i].oldValue != 0)
|
||||
{
|
||||
if (measure->topProcess == 0)
|
||||
if (measure->topProcess == 0)
|
||||
{
|
||||
// Add all values together
|
||||
newValue += g_Processes[i].newValue - g_Processes[i].oldValue;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// Find the top process
|
||||
if (newValue < g_Processes[i].newValue - g_Processes[i].oldValue)
|
||||
@ -197,14 +197,14 @@ double Update2(UINT id)
|
||||
//
|
||||
// // Then substract the excluded processes
|
||||
// std::vector< std::wstring >::iterator j = measure->excludes.begin();
|
||||
// for( ; j != measure->excludes.end(); j++)
|
||||
// for ( ; j != measure->excludes.end(); j++)
|
||||
// {
|
||||
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
|
||||
// newValue += longvalue; // Adding means actually substraction
|
||||
// }
|
||||
//
|
||||
// // Compare with the old value
|
||||
// if(measure->oldValue != 0)
|
||||
// if (measure->oldValue != 0)
|
||||
// {
|
||||
// int val = 10000000 - (UINT)(newValue - measure->oldValue);
|
||||
// if (val < 0) val = 0;
|
||||
@ -216,14 +216,14 @@ double Update2(UINT id)
|
||||
// {
|
||||
// // Add the included processes
|
||||
// std::vector< std::wstring >::iterator j = measure->includes.begin();
|
||||
// for( ; j != measure->includes.end(); j++)
|
||||
// for ( ; j != measure->includes.end(); j++)
|
||||
// {
|
||||
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
|
||||
// newValue += longvalue;
|
||||
// }
|
||||
//
|
||||
// // Compare with the old value
|
||||
// if(measure->oldValue != 0)
|
||||
// if (measure->oldValue != 0)
|
||||
// {
|
||||
// value = (UINT)(newValue - measure->oldValue);
|
||||
// }
|
||||
@ -241,14 +241,14 @@ double Update2(UINT id)
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
if (i != g_CPUMeasures.end())
|
||||
{
|
||||
CPUMeasure* measure = (*i).second;
|
||||
|
||||
if (measure->topProcess == 2)
|
||||
if (measure->topProcess == 2)
|
||||
{
|
||||
return measure->topProcessName.c_str();
|
||||
}
|
||||
@ -266,7 +266,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
// delete the measure
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
if (i != g_CPUMeasures.end())
|
||||
{
|
||||
delete (*i).second;
|
||||
g_CPUMeasures.erase(i);
|
||||
@ -291,17 +291,17 @@ void UpdateProcesses()
|
||||
CPerfSnapshot snapshot(&g_CounterTitles);
|
||||
CPerfObjectList objList(&snapshot, &g_CounterTitles);
|
||||
|
||||
if(snapshot.TakeSnapshot(L"Process"))
|
||||
if (snapshot.TakeSnapshot(L"Process"))
|
||||
{
|
||||
pPerfObj = objList.GetPerfObject(L"Process");
|
||||
|
||||
if(pPerfObj)
|
||||
if (pPerfObj)
|
||||
{
|
||||
for(pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
for (pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
pObjInst != NULL;
|
||||
pObjInst = pPerfObj->GetNextObjectInstance())
|
||||
{
|
||||
if(pObjInst->GetObjectInstanceName(name, 256))
|
||||
if (pObjInst->GetObjectInstanceName(name, 256))
|
||||
{
|
||||
if (_wcsicmp(name, L"_Total") == 0)
|
||||
{
|
||||
@ -309,20 +309,20 @@ void UpdateProcesses()
|
||||
}
|
||||
|
||||
pPerfCntr = pObjInst->GetCounterByName(L"% Processor Time");
|
||||
if(pPerfCntr != NULL)
|
||||
if (pPerfCntr != NULL)
|
||||
{
|
||||
pPerfCntr->GetData(data, 256, NULL);
|
||||
|
||||
if(pPerfCntr->GetSize() == 8)
|
||||
|
||||
if (pPerfCntr->GetSize() == 8)
|
||||
{
|
||||
ProcessValues values;
|
||||
values.name = name;
|
||||
values.oldValue = 0;
|
||||
|
||||
// Check if we can find the old value
|
||||
for (size_t i = 0; i < g_Processes.size(); i++)
|
||||
for (size_t i = 0; i < g_Processes.size(); i++)
|
||||
{
|
||||
if (!g_Processes[i].found && g_Processes[i].name == name)
|
||||
if (!g_Processes[i].found && g_Processes[i].name == name)
|
||||
{
|
||||
values.oldValue = g_Processes[i].newValue;
|
||||
g_Processes[i].found = true;
|
||||
|
@ -61,7 +61,7 @@ float getHighestTemp();
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -73,10 +73,10 @@ float getHighestTemp();
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
/*
|
||||
Read our own settings from the ini-file
|
||||
/*
|
||||
Read our own settings from the ini-file
|
||||
The ReadConfigString can be used for this purpose. Plugins
|
||||
can also read the config some other way (e.g. with
|
||||
can also read the config some other way (e.g. with
|
||||
GetPrivateProfileInt, but in that case the variables
|
||||
do not work.
|
||||
*/
|
||||
@ -100,7 +100,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -17,34 +17,34 @@ bool CSharedMemClient::ReadSharedMem(PCORE_TEMP_SHARED_DATA i_SharedData)
|
||||
HANDLE hdlMutex;
|
||||
|
||||
hdlMutex = CreateMutex(NULL,FALSE,CORE_TEMP_MUTEX_OBJECT);
|
||||
if (hdlMutex == NULL)
|
||||
{
|
||||
if (hdlMutex == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
WaitForSingleObject(hdlMutex, INFINITE);
|
||||
|
||||
}
|
||||
|
||||
WaitForSingleObject(hdlMutex, INFINITE);
|
||||
|
||||
hdlMemory = OpenFileMapping(
|
||||
FILE_MAP_READ, // Read only permission.
|
||||
TRUE,
|
||||
FILE_MAP_READ, // Read only permission.
|
||||
TRUE,
|
||||
CORE_TEMP_MAPPING_OBJECT); // "CoreTempMappingObject"
|
||||
|
||||
if (hdlMemory == NULL)
|
||||
{
|
||||
ReleaseMutex(hdlMutex);
|
||||
|
||||
if (hdlMemory == NULL)
|
||||
{
|
||||
ReleaseMutex(hdlMutex);
|
||||
CloseHandle(hdlMutex);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pSharedData = (PCORE_TEMP_SHARED_DATA)MapViewOfFile(hdlMemory, FILE_MAP_READ, 0, 0, 0);
|
||||
if (pSharedData == NULL)
|
||||
if (pSharedData == NULL)
|
||||
{
|
||||
CloseHandle(hdlMemory);
|
||||
hdlMemory = NULL;
|
||||
ReleaseMutex(hdlMutex);
|
||||
ReleaseMutex(hdlMutex);
|
||||
CloseHandle(hdlMutex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
__try
|
||||
{
|
||||
@ -59,7 +59,7 @@ bool CSharedMemClient::ReadSharedMem(PCORE_TEMP_SHARED_DATA i_SharedData)
|
||||
|
||||
UnmapViewOfFile(pSharedData);
|
||||
CloseHandle(hdlMemory);
|
||||
ReleaseMutex(hdlMutex);
|
||||
ReleaseMutex(hdlMutex);
|
||||
CloseHandle(hdlMutex);
|
||||
|
||||
return bRet;
|
||||
|
@ -97,7 +97,7 @@ static FolderInfo* GetFolderInfo(const wchar_t* aPath, const wchar_t* aIniPath)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -139,7 +139,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
if (_wcsicmp(strIncludeSubFolders, L"1") == 0) {
|
||||
measureInfo->Folder->IncludeSubFolders(true);
|
||||
}
|
||||
|
||||
|
||||
const wchar_t* strShowHiddenFiles = ReadConfigString(section, L"IncludeHiddenFiles", L"");
|
||||
if (_wcsicmp(strShowHiddenFiles, L"1") == 0) {
|
||||
measureInfo->Folder->IncludeHiddenFiles(true);
|
||||
|
@ -19,119 +19,119 @@
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObjectInstance::CPerfObjectInstance(
|
||||
PPERF_INSTANCE_DEFINITION const pPerfInstDef,
|
||||
PPERF_COUNTER_DEFINITION const pPerfCntrDef,
|
||||
DWORD nCounters, CPerfTitleDatabase * const pPerfCounterTitles,
|
||||
BOOL fDummy)
|
||||
PPERF_INSTANCE_DEFINITION const pPerfInstDef,
|
||||
PPERF_COUNTER_DEFINITION const pPerfCntrDef,
|
||||
DWORD nCounters, CPerfTitleDatabase * const pPerfCounterTitles,
|
||||
BOOL fDummy)
|
||||
{
|
||||
m_pPerfInstDef = pPerfInstDef;
|
||||
m_pPerfCntrDef = pPerfCntrDef;
|
||||
m_nCounters = nCounters;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
|
||||
m_fDummy = fDummy;
|
||||
m_pPerfInstDef = pPerfInstDef;
|
||||
m_pPerfCntrDef = pPerfCntrDef;
|
||||
m_nCounters = nCounters;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
|
||||
m_fDummy = fDummy;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfObjectInstance::GetObjectInstanceName(
|
||||
PTSTR pszObjInstName, DWORD nSize )
|
||||
PTSTR pszObjInstName, DWORD nSize )
|
||||
{
|
||||
if ( m_fDummy )
|
||||
{
|
||||
*pszObjInstName = 0; // Return an empty string
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
|
||||
return FALSE;
|
||||
if ( m_fDummy )
|
||||
{
|
||||
*pszObjInstName = 0; // Return an empty string
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset);
|
||||
|
||||
#ifdef UNICODE
|
||||
lstrcpy( pszObjInstName, pszName );
|
||||
#else
|
||||
wcstombs( pszObjInstName, pszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
|
||||
return FALSE;
|
||||
|
||||
PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset);
|
||||
|
||||
#ifdef UNICODE
|
||||
lstrcpy( pszObjInstName, pszName );
|
||||
#else
|
||||
wcstombs( pszObjInstName, pszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::MakeCounter( PPERF_COUNTER_DEFINITION const pCounterDef )
|
||||
{
|
||||
// Look up the name of this counter in the title database
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
pCounterDef->CounterNameTitleIndex );
|
||||
|
||||
DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
|
||||
// Look up the name of this counter in the title database
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
pCounterDef->CounterNameTitleIndex );
|
||||
|
||||
// Create a new CPerfCounter. The caller is responsible for deleting it.
|
||||
return new CPerfCounter(pszName,
|
||||
pCounterDef->CounterType,
|
||||
MakePtr( PBYTE, m_pPerfInstDef,
|
||||
nInstanceDefSize +
|
||||
pCounterDef->CounterOffset ),
|
||||
pCounterDef->CounterSize );
|
||||
DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
|
||||
|
||||
// Create a new CPerfCounter. The caller is responsible for deleting it.
|
||||
return new CPerfCounter(pszName,
|
||||
pCounterDef->CounterType,
|
||||
MakePtr( PBYTE, m_pPerfInstDef,
|
||||
nInstanceDefSize +
|
||||
pCounterDef->CounterOffset ),
|
||||
pCounterDef->CounterSize );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetCounterByIndex( DWORD index )
|
||||
{
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter;
|
||||
|
||||
if ( index >= m_nCounters )
|
||||
return 0;
|
||||
|
||||
pCurrentCounter = m_pPerfCntrDef;
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter;
|
||||
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping
|
||||
for ( DWORD i = 0; i < index; i++ )
|
||||
{
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
if ( index >= m_nCounters )
|
||||
return 0;
|
||||
|
||||
if ( pCurrentCounter->ByteLength == 0 )
|
||||
return 0;
|
||||
pCurrentCounter = m_pPerfCntrDef;
|
||||
|
||||
return MakeCounter( pCurrentCounter );
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping
|
||||
for ( DWORD i = 0; i < index; i++ )
|
||||
{
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
|
||||
if ( pCurrentCounter->ByteLength == 0 )
|
||||
return 0;
|
||||
|
||||
return MakeCounter( pCurrentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetFirstCounter( void )
|
||||
{
|
||||
m_currentCounter = 0;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
m_currentCounter = 0;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetNextCounter( void )
|
||||
{
|
||||
m_currentCounter++;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
m_currentCounter++;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetCounterByName( PCTSTR const pszName )
|
||||
{
|
||||
DWORD cntrIdx = m_pPerfCounterTitles->GetIndexFromTitleString(pszName);
|
||||
if ( cntrIdx == 0 )
|
||||
return 0;
|
||||
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
|
||||
DWORD cntrIdx = m_pPerfCounterTitles->GetIndexFromTitleString(pszName);
|
||||
if ( cntrIdx == 0 )
|
||||
return 0;
|
||||
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping and comparing
|
||||
for ( DWORD i = 0; i < m_nCounters; i++ )
|
||||
{
|
||||
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
|
||||
return MakeCounter( pCurrentCounter );
|
||||
|
||||
// Nope. Not this one. Advance to the next counter
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
|
||||
|
||||
return 0;
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping and comparing
|
||||
for ( DWORD i = 0; i < m_nCounters; i++ )
|
||||
{
|
||||
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
|
||||
return MakeCounter( pCurrentCounter );
|
||||
|
||||
// Nope. Not this one. Advance to the next counter
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -19,65 +19,65 @@
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObjectList::CPerfObjectList(
|
||||
CPerfSnapshot * const pPerfSnapshot,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase )
|
||||
CPerfSnapshot * const pPerfSnapshot,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase )
|
||||
{
|
||||
m_pPerfSnapshot = pPerfSnapshot;
|
||||
m_pPerfCounterTitles = pPerfTitleDatabase;
|
||||
m_pPerfSnapshot = pPerfSnapshot;
|
||||
m_pPerfCounterTitles = pPerfTitleDatabase;
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetFirstPerfObject( void )
|
||||
{
|
||||
m_currentObjectListIndex = 0;
|
||||
if ( m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
m_currentObjectListIndex = 0;
|
||||
if ( m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
|
||||
m_pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
m_pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetNextPerfObject( void )
|
||||
{
|
||||
// Are we at the last object in the list? Return NULL if so.
|
||||
if ( ++m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
// Are we at the last object in the list? Return NULL if so.
|
||||
if ( ++m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
|
||||
// Advance to the next PERF_OBJECT_TYPE structure
|
||||
m_pCurrObjectType = MakePtr(PPERF_OBJECT_TYPE,
|
||||
m_pCurrObjectType,
|
||||
m_pCurrObjectType->TotalByteLength );
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
// Advance to the next PERF_OBJECT_TYPE structure
|
||||
m_pCurrObjectType = MakePtr(PPERF_OBJECT_TYPE,
|
||||
m_pCurrObjectType,
|
||||
m_pCurrObjectType->TotalByteLength );
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
}
|
||||
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetPerfObject( PCTSTR const pszObjListName )
|
||||
{
|
||||
DWORD objListIdx
|
||||
= m_pPerfCounterTitles->GetIndexFromTitleString( pszObjListName );
|
||||
if ( 0 == objListIdx )
|
||||
return 0;
|
||||
DWORD objListIdx
|
||||
= m_pPerfCounterTitles->GetIndexFromTitleString( pszObjListName );
|
||||
if ( 0 == objListIdx )
|
||||
return 0;
|
||||
|
||||
// Point at first PERF_OBJECT_TYPE, and loop through the list, looking
|
||||
// for one that matches.
|
||||
PPERF_OBJECT_TYPE pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
// Point at first PERF_OBJECT_TYPE, and loop through the list, looking
|
||||
// for one that matches.
|
||||
PPERF_OBJECT_TYPE pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
|
||||
for ( unsigned i=0; i < m_pPerfSnapshot->GetNumObjectTypes(); i++ )
|
||||
{
|
||||
// Is this the one that matches?
|
||||
if ( pCurrObjectType->ObjectNameTitleIndex == objListIdx )
|
||||
return new CPerfObject(pCurrObjectType, m_pPerfCounterTitles);
|
||||
for ( unsigned i=0; i < m_pPerfSnapshot->GetNumObjectTypes(); i++ )
|
||||
{
|
||||
// Is this the one that matches?
|
||||
if ( pCurrObjectType->ObjectNameTitleIndex == objListIdx )
|
||||
return new CPerfObject(pCurrObjectType, m_pPerfCounterTitles);
|
||||
|
||||
// Nope... try the next object type
|
||||
pCurrObjectType = MakePtr( PPERF_OBJECT_TYPE,
|
||||
pCurrObjectType,
|
||||
pCurrObjectType->TotalByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
// Nope... try the next object type
|
||||
pCurrObjectType = MakePtr( PPERF_OBJECT_TYPE,
|
||||
pCurrObjectType,
|
||||
pCurrObjectType->TotalByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -19,105 +19,105 @@
|
||||
#include "perfcntr.h"
|
||||
|
||||
CPerfCounter::CPerfCounter( PTSTR const pszName, DWORD type,
|
||||
PBYTE const pData, DWORD cbData )
|
||||
PBYTE const pData, DWORD cbData )
|
||||
{
|
||||
m_pszName = _tcsdup( pszName );
|
||||
m_type = type;
|
||||
m_cbData = cbData;
|
||||
m_pData = new BYTE[m_cbData];
|
||||
memcpy( m_pData, pData, m_cbData );
|
||||
m_pszName = _tcsdup( pszName );
|
||||
m_type = type;
|
||||
m_cbData = cbData;
|
||||
m_pData = new BYTE[m_cbData];
|
||||
memcpy( m_pData, pData, m_cbData );
|
||||
}
|
||||
|
||||
CPerfCounter::~CPerfCounter( void )
|
||||
{
|
||||
free( m_pszName );
|
||||
delete []m_pData;
|
||||
free( m_pszName );
|
||||
delete []m_pData;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfCounter::GetData( PBYTE pBuffer, DWORD cbBuffer, DWORD *pType )
|
||||
{
|
||||
if ( cbBuffer < m_cbData ) // Make sure the buffer is big enough
|
||||
return FALSE;
|
||||
|
||||
memcpy( pBuffer, m_pData, m_cbData ); // copy the data
|
||||
if ( cbBuffer < m_cbData ) // Make sure the buffer is big enough
|
||||
return FALSE;
|
||||
|
||||
if ( pType ) // If the user wants the type, give it to them
|
||||
*pType = m_type;
|
||||
|
||||
return TRUE;
|
||||
memcpy( pBuffer, m_pData, m_cbData ); // copy the data
|
||||
|
||||
if ( pType ) // If the user wants the type, give it to them
|
||||
*pType = m_type;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
CPerfCounter::Format( PTSTR pszBuffer, DWORD nSize, BOOL fHex )
|
||||
{
|
||||
// Do better formatting!!! Check length!!!
|
||||
// Do better formatting!!! Check length!!!
|
||||
|
||||
PTSTR pszPrefix = TEXT("");
|
||||
TCHAR szTemp[512];
|
||||
|
||||
// First, ascertain the basic type (number, counter, text, or zero)
|
||||
switch ( m_type & 0x00000C00 )
|
||||
{
|
||||
case PERF_TYPE_ZERO:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("ZERO") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_TEXT:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("text counter") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_COUNTER:
|
||||
{
|
||||
switch( m_type & 0x00070000 )
|
||||
{
|
||||
case PERF_COUNTER_RATE:
|
||||
pszPrefix = TEXT("counter rate "); break;
|
||||
case PERF_COUNTER_FRACTION:
|
||||
pszPrefix = TEXT("counter fraction "); break;
|
||||
case PERF_COUNTER_BASE:
|
||||
pszPrefix = TEXT("counter base "); break;
|
||||
case PERF_COUNTER_ELAPSED:
|
||||
pszPrefix = TEXT("counter elapsed "); break;
|
||||
case PERF_COUNTER_QUEUELEN:
|
||||
pszPrefix = TEXT("counter queuelen "); break;
|
||||
case PERF_COUNTER_HISTOGRAM:
|
||||
pszPrefix = TEXT("counter histogram "); break;
|
||||
default:
|
||||
pszPrefix = TEXT("counter value "); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PTSTR pszFmt = fHex ? TEXT("%s%Xh") : TEXT("%s%u");
|
||||
|
||||
switch ( m_cbData )
|
||||
{
|
||||
case 1: wsprintf(szTemp, pszFmt, pszPrefix, *(PBYTE)m_pData);
|
||||
break;
|
||||
case 2: wsprintf(szTemp, pszFmt, pszPrefix, *(PWORD)m_pData);
|
||||
break;
|
||||
case 4: wsprintf(szTemp, pszFmt, pszPrefix, *(PDWORD)m_pData);
|
||||
break;
|
||||
case 8: // Danger! Assumes little-endian (X86) byte ordering
|
||||
wsprintf( szTemp, TEXT("%s%X%X"), pszPrefix,
|
||||
*(PDWORD)(m_pData+4), *(PDWORD)m_pData ); break;
|
||||
PTSTR pszPrefix = TEXT("");
|
||||
TCHAR szTemp[512];
|
||||
|
||||
// First, ascertain the basic type (number, counter, text, or zero)
|
||||
switch ( m_type & 0x00000C00 )
|
||||
{
|
||||
case PERF_TYPE_ZERO:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("ZERO") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_TEXT:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("text counter") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_COUNTER:
|
||||
{
|
||||
switch( m_type & 0x00070000 )
|
||||
{
|
||||
case PERF_COUNTER_RATE:
|
||||
pszPrefix = TEXT("counter rate "); break;
|
||||
case PERF_COUNTER_FRACTION:
|
||||
pszPrefix = TEXT("counter fraction "); break;
|
||||
case PERF_COUNTER_BASE:
|
||||
pszPrefix = TEXT("counter base "); break;
|
||||
case PERF_COUNTER_ELAPSED:
|
||||
pszPrefix = TEXT("counter elapsed "); break;
|
||||
case PERF_COUNTER_QUEUELEN:
|
||||
pszPrefix = TEXT("counter queuelen "); break;
|
||||
case PERF_COUNTER_HISTOGRAM:
|
||||
pszPrefix = TEXT("counter histogram "); break;
|
||||
default:
|
||||
pszPrefix = TEXT("counter value "); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PTSTR pszFmt = fHex ? TEXT("%s%Xh") : TEXT("%s%u");
|
||||
|
||||
switch ( m_cbData )
|
||||
{
|
||||
case 1: wsprintf(szTemp, pszFmt, pszPrefix, *(PBYTE)m_pData);
|
||||
break;
|
||||
case 2: wsprintf(szTemp, pszFmt, pszPrefix, *(PWORD)m_pData);
|
||||
break;
|
||||
case 4: wsprintf(szTemp, pszFmt, pszPrefix, *(PDWORD)m_pData);
|
||||
break;
|
||||
case 8: // Danger! Assumes little-endian (X86) byte ordering
|
||||
wsprintf( szTemp, TEXT("%s%X%X"), pszPrefix,
|
||||
*(PDWORD)(m_pData+4), *(PDWORD)m_pData ); break;
|
||||
break;
|
||||
|
||||
default: wsprintf( szTemp, TEXT("<unhandled size %u>"), m_cbData );
|
||||
}
|
||||
|
||||
switch ( m_type & 0x70000000 )
|
||||
{
|
||||
case PERF_DISPLAY_SECONDS:
|
||||
_tcscat( szTemp, TEXT(" secs") ); break;
|
||||
case PERF_DISPLAY_PERCENT:
|
||||
_tcscat( szTemp, TEXT(" %") ); break;
|
||||
case PERF_DISPLAY_PER_SEC:
|
||||
_tcscat( szTemp, TEXT(" /sec") ); break;
|
||||
}
|
||||
default: wsprintf( szTemp, TEXT("<unhandled size %u>"), m_cbData );
|
||||
}
|
||||
|
||||
lstrcpyn( pszBuffer, szTemp, nSize );
|
||||
|
||||
return TRUE;
|
||||
switch ( m_type & 0x70000000 )
|
||||
{
|
||||
case PERF_DISPLAY_SECONDS:
|
||||
_tcscat( szTemp, TEXT(" secs") ); break;
|
||||
case PERF_DISPLAY_PERCENT:
|
||||
_tcscat( szTemp, TEXT(" %") ); break;
|
||||
case PERF_DISPLAY_PER_SEC:
|
||||
_tcscat( szTemp, TEXT(" /sec") ); break;
|
||||
}
|
||||
|
||||
lstrcpyn( pszBuffer, szTemp, nSize );
|
||||
|
||||
return TRUE;
|
||||
}
|
@ -42,7 +42,7 @@ static std::map<UINT, PerfMeasure*> g_Measures;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -105,21 +105,21 @@ double Update2(UINT id)
|
||||
double value = 0;
|
||||
|
||||
std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id);
|
||||
if(i != g_Measures.end())
|
||||
if (i != g_Measures.end())
|
||||
{
|
||||
PerfMeasure* measure = (*i).second;
|
||||
|
||||
if(measure)
|
||||
if (measure)
|
||||
{
|
||||
ULONGLONG longvalue;
|
||||
longvalue = GetPerfData(measure->ObjectName.c_str(),
|
||||
measure->InstanceName.c_str(),
|
||||
longvalue = GetPerfData(measure->ObjectName.c_str(),
|
||||
measure->InstanceName.c_str(),
|
||||
measure->CounterName.c_str());
|
||||
|
||||
if(measure->Difference)
|
||||
if (measure->Difference)
|
||||
{
|
||||
// Compare with the old value
|
||||
if(!measure->FirstTime)
|
||||
if (!measure->FirstTime)
|
||||
{
|
||||
value = (double)(longvalue - measure->OldValue);
|
||||
}
|
||||
@ -145,7 +145,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
// delete the measure
|
||||
std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id);
|
||||
if(i != g_Measures.end())
|
||||
if (i != g_Measures.end())
|
||||
{
|
||||
delete (*i).second;
|
||||
g_Measures.erase(i);
|
||||
@ -166,7 +166,7 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
|
||||
WCHAR name[256];
|
||||
ULONGLONG value = 0;
|
||||
|
||||
if(ObjectName == NULL || CounterName == NULL || wcslen(ObjectName) == 0 || wcslen(CounterName) == 0)
|
||||
if (ObjectName == NULL || CounterName == NULL || wcslen(ObjectName) == 0 || wcslen(CounterName) == 0)
|
||||
{
|
||||
// Unable to continue
|
||||
return 0;
|
||||
@ -175,21 +175,21 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
|
||||
CPerfSnapshot snapshot(&g_CounterTitles);
|
||||
CPerfObjectList objList(&snapshot, &g_CounterTitles);
|
||||
|
||||
if(snapshot.TakeSnapshot(ObjectName))
|
||||
if (snapshot.TakeSnapshot(ObjectName))
|
||||
{
|
||||
pPerfObj = objList.GetPerfObject(ObjectName);
|
||||
|
||||
if(pPerfObj)
|
||||
if (pPerfObj)
|
||||
{
|
||||
for(pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
for (pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
pObjInst != NULL;
|
||||
pObjInst = pPerfObj->GetNextObjectInstance())
|
||||
{
|
||||
if (InstanceName != NULL && wcslen(InstanceName) > 0)
|
||||
{
|
||||
if(pObjInst->GetObjectInstanceName(name, 256))
|
||||
if (pObjInst->GetObjectInstanceName(name, 256))
|
||||
{
|
||||
if(_wcsicmp(InstanceName, name) != 0)
|
||||
if (_wcsicmp(InstanceName, name) != 0)
|
||||
{
|
||||
delete pObjInst;
|
||||
continue;
|
||||
@ -203,23 +203,23 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
|
||||
}
|
||||
|
||||
pPerfCntr = pObjInst->GetCounterByName(CounterName);
|
||||
if(pPerfCntr != NULL)
|
||||
if (pPerfCntr != NULL)
|
||||
{
|
||||
pPerfCntr->GetData(data, 256, NULL);
|
||||
|
||||
if(pPerfCntr->GetSize() == 1)
|
||||
|
||||
if (pPerfCntr->GetSize() == 1)
|
||||
{
|
||||
value = *(BYTE*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 2)
|
||||
}
|
||||
else if (pPerfCntr->GetSize() == 2)
|
||||
{
|
||||
value = *(WORD*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 4)
|
||||
else if (pPerfCntr->GetSize() == 4)
|
||||
{
|
||||
value = *(DWORD*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 8)
|
||||
else if (pPerfCntr->GetSize() == 8)
|
||||
{
|
||||
value = *(ULONGLONG*)data;
|
||||
}
|
||||
|
@ -19,78 +19,78 @@
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObject::CPerfObject( PPERF_OBJECT_TYPE const pObjectList,
|
||||
CPerfTitleDatabase * const pPerfCounterTitles)
|
||||
CPerfTitleDatabase * const pPerfCounterTitles)
|
||||
{
|
||||
m_pObjectList = pObjectList;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
m_pObjectList = pObjectList;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
}
|
||||
|
||||
CPerfObjectInstance *
|
||||
CPerfObject::GetFirstObjectInstance( void )
|
||||
{
|
||||
m_currentObjectInstance = 0;
|
||||
if ( m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
m_currentObjectInstance = 0;
|
||||
if ( m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
|
||||
// Point at the first PERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition =
|
||||
MakePtr( PPERF_INSTANCE_DEFINITION, m_pObjectList,
|
||||
m_pObjectList->DefinitionLength );
|
||||
// Point at the first PERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition =
|
||||
MakePtr( PPERF_INSTANCE_DEFINITION, m_pObjectList,
|
||||
m_pObjectList->DefinitionLength );
|
||||
|
||||
return new CPerfObjectInstance(
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList, m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
m_pObjectList->NumInstances ==
|
||||
PERF_NO_INSTANCES ? TRUE : FALSE );
|
||||
return new CPerfObjectInstance(
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList, m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
m_pObjectList->NumInstances ==
|
||||
PERF_NO_INSTANCES ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
CPerfObjectInstance *
|
||||
CPerfObject::GetNextObjectInstance( void )
|
||||
{
|
||||
if ( m_pObjectList->NumInstances == PERF_NO_INSTANCES )
|
||||
return 0;
|
||||
if ( m_pObjectList->NumInstances == PERF_NO_INSTANCES )
|
||||
return 0;
|
||||
|
||||
if ( ++m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
if ( ++m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
|
||||
// Advance to the next PERF_INSTANCE_DEFINITION in the list. However,
|
||||
// following the current PERF_INSTANCE_DEFINITION is the counter data,
|
||||
// which is also of variable length. So, we gotta take that into
|
||||
// account when finding the next PERF_INSTANCE_DEFINITION
|
||||
|
||||
// First, get a pointer to the counter data size field
|
||||
PDWORD pCounterDataSize
|
||||
= MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength);
|
||||
// Advance to the next PERF_INSTANCE_DEFINITION in the list. However,
|
||||
// following the current PERF_INSTANCE_DEFINITION is the counter data,
|
||||
// which is also of variable length. So, we gotta take that into
|
||||
// account when finding the next PERF_INSTANCE_DEFINITION
|
||||
|
||||
// Now we can point at the next PPERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION,
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength
|
||||
+ *pCounterDataSize);
|
||||
|
||||
// Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION
|
||||
return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList,
|
||||
m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
FALSE );
|
||||
// First, get a pointer to the counter data size field
|
||||
PDWORD pCounterDataSize
|
||||
= MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength);
|
||||
|
||||
// Now we can point at the next PPERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION,
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength
|
||||
+ *pCounterDataSize);
|
||||
|
||||
// Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION
|
||||
return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList,
|
||||
m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
FALSE );
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfObject::GetObjectTypeName( PTSTR pszObjTypeName, DWORD nSize )
|
||||
{
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
m_pObjectList->ObjectNameTitleIndex );
|
||||
|
||||
if ( !pszName )
|
||||
return FALSE;
|
||||
|
||||
lstrcpyn( pszObjTypeName, pszName, nSize );
|
||||
return TRUE;
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
m_pObjectList->ObjectNameTitleIndex );
|
||||
|
||||
if ( !pszName )
|
||||
return FALSE;
|
||||
|
||||
lstrcpyn( pszObjTypeName, pszName, nSize );
|
||||
return TRUE;
|
||||
}
|
@ -21,145 +21,145 @@ PBYTE CPerfSnapshot::c_pBuffer = NULL;
|
||||
DWORD CPerfSnapshot::c_cbBufferSize = 0;
|
||||
|
||||
CPerfSnapshot::CPerfSnapshot(
|
||||
CPerfTitleDatabase * pCounterTitles )
|
||||
CPerfTitleDatabase * pCounterTitles )
|
||||
{
|
||||
m_pPerfDataHeader = 0;
|
||||
m_pCounterTitles = pCounterTitles;
|
||||
m_pPerfDataHeader = 0;
|
||||
m_pCounterTitles = pCounterTitles;
|
||||
}
|
||||
|
||||
CPerfSnapshot::~CPerfSnapshot( void )
|
||||
{
|
||||
DisposeSnapshot();
|
||||
DisposeSnapshot();
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::TakeSnapshot( PCTSTR pszSnapshotItems )
|
||||
{
|
||||
DisposeSnapshot(); // Clear out any current snapshot
|
||||
DisposeSnapshot(); // Clear out any current snapshot
|
||||
|
||||
// Convert the input string (e.g., "Process") into the form required
|
||||
// by the HKEY_PERFORMANCE_DATA key (e.g., "232")
|
||||
// Convert the input string (e.g., "Process") into the form required
|
||||
// by the HKEY_PERFORMANCE_DATA key (e.g., "232")
|
||||
|
||||
TCHAR szConvertedItemNames[ 256 ];
|
||||
if ( !ConvertSnapshotItemName( pszSnapshotItems, szConvertedItemNames,
|
||||
sizeof(szConvertedItemNames) ) )
|
||||
return FALSE;
|
||||
TCHAR szConvertedItemNames[ 256 ];
|
||||
if ( !ConvertSnapshotItemName( pszSnapshotItems, szConvertedItemNames,
|
||||
sizeof(szConvertedItemNames) ) )
|
||||
return FALSE;
|
||||
|
||||
DWORD cbAllocSize = 0;
|
||||
LONG retValue;
|
||||
|
||||
while ( 1 ) // Loop until we get the data, or we fail unexpectedly
|
||||
{
|
||||
retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
szConvertedItemNames, 0, 0,
|
||||
c_pBuffer, &c_cbBufferSize );
|
||||
DWORD cbAllocSize = 0;
|
||||
LONG retValue;
|
||||
|
||||
if ( retValue == ERROR_SUCCESS ) // We apparently got the snapshot
|
||||
{
|
||||
while ( 1 ) // Loop until we get the data, or we fail unexpectedly
|
||||
{
|
||||
retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
szConvertedItemNames, 0, 0,
|
||||
c_pBuffer, &c_cbBufferSize );
|
||||
|
||||
if ( retValue == ERROR_SUCCESS ) // We apparently got the snapshot
|
||||
{
|
||||
m_pPerfDataHeader = (PPERF_DATA_BLOCK)c_pBuffer;
|
||||
|
||||
// Verify that the signature is a unicode "PERF"
|
||||
if ( memcmp( m_pPerfDataHeader->Signature, L"PERF", 8 ) )
|
||||
break;
|
||||
// Verify that the signature is a unicode "PERF"
|
||||
if ( memcmp( m_pPerfDataHeader->Signature, L"PERF", 8 ) )
|
||||
break;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if ( retValue != ERROR_MORE_DATA ) // Anything other failure
|
||||
break; // code means something
|
||||
// bad happened, so bail out.
|
||||
return TRUE;
|
||||
}
|
||||
else if ( retValue != ERROR_MORE_DATA ) // Anything other failure
|
||||
break; // code means something
|
||||
// bad happened, so bail out.
|
||||
|
||||
// If we get here, our buffer wasn't big enough. Delete it and
|
||||
// try again with a bigger buffer.
|
||||
delete [] c_pBuffer;
|
||||
|
||||
// The new buffer size will be 4096 bytes bigger than the larger
|
||||
// of: 1) The previous allocation size, or 2) The size that the
|
||||
// RegQueryValueEx call said was necessary.
|
||||
if ( c_cbBufferSize > cbAllocSize )
|
||||
cbAllocSize = c_cbBufferSize + 4096;
|
||||
else
|
||||
cbAllocSize += 4096;
|
||||
// If we get here, our buffer wasn't big enough. Delete it and
|
||||
// try again with a bigger buffer.
|
||||
delete [] c_pBuffer;
|
||||
|
||||
// Allocate a new, larger buffer in preparation to try again.
|
||||
c_pBuffer = new BYTE[ cbAllocSize ];
|
||||
if ( !c_pBuffer )
|
||||
break;
|
||||
// The new buffer size will be 4096 bytes bigger than the larger
|
||||
// of: 1) The previous allocation size, or 2) The size that the
|
||||
// RegQueryValueEx call said was necessary.
|
||||
if ( c_cbBufferSize > cbAllocSize )
|
||||
cbAllocSize = c_cbBufferSize + 4096;
|
||||
else
|
||||
cbAllocSize += 4096;
|
||||
|
||||
c_cbBufferSize = cbAllocSize;
|
||||
}
|
||||
// Allocate a new, larger buffer in preparation to try again.
|
||||
c_pBuffer = new BYTE[ cbAllocSize ];
|
||||
if ( !c_pBuffer )
|
||||
break;
|
||||
|
||||
// If we get here, the RegQueryValueEx failed unexpectedly.
|
||||
return FALSE;
|
||||
c_cbBufferSize = cbAllocSize;
|
||||
}
|
||||
|
||||
// If we get here, the RegQueryValueEx failed unexpectedly.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
CPerfSnapshot::DisposeSnapshot( void )
|
||||
{
|
||||
m_pPerfDataHeader = 0;
|
||||
m_pPerfDataHeader = 0;
|
||||
}
|
||||
|
||||
void
|
||||
CPerfSnapshot::CleanUp( void )
|
||||
{
|
||||
delete [] c_pBuffer;
|
||||
c_pBuffer = 0;
|
||||
delete [] c_pBuffer;
|
||||
c_pBuffer = 0;
|
||||
c_cbBufferSize = 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
CPerfSnapshot::GetNumObjectTypes( void )
|
||||
{
|
||||
return m_pPerfDataHeader ? m_pPerfDataHeader->NumObjectTypes: 0;
|
||||
return m_pPerfDataHeader ? m_pPerfDataHeader->NumObjectTypes: 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::GetSystemName( PTSTR pszSystemName, DWORD nSize )
|
||||
{
|
||||
if ( !m_pPerfDataHeader ) // If no snapshot data, bail out.
|
||||
return FALSE;
|
||||
if ( !m_pPerfDataHeader ) // If no snapshot data, bail out.
|
||||
return FALSE;
|
||||
|
||||
// Make sure the input buffer size is big enough
|
||||
if ( nSize < m_pPerfDataHeader->SystemNameLength )
|
||||
return FALSE;
|
||||
// Make sure the input buffer size is big enough
|
||||
if ( nSize < m_pPerfDataHeader->SystemNameLength )
|
||||
return FALSE;
|
||||
|
||||
// Make a unicode string point to the system name string
|
||||
// that's stored in the PERF_DATA_BLOCK
|
||||
LPWSTR lpwszName = MakePtr( LPWSTR, m_pPerfDataHeader,
|
||||
m_pPerfDataHeader->SystemNameOffset );
|
||||
// Make a unicode string point to the system name string
|
||||
// that's stored in the PERF_DATA_BLOCK
|
||||
LPWSTR lpwszName = MakePtr( LPWSTR, m_pPerfDataHeader,
|
||||
m_pPerfDataHeader->SystemNameOffset );
|
||||
|
||||
#ifdef UNICODE // Copy the PERF_DATA_BLOCK string to the input buffer
|
||||
lstrcpy( pszSystemName, lpwszName );
|
||||
#else
|
||||
wcstombs( pszSystemName, lpwszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
#ifdef UNICODE // Copy the PERF_DATA_BLOCK string to the input buffer
|
||||
lstrcpy( pszSystemName, lpwszName );
|
||||
#else
|
||||
wcstombs( pszSystemName, lpwszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PVOID
|
||||
CPerfSnapshot::GetPostHeaderPointer( void )
|
||||
{
|
||||
// Returns a header to the first byte following the PERF_DATA_BLOCK
|
||||
// (including the variable length system name string at the end)
|
||||
return m_pPerfDataHeader ?
|
||||
MakePtr(PVOID, m_pPerfDataHeader,m_pPerfDataHeader->HeaderLength)
|
||||
: 0;
|
||||
// Returns a header to the first byte following the PERF_DATA_BLOCK
|
||||
// (including the variable length system name string at the end)
|
||||
return m_pPerfDataHeader ?
|
||||
MakePtr(PVOID, m_pPerfDataHeader,m_pPerfDataHeader->HeaderLength)
|
||||
: 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::ConvertSnapshotItemName( PCTSTR pszIn,
|
||||
PTSTR pszOut, DWORD nSize )
|
||||
PTSTR pszOut, DWORD nSize )
|
||||
{
|
||||
if ( IsBadStringPtr( pszIn, 0xFFFFFFFF ) )
|
||||
return FALSE;
|
||||
if ( IsBadStringPtr( pszIn, 0xFFFFFFFF ) )
|
||||
return FALSE;
|
||||
|
||||
|
||||
DWORD objectID = m_pCounterTitles->GetIndexFromTitleString(pszIn);
|
||||
|
||||
if ( objectID )
|
||||
pszOut += wsprintf( pszOut, TEXT("%u "), objectID );
|
||||
else
|
||||
pszOut += wsprintf( pszOut, TEXT("%s "), pszIn );
|
||||
if ( objectID )
|
||||
pszOut += wsprintf( pszOut, TEXT("%u "), objectID );
|
||||
else
|
||||
pszOut += wsprintf( pszOut, TEXT("%s "), pszIn );
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
@ -16,143 +16,143 @@
|
||||
#include "Titledb.h"
|
||||
|
||||
CPerfTitleDatabase::CPerfTitleDatabase(
|
||||
PERFORMANCE_TITLE_TYPE titleType )
|
||||
PERFORMANCE_TITLE_TYPE titleType )
|
||||
{
|
||||
m_nLastIndex = 0;
|
||||
m_TitleStrings = 0;
|
||||
m_pszRawStrings = 0;
|
||||
m_nLastIndex = 0;
|
||||
m_TitleStrings = 0;
|
||||
m_pszRawStrings = 0;
|
||||
|
||||
// Determine the appropriate strings to pass to RegOpenKeyEx
|
||||
PTSTR psz009RegValue, pszLastIndexRegValue;
|
||||
if ( PERF_TITLE_COUNTER == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Counter 009");
|
||||
pszLastIndexRegValue = TEXT("Last Counter");
|
||||
}
|
||||
else if ( PERF_TITLE_EXPLAIN == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Explain 009");
|
||||
pszLastIndexRegValue = TEXT("Last Help");
|
||||
}
|
||||
else
|
||||
return;
|
||||
// Determine the appropriate strings to pass to RegOpenKeyEx
|
||||
PTSTR psz009RegValue, pszLastIndexRegValue;
|
||||
if ( PERF_TITLE_COUNTER == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Counter 009");
|
||||
pszLastIndexRegValue = TEXT("Last Counter");
|
||||
}
|
||||
else if ( PERF_TITLE_EXPLAIN == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Explain 009");
|
||||
pszLastIndexRegValue = TEXT("Last Help");
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
// Find out the max number of entries
|
||||
HKEY hKeyPerflib = 0;
|
||||
DWORD cbLastIndex;
|
||||
|
||||
// Open the registry key that has the values for the maximum number
|
||||
// of title strings
|
||||
if ( ERROR_SUCCESS != RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"),
|
||||
0, KEY_READ, &hKeyPerflib ) )
|
||||
return;
|
||||
// Find out the max number of entries
|
||||
HKEY hKeyPerflib = 0;
|
||||
DWORD cbLastIndex;
|
||||
|
||||
// Read in the number of title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx(
|
||||
hKeyPerflib, pszLastIndexRegValue, 0, 0,
|
||||
(PBYTE)&m_nLastIndex, &cbLastIndex ) )
|
||||
{
|
||||
RegCloseKey( hKeyPerflib );
|
||||
return;
|
||||
}
|
||||
|
||||
RegCloseKey( hKeyPerflib );
|
||||
|
||||
//
|
||||
// Now go find and process the raw string data
|
||||
//
|
||||
// Open the registry key that has the values for the maximum number
|
||||
// of title strings
|
||||
if ( ERROR_SUCCESS != RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"),
|
||||
0, KEY_READ, &hKeyPerflib ) )
|
||||
return;
|
||||
|
||||
// Determine how big the raw data in the REG_MULTI_SZ value is
|
||||
DWORD cbTitleStrings;
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings))
|
||||
return;
|
||||
// Read in the number of title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx(
|
||||
hKeyPerflib, pszLastIndexRegValue, 0, 0,
|
||||
(PBYTE)&m_nLastIndex, &cbLastIndex ) )
|
||||
{
|
||||
RegCloseKey( hKeyPerflib );
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate memory for the raw registry title string data
|
||||
m_pszRawStrings = new TCHAR[cbTitleStrings];
|
||||
|
||||
// Read in the raw title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings,
|
||||
&cbTitleStrings ) )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
RegCloseKey( hKeyPerflib );
|
||||
|
||||
// allocate memory for an array of string pointers.
|
||||
m_TitleStrings = new PTSTR[ m_nLastIndex+1 ];
|
||||
if ( !m_TitleStrings )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Now go find and process the raw string data
|
||||
//
|
||||
|
||||
// Initialize the m_TitleStrings to all NULLs, since there may
|
||||
// be some array slots that aren't used.
|
||||
memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) );
|
||||
// Determine how big the raw data in the REG_MULTI_SZ value is
|
||||
DWORD cbTitleStrings;
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings))
|
||||
return;
|
||||
|
||||
// The raw data entries are an ASCII string index (e.g., "242"), followed
|
||||
// by the corresponding string. Fill in the appropriate slot in the
|
||||
// m_TitleStrings array with the pointer to the string name. The end
|
||||
// of the list is indicated by a double NULL.
|
||||
// Allocate memory for the raw registry title string data
|
||||
m_pszRawStrings = new TCHAR[cbTitleStrings];
|
||||
|
||||
PTSTR pszWorkStr = (PTSTR)m_pszRawStrings;
|
||||
unsigned cbCurrStr;
|
||||
// Read in the raw title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings,
|
||||
&cbTitleStrings ) )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
|
||||
// While the length of the current string isn't 0...
|
||||
while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) )
|
||||
{
|
||||
// Convert the first string to a binary representation
|
||||
unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi()
|
||||
// allocate memory for an array of string pointers.
|
||||
m_TitleStrings = new PTSTR[ m_nLastIndex+1 ];
|
||||
if ( !m_TitleStrings )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( index > m_nLastIndex )
|
||||
break;
|
||||
|
||||
// Now point to the string following it. This is the title string
|
||||
pszWorkStr += cbCurrStr + 1;
|
||||
// Initialize the m_TitleStrings to all NULLs, since there may
|
||||
// be some array slots that aren't used.
|
||||
memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) );
|
||||
|
||||
// Fill in the appropriate slot in the title strings array.
|
||||
m_TitleStrings[index] = pszWorkStr;
|
||||
|
||||
// Advance to the next index/title pair
|
||||
pszWorkStr += lstrlen(pszWorkStr) + 1;
|
||||
}
|
||||
// The raw data entries are an ASCII string index (e.g., "242"), followed
|
||||
// by the corresponding string. Fill in the appropriate slot in the
|
||||
// m_TitleStrings array with the pointer to the string name. The end
|
||||
// of the list is indicated by a double NULL.
|
||||
|
||||
PTSTR pszWorkStr = (PTSTR)m_pszRawStrings;
|
||||
unsigned cbCurrStr;
|
||||
|
||||
// While the length of the current string isn't 0...
|
||||
while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) )
|
||||
{
|
||||
// Convert the first string to a binary representation
|
||||
unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi()
|
||||
|
||||
if ( index > m_nLastIndex )
|
||||
break;
|
||||
|
||||
// Now point to the string following it. This is the title string
|
||||
pszWorkStr += cbCurrStr + 1;
|
||||
|
||||
// Fill in the appropriate slot in the title strings array.
|
||||
m_TitleStrings[index] = pszWorkStr;
|
||||
|
||||
// Advance to the next index/title pair
|
||||
pszWorkStr += lstrlen(pszWorkStr) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
CPerfTitleDatabase::~CPerfTitleDatabase( )
|
||||
{
|
||||
delete []m_TitleStrings;
|
||||
m_TitleStrings = 0;
|
||||
delete []m_pszRawStrings;
|
||||
m_pszRawStrings = 0;
|
||||
m_nLastIndex = 0;
|
||||
delete []m_TitleStrings;
|
||||
m_TitleStrings = 0;
|
||||
delete []m_pszRawStrings;
|
||||
m_pszRawStrings = 0;
|
||||
m_nLastIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
PTSTR
|
||||
CPerfTitleDatabase::GetTitleStringFromIndex( unsigned index )
|
||||
{
|
||||
if ( index > m_nLastIndex ) // Is index within range?
|
||||
return 0;
|
||||
|
||||
return m_TitleStrings[ index ];
|
||||
if ( index > m_nLastIndex ) // Is index within range?
|
||||
return 0;
|
||||
|
||||
return m_TitleStrings[ index ];
|
||||
}
|
||||
|
||||
unsigned
|
||||
CPerfTitleDatabase::GetIndexFromTitleString( PCTSTR pszTitleString )
|
||||
{
|
||||
if ( IsBadStringPtr(pszTitleString, 0xFFFFFFFF) )
|
||||
return 0;
|
||||
if ( IsBadStringPtr(pszTitleString, 0xFFFFFFFF) )
|
||||
return 0;
|
||||
|
||||
// Loop through all the non-null string array entries, doing a case-
|
||||
// insensitive comparison. If found, return the correpsonding index
|
||||
for ( unsigned i = 1; i <= m_nLastIndex; i++ )
|
||||
{
|
||||
if ( m_TitleStrings[i] )
|
||||
if ( 0 == _tcsicmp( pszTitleString, m_TitleStrings[i] ) )
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
// Loop through all the non-null string array entries, doing a case-
|
||||
// insensitive comparison. If found, return the correpsonding index
|
||||
for ( unsigned i = 1; i <= m_nLastIndex; i++ )
|
||||
{
|
||||
if ( m_TitleStrings[i] )
|
||||
if ( 0 == _tcsicmp( pszTitleString, m_TitleStrings[i] ) )
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ typedef struct tagIPINFO
|
||||
typedef IPINFO* PIPINFO;
|
||||
|
||||
static std::map<UINT, pingData*> g_Values;
|
||||
static CRITICAL_SECTION g_CriticalSection;
|
||||
static CRITICAL_SECTION g_CriticalSection;
|
||||
static bool g_Initialized = false;
|
||||
static HINSTANCE g_ICMPInstance = NULL;
|
||||
|
||||
@ -99,7 +99,7 @@ std::string ConvertToAscii(LPCTSTR str)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -127,7 +127,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
g_IcmpSendEcho = (IcmpSendEcho)GetProcAddress(g_ICMPInstance,"IcmpSendEcho");
|
||||
g_IcmpSendEcho2 = (IcmpSendEcho2)GetProcAddress(g_ICMPInstance,"IcmpSendEcho2");
|
||||
}
|
||||
|
||||
|
||||
g_Initialized = true;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
if (pData->destAddr == INADDR_NONE)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(0x0101, &wsaData) == 0)
|
||||
if (WSAStartup(0x0101, &wsaData) == 0)
|
||||
{
|
||||
LPHOSTENT pHost;
|
||||
|
||||
@ -184,7 +184,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
pData->timeoutValue = wcstod(data, NULL);
|
||||
}
|
||||
|
||||
|
||||
if (valid)
|
||||
{
|
||||
g_Values[id] = pData;
|
||||
@ -210,10 +210,10 @@ DWORD WINAPI NetworkThreadProc(LPVOID pParam)
|
||||
DWORD res = g_IcmpSendEcho(
|
||||
hIcmpFile,
|
||||
pData->destAddr,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
reply,
|
||||
reply,
|
||||
replySize,
|
||||
pData->timeout);
|
||||
|
||||
@ -236,7 +236,7 @@ DWORD WINAPI NetworkThreadProc(LPVOID pParam)
|
||||
pData->threadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
return 0; // thread completed successfully
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
/*
|
||||
@ -299,7 +299,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
}
|
||||
|
||||
// Last instance deletes the critical section
|
||||
if (g_Values.empty())
|
||||
if (g_Values.empty())
|
||||
{
|
||||
if (g_ICMPInstance)
|
||||
{
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
|
||||
|
||||
typedef struct _PROCESSOR_POWER_INFORMATION
|
||||
typedef struct _PROCESSOR_POWER_INFORMATION
|
||||
{
|
||||
ULONG Number;
|
||||
ULONG MaxMhz;
|
||||
@ -69,7 +69,7 @@ FPCALLNTPOWERINFORMATION fpCallNtPowerInformation = NULL;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -99,20 +99,20 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"PowerState", L"");
|
||||
if(type)
|
||||
if (type)
|
||||
{
|
||||
if (_wcsicmp(L"ACLINE", type) == 0)
|
||||
{
|
||||
powerState = POWER_ACLINE;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"STATUS", type) == 0)
|
||||
{
|
||||
powerState = POWER_STATUS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"STATUS2", type) == 0)
|
||||
{
|
||||
powerState = POWER_STATUS2;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"LIFETIME", type) == 0)
|
||||
{
|
||||
powerState= POWER_LIFETIME;
|
||||
@ -122,7 +122,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
g_Formats[id] = format;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"MHZ", type) == 0)
|
||||
{
|
||||
powerState= POWER_MHZ;
|
||||
@ -237,7 +237,7 @@ double Update2(UINT id)
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR buffer[256];
|
||||
|
||||
|
@ -94,7 +94,7 @@ std::wstring ConvertToWide(LPCSTR str)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -129,7 +129,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
|
||||
size_t start = 0;
|
||||
size_t pos = ext.find(L';');
|
||||
while (pos != std::wstring::npos)
|
||||
while (pos != std::wstring::npos)
|
||||
{
|
||||
qData.fileFilters.push_back(ext.substr(start, pos - start));
|
||||
start = pos + 1;
|
||||
@ -157,9 +157,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
}
|
||||
|
||||
if (PathIsDirectory(qData.pathname.c_str()))
|
||||
if (PathIsDirectory(qData.pathname.c_str()))
|
||||
{
|
||||
if (qData.pathname[qData.pathname.size() - 1] != L'\\')
|
||||
if (qData.pathname[qData.pathname.size() - 1] != L'\\')
|
||||
{
|
||||
qData.pathname += L"\\";
|
||||
}
|
||||
@ -168,7 +168,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
ScanFolder(qData, bSubfolders, qData.pathname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!qData.pathname.empty())
|
||||
{
|
||||
g_Values[id] = qData;
|
||||
@ -192,11 +192,11 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
|
||||
hSearch = FindFirstFile(searchPath.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
if (bSubfolders)
|
||||
if (bSubfolders)
|
||||
{
|
||||
if (wcscmp(fileData.cFileName, L".") != 0 && wcscmp(fileData.cFileName, L"..") != 0)
|
||||
{
|
||||
@ -206,11 +206,11 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!qData.fileFilters.empty())
|
||||
if (!qData.fileFilters.empty())
|
||||
{
|
||||
for (int i = 0; i < qData.fileFilters.size(); i++)
|
||||
for (int i = 0; i < qData.fileFilters.size(); i++)
|
||||
{
|
||||
if (!qData.fileFilters[i].empty() && PathMatchSpec(fileData.cFileName, qData.fileFilters[i].c_str()))
|
||||
if (!qData.fileFilters[i].empty() && PathMatchSpec(fileData.cFileName, qData.fileFilters[i].c_str()))
|
||||
{
|
||||
qData.files.push_back(path + fileData.cFileName);
|
||||
break;
|
||||
@ -223,7 +223,7 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
|
||||
}
|
||||
}
|
||||
}
|
||||
while(FindNextFile(hSearch, &fileData));
|
||||
while (FindNextFile(hSearch, &fileData));
|
||||
}
|
||||
|
||||
#define BUFFER_SIZE 4096
|
||||
@ -262,7 +262,7 @@ double Update2(UINT id)
|
||||
|
||||
qData.value.erase();
|
||||
|
||||
if (0xFEFF == *(WCHAR*)buffer)
|
||||
if (0xFEFF == *(WCHAR*)buffer)
|
||||
{
|
||||
// It's unicode
|
||||
WCHAR* wBuffer = (WCHAR*)buffer;
|
||||
@ -270,7 +270,7 @@ double Update2(UINT id)
|
||||
// Read until we find the first separator
|
||||
WCHAR* sepPos1 = NULL;
|
||||
WCHAR* sepPos2 = NULL;
|
||||
do
|
||||
do
|
||||
{
|
||||
size_t len = fread(buffer, sizeof(BYTE), BUFFER_SIZE, file);
|
||||
buffer[len] = 0;
|
||||
@ -299,7 +299,7 @@ double Update2(UINT id)
|
||||
while (sepPos1 == NULL);
|
||||
|
||||
// Find the second separator
|
||||
do
|
||||
do
|
||||
{
|
||||
sepPos2 = wcsstr(sepPos1, qData.separator.c_str());
|
||||
if (sepPos2 == NULL)
|
||||
@ -343,7 +343,7 @@ double Update2(UINT id)
|
||||
// Read until we find the first separator
|
||||
char* sepPos1 = NULL;
|
||||
char* sepPos2 = NULL;
|
||||
do
|
||||
do
|
||||
{
|
||||
size_t len = fread(buffer, sizeof(char), BUFFER_SIZE, file);
|
||||
aBuffer[len] = 0;
|
||||
@ -370,7 +370,7 @@ double Update2(UINT id)
|
||||
while (sepPos1 == NULL);
|
||||
|
||||
// Find the second separator
|
||||
do
|
||||
do
|
||||
{
|
||||
sepPos2 = strstr(sepPos1, ConvertToAscii(qData.separator.c_str()).c_str());
|
||||
if (sepPos2 == NULL)
|
||||
@ -419,11 +419,11 @@ double Update2(UINT id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, quoteData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
|
@ -70,7 +70,7 @@ id The identifier for the measure. This is used to identify the measures
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
MEASURETYPE dataType = NUMRECYCLE; // 1 for numRecycled, 2 for sizeRecycled
|
||||
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"RecycleType", L"COUNT");
|
||||
if (type)
|
||||
@ -78,11 +78,11 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
if (_wcsicmp(L"COUNT", type) == 0)
|
||||
{
|
||||
dataType = NUMRECYCLE;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"SIZE", type) == 0)
|
||||
{
|
||||
dataType = SIZERECYCLE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"RecycleType=";
|
||||
@ -93,9 +93,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
g_Values[id] = dataType;
|
||||
|
||||
|
||||
LPCTSTR drives = ReadConfigString(section, L"Drives", L"ALL");
|
||||
if (drives && wcslen(drives) > 0)
|
||||
{
|
||||
@ -105,7 +105,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
g_DriveList[id] = L"ALL";
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ void Tokenize(const std::wstring& str, std::vector<std::wstring>& tokens, const
|
||||
std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0);
|
||||
// Find first "non-delimiter".
|
||||
std::wstring::size_type pos = str.find_first_of(delimiters, lastPos);
|
||||
|
||||
|
||||
while (std::wstring::npos != pos || std::wstring::npos != lastPos)
|
||||
{
|
||||
// Found a token, add it to the vector.
|
||||
@ -136,13 +136,13 @@ double Update2(UINT id)
|
||||
{
|
||||
MEASURETYPE dataType = g_Values[id];
|
||||
std::wstring driveSet = g_DriveList[id];
|
||||
|
||||
SHQUERYRBINFO RecycleBinInfo = { 0 };
|
||||
RecycleBinInfo.cbSize = sizeof( RecycleBinInfo ); // Tell size of structure
|
||||
|
||||
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
|
||||
SHQUERYRBINFO RecycleBinInfo = { 0 };
|
||||
RecycleBinInfo.cbSize = sizeof( RecycleBinInfo ); // Tell size of structure
|
||||
|
||||
if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{
|
||||
if(SHQueryRecycleBin( NULL, &RecycleBinInfo ) == S_OK)
|
||||
if (SHQueryRecycleBin( NULL, &RecycleBinInfo ) == S_OK)
|
||||
{
|
||||
if (dataType == SIZERECYCLE)
|
||||
{
|
||||
@ -160,15 +160,15 @@ double Update2(UINT id)
|
||||
}
|
||||
}
|
||||
std::vector<std::wstring> tokens;
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
double retVal = 0;
|
||||
Tokenize(toSplit, tokens, L"|");
|
||||
|
||||
for(int i=0;i < tokens.size(); i++)
|
||||
|
||||
for (int i=0;i < tokens.size(); i++)
|
||||
{
|
||||
double tempVal;
|
||||
std::wstring strd = tokens.at(i);
|
||||
SHQueryRecycleBin( strd.c_str(), &RecycleBinInfo ); // Get recycle bin info
|
||||
SHQueryRecycleBin( strd.c_str(), &RecycleBinInfo ); // Get recycle bin info
|
||||
if (dataType == SIZERECYCLE)
|
||||
{
|
||||
tempVal = (double)RecycleBinInfo.i64Size; // size in bytes
|
||||
@ -179,7 +179,7 @@ double Update2(UINT id)
|
||||
}
|
||||
retVal += tempVal;
|
||||
}
|
||||
|
||||
|
||||
return (retVal);
|
||||
}
|
||||
|
||||
@ -209,14 +209,14 @@ LPCTSTR GetPluginAuthor()
|
||||
|
||||
void ExecuteBang(LPCTSTR args, UINT id)
|
||||
{
|
||||
std::wstring bang = args;
|
||||
std::wstring bang = args;
|
||||
std::wstring driveSet = g_DriveList[id];
|
||||
|
||||
if (_wcsicmp(bang.c_str(), L"EmptyBin") == 0)
|
||||
{ //Empty the Recycle Bin
|
||||
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
if (_wcsicmp(bang.c_str(), L"EmptyBin") == 0)
|
||||
{ //Empty the Recycle Bin
|
||||
if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{
|
||||
if(SHEmptyRecycleBin( NULL, NULL, NULL ) == S_OK)
|
||||
if (SHEmptyRecycleBin( NULL, NULL, NULL ) == S_OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -226,23 +226,23 @@ void ExecuteBang(LPCTSTR args, UINT id)
|
||||
}
|
||||
}
|
||||
std::vector<std::wstring> tokens;
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
Tokenize(toSplit, tokens, L"|");
|
||||
|
||||
for(int i=0;i < tokens.size(); i++)
|
||||
|
||||
for (int i=0;i < tokens.size(); i++)
|
||||
{
|
||||
std::wstring strd = tokens.at(i);
|
||||
SHEmptyRecycleBin( NULL, strd.c_str(), NULL ); // empty bin
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_wcsicmp(bang.c_str(), L"EmptyBinSilent") == 0)
|
||||
{ //Empty the Recycle Bin (no prompt)
|
||||
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{ //Empty the Recycle Bin (no prompt)
|
||||
if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{
|
||||
if(SHEmptyRecycleBin( NULL, NULL, SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ) == S_OK)
|
||||
if (SHEmptyRecycleBin( NULL, NULL, SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ) == S_OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -252,24 +252,24 @@ void ExecuteBang(LPCTSTR args, UINT id)
|
||||
}
|
||||
}
|
||||
std::vector<std::wstring> tokens;
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
Tokenize(toSplit, tokens, L"|");
|
||||
|
||||
for(int i=0;i < tokens.size(); i++)
|
||||
for (int i=0;i < tokens.size(); i++)
|
||||
{
|
||||
std::wstring strd = tokens.at(i);
|
||||
SHEmptyRecycleBin( NULL, strd.c_str(), SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ); // empty bin
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (_wcsicmp(bang.c_str(), L"OpenBin") == 0)
|
||||
{ //Open the Recycle Bin folder
|
||||
//system("explorer.exe /N,::{645FF040-5081-101B-9F08-00AA002F954E}");
|
||||
}
|
||||
else if (_wcsicmp(bang.c_str(), L"OpenBin") == 0)
|
||||
{ //Open the Recycle Bin folder
|
||||
//system("explorer.exe /N,::{645FF040-5081-101B-9F08-00AA002F954E}");
|
||||
std::wstring szCmd = L"explorer.exe";
|
||||
std::wstring szParm= L"/N,::{645FF040-5081-101B-9F08-00AA002F954E}";
|
||||
ShellExecute(NULL,L"open",szCmd.c_str(),szParm.c_str(),NULL,SW_SHOW);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ BOOL CALLBACK EnumWindowProc ( HWND hWnd, LPARAM lParam )
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -186,7 +186,7 @@ UINT Update(UINT id)
|
||||
{
|
||||
if (processName)
|
||||
{
|
||||
if(EnumProcessModules(hProcess, hMod, sizeof(hMod), &cbNeeded))
|
||||
if (EnumProcessModules(hProcess, hMod, sizeof(hMod), &cbNeeded))
|
||||
{
|
||||
if (GetModuleBaseName(hProcess, hMod[0], buffer, sizeof(buffer)))
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ __declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
struct SpeedFanData
|
||||
struct SpeedFanData
|
||||
{
|
||||
WORD version;
|
||||
WORD flags;
|
||||
@ -50,7 +50,7 @@ struct SpeedFanData
|
||||
INT volts[32];
|
||||
};
|
||||
|
||||
enum SensorType
|
||||
enum SensorType
|
||||
{
|
||||
TYPE_TEMP,
|
||||
TYPE_FAN,
|
||||
@ -73,7 +73,7 @@ static std::map<UINT, UINT> g_Numbers;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -99,15 +99,15 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
if (_wcsicmp(L"C", scale) == 0)
|
||||
{
|
||||
g_Scales[id] = SCALE_CENTIGRADE;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"F", scale) == 0)
|
||||
{
|
||||
g_Scales[id] = SCALE_FARENHEIT;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"K", scale) == 0)
|
||||
{
|
||||
g_Scales[id] = SCALE_KELVIN;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"SpeedFanScale=";
|
||||
@ -118,15 +118,15 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"FAN", type) == 0)
|
||||
{
|
||||
g_Types[id] = TYPE_FAN;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"VOLTAGE", type) == 0)
|
||||
{
|
||||
g_Types[id] = TYPE_VOLT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"SpeedFanType=";
|
||||
@ -137,7 +137,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LPCTSTR data = ReadConfigString(section, L"SpeedFanNumber", L"0");
|
||||
if (data)
|
||||
{
|
||||
@ -153,13 +153,13 @@ The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
double value = 0.0;
|
||||
|
||||
double value = 0.0;
|
||||
|
||||
std::map<UINT, SensorType>::const_iterator type = g_Types.find(id);
|
||||
std::map<UINT, TempScale>::const_iterator scale = g_Scales.find(id);
|
||||
std::map<UINT, UINT>::const_iterator number = g_Numbers.find(id);
|
||||
|
||||
if(type == g_Types.end() || number == g_Numbers.end())
|
||||
|
||||
if (type == g_Types.end() || number == g_Numbers.end())
|
||||
{
|
||||
return 0.0; // No id in the map. How this can be ????
|
||||
}
|
||||
@ -179,7 +179,7 @@ double Update2(UINT id)
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@ -216,10 +216,10 @@ bool ReadSharedData(SensorType type, TempScale scale, UINT number, double* value
|
||||
{
|
||||
SpeedFanData* ptr;
|
||||
HANDLE hData;
|
||||
|
||||
|
||||
hData = OpenFileMapping(FILE_MAP_READ, FALSE, L"SFSharedMemory_ALM");
|
||||
if (hData == NULL) return false;
|
||||
|
||||
|
||||
ptr = (SpeedFanData*)MapViewOfFile(hData, FILE_MAP_READ, 0, 0, 0);
|
||||
if (ptr == 0)
|
||||
{
|
||||
@ -229,7 +229,7 @@ bool ReadSharedData(SensorType type, TempScale scale, UINT number, double* value
|
||||
|
||||
if (ptr->version == 1)
|
||||
{
|
||||
switch(type)
|
||||
switch(type)
|
||||
{
|
||||
case TYPE_TEMP:
|
||||
if (number < ptr->NumTemps)
|
||||
@ -272,7 +272,7 @@ bool ReadSharedData(SensorType type, TempScale scale, UINT number, double* value
|
||||
|
||||
UnmapViewOfFile(ptr);
|
||||
CloseHandle(hData);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ __declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
int count; //Number of monitors
|
||||
HMONITOR m_Monitors[32]; //Monitor info
|
||||
@ -87,7 +87,7 @@ static std::map<UINT, UINT> g_Datas;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -101,109 +101,109 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"SysInfoType", L"");
|
||||
if(type)
|
||||
if (type)
|
||||
{
|
||||
if (_wcsicmp(L"COMPUTER_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = COMPUTER_NAME;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"USER_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = USER_NAME;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"WORK_AREA", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"SCREEN_SIZE", type) == 0)
|
||||
{
|
||||
g_Types[id] = SCREEN_SIZE;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"RAS_STATUS", type) == 0)
|
||||
{
|
||||
g_Types[id] = RAS_STATUS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"OS_VERSION", type) == 0)
|
||||
{
|
||||
g_Types[id] = OS_VERSION;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"OS_BITS", type) == 0)
|
||||
{
|
||||
g_Types[id] = OS_BITS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0)
|
||||
{
|
||||
g_Types[id] = ADAPTER_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"NET_MASK", type) == 0)
|
||||
{
|
||||
g_Types[id] = NET_MASK;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"IP_ADDRESS", type) == 0)
|
||||
{
|
||||
g_Types[id] = IP_ADDRESS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"GATEWAY_ADDRESS", type) == 0)
|
||||
{
|
||||
g_Types[id] = GATEWAY_ADDRESS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"HOST_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = HOST_NAME;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"DOMAIN_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = DOMAIN_NAME;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"DNS_SERVER", type) == 0)
|
||||
{
|
||||
g_Types[id] = DNS_SERVER;
|
||||
}
|
||||
}
|
||||
|
||||
else if (_wcsicmp(L"WORK_AREA_TOP", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA_TOP;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"WORK_AREA_LEFT", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA_LEFT;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"WORK_AREA_WIDTH", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA_WIDTH;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"WORK_AREA_HEIGHT", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA_HEIGHT;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"SCREEN_WIDTH", type) == 0)
|
||||
{
|
||||
g_Types[id] = SCREEN_WIDTH;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"SCREEN_HEIGHT", type) == 0)
|
||||
{
|
||||
g_Types[id] = SCREEN_HEIGHT;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"NUM_MONITORS", type) == 0)
|
||||
{
|
||||
g_Types[id] = NUM_MONITORS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"VIRTUAL_SCREEN_TOP", type) == 0)
|
||||
{
|
||||
g_Types[id] = VIRTUAL_SCREEN_TOP;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"VIRTUAL_SCREEN_LEFT", type) == 0)
|
||||
{
|
||||
g_Types[id] = VIRTUAL_SCREEN_LEFT;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"VIRTUAL_SCREEN_WIDTH", type) == 0)
|
||||
{
|
||||
g_Types[id] = VIRTUAL_SCREEN_WIDTH;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"VIRTUAL_SCREEN_HEIGHT", type) == 0)
|
||||
{
|
||||
g_Types[id] = VIRTUAL_SCREEN_HEIGHT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"SysInfoType=";
|
||||
@ -248,7 +248,7 @@ std::wstring ConvertToWide(LPCSTR str)
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR buffer[4096];
|
||||
UINT data;
|
||||
@ -256,8 +256,8 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id);
|
||||
std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id);
|
||||
|
||||
if(typeIter == g_Types.end()) return NULL;
|
||||
if(dataIter == g_Datas.end())
|
||||
if (typeIter == g_Types.end()) return NULL;
|
||||
if (dataIter == g_Datas.end())
|
||||
{
|
||||
data = 0;
|
||||
}
|
||||
@ -321,11 +321,11 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
if (data >= 1000)
|
||||
{
|
||||
data = data-999;
|
||||
for(UINT i=0; i<ipTable->dwNumEntries; i++)
|
||||
for (UINT i=0; i<ipTable->dwNumEntries; i++)
|
||||
{
|
||||
if((ipTable->table[i].wType)&MIB_IPADDR_DISCONNECTED) continue;
|
||||
if ((ipTable->table[i].wType)&MIB_IPADDR_DISCONNECTED) continue;
|
||||
data--;
|
||||
if(data==0)
|
||||
if (data==0)
|
||||
{
|
||||
DWORD ip = ipTable->table[i].dwAddr;
|
||||
wsprintf(buffer, L"%i.%i.%i.%i", ip%256, (ip>>8)%256, (ip>>16)%256, (ip>>24)%256);
|
||||
@ -423,8 +423,8 @@ double Update2(UINT id)
|
||||
std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id);
|
||||
std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id);
|
||||
|
||||
if(typeIter == g_Types.end()) return NULL;
|
||||
if(dataIter == g_Datas.end())
|
||||
if (typeIter == g_Types.end()) return NULL;
|
||||
if (dataIter == g_Datas.end())
|
||||
{
|
||||
data = 0;
|
||||
}
|
||||
@ -433,16 +433,16 @@ double Update2(UINT id)
|
||||
data = (*dataIter).second;
|
||||
}
|
||||
|
||||
if(data) //For speed purposes, only check if they specify a non-primary monitor.
|
||||
if (data) //For speed purposes, only check if they specify a non-primary monitor.
|
||||
{
|
||||
if(GetSystemMetrics(SM_CMONITORS)>32)
|
||||
if (GetSystemMetrics(SM_CMONITORS)>32)
|
||||
{
|
||||
std::wstring error = L"That's alot of monitors! 32 is the max.";
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONERROR);
|
||||
exit(-1);
|
||||
}
|
||||
m_Monitors.count = 0;
|
||||
EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc, (LPARAM)(&m_Monitors));
|
||||
EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc, (LPARAM)(&m_Monitors));
|
||||
}
|
||||
|
||||
|
||||
@ -633,17 +633,17 @@ BOOL CheckConnection()
|
||||
static HRASCONN g_hRasConn=NULL;
|
||||
RASCONNSTATUS rasStatus;
|
||||
LPRASCONN lpRasConn=NULL;
|
||||
DWORD cbBuf=0;
|
||||
DWORD cConn=1;
|
||||
DWORD dwRet=0;
|
||||
DWORD cbBuf=0;
|
||||
DWORD cConn=1;
|
||||
DWORD dwRet=0;
|
||||
|
||||
if(g_hRasConn==NULL) {
|
||||
// Enumerate connections
|
||||
if (g_hRasConn==NULL) {
|
||||
// Enumerate connections
|
||||
cbBuf=sizeof(RASCONN);
|
||||
if(((lpRasConn=(LPRASCONN)malloc((UINT)cbBuf))!= NULL)) {
|
||||
if (((lpRasConn=(LPRASCONN)malloc((UINT)cbBuf))!= NULL)) {
|
||||
lpRasConn->dwSize=sizeof(RASCONN);
|
||||
if(0==RasEnumConnections(lpRasConn, &cbBuf, &cConn)) {
|
||||
if(cConn!=0) {
|
||||
if (0==RasEnumConnections(lpRasConn, &cbBuf, &cConn)) {
|
||||
if (cConn!=0) {
|
||||
g_hRasConn=lpRasConn->hrasconn;
|
||||
}
|
||||
}
|
||||
@ -651,19 +651,19 @@ BOOL CheckConnection()
|
||||
}
|
||||
}
|
||||
|
||||
if(g_hRasConn!=NULL) {
|
||||
if (g_hRasConn!=NULL) {
|
||||
// get connection status
|
||||
rasStatus.dwSize=sizeof(RASCONNSTATUS);
|
||||
dwRet=RasGetConnectStatus(g_hRasConn, &rasStatus );
|
||||
if(dwRet==0) {
|
||||
if (dwRet==0) {
|
||||
// Check for connection
|
||||
if(rasStatus.rasconnstate==RASCS_Connected) return TRUE;
|
||||
if (rasStatus.rasconnstate==RASCS_Connected) return TRUE;
|
||||
} else {
|
||||
g_hRasConn=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
|
@ -45,28 +45,28 @@ DexpotMeasure* DexpotMeasure::CreateMeasure(HMODULE instance, UINT id, LPCTSTR i
|
||||
{
|
||||
std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));
|
||||
|
||||
if(TypeString == _T("VDMActive")) return new DexpotVDMActiveMeasure(instance, id);
|
||||
else if(TypeString == _T("DesktopCount")) return new DexpotDesktopCountMeasure(instance, id);
|
||||
else if(TypeString == _T("CurrentDesktop")) return new DexpotCurrentDesktopMeasure(instance, id);
|
||||
else if(TypeString == _T("SwitchDesktop")) return new DexpotSwitchDesktopMeasure(instance, id);
|
||||
else if(TypeString == _T("Screenshot")) return new DexpotScreenshotMeasure(instance, id);
|
||||
else if(TypeString == _T("DesktopName")) return new DexpotDesktopNameMeasure(instance, id);
|
||||
else if(TypeString == _T("DesktopWallpaper")) return new DexpotDesktopWallpaperMeasure(instance, id);
|
||||
else if(TypeString == _T("Command")) return new DexpotCommandMeasure(instance, id);
|
||||
if (TypeString == _T("VDMActive")) return new DexpotVDMActiveMeasure(instance, id);
|
||||
else if (TypeString == _T("DesktopCount")) return new DexpotDesktopCountMeasure(instance, id);
|
||||
else if (TypeString == _T("CurrentDesktop")) return new DexpotCurrentDesktopMeasure(instance, id);
|
||||
else if (TypeString == _T("SwitchDesktop")) return new DexpotSwitchDesktopMeasure(instance, id);
|
||||
else if (TypeString == _T("Screenshot")) return new DexpotScreenshotMeasure(instance, id);
|
||||
else if (TypeString == _T("DesktopName")) return new DexpotDesktopNameMeasure(instance, id);
|
||||
else if (TypeString == _T("DesktopWallpaper")) return new DexpotDesktopWallpaperMeasure(instance, id);
|
||||
else if (TypeString == _T("Command")) return new DexpotCommandMeasure(instance, id);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UINT DexpotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
{
|
||||
if(InstanceCount == 0)
|
||||
if (InstanceCount == 0)
|
||||
{
|
||||
hWndRainmeterControl = FindWindow(_T("DummyRainWClass"), _T("Rainmeter control window"));
|
||||
hWndMessageWindow = CreateMessageWindow();
|
||||
}
|
||||
InstanceCount++;
|
||||
|
||||
if(!PluginRegistered && FindDexpotWindow())
|
||||
if (!PluginRegistered && FindDexpotWindow())
|
||||
{
|
||||
SendNotifyMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
|
||||
CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0);
|
||||
@ -82,9 +82,9 @@ UINT DexpotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
void DexpotMeasure::Finalize()
|
||||
{
|
||||
InstanceCount--;
|
||||
if(InstanceCount == 0)
|
||||
if (InstanceCount == 0)
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
SendNotifyMessage(hWndDexpot, DEX_UNREGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
|
||||
PluginRegistered = FALSE;
|
||||
@ -113,7 +113,7 @@ void DexpotMeasure::OnDexpotStarted()
|
||||
|
||||
BOOL DexpotMeasure::FindDexpotWindow()
|
||||
{
|
||||
if(IsWindow(hWndDexpot)) return TRUE;
|
||||
if (IsWindow(hWndDexpot)) return TRUE;
|
||||
hWndDexpot = FindWindow(DEXPOTCLASS, DEXPOTTITLE);
|
||||
return hWndDexpot != NULL;
|
||||
}
|
||||
@ -153,14 +153,14 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
{
|
||||
case DEX_SWITCHED:
|
||||
CurrentDesktop = HIWORD(lParam);
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnSwitched(LOWORD(lParam), HIWORD(lParam), LOWORD(wParam), HIWORD(wParam));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case DEX_DESKTOPCOUNTCHANGED:
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnDesktopCountChanged((int)wParam);
|
||||
}
|
||||
@ -168,21 +168,21 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
|
||||
case DEX_SHUTDOWN:
|
||||
PluginRegistered = FALSE;
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnShutdown();
|
||||
}
|
||||
return 0;
|
||||
|
||||
case DEX_DESKTOPCONFIGURATIONCHANGED:
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnDesktopConfigurationChanged();
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_COPYDATA:
|
||||
if((HWND) wParam == hWndDexpot)
|
||||
if ((HWND) wParam == hWndDexpot)
|
||||
{
|
||||
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam;
|
||||
switch(LOWORD(cds->dwData))
|
||||
@ -198,17 +198,17 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
return 0;
|
||||
|
||||
default:
|
||||
if(message == WM_DEXPOTSTARTED)
|
||||
if (message == WM_DEXPOTSTARTED)
|
||||
{
|
||||
hWndDexpot = (HWND) wParam;
|
||||
if(!hWndDexpot) FindDexpotWindow();
|
||||
if(hWndDexpot)
|
||||
if (!hWndDexpot) FindDexpotWindow();
|
||||
if (hWndDexpot)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
|
||||
CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0);
|
||||
PluginRegistered = TRUE;
|
||||
}
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnDexpotStarted();
|
||||
}
|
||||
@ -222,7 +222,7 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
|
||||
/*
|
||||
* DexpotDesktopCountMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotDesktopCountMeasure::DexpotDesktopCountMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
@ -230,11 +230,11 @@ UINT DexpotDesktopCountMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
{
|
||||
DesktopCount = 0;
|
||||
OnChange = ReadConfigString(section, _T("VDOnChange"), _T(""));
|
||||
|
||||
|
||||
CountType = Total;
|
||||
LPCTSTR TypeString = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
|
||||
if(_tcsicmp(TypeString, _T("X")) == 0) CountType = Columns;
|
||||
else if(_tcsicmp(TypeString, _T("Y")) == 0) CountType = Rows;
|
||||
if (_tcsicmp(TypeString, _T("X")) == 0) CountType = Columns;
|
||||
else if (_tcsicmp(TypeString, _T("Y")) == 0) CountType = Rows;
|
||||
|
||||
DexpotMeasure::Initialize(iniFile, section);
|
||||
return 20;
|
||||
@ -242,25 +242,25 @@ UINT DexpotDesktopCountMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
void DexpotDesktopCountMeasure::InitializeData()
|
||||
{
|
||||
if(PluginRegistered) DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
if (PluginRegistered) DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
}
|
||||
|
||||
UINT DexpotDesktopCountMeasure::Update()
|
||||
{
|
||||
if(CountType == Rows) return 1;
|
||||
if (CountType == Rows) return 1;
|
||||
else return DesktopCount;
|
||||
}
|
||||
|
||||
void DexpotDesktopCountMeasure::OnDesktopCountChanged(int NewCount)
|
||||
{
|
||||
DesktopCount = NewCount;
|
||||
if(OnChange.length()) SendBang(OnChange);
|
||||
if (OnChange.length()) SendBang(OnChange);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DexpotCurrentDesktopMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotCurrentDesktopMeasure::DexpotCurrentDesktopMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
@ -279,13 +279,13 @@ UINT DexpotCurrentDesktopMeasure::Update()
|
||||
|
||||
void DexpotCurrentDesktopMeasure::OnSwitched(int FromDesktop, int ToDesktop, WORD Flags, WORD Trigger)
|
||||
{
|
||||
if(OnChange.length()) SendBang(OnChange);
|
||||
if (OnChange.length()) SendBang(OnChange);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DexpotVDMActiveMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotVDMActiveMeasure::DexpotVDMActiveMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {};
|
||||
|
||||
@ -305,30 +305,30 @@ UINT DexpotVDMActiveMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
void DexpotVDMActiveMeasure::OnShutdown()
|
||||
{
|
||||
if(OnDeactivate.length()) SendBang(OnDeactivate);
|
||||
if (OnDeactivate.length()) SendBang(OnDeactivate);
|
||||
}
|
||||
|
||||
void DexpotVDMActiveMeasure::OnDexpotStarted()
|
||||
{
|
||||
if(OnActivate.length()) SendBang(OnActivate);
|
||||
if (OnActivate.length()) SendBang(OnActivate);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DexpotSwitchDesktopMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotSwitchDesktopMeasure::DexpotSwitchDesktopMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
void DexpotSwitchDesktopMeasure::ExecuteBang(LPCTSTR args)
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
DWORD Desktop;
|
||||
|
||||
if(_tcsicmp(args, _T("next")) == 0) Desktop = MAKELPARAM(0, 1);
|
||||
else if(_tcsicmp(args, _T("prev")) == 0) Desktop = MAKELPARAM(0, 2);
|
||||
else if(_tcsicmp(args, _T("back")) == 0) Desktop = MAKELPARAM(0, 3);
|
||||
if (_tcsicmp(args, _T("next")) == 0) Desktop = MAKELPARAM(0, 1);
|
||||
else if (_tcsicmp(args, _T("prev")) == 0) Desktop = MAKELPARAM(0, 2);
|
||||
else if (_tcsicmp(args, _T("back")) == 0) Desktop = MAKELPARAM(0, 3);
|
||||
else Desktop = _ttoi(args);
|
||||
|
||||
SendNotifyMessage(hWndDexpot, DEX_SWITCHDESKTOP, 0, Desktop);
|
||||
@ -338,7 +338,7 @@ void DexpotSwitchDesktopMeasure::ExecuteBang(LPCTSTR args)
|
||||
|
||||
/*
|
||||
* DexpotScreenshotMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotScreenshotMeasure::DexpotScreenshotMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
@ -356,7 +356,7 @@ UINT DexpotScreenshotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
UINT DexpotScreenshotMeasure::Update()
|
||||
{
|
||||
if(RefreshOnUpdate && (DesktopNumber == 0 || DesktopNumber == CurrentDesktop))
|
||||
if (RefreshOnUpdate && (DesktopNumber == 0 || DesktopNumber == CurrentDesktop))
|
||||
{
|
||||
UpdateScreenshot();
|
||||
}
|
||||
@ -375,7 +375,7 @@ void DexpotScreenshotMeasure::InitializeData()
|
||||
|
||||
void DexpotScreenshotMeasure::OnSwitched(int FromDesktop, int ToDesktop, WORD Flags, WORD Trigger)
|
||||
{
|
||||
if(DesktopNumber == FromDesktop || DesktopNumber == 0)
|
||||
if (DesktopNumber == FromDesktop || DesktopNumber == 0)
|
||||
{
|
||||
UpdateScreenshot();
|
||||
}
|
||||
@ -385,11 +385,11 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
{
|
||||
int Desktop = DesktopNumber == 0 ? CurrentDesktop : DesktopNumber;
|
||||
int nBytes = 0;
|
||||
BYTE *pBytes = NULL;
|
||||
BYTE *pBytes = NULL;
|
||||
HANDLE fm;
|
||||
HANDLE mutex;
|
||||
|
||||
if(!IsWindow(hWndDexpot)) return;
|
||||
if (!IsWindow(hWndDexpot)) return;
|
||||
|
||||
int DesktopWidth = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPWIDTH, Desktop, 0);
|
||||
int DesktopHeight = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPHEIGHT, Desktop, 0);
|
||||
@ -398,9 +398,9 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
WaitForSingleObject(mutex, 2000);
|
||||
fm = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, DesktopWidth * DesktopHeight * 4, L"Local\\DexpotScreenshotFilemap");
|
||||
pBytes = (BYTE*) MapViewOfFile(fm, FILE_MAP_ALL_ACCESS, 0, 0, 0);
|
||||
if(pBytes) nBytes = (int) SendMessage(hWndDexpot, DEX_GETSCREENSHOT, Desktop, 0);
|
||||
if (pBytes) nBytes = (int) SendMessage(hWndDexpot, DEX_GETSCREENSHOT, Desktop, 0);
|
||||
|
||||
if(nBytes > 0 && nBytes == DesktopWidth * DesktopHeight * 4)
|
||||
if (nBytes > 0 && nBytes == DesktopWidth * DesktopHeight * 4)
|
||||
{
|
||||
HDC ScreenDC;
|
||||
HDC MemDC;
|
||||
@ -415,10 +415,10 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
int ScaledHeight = Height;
|
||||
int ScaledWidth = Width;
|
||||
|
||||
if(ScaledHeight == 0) ScaledHeight = (int) ((float) DesktopHeight * (ScaledWidth / (float) DesktopWidth) + .5f);
|
||||
if(ScaledWidth == 0) ScaledWidth = (int) ((float) DesktopWidth * (ScaledHeight / (float) DesktopHeight) + .5f);
|
||||
if(ScaledHeight == 0) ScaledHeight = DesktopHeight;
|
||||
if(ScaledWidth == 0) ScaledWidth = DesktopWidth;
|
||||
if (ScaledHeight == 0) ScaledHeight = (int) ((float) DesktopHeight * (ScaledWidth / (float) DesktopWidth) + .5f);
|
||||
if (ScaledWidth == 0) ScaledWidth = (int) ((float) DesktopWidth * (ScaledHeight / (float) DesktopHeight) + .5f);
|
||||
if (ScaledHeight == 0) ScaledHeight = DesktopHeight;
|
||||
if (ScaledWidth == 0) ScaledWidth = DesktopWidth;
|
||||
|
||||
ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
@ -433,7 +433,7 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
MemDC = CreateCompatibleDC(ScreenDC);
|
||||
MemDC2 = CreateCompatibleDC(ScreenDC);
|
||||
OriginalBitmap = CreateCompatibleBitmap(ScreenDC, DesktopWidth, DesktopHeight);
|
||||
SetDIBits(MemDC2, OriginalBitmap, 0, DesktopHeight, pBytes, &bmi, 0);
|
||||
SetDIBits(MemDC2, OriginalBitmap, 0, DesktopHeight, pBytes, &bmi, 0);
|
||||
OldBitmap2 = SelectObject(MemDC2, (HGDIOBJ) OriginalBitmap);
|
||||
|
||||
nBytes = ScaledWidth * ScaledHeight * 4;
|
||||
@ -453,7 +453,7 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
bmfh.bfType = 0x4d42;
|
||||
|
||||
std::ofstream ofs(OutputFile.c_str(), std::ios_base::binary);
|
||||
if(ofs)
|
||||
if (ofs)
|
||||
{
|
||||
ofs.write((char*) &bmfh, sizeof(BITMAPFILEHEADER));
|
||||
ofs.write((char*) &bmi, sizeof(BITMAPINFOHEADER));
|
||||
@ -479,7 +479,7 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
|
||||
/*
|
||||
* DexpotDesktopNameMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotDesktopNameMeasure::DexpotDesktopNameMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
@ -492,7 +492,7 @@ UINT DexpotDesktopNameMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
LPCTSTR DexpotDesktopNameMeasure::GetString(UINT flags)
|
||||
{
|
||||
UINT Desktop = (DesktopNumber == 0 ? CurrentDesktop : DesktopNumber) - 1;
|
||||
if(Desktop >= 0 && Desktop < DesktopNames.size())
|
||||
if (Desktop >= 0 && Desktop < DesktopNames.size())
|
||||
{
|
||||
return DesktopNames[Desktop].c_str();
|
||||
}
|
||||
@ -505,18 +505,18 @@ LPCTSTR DexpotDesktopNameMeasure::GetString(UINT flags)
|
||||
|
||||
void DexpotDesktopNameMeasure::InitializeData()
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
int DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
DesktopNames.resize(DesktopCount);
|
||||
if(DesktopNumber == 0)
|
||||
if (DesktopNumber == 0)
|
||||
{
|
||||
for(int i = 1; i <= DesktopCount; i++)
|
||||
for (int i = 1; i <= DesktopCount; i++)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPTITLE, i, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
}
|
||||
else if(DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
else if (DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPTITLE, DesktopNumber, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
@ -535,14 +535,14 @@ void DexpotDesktopNameMeasure::OnDesktopCountChanged(int NewCount)
|
||||
|
||||
void DexpotDesktopNameMeasure::SetDesktopName(UINT Desktop, std::wstring &Name)
|
||||
{
|
||||
if(--Desktop >= DesktopNames.size()) DesktopNames.resize(Desktop + 1);
|
||||
if(Desktop >= 0) DesktopNames[Desktop] = Name;
|
||||
if (--Desktop >= DesktopNames.size()) DesktopNames.resize(Desktop + 1);
|
||||
if (Desktop >= 0) DesktopNames[Desktop] = Name;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DexpotDesktopWallpaperMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotDesktopWallpaperMeasure::DexpotDesktopWallpaperMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
@ -554,12 +554,12 @@ UINT DexpotDesktopWallpaperMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
LPCTSTR DexpotDesktopWallpaperMeasure::GetString(UINT flags)
|
||||
{
|
||||
if(DesktopNumber == 0)
|
||||
if (DesktopNumber == 0)
|
||||
{
|
||||
SystemParametersInfo(SPI_GETDESKWALLPAPER, STRINGBUFFER_SIZE, StringBuffer, 0);
|
||||
return StringBuffer;
|
||||
}
|
||||
else if(DesktopNumber > 0 && (UINT) DesktopNumber <= DesktopWallpapers.size())
|
||||
else if (DesktopNumber > 0 && (UINT) DesktopNumber <= DesktopWallpapers.size())
|
||||
{
|
||||
return DesktopWallpapers[DesktopNumber - 1].c_str();
|
||||
}
|
||||
@ -570,18 +570,18 @@ LPCTSTR DexpotDesktopWallpaperMeasure::GetString(UINT flags)
|
||||
|
||||
void DexpotDesktopWallpaperMeasure::InitializeData()
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
int DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
DesktopWallpapers.resize(DesktopCount);
|
||||
if(DesktopNumber == 0)
|
||||
if (DesktopNumber == 0)
|
||||
{
|
||||
for(int i = 1; i <= DesktopCount; i++)
|
||||
for (int i = 1; i <= DesktopCount; i++)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPWALLPAPER, i, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
}
|
||||
else if(DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
else if (DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPWALLPAPER, DesktopNumber, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
@ -604,20 +604,20 @@ void DexpotDesktopWallpaperMeasure::OnDesktopCountChanged(int NewCount)
|
||||
|
||||
void DexpotDesktopWallpaperMeasure::SetDesktopWallpaper(UINT Desktop, std::wstring &Wallpaper)
|
||||
{
|
||||
if(--Desktop >= DesktopWallpapers.size()) DesktopWallpapers.resize(Desktop + 1);
|
||||
if(Desktop >= 0) DesktopWallpapers[Desktop] = Wallpaper;
|
||||
if (--Desktop >= DesktopWallpapers.size()) DesktopWallpapers.resize(Desktop + 1);
|
||||
if (Desktop >= 0) DesktopWallpapers[Desktop] = Wallpaper;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DexpotCommandMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotCommandMeasure::DexpotCommandMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
void DexpotCommandMeasure::ExecuteBang(LPCTSTR args)
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
COPYDATASTRUCT cds;
|
||||
|
||||
|
@ -28,7 +28,7 @@ std::map<std::wstring, VirtuaWinMeasure::MeasureType> VirtuaWinMeasure::StringTo
|
||||
|
||||
VirtuaWinMeasure::VirtuaWinMeasure(HMODULE instance, UINT id) : VDMeasure(instance, id)
|
||||
{
|
||||
if(StringToType.size() == 0)
|
||||
if (StringToType.size() == 0)
|
||||
{
|
||||
StringToType.insert(std::make_pair(std::wstring(L"VDMActive"), VDMActive));
|
||||
StringToType.insert(std::make_pair(std::wstring(L"DesktopCount"), DesktopCountTotal));
|
||||
@ -45,7 +45,7 @@ UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
{
|
||||
std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));
|
||||
std::map<std::wstring, MeasureType>::iterator i = StringToType.find(TypeString);
|
||||
if(i != StringToType.end())
|
||||
if (i != StringToType.end())
|
||||
{
|
||||
Type = i->second;
|
||||
}
|
||||
@ -62,9 +62,9 @@ UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
case DesktopCountTotal:
|
||||
{
|
||||
LPCTSTR CountType = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
|
||||
if(_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns;
|
||||
else if(_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows;
|
||||
if(FindVirtuaWinWindow())
|
||||
if (_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns;
|
||||
else if (_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows;
|
||||
if (FindVirtuaWinWindow())
|
||||
{
|
||||
return (UINT) SendMessage(vwHandle, VW_DESKTOP_SIZE, 0, 0);
|
||||
}
|
||||
@ -81,7 +81,7 @@ void VirtuaWinMeasure::Finalize()
|
||||
|
||||
UINT VirtuaWinMeasure::Update()
|
||||
{
|
||||
if(!FindVirtuaWinWindow())
|
||||
if (!FindVirtuaWinWindow())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -130,7 +130,7 @@ void VirtuaWinMeasure::ExecuteBang(LPCTSTR args)
|
||||
{
|
||||
INT32 Desktop;
|
||||
|
||||
if(!FindVirtuaWinWindow()) return;
|
||||
if (!FindVirtuaWinWindow()) return;
|
||||
|
||||
switch(Type)
|
||||
{
|
||||
@ -142,7 +142,7 @@ void VirtuaWinMeasure::ExecuteBang(LPCTSTR args)
|
||||
|
||||
BOOL VirtuaWinMeasure::FindVirtuaWinWindow()
|
||||
{
|
||||
if(IsWindow(vwHandle)) return TRUE;
|
||||
if (IsWindow(vwHandle)) return TRUE;
|
||||
vwHandle = FindWindow(_T("VirtuaWinMainClass"), _T("VirtuaWinMainClass"));
|
||||
return vwHandle != NULL;
|
||||
}
|
||||
|
@ -24,43 +24,43 @@
|
||||
This plugin aims to give Rainmeter skins access to various virtual desktop
|
||||
managers through a common interface. The following VDMs are supported:
|
||||
|
||||
* Dexpot
|
||||
* VirtuaWin
|
||||
* Dexpot
|
||||
* VirtuaWin
|
||||
|
||||
To add support for another virtual desktop manager,
|
||||
|
||||
1) implement a new class derived from VDMeasure
|
||||
2) include its header file below
|
||||
3) add a new case for the "VDManager" config string in the Initialize
|
||||
funtion below
|
||||
1) implement a new class derived from VDMeasure
|
||||
2) include its header file below
|
||||
3) add a new case for the "VDManager" config string in the Initialize
|
||||
funtion below
|
||||
|
||||
Different types of measures are identified using the "VDMeasureType" config
|
||||
string, i.e.
|
||||
|
||||
[VirtualDesktopsMeasure]
|
||||
Measure=Plugin
|
||||
Plugin=VirtualDesktops.dll
|
||||
VDManager=SomeVDM
|
||||
VDMeasureType=...
|
||||
|
||||
[VirtualDesktopsMeasure]
|
||||
Measure=Plugin
|
||||
Plugin=VirtualDesktops.dll
|
||||
VDManager=SomeVDM
|
||||
VDMeasureType=...
|
||||
|
||||
The following basic measure types have to be implemented:
|
||||
|
||||
* VDMActive: returns 1 when the VDM is running, 0 otherwise
|
||||
* VDMActive: returns 1 when the VDM is running, 0 otherwise
|
||||
|
||||
* DesktopCount: returns the number of virtual desktops available; when
|
||||
"VDDesktopCount=X" or "VDDesktopCount=Y" is given, returns
|
||||
the number of columns or rows, respectively, in a grid of
|
||||
desktops
|
||||
* DesktopCount: returns the number of virtual desktops available; when
|
||||
"VDDesktopCount=X" or "VDDesktopCount=Y" is given, returns
|
||||
the number of columns or rows, respectively, in a grid of
|
||||
desktops
|
||||
|
||||
* CurrentDesktop: returns the number of the currently active desktop
|
||||
* CurrentDesktop: returns the number of the currently active desktop
|
||||
|
||||
* SwitchDesktop: when sent a desktop number as a bang, switches to the
|
||||
corresponding desktop
|
||||
* SwitchDesktop: when sent a desktop number as a bang, switches to the
|
||||
corresponding desktop
|
||||
|
||||
You're welcome to add any other measure types that suit the feature set of
|
||||
the virtual desktop manager in question. Examples can be found in the
|
||||
existing implementations.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "DexpotMeasure.h"
|
||||
@ -92,29 +92,29 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
VDMeasure *Measure = NULL;
|
||||
LPCTSTR VDManager = ReadConfigString(section, _T("VDManager"), _T(""));
|
||||
|
||||
if(_tcsicmp(VDManager, _T("Dexpot")) == 0)
|
||||
|
||||
if (_tcsicmp(VDManager, _T("Dexpot")) == 0)
|
||||
{
|
||||
Measure = DexpotMeasure::CreateMeasure(instance, id, iniFile, section);
|
||||
}
|
||||
else if(_tcsicmp(VDManager, _T("VirtuaWin")) == 0)
|
||||
else if (_tcsicmp(VDManager, _T("VirtuaWin")) == 0)
|
||||
{
|
||||
Measure = new VirtuaWinMeasure(instance, id);
|
||||
}
|
||||
|
||||
if(Measure)
|
||||
if (Measure)
|
||||
{
|
||||
Measures.insert(std::make_pair(id, Measure));
|
||||
return Measure->Initialize(iniFile, section);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
return i->second->Update();
|
||||
}
|
||||
@ -125,7 +125,7 @@ UINT Update(UINT id)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
return i->second->GetString(flags);
|
||||
}
|
||||
@ -136,7 +136,7 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
void ExecuteBang(LPCTSTR args, UINT id)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
i->second->ExecuteBang(args);
|
||||
}
|
||||
@ -145,7 +145,7 @@ void ExecuteBang(LPCTSTR args, UINT id)
|
||||
void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
i->second->Finalize();
|
||||
delete i->second;
|
||||
|
@ -76,7 +76,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam);
|
||||
void Log(const WCHAR* string);
|
||||
void ParseData(UrlData* urlData, LPCSTR parseData);
|
||||
|
||||
CRITICAL_SECTION g_CriticalSection;
|
||||
CRITICAL_SECTION g_CriticalSection;
|
||||
bool g_Initialized = false;
|
||||
|
||||
static std::map<UINT, UrlData*> g_UrlData;
|
||||
@ -290,7 +290,7 @@ void FillCharacterEntityReferences()
|
||||
g_CERs[L"lsaquo"] = (WCHAR)8249;
|
||||
g_CERs[L"rsaquo"] = (WCHAR)8250;
|
||||
g_CERs[L"euro"] = (WCHAR)8364;
|
||||
|
||||
|
||||
// for ISO 8859-1 characters
|
||||
g_CERs[L"nbsp"] = (WCHAR)160;
|
||||
g_CERs[L"iexcl"] = (WCHAR)161;
|
||||
@ -388,7 +388,7 @@ void FillCharacterEntityReferences()
|
||||
g_CERs[L"yacute"] = (WCHAR)253;
|
||||
g_CERs[L"thorn"] = (WCHAR)254;
|
||||
g_CERs[L"yuml"] = (WCHAR)255;
|
||||
|
||||
|
||||
// for symbols, mathematical symbols, and Greek letters
|
||||
g_CERs[L"fnof"] = (WCHAR)402;
|
||||
g_CERs[L"Alpha"] = (WCHAR)913;
|
||||
@ -565,7 +565,7 @@ HWND FindMeterWindow(HWND parent = NULL)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -577,7 +577,7 @@ HWND FindMeterWindow(HWND parent = NULL)
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
LPCTSTR tmpSz;
|
||||
LPCTSTR tmpSz;
|
||||
|
||||
if (!g_Initialized)
|
||||
{
|
||||
@ -602,10 +602,10 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
data->proxy = ReadConfigString(section, L"ProxyServer", L"");
|
||||
data->downloadFile = ReadConfigString(section, L"DownloadFile", L"");
|
||||
data->debugFileLocation = ReadConfigString(section, L"Debug2File", L"c:\\WebParserDump.txt");
|
||||
|
||||
if(data->debugFileLocation.find(L"\\") == std::wstring::npos)
|
||||
|
||||
if (data->debugFileLocation.find(L"\\") == std::wstring::npos)
|
||||
{
|
||||
std::wstring str = data->iniFile.substr(0,data->iniFile.find_last_of(L"\\")+1);
|
||||
std::wstring str = data->iniFile.substr(0,data->iniFile.find_last_of(L"\\")+1);
|
||||
str += data->debugFileLocation;
|
||||
Log(str.c_str());
|
||||
data->debugFileLocation = str;
|
||||
@ -706,12 +706,12 @@ double Update2(UINT id)
|
||||
|
||||
// Find the data for this instance (the data structure is not changed by anyone so this should be safe)
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
if(urlIter != g_UrlData.end())
|
||||
if (urlIter != g_UrlData.end())
|
||||
{
|
||||
urlData = (*urlIter).second;
|
||||
}
|
||||
|
||||
if (urlData)
|
||||
if (urlData)
|
||||
{
|
||||
if (urlData->download && urlData->regExp.empty() && urlData->url.find(L'[') == std::wstring::npos)
|
||||
{
|
||||
@ -749,7 +749,7 @@ double Update2(UINT id)
|
||||
{
|
||||
// Make sure that the thread is not writing to the result at the same time
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
|
||||
|
||||
if (!urlData->resultString.empty())
|
||||
{
|
||||
value = wcstod(urlData->resultString.c_str(), NULL);
|
||||
@ -837,7 +837,7 @@ unsigned __stdcall NetworkThreadProc(void* pParam)
|
||||
urlData->threadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
return 0; // thread completed successfully
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
@ -851,12 +851,12 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
int ovector[OVECCOUNT];
|
||||
int rc;
|
||||
int flags = PCRE_UTF8;
|
||||
|
||||
|
||||
if (urlData->codepage == 0)
|
||||
{
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
|
||||
// Compile the regular expression in the first argument
|
||||
re = pcre_compile(
|
||||
ConvertWideToUTF8(urlData->regExp.c_str()).c_str(), // the pattern
|
||||
@ -864,7 +864,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
&error, // for error message
|
||||
&erroffset, // for error offset
|
||||
NULL); // use default character tables
|
||||
|
||||
|
||||
if (re != NULL)
|
||||
{
|
||||
// Compilation succeeded: match the subject in the second argument
|
||||
@ -878,7 +878,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
}
|
||||
|
||||
dwSize = strlen(parseData);
|
||||
|
||||
|
||||
rc = pcre_exec(
|
||||
re, // the compiled pattern
|
||||
NULL, // no extra data - we didn't study the pattern
|
||||
@ -888,8 +888,8 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
0, // default options
|
||||
ovector, // output vector for substring information
|
||||
OVECCOUNT); // number of elements in the output vector
|
||||
|
||||
|
||||
|
||||
|
||||
if (rc >= 0)
|
||||
{
|
||||
if (rc == 0)
|
||||
@ -941,7 +941,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
log += L"] Not enough substrings!";
|
||||
Log(log.c_str());
|
||||
|
||||
// Clear the old result
|
||||
// Clear the old result
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
urlData->resultString.clear();
|
||||
if (urlData->download)
|
||||
@ -975,7 +975,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
|
||||
std::string szResult(substring_start, substring_length);
|
||||
|
||||
if (!((*i).second)->regExp.empty())
|
||||
if (!((*i).second)->regExp.empty())
|
||||
{
|
||||
// Change the index and parse the substring
|
||||
int index = (*i).second->stringIndex;
|
||||
@ -985,9 +985,9 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the result
|
||||
// Set the result
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
|
||||
|
||||
// Substitude the [measure] with szResult
|
||||
std::wstring wzResult = ConvertUTF8ToWide(szResult.c_str());
|
||||
std::wstring wzUrl = ((*i).second)->url;
|
||||
@ -1024,7 +1024,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
log += L"] Not enough substrings!";
|
||||
Log(log.c_str());
|
||||
|
||||
// Clear the old result
|
||||
// Clear the old result
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
((*i).second)->resultString.clear();
|
||||
if ((*i).second->download)
|
||||
@ -1076,7 +1076,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
|
||||
// Release memory used for the compiled pattern
|
||||
// Release memory used for the compiled pattern
|
||||
pcre_free(re);
|
||||
}
|
||||
else
|
||||
@ -1114,7 +1114,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!urlData->finishAction.empty())
|
||||
if (!urlData->finishAction.empty())
|
||||
{
|
||||
HWND wnd = FindMeterWindow();
|
||||
|
||||
@ -1156,7 +1156,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
url = urlData->resultString;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
|
||||
std::wstring::size_type pos = url.find(L':');
|
||||
if (pos == std::wstring::npos && !url.empty()) // No protocol
|
||||
{
|
||||
@ -1420,8 +1420,8 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
||||
urlData->downloadedFile = fullpath;
|
||||
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
if (!urlData->finishAction.empty())
|
||||
|
||||
if (!urlData->finishAction.empty())
|
||||
{
|
||||
HWND wnd = FindMeterWindow();
|
||||
|
||||
@ -1505,20 +1505,20 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
||||
urlData->dlThreadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
return 0; // thread completed successfully
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static std::wstring resultString;
|
||||
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
|
||||
if(urlIter != g_UrlData.end())
|
||||
if (urlIter != g_UrlData.end())
|
||||
{
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
if (((*urlIter).second)->download)
|
||||
@ -1546,7 +1546,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
|
||||
if(urlIter != g_UrlData.end())
|
||||
if (urlIter != g_UrlData.end())
|
||||
{
|
||||
if (((*urlIter).second)->threadHandle)
|
||||
{
|
||||
@ -1555,7 +1555,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
|
||||
TerminateThread(((*urlIter).second)->threadHandle, 0);
|
||||
(*urlIter).second->threadHandle = NULL;
|
||||
|
||||
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
|
||||
@ -1566,7 +1566,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
|
||||
TerminateThread(((*urlIter).second)->dlThreadHandle, 0);
|
||||
(*urlIter).second->dlThreadHandle = NULL;
|
||||
|
||||
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
|
||||
@ -1618,7 +1618,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
||||
std::wstring err = L"WebParser: Fetching URL: ";
|
||||
err += url;
|
||||
Log(err.c_str());
|
||||
|
||||
|
||||
DWORD flags = INTERNET_FLAG_RESYNCHRONIZE;
|
||||
if (forceReload)
|
||||
{
|
||||
@ -1662,14 +1662,14 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Determine the buffer size to hold the new data and the data
|
||||
// already written (if any).
|
||||
nBufferSize = *dwDataSize + dwSize;
|
||||
|
||||
|
||||
// Allocate the output buffer.
|
||||
lpOutPut = new BYTE[nBufferSize + 2];
|
||||
|
||||
|
||||
// Make sure the buffer is not the initial buffer.
|
||||
if (lpHolding != NULL)
|
||||
{
|
||||
@ -1695,7 +1695,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
||||
// End with double null
|
||||
lpOutPut[dwSize] = 0;
|
||||
lpOutPut[dwSize + 1] = 0;
|
||||
|
||||
|
||||
// Increment the number of buffers read.
|
||||
++nCounter;
|
||||
|
||||
@ -1703,7 +1703,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
||||
memset(lpData, 0, CHUNK_SIZE);
|
||||
}
|
||||
} while (TRUE);
|
||||
|
||||
|
||||
// Close the HINTERNET handle.
|
||||
InternetCloseHandle(hUrlDump);
|
||||
|
||||
@ -1734,7 +1734,7 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
|
||||
|
||||
if (errorMsg == NULL)
|
||||
{
|
||||
if (dwErr == ERROR_INTERNET_EXTENDED_ERROR)
|
||||
if (dwErr == ERROR_INTERNET_EXTENDED_ERROR)
|
||||
{
|
||||
WCHAR szBuffer[1024];
|
||||
DWORD dwError, dwLen = 1024;
|
||||
@ -1757,10 +1757,10 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
|
||||
{
|
||||
LPVOID lpMsgBuf = NULL;
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_HMODULE |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_HMODULE |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
GetModuleHandle(L"wininet"),
|
||||
@ -1768,10 +1768,10 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
NULL
|
||||
);
|
||||
|
||||
if (lpMsgBuf == NULL)
|
||||
if (lpMsgBuf == NULL)
|
||||
{
|
||||
err += L"Unknown error";
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ PWLAN_INTERFACE_INFO_LIST pIntfList = NULL;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -90,9 +90,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
DWORD dwErr;
|
||||
g_Instances++;
|
||||
//Create WINLAN API Handle
|
||||
if(hClient == NULL){
|
||||
if (hClient == NULL){
|
||||
dwErr = WlanOpenHandle( WLAN_API_VERSION, NULL, &dwNegotiatedVersion, &hClient );
|
||||
if( ERROR_SUCCESS != dwErr ){
|
||||
if ( ERROR_SUCCESS != dwErr ){
|
||||
WCHAR buffer[256];
|
||||
wsprintf(buffer, L"WifiStatus.dll: Unable to open WLAN API Handle. Error code (%d): %s",(int)dwErr,getDot11str(dwErr,5));
|
||||
Log(buffer);
|
||||
@ -100,9 +100,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
}
|
||||
//Query list of WLAN interfaces
|
||||
if(pIntfList == NULL){
|
||||
if (pIntfList == NULL){
|
||||
dwErr= WlanEnumInterfaces(hClient, NULL, &pIntfList);
|
||||
if(( ERROR_SUCCESS != dwErr) || (&pIntfList->dwNumberOfItems <= 0)){
|
||||
if (( ERROR_SUCCESS != dwErr) || (&pIntfList->dwNumberOfItems <= 0)){
|
||||
WCHAR buffer[256];
|
||||
wsprintf(buffer, L"WifiStatus.dll: Unable to find any WLAN interfaces/adapters. Error code %d",(int) dwErr);
|
||||
Log(buffer);
|
||||
@ -111,22 +111,22 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
//Select a WLAN interface, default 0.
|
||||
LPCTSTR data = ReadConfigString(section, L"WifiIntfID", L"");
|
||||
|
||||
|
||||
if ((data != NULL) && (_wcsicmp(L"", data) != 0)){
|
||||
if(_wtoi(data) < (int)pIntfList->dwNumberOfItems){
|
||||
if (_wtoi(data) < (int)pIntfList->dwNumberOfItems){
|
||||
pInterface = &pIntfList->InterfaceInfo[_wtoi(data)];
|
||||
} else {
|
||||
WCHAR buffer[256];
|
||||
wsprintf(buffer, L"WifiStatus.dll: Adapter is disabled or invalid (WifiIntfID=%s), fix INTF ID(default=0) or enable the adapter.",data);
|
||||
Log(buffer);
|
||||
pInterface = &pIntfList->InterfaceInfo[0];
|
||||
}
|
||||
pInterface = &pIntfList->InterfaceInfo[0];
|
||||
}
|
||||
} else {
|
||||
pInterface = &pIntfList->InterfaceInfo[0];
|
||||
pInterface = &pIntfList->InterfaceInfo[0];
|
||||
}
|
||||
//Select LIST style
|
||||
data = ReadConfigString(section, L"WifiListStyle", L"");
|
||||
|
||||
|
||||
if ((data != NULL) && (_wcsicmp(L"", data) != 0)){
|
||||
if ( (_wtoi(data) >= 0) && (_wtoi(data) <= 3)){
|
||||
g_meas_data[id].listStyle = _wtoi(data);
|
||||
@ -135,7 +135,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
wsprintf(buffer, L"WifiStatus.dll: Invalid List Style given (WifiListStyle=%s), defaulting to 0.",data);
|
||||
Log(buffer);
|
||||
g_meas_data[id].listStyle = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
g_meas_data[id].listStyle = 0;
|
||||
}
|
||||
@ -151,29 +151,29 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
wsprintf(buffer, L"WifiStatus.dll: Invalid List Limit given (WifiListLimit=%s), defaulting to 5.",data);
|
||||
Log(buffer);
|
||||
g_meas_data[id].listMax = 5;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
g_meas_data[id].listMax = 5;
|
||||
}
|
||||
//Select type of measure
|
||||
MEASURETYPE infoType = UNKNOWN;
|
||||
LPCTSTR type = ReadConfigString(section, L"WifiInfoType", L"");
|
||||
if(type){
|
||||
if (type){
|
||||
if (_wcsicmp(L"SSID", type) == 0){
|
||||
infoType=SSID;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"QUALITY", type) == 0){
|
||||
infoType=QUALITY;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"ENCRYPTION", type) == 0){
|
||||
infoType=ENCRYPTION;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"AUTH", type) == 0){
|
||||
infoType=AUTH;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"LIST", type) == 0){
|
||||
infoType=LIST;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"PHY", type) == 0){
|
||||
infoType=PHY;
|
||||
} else {
|
||||
@ -202,11 +202,11 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
*/
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
if(pInterface == NULL) return NULL;
|
||||
if (pInterface == NULL) return NULL;
|
||||
|
||||
//Get measure id, and identify type
|
||||
//std::map<UINT, MEASURETYPE>::iterator typeIter = g_Types.find(id);
|
||||
//if(typeIter == g_Types.end()) return NULL;
|
||||
//if (typeIter == g_Types.end()) return NULL;
|
||||
MEASURETYPE current_type = g_meas_data[id].type;
|
||||
switch(current_type)
|
||||
{
|
||||
@ -217,23 +217,23 @@ UINT Update(UINT id)
|
||||
DWORD dwErr;
|
||||
GUID& intfGUID = pInterface->InterfaceGuid;
|
||||
dwErr = WlanQueryInterface( hClient, &intfGUID, wlan_intf_opcode_current_connection, NULL, &outsize, (PVOID*)&wlan_cattr, NULL );
|
||||
if( ERROR_SUCCESS != dwErr){
|
||||
if ( ERROR_SUCCESS != dwErr){
|
||||
return 0;
|
||||
}
|
||||
int retval = (int)wlan_cattr->wlanAssociationAttributes.wlanSignalQuality;
|
||||
if(wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
if (wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
return retval;
|
||||
|
||||
|
||||
//Transfer rates will go here
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
if(pInterface == NULL) return NULL;
|
||||
|
||||
if (pInterface == NULL) return NULL;
|
||||
|
||||
//Some variables for data manipulation in this function
|
||||
static WCHAR buffer[128];
|
||||
bool bNetList = false; //whether to return buffer or netlist
|
||||
@ -258,14 +258,14 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
UINT listMax = g_meas_data[id].listMax;
|
||||
|
||||
switch(current_type)
|
||||
{
|
||||
{
|
||||
case LIST:
|
||||
if(ERROR_SUCCESS != dwLErr){return L"Error";}
|
||||
|
||||
if (ERROR_SUCCESS != dwLErr){return L"Error";}
|
||||
|
||||
if (!g_meas_data[id].listInit){//Check if netlist has memory allocated already
|
||||
//Size of network name can be up to 64 chars, set to 80 to add room for delimiters
|
||||
g_meas_data[id].netlist = (WCHAR*)malloc( 80 * sizeof(WCHAR) * g_meas_data[id].listMax);
|
||||
if(g_meas_data[id].netlist == NULL){
|
||||
if (g_meas_data[id].netlist == NULL){
|
||||
WCHAR debug[256];
|
||||
wsprintf(debug, L"WifiStatus.dll: Unable to allocate memory for network list.");
|
||||
Log(buffer);
|
||||
@ -275,32 +275,32 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
}
|
||||
g_meas_data[id].listInit = true;
|
||||
}
|
||||
|
||||
|
||||
memset(g_meas_data[id].netlist,'\0', (80 * sizeof(WCHAR) * g_meas_data[id].listMax));
|
||||
memset(buffer,'\0',128);
|
||||
|
||||
|
||||
//Check all items in WLAN NETWORK LIST
|
||||
for(int i=0; i < (int)pwnl->dwNumberOfItems ; i++){
|
||||
if(printed == g_meas_data[id].listMax)
|
||||
for (int i=0; i < (int)pwnl->dwNumberOfItems ; i++){
|
||||
if (printed == g_meas_data[id].listMax)
|
||||
break;
|
||||
|
||||
|
||||
//SSID is in UCHAR, convert to WCHAR
|
||||
mbstowcs(buffer,(char*)pwnl->Network[i].dot11Ssid.ucSSID,pwnl->Network[i].dot11Ssid.uSSIDLength);
|
||||
|
||||
|
||||
//Prevent duplicates that result from profiles, check using SSID
|
||||
if((wcsstr(g_meas_data[id].netlist,buffer)== NULL)&&(_wcsicmp(L"", buffer) != 0)){
|
||||
if ((wcsstr(g_meas_data[id].netlist,buffer)== NULL)&&(_wcsicmp(L"", buffer) != 0)){
|
||||
printed++;
|
||||
if(listStyle > 0){
|
||||
if (listStyle > 0){
|
||||
wsprintf(g_meas_data[id].netlist,L"%s%s",g_meas_data[id].netlist,buffer);
|
||||
memset(buffer,'\0',128);
|
||||
if(listStyle == 1 || listStyle == 3){
|
||||
if (listStyle == 1 || listStyle == 3){
|
||||
//ADD PHY type
|
||||
wsprintf(buffer,L" @%s", getDot11str(pwnl->Network[i].dot11PhyTypes[0],4));
|
||||
wsprintf(buffer,L" @%s", getDot11str(pwnl->Network[i].dot11PhyTypes[0],4));
|
||||
}
|
||||
if(listStyle == 2 || listStyle == 3){
|
||||
if (listStyle == 2 || listStyle == 3){
|
||||
//ADD cipher and authentication
|
||||
wsprintf(buffer,L"%s (%s:%s)",buffer,getDot11str(pwnl->Network[i].dot11DefaultCipherAlgorithm,1)
|
||||
,getDot11str(pwnl->Network[i].dot11DefaultAuthAlgorithm,2));
|
||||
,getDot11str(pwnl->Network[i].dot11DefaultAuthAlgorithm,2));
|
||||
}
|
||||
}
|
||||
wsprintf(g_meas_data[id].netlist,L"%s%s\n",g_meas_data[id].netlist,buffer);
|
||||
@ -310,9 +310,9 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
}//end for
|
||||
bNetList=true;
|
||||
break;
|
||||
|
||||
|
||||
case SSID:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
@ -321,9 +321,9 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
//If not connected yet add current status
|
||||
wcscat(buffer,getDot11str(wlan_cattr->isState,3));
|
||||
break;
|
||||
|
||||
|
||||
case PHY:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
@ -331,7 +331,7 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
break;
|
||||
|
||||
case ENCRYPTION:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
@ -339,27 +339,27 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
break;
|
||||
|
||||
case AUTH:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
wcscpy(buffer,getDot11str(wlan_cattr->wlanSecurityAttributes.dot11AuthAlgorithm,2));
|
||||
wcscpy(buffer,getDot11str(wlan_cattr->wlanSecurityAttributes.dot11AuthAlgorithm,2));
|
||||
break;
|
||||
|
||||
default: //InfoType does not refer to a string measure
|
||||
bInvalidType= true;
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
if(wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
if(pwnl!=NULL)WlanFreeMemory(pwnl);
|
||||
|
||||
if(bNetList)
|
||||
if (wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
if (pwnl!=NULL)WlanFreeMemory(pwnl);
|
||||
|
||||
if (bNetList)
|
||||
return g_meas_data[id].netlist;
|
||||
if(bIntfError)
|
||||
if (bIntfError)
|
||||
return L"-1";
|
||||
else {
|
||||
if(bInvalidType)
|
||||
if (bInvalidType)
|
||||
return NULL;
|
||||
else
|
||||
return buffer;
|
||||
@ -367,13 +367,13 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
}
|
||||
|
||||
/*
|
||||
switches from winlanapi.h + SDK
|
||||
switches from winlanapi.h + SDK
|
||||
in: -DOT11 ENUM (converted to int)
|
||||
-type of ENUM (cipher=1, auth=2, status=3, phy=4, otherwise=error strings)
|
||||
-type of ENUM (cipher=1, auth=2, status=3, phy=4, otherwise=error strings)
|
||||
out: String to be returned by measure
|
||||
*/
|
||||
LPCTSTR getDot11str(int dot11enum,int type){
|
||||
if(type ==1){
|
||||
if (type ==1){
|
||||
switch(dot11enum){
|
||||
case DOT11_CIPHER_ALGO_NONE:
|
||||
return L"NONE";
|
||||
@ -390,7 +390,7 @@ LPCTSTR getDot11str(int dot11enum,int type){
|
||||
case DOT11_CIPHER_ALGO_WEP:
|
||||
return L"WEP";
|
||||
default:
|
||||
return L"???";
|
||||
return L"???";
|
||||
}
|
||||
}
|
||||
else if (type == 2){
|
||||
@ -410,10 +410,10 @@ LPCTSTR getDot11str(int dot11enum,int type){
|
||||
case DOT11_AUTH_ALGO_RSNA_PSK:
|
||||
return L"WPA2-Personal";
|
||||
default:
|
||||
return L"???";
|
||||
return L"???";
|
||||
}
|
||||
}
|
||||
else if(type==3){
|
||||
else if (type==3){
|
||||
switch(dot11enum){
|
||||
case wlan_interface_state_connected:
|
||||
return L"";
|
||||
@ -423,14 +423,14 @@ LPCTSTR getDot11str(int dot11enum,int type){
|
||||
return L"(connecting...)";
|
||||
}
|
||||
}
|
||||
else if(type==4){
|
||||
else if (type==4){
|
||||
switch(dot11enum){
|
||||
case dot11_phy_type_unknown:
|
||||
return L"???";
|
||||
case dot11_phy_type_dsss:
|
||||
return L"DSSS";
|
||||
case dot11_phy_type_erp:
|
||||
return L"802.11g";
|
||||
return L"802.11g";
|
||||
case dot11_phy_type_fhss:
|
||||
return L"FHSS";
|
||||
case dot11_phy_type_hrdsss:
|
||||
@ -476,11 +476,11 @@ void Finalize(HMODULE instance, UINT id)
|
||||
g_meas_data.erase(i1);
|
||||
}
|
||||
g_Instances--;
|
||||
if(hClient != NULL && g_Instances == 0){
|
||||
if (hClient != NULL && g_Instances == 0){
|
||||
WlanCloseHandle(hClient, NULL);
|
||||
hClient = NULL;
|
||||
}
|
||||
if(pIntfList != NULL && g_Instances == 0){
|
||||
if (pIntfList != NULL && g_Instances == 0){
|
||||
WlanFreeMemory(pIntfList);
|
||||
pIntfList = NULL;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
|
||||
|
||||
#define SAFE_RELEASE(punk) \
|
||||
if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; }
|
||||
if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; }
|
||||
|
||||
/* The exported functions */
|
||||
extern "C"
|
||||
@ -148,7 +148,7 @@ HRESULT RegisterDevice(PCWSTR devID)
|
||||
hr = S_FALSE;
|
||||
}
|
||||
UnInitCom();
|
||||
return hr;
|
||||
return hr;
|
||||
}
|
||||
|
||||
std::wstring GetDefaultID()
|
||||
@ -216,7 +216,7 @@ bool GetWin7AudioState(const VolumeAction action)
|
||||
|
||||
UINT GetIndex()
|
||||
{
|
||||
|
||||
|
||||
std::wstring id_default = L"";
|
||||
if (InitCom()) id_default = GetDefaultID();
|
||||
UnInitCom();
|
||||
@ -275,7 +275,7 @@ bool SetWin7Volume(UINT volume, int offset = 0)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -294,7 +294,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
|
||||
UINT count;
|
||||
if (!pCollection || (S_OK != pCollection->GetCount(&count)))
|
||||
if (!pCollection || (S_OK != pCollection->GetCount(&count)))
|
||||
{
|
||||
UnInitCom();
|
||||
return 0;
|
||||
@ -302,10 +302,10 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
endpointIDs = std::vector<std::wstring>(count);
|
||||
|
||||
for (UINT i = 0; i < count; i++)
|
||||
{
|
||||
IMMDevice *pEndpoint = 0;
|
||||
{
|
||||
IMMDevice *pEndpoint = 0;
|
||||
|
||||
// Get pointer to endpoint number i.
|
||||
// Get pointer to endpoint number i.
|
||||
if (pCollection->Item(i, &pEndpoint) == S_OK)
|
||||
{
|
||||
// Get the endpoint ID string.
|
||||
@ -339,13 +339,13 @@ This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
{
|
||||
GetWin7AudioState(GET_VOLUME);
|
||||
double volume = is_mute == TRUE ? -1.0 : floor(master_volume * 100.0 + 0.5); // rounding up at 0.5
|
||||
return volume > 100.0 ? 100.0 : volume;
|
||||
}
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR result[256];
|
||||
wsprintf(result, L"ERROR");
|
||||
|
@ -53,7 +53,7 @@ static std::map<UINT, windowData> g_Values;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -107,7 +107,7 @@ This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
{
|
||||
std::map<UINT, windowData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
{
|
||||
@ -134,7 +134,7 @@ double Update2(UINT id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR buffer[256];
|
||||
|
||||
|
@ -310,7 +310,7 @@ static bool updateCurrentTrack()
|
||||
IITArtworkPtr artwork;
|
||||
ITArtworkFormat artworkFormat;
|
||||
if (count > 0 &&
|
||||
SUCCEEDED(artworkCollection->get_Item(1, &artwork)) &&
|
||||
SUCCEEDED(artworkCollection->get_Item(1, &artwork)) &&
|
||||
SUCCEEDED(artwork->get_Format(&artworkFormat)))
|
||||
{
|
||||
_bstr_t path;
|
||||
@ -427,7 +427,7 @@ static void initEventHandler()
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -469,7 +469,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
|
||||
const wchar_t* type = ReadConfigString(section, L"Command", L"");
|
||||
for(int i = 0; i < COMMAND_COUNT; i++)
|
||||
for (int i = 0; i < COMMAND_COUNT; i++)
|
||||
{
|
||||
if (CommandName[i] && type && _wcsicmp(CommandName[i], type) == 0)
|
||||
{
|
||||
@ -552,7 +552,7 @@ This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
#define BUFFER_SIZE 256
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
//Error Check
|
||||
static wchar_t buffer[BUFFER_SIZE];
|
||||
|
Loading…
x
Reference in New Issue
Block a user