summaryrefslogtreecommitdiff
path: root/plugins/VersionInfo/src
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-07-24 12:45:18 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-07-24 12:45:18 +0000
commit0cda0baab21d4d4bf40c9459f6f5a7e49aa92492 (patch)
treec1244d2f42e6d1728a81a18bd0fbd091904bf20c /plugins/VersionInfo/src
parent171e81205e357e0d54283a63997ed58ff97d54a9 (diff)
VersionInfo, W7UI, WhoUsesMyFiles, YAPP, ZeroNotification: changed folder structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@1161 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/VersionInfo/src')
-rw-r--r--plugins/VersionInfo/src/CPlugin.cpp147
-rw-r--r--plugins/VersionInfo/src/CPlugin.h73
-rw-r--r--plugins/VersionInfo/src/CVersionInfo.cpp1198
-rw-r--r--plugins/VersionInfo/src/CVersionInfo.h115
-rw-r--r--plugins/VersionInfo/src/common.h96
-rw-r--r--plugins/VersionInfo/src/dlgHandlers.cpp589
-rw-r--r--plugins/VersionInfo/src/dlgHandlers.h43
-rw-r--r--plugins/VersionInfo/src/hooked_events.cpp80
-rw-r--r--plugins/VersionInfo/src/hooked_events.h33
-rw-r--r--plugins/VersionInfo/src/main.cpp119
-rw-r--r--plugins/VersionInfo/src/resource.h71
-rw-r--r--plugins/VersionInfo/src/services.cpp76
-rw-r--r--plugins/VersionInfo/src/services.h31
-rw-r--r--plugins/VersionInfo/src/utils.cpp526
-rw-r--r--plugins/VersionInfo/src/utils.h49
-rw-r--r--plugins/VersionInfo/src/version.h44
16 files changed, 3290 insertions, 0 deletions
diff --git a/plugins/VersionInfo/src/CPlugin.cpp b/plugins/VersionInfo/src/CPlugin.cpp
new file mode 100644
index 0000000000..54d762064a
--- /dev/null
+++ b/plugins/VersionInfo/src/CPlugin.cpp
@@ -0,0 +1,147 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "CPlugin.h"
+
+#include "common.h"
+
+#pragma comment(lib, "version.lib")
+
+const int cPLUGIN_UUID_MARK = 4;
+TCHAR PLUGIN_UUID_MARK[cPLUGIN_UUID_MARK];
+
+#define PLUGIN_UNCERTAIN_MARK "?"
+
+#define RJUST 70
+
+CPlugin::CPlugin() {
+ pluginID = UUID_NULL;
+}
+
+CPlugin::CPlugin(LPCTSTR eFileName, LPCTSTR eShortName, MUUID pluginID, LPCTSTR eUnicodeInfo, DWORD eVersion, LPCTSTR eTimestamp, LPCTSTR eLinkedModules) {
+ lpzFileName = eFileName;
+ lpzShortName = eShortName;
+ lpzUnicodeInfo = eUnicodeInfo;
+ lpzTimestamp = eTimestamp;
+ lpzLinkedModules = eLinkedModules;
+
+ int v1, v2, v3, v4;
+
+ DWORD unused, verInfoSize = GetFileVersionInfoSize(eFileName, &unused);
+ if (verInfoSize != 0) {
+ UINT blockSize;
+ VS_FIXEDFILEINFO* fi;
+ void* pVerInfo = mir_alloc(verInfoSize);
+ GetFileVersionInfo(eFileName, 0, verInfoSize, pVerInfo);
+ VerQueryValue(pVerInfo, _T("\\"), (LPVOID*)&fi, &blockSize);
+ v1 = HIWORD(fi->dwProductVersionMS), v2 = LOWORD(fi->dwProductVersionMS),
+ v3 = HIWORD(fi->dwProductVersionLS), v4 = LOWORD(fi->dwProductVersionLS);
+ mir_free(pVerInfo);
+ }
+ else {
+ DWORD ver = eVersion;
+ v1 = HIBYTE(HIWORD(ver)), v2 = LOBYTE(HIWORD(ver)), v3 = HIBYTE(LOWORD(ver)), v4 = LOBYTE(LOWORD(ver));
+ }
+
+ TCHAR aux[128];
+ mir_sntprintf(aux, SIZEOF(aux), _T("%d.%d.%d.%d"), v1, v2, v3, v4);
+ lpzVersion = aux;
+
+ this->pluginID = pluginID;
+};
+
+CPlugin::CPlugin(const CPlugin& other) {
+ lpzFileName = other.lpzFileName;
+ lpzShortName = other.lpzShortName;
+ lpzUnicodeInfo = other.lpzUnicodeInfo;
+ lpzVersion = other.lpzVersion;
+ lpzTimestamp = other.lpzTimestamp;
+ lpzLinkedModules = other.lpzLinkedModules;
+ pluginID = other.pluginID;
+}
+
+CPlugin::~CPlugin()
+{
+}
+
+void CPlugin::SetErrorMessage(LPCTSTR error)
+{
+ lpzLinkedModules = error;
+}
+
+bool CPlugin::operator<(CPlugin &anotherPlugin)
+{
+ std::tstring anotherFileName = anotherPlugin.getFileName();
+
+ TCHAR szThis[MAX_PATH]; lstrcpy(szThis, lpzFileName.c_str());
+ TCHAR szThat[MAX_PATH]; lstrcpy(szThat, anotherFileName.c_str());
+
+ if (lstrcmpi(szThis, szThat) < 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+bool CPlugin::operator>(CPlugin &anotherPlugin)
+{
+ return !((*this) < anotherPlugin);
+}
+bool CPlugin::operator==(CPlugin &anotherPlugin)
+{
+ return !((*this) < anotherPlugin || (*this) > anotherPlugin);
+}
+
+std::tstring CPlugin::getFileName()
+{
+ return this->lpzFileName;
+}
+
+std::tstring CPlugin::getInformations(DWORD flags, TCHAR *szHighlightHeader, TCHAR *szHighlightFooter)
+{
+ std::tstring lpzInformations;
+ if (flags & VISF_SHOWUUID)
+ {
+ TCHAR aux[128];
+ UUIDToString(pluginID, aux, SIZEOF(aux));
+ lpzInformations = aux;
+ }
+ else lpzInformations = (IsUUIDNull(pluginID)) ? _T(" ") : PLUGIN_UUID_MARK;
+
+ lpzInformations += std::tstring(_T(" ") + lpzFileName + _T(" v.") + szHighlightHeader + lpzVersion + szHighlightFooter + _T(" [") + lpzTimestamp + _T("] - ") + lpzShortName);
+ if (lpzUnicodeInfo.size() > 0)
+ {
+ TCHAR *lwr = _tcslwr(_tcsdup(lpzShortName.c_str()));
+ if ( !_tcsstr(lwr, _T("unicode")) && !_tcsstr(lwr, _T("2in1")))
+ lpzInformations.append( _T(" |") + lpzUnicodeInfo + _T("|"));
+
+ free(lwr);
+ }
+ //lpzInformations.append("\t");
+ //lpzInformations.append(lpzPluginID);
+ lpzInformations.append( _T("\r\n"));
+
+ if (lpzLinkedModules.size() > 0)
+ {
+ lpzInformations.append(lpzLinkedModules);
+ lpzInformations.append( _T("\r\n"));
+ }
+// std::string lpzInformations = std::string(lpzFileName + " - " + lpzShortName + " [" + lpzTimestamp + " · " + lpzVersion +"]\r\n");
+ return lpzInformations;
+}; \ No newline at end of file
diff --git a/plugins/VersionInfo/src/CPlugin.h b/plugins/VersionInfo/src/CPlugin.h
new file mode 100644
index 0000000000..5da1b1dc6b
--- /dev/null
+++ b/plugins/VersionInfo/src/CPlugin.h
@@ -0,0 +1,73 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#ifndef CPLUGIN_H
+#define CPLUGIN_H
+
+//#define STRICT
+#define WIN32_LEAN_AND_MEAN
+
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include <windows.h>
+#include <string>
+
+#ifndef M_NEWPLUGINAPI_H__
+ #include "newpluginapi.h"
+#endif
+
+#define DEF_UUID_CHARMARK "¤"
+
+extern const int cPLUGIN_UUID_MARK;
+extern TCHAR PLUGIN_UUID_MARK[];
+
+//using namespace std;
+
+
+ #define tstring wstring
+
+
+class CPlugin {
+ private:
+ std::tstring lpzFileName;
+ std::tstring lpzShortName;
+ std::tstring lpzVersion;
+ std::tstring lpzUnicodeInfo; //aditional info, Unicode aware ...
+ std::tstring lpzTimestamp; //to show the last modified timestamp
+ std::tstring lpzLinkedModules; //to show linked modules that aren't found
+ MUUID pluginID;
+
+ public:
+ CPlugin();
+ CPlugin(LPCTSTR fileName, LPCTSTR shortName, MUUID pluginID, LPCTSTR unicodeInfo, DWORD version, LPCTSTR timestamp, LPCTSTR linkedModules);
+ CPlugin(const CPlugin&);
+ ~CPlugin();
+ std::tstring getFileName();
+ std::tstring getInformations(DWORD, TCHAR *, TCHAR *);
+
+ void SetErrorMessage(LPCTSTR error);
+
+ //Operators
+ bool operator<(CPlugin&);
+ bool operator>(CPlugin&);
+ bool operator==(CPlugin&);
+};
+#endif \ No newline at end of file
diff --git a/plugins/VersionInfo/src/CVersionInfo.cpp b/plugins/VersionInfo/src/CVersionInfo.cpp
new file mode 100644
index 0000000000..da10f4b9a9
--- /dev/null
+++ b/plugins/VersionInfo/src/CVersionInfo.cpp
@@ -0,0 +1,1198 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#include "CVersionInfo.h"
+//#include "AggressiveOptimize.h"
+
+#include "common.h"
+#include "resource.h"
+
+//using namespace std;
+
+BOOL (WINAPI *MyGetDiskFreeSpaceEx)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
+BOOL (WINAPI *MyIsWow64Process)(HANDLE, PBOOL);
+void (WINAPI *MyGetSystemInfo)(LPSYSTEM_INFO);
+BOOL (WINAPI *MyGlobalMemoryStatusEx)(LPMEMORYSTATUSEX lpBuffer) = NULL;
+
+LANGID (WINAPI *MyGetUserDefaultUILanguage)() = NULL;
+LANGID (WINAPI *MyGetSystemDefaultUILanguage)() = NULL;
+
+static int ValidExtension(TCHAR *fileName, TCHAR *extension)
+{
+ TCHAR *dot = _tcschr(fileName, '.');
+ if ( dot != NULL && !lstrcmpi(dot + 1, extension))
+ if (dot[lstrlen(extension) + 1] == 0)
+ return 1;
+
+ return 0;
+}
+
+void FillLocalTime(std::tstring &output, FILETIME *fileTime)
+{
+ TIME_ZONE_INFORMATION tzInfo = {0};
+ FILETIME local = {0};
+ SYSTEMTIME sysTime;
+ TCHAR date[1024];
+ TCHAR time[256];
+
+ FileTimeToLocalFileTime(fileTime, &local);
+ FileTimeToSystemTime(&local, &sysTime);
+
+ GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date));
+ GetTimeFormat(NULL, TIME_FORCE24HOURFORMAT, &sysTime, _T("HH':'mm':'ss"), time, SIZEOF(time)); //americans love 24hour format ;)
+ output = std::tstring(date) + _T(" at ") + std::tstring(time);
+
+ int res = GetTimeZoneInformation(&tzInfo);
+ char tzName[32] = {0};
+ TCHAR tzOffset[64] = {0};
+ int offset = 0;
+ switch (res) {
+ case TIME_ZONE_ID_DAYLIGHT:
+ offset = -(tzInfo.Bias + tzInfo.DaylightBias);
+ WideCharToMultiByte(CP_ACP, 0, tzInfo.DaylightName, -1, tzName, SIZEOF(tzName), NULL, NULL);
+ break;
+
+ case TIME_ZONE_ID_STANDARD:
+ WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL);
+ offset = -(tzInfo.Bias + tzInfo.StandardBias);
+ break;
+
+ case TIME_ZONE_ID_UNKNOWN:
+ WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL);
+ offset = -tzInfo.Bias;
+ break;
+ }
+
+ mir_sntprintf(tzOffset, SIZEOF(tzOffset), _T("UTC %+02d:%02d"), offset / 60, offset % 60);
+ output += _T(" (") + std::tstring(tzOffset) + _T(")");
+}
+
+CVersionInfo::CVersionInfo()
+{
+ luiFreeDiskSpace = 0;
+ bDEPEnabled = 0;
+}
+
+CVersionInfo::~CVersionInfo()
+{
+ listInactivePlugins.clear();
+ listActivePlugins.clear();
+ listUnloadablePlugins.clear();
+
+ lpzMirandaVersion.~basic_string();
+ lpzNightly.~basic_string();
+ lpzUnicodeBuild.~basic_string();
+ lpzBuildTime.~basic_string();
+ lpzOSVersion.~basic_string();
+ lpzMirandaPath.~basic_string();
+ lpzCPUName.~basic_string();
+ lpzCPUIdentifier.~basic_string();
+};
+
+void CVersionInfo::Initialize()
+{
+#ifdef _DEBUG
+ if (verbose) PUShowMessage("Before GetMirandaVersion().", SM_NOTIFY);
+#endif
+ GetMirandaVersion();
+
+#ifdef _DEBUG
+ if (verbose) PUShowMessage("Before GetProfileSettings().", SM_NOTIFY);
+#endif
+ GetProfileSettings();
+
+#ifdef _DEBUG
+ if (verbose) PUShowMessage("Before GetLangpackInfo().", SM_NOTIFY);
+#endif
+ GetOSLanguages();
+ GetLangpackInfo();
+
+#ifdef _DEBUG
+ if (verbose) PUShowMessage("Before GetPluginLists().", SM_NOTIFY);
+#endif
+ GetPluginLists();
+
+#ifdef _DEBUG
+ if (verbose) PUShowMessage("Before GetOSVersion().", SM_NOTIFY);
+#endif
+ GetOSVersion();
+
+#ifdef _DEBUG
+ if (verbose) PUShowMessage("Before GetHWSettings().", SM_NOTIFY);
+#endif
+ GetHWSettings();
+
+#ifdef _DEBUG
+ if (verbose) PUShowMessage("Done with GetHWSettings().", SM_NOTIFY);
+#endif
+}
+
+bool CVersionInfo::GetMirandaVersion()
+{
+ //Miranda version
+ const BYTE str_size = 64;
+ char str[str_size];
+ CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)str_size, (LPARAM)str);
+ this->lpzMirandaVersion = _A2T(str);
+ //Is it a nightly?
+ if (lpzMirandaVersion.find( _T("alpha"),0) != std::string::npos)
+ lpzNightly = _T("Yes");
+ else
+ lpzNightly = _T("No");
+
+ if (lpzMirandaVersion.find( _T("Unicode"), 0) != std::string::npos)
+ lpzUnicodeBuild = _T("Yes");
+ else
+ lpzUnicodeBuild = _T("No");
+
+ TCHAR time[128], date[128];
+ GetModuleTimeStamp(date, time);
+ lpzBuildTime = std::tstring(time) + _T(" (UTC) on ") + std::tstring(date);
+ return TRUE;
+}
+
+bool CVersionInfo::GetOSVersion()
+{
+ //Operating system informations
+ OSVERSIONINFO osvi = { 0 };
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+
+ //Now fill the private members.
+ TCHAR aux[256];
+ wsprintf(aux, _T("%d.%d.%d %s"), osvi.dwMajorVersion, osvi.dwMinorVersion, LOWORD(osvi.dwBuildNumber), osvi.szCSDVersion);
+ lpzOSVersion = aux;
+
+ //OSName
+ //Let's read the registry.
+ HKEY hKey;
+ TCHAR szKey[MAX_PATH], szValue[MAX_PATH];
+ lstrcpyn(szKey, _T("Hardware\\Description\\System\\CentralProcessor\\0"), MAX_PATH);
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
+ DWORD type, size, result;
+
+ lstrcpyn(szValue, _T("Identifier"), MAX_PATH);
+ result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size);
+ if (result == ERROR_SUCCESS) {
+ TCHAR *aux = new TCHAR[size+1];
+ result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size);
+ lpzCPUIdentifier = aux;
+ delete[] aux;
+ }
+ else {
+ NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__);
+ lpzCPUIdentifier = _T("<Error in RegQueryValueEx()>");
+ }
+
+ lstrcpyn(szValue, _T("ProcessorNameString"), MAX_PATH);
+ result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); //get the size
+ if (result == ERROR_SUCCESS) {
+ TCHAR *aux = new TCHAR[size+1];
+ result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size);
+ lpzCPUName = aux;
+ delete[] aux;
+ }
+ else { //else try to use cpuid instruction to get the proc name
+ char szName[50];
+ #if (!defined(WIN64) && !defined(_WIN64))
+ __asm
+ {
+ push eax //save the registers
+ push ebx
+ push ecx
+ push edx
+
+ xor eax, eax //get simple name
+ cpuid
+ mov DWORD PTR szName[0], ebx
+ mov DWORD PTR szName[4], edx
+ mov DWORD PTR szName[8], ecx
+ mov DWORD PTR szName[12], 0
+
+ mov eax, 0x80000000 //try to get pretty name
+ cpuid
+
+ cmp eax, 0x80000004
+ jb end //if we don't have the extension end the check
+
+ mov DWORD PTR szName[0], 0 //make the string null
+
+ mov eax, 0x80000002 //first part of the string
+ cpuid
+ mov DWORD PTR szName[0], eax
+ mov DWORD PTR szName[4], ebx
+ mov DWORD PTR szName[8], ecx
+ mov DWORD PTR szName[12], edx
+
+ mov eax, 0x80000003 //second part of the string
+ cpuid
+ mov DWORD PTR szName[16], eax
+ mov DWORD PTR szName[20], ebx
+ mov DWORD PTR szName[24], ecx
+ mov DWORD PTR szName[28], edx
+
+ mov eax, 0x80000004 //third part of the string
+ cpuid
+ mov DWORD PTR szName[32], eax
+ mov DWORD PTR szName[36], ebx
+ mov DWORD PTR szName[40], ecx
+ mov DWORD PTR szName[44], edx
+
+end:
+ pop edx //load them back
+ pop ecx
+ pop ebx
+ pop eax
+ }
+ szName[SIZEOF(szName) - 1] = '\0';
+ #else
+ szName[0] = 0;
+ #endif
+
+ if ( !szName[0] )
+ lpzCPUName = _T("<name N/A>");
+ else
+ lpzCPUName = _A2T(szName);
+ }
+ }
+
+ bDEPEnabled = IsProcessorFeaturePresent(PF_NX_ENABLED);
+
+ switch (osvi.dwPlatformId) {
+ case VER_PLATFORM_WIN32_WINDOWS:
+ lstrcpyn(szKey, _T("Software\\Microsoft\\Windows\\CurrentVersion"), MAX_PATH);
+ lstrcpyn(szValue, _T("Version"), MAX_PATH);
+ break;
+ case VER_PLATFORM_WIN32_NT:
+
+ lstrcpyn(szKey, _T("Software\\Microsoft\\Windows NT\\CurrentVersion"), MAX_PATH);
+ lstrcpyn(szValue, _T("ProductName"), MAX_PATH);
+ break;
+ }
+
+ RegCloseKey(hKey);
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,szKey,0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) {
+ DWORD type, size, result;
+ //Get the size of the value we'll read.
+ result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)NULL,
+ (LPDWORD)&size);
+ if (result == ERROR_SUCCESS) {
+ //Read it.
+ TCHAR *aux = new TCHAR[size+1];
+ result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)aux,(LPDWORD)&size);
+ lpzOSName = aux;
+ delete[] aux;
+ }
+ else {
+ NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__);
+ lpzOSName = _T("<Error in RegQueryValueEx()>");
+ }
+ }
+ else {
+ NotifyError(GetLastError(), _T("RegOpenKeyEx()"), __LINE__);
+ lpzOSName = _T("<Error in RegOpenKeyEx()>");
+ }
+
+ //Now we can improve it if we can.
+ switch (LOWORD(osvi.dwBuildNumber)) {
+ case 950: lpzOSName = _T("Microsoft Windows 95"); break;
+ case 1111: lpzOSName = _T("Microsoft Windows 95 OSR2"); break;
+ case 1998: lpzOSName = _T("Microsoft Windows 98"); break;
+ case 2222: lpzOSName = _T("Microsoft Windows 98 SE"); break;
+ case 3000: lpzOSName = _T("Microsoft Windows ME"); break; //Even if this is wrong, we have already read it in the registry.
+ case 1381: lpzOSName = _T("Microsoft Windows NT"); break; //What about service packs?
+ case 2195: lpzOSName = _T("Microsoft Windows 2000"); break; //What about service packs?
+ case 2600: lpzOSName = _T("Microsoft Windows XP"); break;
+ case 3790:
+ if ( GetSystemMetrics( 89 )) //R2 ?
+ lpzOSName = _T("Microsoft Windows 2003 R2");
+ else
+ lpzOSName = _T("Microsoft Windows 2003");
+
+ break; //added windows 2003 info
+ }
+
+ return TRUE;
+}
+
+bool CVersionInfo::GetHWSettings() {
+ //Free space on Miranda Partition.
+ TCHAR szMirandaPath[MAX_PATH] = { 0 };
+ {
+ GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath));
+ TCHAR* str2 = _tcsrchr(szMirandaPath,'\\');
+ if ( str2 != NULL) *str2=0;
+ }
+ HMODULE hKernel32;
+ hKernel32 = LoadLibraryA("kernel32.dll");
+ if (hKernel32) {
+
+ MyGetDiskFreeSpaceEx = (BOOL (WINAPI *)(LPCTSTR,PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER))GetProcAddress(hKernel32, "GetDiskFreeSpaceExW");
+
+
+ MyIsWow64Process = (BOOL (WINAPI *) (HANDLE, PBOOL)) GetProcAddress(hKernel32, "IsWow64Process");
+ MyGetSystemInfo = (void (WINAPI *) (LPSYSTEM_INFO)) GetProcAddress(hKernel32, "GetNativeSystemInfo");
+ MyGlobalMemoryStatusEx = (BOOL (WINAPI *) (LPMEMORYSTATUSEX)) GetProcAddress(hKernel32, "GlobalMemoryStatusEx");
+ if ( !MyGetSystemInfo )
+ MyGetSystemInfo = GetSystemInfo;
+
+ FreeLibrary(hKernel32);
+ }
+ if ( MyGetDiskFreeSpaceEx ) {
+ ULARGE_INTEGER FreeBytes, a, b;
+ MyGetDiskFreeSpaceEx(szMirandaPath, &FreeBytes, &a, &b);
+ //Now we need to convert it.
+ __int64 aux = FreeBytes.QuadPart;
+ aux /= (1024*1024);
+ luiFreeDiskSpace = (unsigned long int)aux;
+ }
+ else luiFreeDiskSpace = 0;
+
+ TCHAR szInfo[1024];
+ GetWindowsShell(szInfo, SIZEOF(szInfo));
+ lpzShell = szInfo;
+ GetInternetExplorerVersion(szInfo, SIZEOF(szInfo));
+ lpzIEVersion = szInfo;
+
+
+ lpzAdministratorPrivileges = (IsCurrentUserLocalAdministrator()) ? _T("Yes") : _T("No");
+
+ bIsWOW64 = 0;
+ if (MyIsWow64Process)
+ if (!MyIsWow64Process(GetCurrentProcess(), &bIsWOW64))
+ bIsWOW64 = 0;
+
+ SYSTEM_INFO sysInfo = {0};
+ GetSystemInfo(&sysInfo);
+ luiProcessors = sysInfo.dwNumberOfProcessors;
+
+ //Installed RAM
+ if (MyGlobalMemoryStatusEx) { //windows 2000+
+ MEMORYSTATUSEX ms = {0};
+ ms.dwLength = sizeof(ms);
+ MyGlobalMemoryStatusEx(&ms);
+ luiRAM = (unsigned int) ((ms.ullTotalPhys / (1024 * 1024)) + 1);
+ }
+ else {
+ MEMORYSTATUS ms = {0};
+ ms.dwLength = sizeof(ms);
+ GlobalMemoryStatus(&ms);
+ luiRAM = (ms.dwTotalPhys/(1024*1024))+1; //Ugly hack!!!!
+ }
+
+ return TRUE;
+}
+
+bool CVersionInfo::GetProfileSettings()
+{
+ TCHAR* tszProfileName = Utils_ReplaceVarsT(_T("%miranda_userdata%\\%miranda_profilename%.dat"));
+ lpzProfilePath = tszProfileName;
+
+ WIN32_FIND_DATA fd;
+ if ( FindFirstFile(tszProfileName, &fd) != INVALID_HANDLE_VALUE ) {
+ TCHAR number[40];
+ mir_sntprintf( number, SIZEOF(number), _T("%.2f KBytes"), double(fd.nFileSizeLow) / 1024 );
+ lpzProfileSize = number;
+
+ FillLocalTime(lpzProfileCreationDate, &fd.ftCreationTime);
+ }
+ else {
+ DWORD error = GetLastError();
+ TCHAR tmp[1024];
+ wsprintf(tmp, _T("%d"), error);
+ lpzProfileCreationDate = _T("<error ") + std::tstring(tmp) + _T(" at FileOpen>") + std::tstring(tszProfileName);
+ lpzProfileSize = _T("<error ") + std::tstring(tmp) + _T(" at FileOpen>") + std::tstring(tszProfileName);
+ }
+
+ mir_free( tszProfileName );
+ return true;
+}
+
+static TCHAR szSystemLocales[4096] = {0};
+static WORD systemLangID;
+#define US_LANG_ID 0x00000409
+
+BOOL CALLBACK EnumSystemLocalesProc(TCHAR *szLocale)
+{
+ DWORD locale = _ttoi(szLocale);
+ TCHAR *name = GetLanguageName(locale);
+ if ( !_tcsstr(szSystemLocales, name)) {
+ _tcscat(szSystemLocales, name);
+ _tcscat(szSystemLocales, _T(", "));
+ }
+
+ return TRUE;
+}
+
+BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam)
+{
+ if (!lpszName)
+ return FALSE;
+
+ if (wIDLanguage != US_LANG_ID)
+ systemLangID = wIDLanguage;
+
+ return TRUE;
+}
+
+bool CVersionInfo::GetOSLanguages()
+{
+ lpzOSLanguages = _T("(UI | Locale (User/System)) : ");
+
+ LANGID UILang;
+
+ OSVERSIONINFO os = {0};
+ os.dwOSVersionInfoSize = sizeof(os);
+ GetVersionEx(&os);
+ if (os.dwMajorVersion == 4) {
+ if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) { //Win NT
+ HMODULE hLib = LoadLibraryA("ntdll.dll");
+
+ if (hLib) {
+ EnumResourceLanguages(hLib, RT_VERSION, MAKEINTRESOURCE(1), EnumResLangProc, NULL);
+
+ FreeLibrary(hLib);
+
+ if (systemLangID == US_LANG_ID) {
+ UINT uiACP;
+
+ uiACP = GetACP();
+ switch (uiACP)
+ {
+ case 874: // Thai code page activated, it's a Thai enabled system
+ systemLangID = MAKELANGID(LANG_THAI, SUBLANG_DEFAULT);
+ break;
+
+ case 1255: // Hebrew code page activated, it's a Hebrew enabled system
+ systemLangID = MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT);
+ break;
+
+ case 1256: // Arabic code page activated, it's a Arabic enabled system
+ systemLangID = MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_SAUDI_ARABIA);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+ else { //Win 95-Me
+ HKEY hKey = NULL;
+ TCHAR szLangID[128] = _T("0x");
+ DWORD size = SIZEOF(szLangID) - 2;
+ TCHAR err[512];
+
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Desktop\\ResourceLocale"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
+ if (RegQueryValueEx(hKey, _T(""), 0, NULL, (LPBYTE) &szLangID + 2, &size) == ERROR_SUCCESS)
+ _tscanf(szLangID, _T("%lx"), &systemLangID);
+ else {
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL);
+ MessageBox(0, err, _T("Error at RegQueryValueEx()"), MB_OK);
+ }
+ RegCloseKey(hKey);
+ }
+ else {
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL);
+ MessageBox(0, err, _T("Error at RegOpenKeyEx()"), MB_OK);
+ }
+ }
+
+ lpzOSLanguages += GetLanguageName(systemLangID);
+ }
+ else {
+ HMODULE hKernel32 = LoadLibraryA("kernel32.dll");
+ if (hKernel32) {
+ MyGetUserDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetUserDefaultUILanguage");
+ MyGetSystemDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetSystemDefaultUILanguage");
+
+ FreeLibrary(hKernel32);
+ }
+
+ if ((MyGetUserDefaultUILanguage) && (MyGetSystemDefaultUILanguage)) {
+ UILang = MyGetUserDefaultUILanguage();
+ lpzOSLanguages += GetLanguageName(UILang);
+ lpzOSLanguages += _T("/");
+ UILang = MyGetSystemDefaultUILanguage();
+ lpzOSLanguages += GetLanguageName(UILang);
+ }
+ else lpzOSLanguages += _T("Missing functions in kernel32.dll (GetUserDefaultUILanguage, GetSystemDefaultUILanguage)");
+ }
+
+ lpzOSLanguages += _T(" | ");
+ lpzOSLanguages += GetLanguageName(LOCALE_USER_DEFAULT);
+ lpzOSLanguages += _T("/");
+ lpzOSLanguages += GetLanguageName(LOCALE_SYSTEM_DEFAULT);
+
+ if (DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", 0)) {
+ szSystemLocales[0] = '\0';
+ lpzOSLanguages += _T(" [");
+ EnumSystemLocales(EnumSystemLocalesProc, LCID_INSTALLED);
+ if (_tcslen(szSystemLocales) > 2)
+ szSystemLocales[ _tcslen(szSystemLocales) - 2] = '\0';
+
+ lpzOSLanguages += szSystemLocales;
+ lpzOSLanguages += _T("]");
+ }
+
+ return true;
+}
+
+int SaveInfo(const char *data, const char *lwrData, const char *search, TCHAR *dest, int size)
+{
+ const char *pos = strstr(lwrData, search);
+ int res = 1;
+ if (pos == lwrData) {
+ _tcsncpy(dest, _A2T(&data[strlen(search)]), size);
+ res = 0;
+ }
+
+ return res;
+}
+
+bool CVersionInfo::GetLangpackInfo()
+{
+ TCHAR langpackPath[MAX_PATH] = {0};
+ TCHAR search[MAX_PATH] = {0};
+
+ lpzLangpackModifiedDate = _T("");
+ GetModuleFileName(GetModuleHandle(NULL), langpackPath, SIZEOF(langpackPath));
+ TCHAR* p = _tcsrchr(langpackPath, '\\');
+ if (p) {
+ WIN32_FIND_DATA data = {0};
+ HANDLE hLangpack;
+
+ p[1] = '\0';
+ _tcscpy(search, langpackPath);
+ _tcscat(search, _T("langpack_*.txt"));
+ hLangpack = FindFirstFile(search, &data);
+ if (hLangpack != INVALID_HANDLE_VALUE) {
+ char buffer[1024];
+ char temp[1024];
+ FillLocalTime(lpzLangpackModifiedDate, &data.ftLastWriteTime);
+
+ TCHAR locale[128] = {0};
+ TCHAR language[128] = {0};
+ TCHAR version[128] = {0};
+ _tcscpy(version, _T("N/A"));
+
+ _tcsncpy(language, data.cFileName, SIZEOF(language));
+ p = _tcsrchr(language, '.');
+ p[0] = '\0';
+
+ _tcscat(langpackPath, data.cFileName);
+ FILE *fin = _tfopen(langpackPath, _T("rt"));
+ if (fin) {
+ size_t len;
+ while (!feof(fin)) {
+ fgets(buffer, SIZEOF(buffer), fin);
+ len = strlen(buffer);
+ if (buffer[len - 1] == '\n') buffer[len - 1] = '\0';
+ strncpy(temp, buffer, SIZEOF(temp));
+ _strlwr(temp);
+ if (SaveInfo(buffer, temp, "language: ", language, SIZEOF(language))) {
+ if (SaveInfo(buffer, temp, "locale: ", locale, SIZEOF(locale))) {
+ char* p = strstr(buffer, "; FLID: ");
+ if (p) {
+ int ok = 1;
+ int i;
+ for (i = 0; ((i < 3) && (ok)); i++) {
+ p = strrchr(temp, '.');
+ if (p)
+ p[0] = '\0';
+ else
+ ok = 0;
+ }
+ p = strrchr(temp, ' ');
+ if ((ok) && (p))
+ _tcsncpy(version, _A2T(&buffer[p - temp + 1]), SIZEOF(version));
+ else
+ _tcsncpy(version, _T("<unknown>"), SIZEOF(version));
+ } } } }
+
+ lpzLangpackInfo = std::tstring(language) + _T(" [") + std::tstring(locale) + _T("]");
+ if ( version[0] )
+ lpzLangpackInfo += _T(" v. ") + std::tstring(version);
+
+ fclose(fin);
+ }
+ else {
+ int err = GetLastError();
+ lpzLangpackInfo = _T("<error> Could not open file " + std::tstring(data.cFileName));
+ }
+ FindClose(hLangpack);
+ }
+ else lpzLangpackInfo = _T("No language pack installed");
+ }
+
+ return true;
+}
+
+std::tstring GetPluginTimestamp(FILETIME *fileTime)
+{
+ SYSTEMTIME sysTime;
+ FileTimeToSystemTime(fileTime, &sysTime); //convert the file tyme to system time
+
+ //char time[256];
+ TCHAR date[256]; //lovely
+ GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date));
+ return date;
+}
+
+bool CVersionInfo::GetPluginLists()
+{
+ HANDLE hFind;
+ TCHAR szMirandaPath[MAX_PATH] = { 0 }, szSearchPath[MAX_PATH] = { 0 }; //For search purpose
+ WIN32_FIND_DATA fd;
+ TCHAR szMirandaPluginsPath[MAX_PATH] = { 0 }, szPluginPath[MAX_PATH] = { 0 }; //For info reading purpose
+ BYTE PluginIsEnabled = 0;
+ HINSTANCE hInstPlugin = NULL;
+ PLUGININFOEX *(*MirandaPluginInfo)(DWORD); //These two are used to get informations from the plugin.
+ PLUGININFOEX *pluginInfo = NULL; //Read above.
+ DWORD mirandaVersion = 0;
+ BOOL asmCheckOK = FALSE;
+ DWORD loadError;
+ // SYSTEMTIME sysTime; //for timestamp
+
+ mirandaVersion=(DWORD)CallService(MS_SYSTEM_GETVERSION,0,0);
+ {
+ GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath));
+ TCHAR* str2 = _tcsrchr(szMirandaPath,'\\');
+ if(str2!=NULL) *str2=0;
+ }
+ lpzMirandaPath = szMirandaPath;
+
+ //We got Miranda path, now we'll use it for two different purposes.
+ //1) finding plugins.
+ //2) Reading plugin infos
+ lstrcpyn(szSearchPath,szMirandaPath, MAX_PATH); //We got the path, now we copy it into szSearchPath. We'll use szSearchPath as am auxiliary variable, while szMirandaPath will keep a "fixed" value.
+ lstrcat(szSearchPath, _T("\\Plugins\\*.dll"));
+
+ lstrcpyn(szMirandaPluginsPath, szMirandaPath, MAX_PATH);
+ lstrcat(szMirandaPluginsPath, _T("\\Plugins\\"));
+
+ hFind=FindFirstFile(szSearchPath,&fd);
+ if ( hFind != INVALID_HANDLE_VALUE) {
+ do {
+ if (verbose) PUShowMessageT(fd.cFileName, SM_NOTIFY);
+ if (!ValidExtension(fd.cFileName, _T("dll")))
+ continue; //do not report plugins that do not have extension .dll
+
+ hInstPlugin = GetModuleHandle(fd.cFileName); //try to get the handle of the module
+
+ if (hInstPlugin) //if we got it then the dll is loaded (enabled)
+ PluginIsEnabled = 1;
+ else {
+ PluginIsEnabled = 0;
+ lstrcpyn(szPluginPath, szMirandaPluginsPath, MAX_PATH); // szPluginPath becomes "drive:\path\Miranda\Plugins\"
+ lstrcat(szPluginPath, fd.cFileName); // szPluginPath becomes "drive:\path\Miranda\Plugins\popup.dll"
+ hInstPlugin = LoadLibrary(szPluginPath);
+ }
+ if (!hInstPlugin) { //It wasn't loaded.
+ loadError = GetLastError();
+ int bUnknownError = 1; //assume plugin didn't load because of unknown error
+ //Some error messages.
+ //get the dlls the plugin statically links to
+ if (DBGetContactSettingByte(NULL, ModuleName, "CheckForDependencies", TRUE))
+ {
+ std::tstring linkedModules;
+
+ lstrcpyn(szPluginPath, szMirandaPluginsPath, MAX_PATH); // szPluginPath becomes "drive:\path\Miranda\Plugins\"
+ lstrcat(szPluginPath, fd.cFileName); // szPluginPath becomes "drive:\path\Miranda\Plugins\popup.dll"
+ if (GetLinkedModulesInfo(szPluginPath, linkedModules)) {
+ std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime);
+ CPlugin thePlugin(fd.cFileName, _T("<unknown>"), UUID_NULL, _T(""), 0, time.c_str(), linkedModules.c_str());
+ AddPlugin(thePlugin, listUnloadablePlugins);
+ bUnknownError = 0; //we know why the plugin didn't load
+ }
+ }
+ if (bUnknownError) { //if cause is unknown then report it
+ std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime);
+ TCHAR buffer[4096];
+ TCHAR error[2048];
+ //DWORD_PTR arguments[2] = {loadError, 0};
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, loadError, 0, error, SIZEOF(error), NULL);
+ wsprintf(buffer, _T(" Error %ld - %s"), loadError, error);
+ CPlugin thePlugin( fd.cFileName, _T("<unknown>"), UUID_NULL, _T(""), 0, time.c_str(), buffer);
+ AddPlugin(thePlugin, listUnloadablePlugins);
+ }
+ }
+ else { //It was successfully loaded.
+ MirandaPluginInfo = (PLUGININFOEX *(*)(DWORD))GetProcAddress(hInstPlugin, "MirandaPluginInfoEx");
+ if (!MirandaPluginInfo)
+ MirandaPluginInfo = (PLUGININFOEX *(*)(DWORD))GetProcAddress(hInstPlugin, "MirandaPluginInfo");
+
+ if (!MirandaPluginInfo) //There is no function: it's not a valid plugin. Let's move on to the next file.
+ continue;
+
+ //It's a valid plugin, since we could find MirandaPluginInfo
+ #if (!defined(WIN64) && !defined(_WIN64))
+ asmCheckOK = FALSE;
+ __asm {
+ push mirandaVersion
+ push mirandaVersion
+ call MirandaPluginInfo
+ pop eax
+ pop eax
+ cmp eax, mirandaVersion
+ jne a1
+ mov asmCheckOK, 0xffffffff
+ a1:
+ }
+ #else
+ asmCheckOK = TRUE;
+ #endif
+ if (asmCheckOK)
+ pluginInfo = CopyPluginInfo(MirandaPluginInfo(mirandaVersion));
+ else {
+ ZeroMemory(&pluginInfo, sizeof(pluginInfo));
+ MessageBox(NULL, fd.cFileName, _T("Invalid plugin"), MB_OK);
+ } }
+
+ //Let's get the info.
+ if (MirandaPluginInfo != NULL) {//a valid miranda plugin
+ if (pluginInfo != NULL) {
+ //We have loaded the informations into pluginInfo.
+ std::tstring timedate = GetPluginTimestamp(&fd.ftLastWriteTime);
+ CPlugin thePlugin(fd.cFileName, _A2T(pluginInfo->shortName), pluginInfo->uuid, (pluginInfo->flags & 1) ? _T("Unicode aware") : _T(""), (DWORD) pluginInfo->version, timedate.c_str(), _T(""));
+
+ if (PluginIsEnabled)
+ AddPlugin(thePlugin, listActivePlugins);
+ else {
+ if ((IsUUIDNull(pluginInfo->uuid)) && (mirandaVersion >= PLUGIN_MAKE_VERSION(0,8,0,9))) {
+ thePlugin.SetErrorMessage( _T(" Plugin does not have an UUID and will not work with Miranda 0.8.\r\n"));
+ AddPlugin(thePlugin, listUnloadablePlugins);
+ }
+ else AddPlugin(thePlugin, listInactivePlugins);
+
+ FreeLibrary(hInstPlugin); //We don't need it anymore.
+ }
+ FreePluginInfo(pluginInfo);
+ MirandaPluginInfo = NULL;
+ #ifdef _DEBUG
+ if (verbose) {
+ TCHAR szMsg[4096] = { 0 };
+ wsprintf(szMsg, _T("Done with: %s"), fd.cFileName);
+ PUShowMessageT(szMsg, SM_NOTIFY);
+ }
+ #endif
+ }
+ else { //pluginINFO == NULL
+ pluginInfo = CopyPluginInfo(MirandaPluginInfo(PLUGIN_MAKE_VERSION(9, 9, 9, 9))); //let's see if the plugin likes this miranda version
+ char *szShortName = "<unknown>";
+ std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); //get the plugin timestamp;
+ DWORD version = 0;
+ if (pluginInfo) {
+ szShortName = pluginInfo->shortName;
+ version = pluginInfo->version;
+ }
+
+ CPlugin thePlugin(fd.cFileName, _A2T(szShortName), (pluginInfo) ? pluginInfo->uuid : UUID_NULL, (((pluginInfo) && (pluginInfo->flags & 1)) ? _T("Unicode aware") : _T("")), version, time.c_str(), _T(" Plugin refuses to load. Miranda version too old."));
+
+ AddPlugin(thePlugin, listUnloadablePlugins);
+ if (pluginInfo)
+ FreePluginInfo(pluginInfo);
+ } }
+ }
+ while (FindNextFile(hFind,&fd));
+ FindClose(hFind);
+ }
+ return TRUE;
+}
+
+bool CVersionInfo::AddPlugin(CPlugin &aPlugin, std::list<CPlugin> &aList) {
+ std::list<CPlugin>::iterator pos = aList.begin();
+ bool inserted = FALSE;
+
+ if (aList.begin() == aList.end()) { //It's empty
+ aList.push_back(aPlugin);
+ return TRUE;
+ }
+ else { //It's not empty
+ while (pos != aList.end()) {
+ //It can be either < or >, not equal.
+ if (aPlugin < (*pos)) {
+ aList.insert(pos, aPlugin);
+ return TRUE;
+ }
+
+ //It's greater: we need to insert it.
+ pos++;
+ } }
+
+ if (inserted == FALSE) {
+ aList.push_back(aPlugin);
+ return TRUE;
+ }
+ return TRUE;
+};
+
+static char *GetStringFromRVA(DWORD RVA, const LOADED_IMAGE *image)
+{
+ char *moduleName;
+ moduleName = (char *) ImageRvaToVa(image->FileHeader, image->MappedAddress, RVA, NULL);
+ return moduleName;
+}
+
+bool CVersionInfo::GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules)
+{
+ LOADED_IMAGE image;
+ ULONG importTableSize;
+ IMAGE_IMPORT_DESCRIPTOR *importData;
+ //HMODULE dllModule;
+ linkedModules = _T("");
+ bool result = false;
+ TCHAR szError[20];
+ char* szModuleName = mir_t2a(moduleName);
+ if (MapAndLoad(szModuleName, NULL, &image, TRUE, TRUE) == FALSE) {
+ wsprintf(szError, _T("%d"), GetLastError());
+ mir_free( szModuleName );
+ linkedModules = _T("<error ") + std::tstring(szError) + _T(" at MapAndLoad()>\r\n");
+ return result;
+ }
+ mir_free( szModuleName );
+ importData = (IMAGE_IMPORT_DESCRIPTOR *) ImageDirectoryEntryToData(image.MappedAddress, FALSE, IMAGE_DIRECTORY_ENTRY_IMPORT, &importTableSize);
+ if (!importData) {
+ wsprintf(szError, _T("%d"), GetLastError());
+ linkedModules = _T("<error ") + std::tstring(szError) + _T(" at ImageDirectoryEntryToDataEx()>\r\n");
+ }
+ else {
+ while (importData->Name) {
+ char *moduleName;
+ moduleName = GetStringFromRVA(importData->Name, &image);
+ if (!DoesDllExist(moduleName)) {
+ linkedModules.append( _T(" Plugin statically links to missing dll file: ") + std::tstring(_A2T(moduleName)) + _T("\r\n"));
+ result = true;
+ }
+
+ importData++; //go to next record
+ } }
+
+ // FreeLibrary(dllModule);
+ UnMapAndLoad(&image); //unload the image
+ return result;
+}
+
+std::tstring CVersionInfo::GetListAsString(std::list<CPlugin> &aList, DWORD flags, int beautify) {
+ std::list<CPlugin>::iterator pos = aList.begin();
+ std::tstring out = _T("");
+#ifdef _DEBUG
+ if (verbose) PUShowMessage("CVersionInfo::GetListAsString, begin.", SM_NOTIFY);
+#endif
+
+ TCHAR szHeader[32] = {0};
+ TCHAR szFooter[32] = {0};
+ if ((((flags & VISF_FORUMSTYLE) == VISF_FORUMSTYLE) || beautify) && (DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE))) {
+ GetStringFromDatabase("BoldBegin", _T("[b]"), szHeader, SIZEOF(szHeader));
+ GetStringFromDatabase("BoldEnd", _T("[/b]"), szFooter, SIZEOF(szFooter));
+ }
+
+ while (pos != aList.end()) {
+ out.append(std::tstring((*pos).getInformations(flags, szHeader, szFooter)));
+ pos++;
+ }
+ #ifdef _DEBUG
+ if (verbose) PUShowMessage("CVersionInfo::GetListAsString, end.", SM_NOTIFY);
+ #endif
+ return out;
+};
+
+void CVersionInfo::BeautifyReport(int beautify, LPCTSTR szBeautifyText, LPCTSTR szNonBeautifyText, std::tstring &out)
+{
+ if (beautify)
+ out.append(szBeautifyText);
+ else
+ out.append(szNonBeautifyText);
+}
+
+void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautify, std::tstring &out)
+{
+ if (forumStyle) { //forum style
+ TCHAR szSize[256], szQuote[256];
+
+ GetStringFromDatabase("SizeBegin", _T("[size=1]"), szSize, SIZEOF(szSize));
+ GetStringFromDatabase("QuoteBegin", _T("[quote]"), szQuote, SIZEOF(szQuote));
+ out.append(szQuote);
+ out.append(szSize);
+ }
+ else out = _T("");
+
+ if (!suppressHeader) {
+ out.append( _T("Miranda IM - VersionInformation plugin by Hrk, modified by Eblis\r\n"));
+ if (!forumStyle) {
+ out.append( _T("Miranda's homepage: http://nightly.miranda.im/\r\n")); //changed homepage
+ out.append( _T("Miranda tools: http://nightly.miranda.im/\r\n\r\n")); //was missing a / before download
+ } }
+
+ TCHAR buffer[1024]; //for beautification
+ GetStringFromDatabase("BeautifyHorizLine", _T("<hr />"), buffer, SIZEOF(buffer));
+ BeautifyReport(beautify, buffer, _T(""), out);
+ GetStringFromDatabase("BeautifyBlockStart", _T("<blockquote>"), buffer, SIZEOF(buffer));
+ BeautifyReport(beautify, buffer, _T(""), out);
+ if (!suppressHeader) {
+ //Time of report:
+ TCHAR lpzTime[12]; GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("HH':'mm':'ss"), lpzTime, SIZEOF(lpzTime));
+ TCHAR lpzDate[32]; GetDateFormat(EnglishLocale, 0, NULL, _T("dd' 'MMMM' 'yyyy"), lpzDate, SIZEOF(lpzDate));
+ out.append( _T("Report generated at: ") + std::tstring(lpzTime) + _T(" on ") + std::tstring(lpzDate) + _T("\r\n\r\n"));
+ }
+
+ //Operating system
+ out.append(_T("CPU: ") + lpzCPUName + _T(" [") + lpzCPUIdentifier + _T("]"));
+ if (bDEPEnabled)
+ out.append(_T(" [DEP enabled]"));
+
+ if (luiProcessors > 1) {
+ TCHAR noProcs[128];
+ wsprintf(noProcs, _T(" [%d CPUs]"), luiProcessors);
+ out.append(noProcs);
+ }
+ out.append( _T("\r\n"));
+
+ //RAM
+ TCHAR szRAM[64]; wsprintf(szRAM, _T("%d"), luiRAM);
+ out.append( _T("Installed RAM: ") + std::tstring(szRAM) + _T(" MBytes\r\n"));
+
+ //operating system
+ out.append( _T("Operating System: ") + lpzOSName + _T(" [version: ") + lpzOSVersion + _T("]\r\n"));
+
+ //shell, IE, administrator
+ out.append( _T("Shell: ") + lpzShell + _T(", Internet Explorer ") + lpzIEVersion + _T("\r\n"));
+ out.append( _T("Administrator privileges: ") + lpzAdministratorPrivileges + _T("\r\n"));
+
+ //languages
+ out.append( _T("OS Languages: ") + lpzOSLanguages + _T("\r\n"));
+
+ //FreeDiskSpace
+ if (luiFreeDiskSpace) {
+ TCHAR szDiskSpace[64]; wsprintf(szDiskSpace, _T("%d"), luiFreeDiskSpace);
+ out.append( _T("Free disk space on Miranda partition: ") + std::tstring(szDiskSpace) + _T(" MBytes\r\n"));
+ }
+
+ //Miranda
+ out.append( _T("Miranda path: ") + lpzMirandaPath + _T("\r\n"));
+ out.append( _T("Miranda IM version: ") + lpzMirandaVersion);
+ if (bIsWOW64)
+ out.append( _T(" [running inside WOW64]"));
+ if (bServiceMode)
+ out.append( _T(" [service mode]"));
+
+ out.append( _T("\r\nBuild time: ") + lpzBuildTime + _T("\r\n"));
+ out.append( _T("Profile path: ") + lpzProfilePath + _T("\r\n"));
+ out.append( _T("Profile size: ") + lpzProfileSize + _T("\r\n"));
+ out.append( _T("Profile creation date: ") + lpzProfileCreationDate + _T("\r\n"));
+ out.append( _T("Language pack: ") + lpzLangpackInfo);
+ out.append((lpzLangpackModifiedDate.size() > 0) ? _T(", modified: ") + lpzLangpackModifiedDate : _T(""));
+ out.append( _T("\r\n"));
+
+ out.append( _T("Nightly: ") + lpzNightly + _T("\r\n"));
+ out.append( _T("Unicode core: ") + lpzUnicodeBuild);
+
+ GetStringFromDatabase("BeautifyBlockEnd", _T("</blockquote>"), buffer, SIZEOF(buffer));
+ BeautifyReport(beautify, buffer, _T("\r\n"), out);
+}
+
+void CVersionInfo::AddInfoFooter(int suppressFooter, int forumStyle, int beautify, std::tstring &out)
+{
+ //End of report
+ TCHAR buffer[1024]; //for beautification purposes
+ GetStringFromDatabase("BeautifyHorizLine", _T("<hr />"), buffer, SIZEOF(buffer));
+ if (!suppressFooter) {
+ BeautifyReport(beautify, buffer, _T("\r\n"), out);
+ out.append( _T("\r\nEnd of report.\r\n"));
+ }
+
+ if (!forumStyle) {
+ if (!suppressFooter)
+ out.append( TranslateT("If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!"));
+ }
+ else {
+ TCHAR szSize[256], szQuote[256];
+ GetStringFromDatabase("SizeEnd", _T("[/size]"), szSize, SIZEOF(szSize));
+ GetStringFromDatabase("QuoteEnd", _T("[/quote]"), szQuote, SIZEOF(szQuote));
+ out.append(szSize);
+ out.append(szQuote);
+ }
+}
+
+static void AddSectionAndCount(std::list<CPlugin> list, LPCTSTR listText, std::tstring &out)
+{
+ TCHAR tmp[64];
+ wsprintf(tmp, _T(" (%u)"), list.size());
+ out.append(listText);
+ out.append( tmp );
+ out.append( _T(":"));
+}
+
+std::tstring CVersionInfo::GetInformationsAsString(int bDisableForumStyle) {
+ //Begin of report
+ std::tstring out;
+ int forumStyle = (bDisableForumStyle) ? 0 : DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", TRUE);
+ int showUUID = DBGetContactSettingByte(NULL, ModuleName, "ShowUUIDs", FALSE);
+ int beautify = DBGetContactSettingByte(NULL, ModuleName, "Beautify", 0) & (!forumStyle);
+ int suppressHeader = DBGetContactSettingByte(NULL, ModuleName, "SuppressHeader", TRUE);
+
+ DWORD flags = (forumStyle) | (showUUID << 1);
+
+ AddInfoHeader(suppressHeader, forumStyle, beautify, out);
+ TCHAR normalPluginsStart[1024]; //for beautification purposes, for normal plugins text (start)
+ TCHAR normalPluginsEnd[1024]; //for beautification purposes, for normal plugins text (end)
+ TCHAR horizLine[1024]; //for beautification purposes
+ TCHAR buffer[1024]; //for beautification purposes
+
+ TCHAR headerHighlightStart[10] = _T("");
+ TCHAR headerHighlightEnd[10] = _T("");
+ if (forumStyle) {
+ TCHAR start[128], end[128];
+ GetStringFromDatabase("BoldBegin", _T("[b]"), start, SIZEOF(start));
+ GetStringFromDatabase("BoldEnd", _T("[/b]"), end, SIZEOF(end));
+ _tcsncpy(headerHighlightStart, start, SIZEOF(headerHighlightStart));
+ _tcsncpy(headerHighlightEnd, end, SIZEOF(headerHighlightEnd));
+ }
+
+ //Plugins: list of active (enabled) plugins.
+ GetStringFromDatabase("BeautifyHorizLine", _T("<hr />"), horizLine, SIZEOF(horizLine));
+ BeautifyReport(beautify, horizLine, _T("\r\n"), out);
+ GetStringFromDatabase("BeautifyActiveHeaderBegin", _T("<b><font size=\"-1\" color=\"DarkGreen\">"), buffer, SIZEOF(buffer));
+ BeautifyReport(beautify, buffer, headerHighlightStart, out);
+ AddSectionAndCount(listActivePlugins, _T("Active Plugins"), out);
+ GetStringFromDatabase("BeautifyActiveHeaderEnd", _T("</font></b>"), buffer, SIZEOF(buffer));
+ BeautifyReport(beautify, buffer, headerHighlightEnd, out);
+ out.append( _T("\r\n"));
+
+ GetStringFromDatabase("BeautifyPluginsBegin", _T("<font size=\"-2\" color=\"black\">"), normalPluginsStart, SIZEOF(normalPluginsStart));
+ BeautifyReport(beautify, normalPluginsStart, _T(""), out);
+ out.append(GetListAsString(listActivePlugins, flags, beautify));
+ GetStringFromDatabase("BeautifyPluginsEnd", _T("</font>"), normalPluginsEnd, SIZEOF(normalPluginsEnd));
+ BeautifyReport(beautify, normalPluginsEnd, _T(""), out);
+ //Plugins: list of inactive (disabled) plugins.
+ if ((!forumStyle) && ((DBGetContactSettingByte(NULL, ModuleName, "ShowInactive", TRUE)) || (bServiceMode))) {
+ BeautifyReport(beautify, horizLine, _T("\r\n"), out);
+ GetStringFromDatabase("BeautifyInactiveHeaderBegin", _T("<b><font size=\"-1\" color=\"DarkRed\">"), buffer, SIZEOF(buffer));
+ BeautifyReport(beautify, buffer, headerHighlightStart, out);
+ AddSectionAndCount(listInactivePlugins, _T("Inactive Plugins"), out);
+ GetStringFromDatabase("BeautifyInactiveHeaderEnd", _T("</font></b>"), buffer, SIZEOF(buffer));
+ BeautifyReport(beautify, buffer, headerHighlightEnd, out);
+ out.append( _T("\r\n"));
+ BeautifyReport(beautify, normalPluginsStart, _T(""), out);
+ out.append(GetListAsString(listInactivePlugins, flags, beautify));
+ BeautifyReport(beautify, normalPluginsEnd, _T(""), out);
+ }
+ if (listUnloadablePlugins.size() > 0) {
+ BeautifyReport(beautify, horizLine, _T("\r\n"), out);
+ GetStringFromDatabase("BeautifyUnloadableHeaderBegin", _T("<b><font size=\"-1\"><font color=\"Red\">"), buffer, SIZEOF(buffer));
+ BeautifyReport(beautify, buffer, headerHighlightStart, out);
+ AddSectionAndCount(listUnloadablePlugins, _T("Unloadable Plugins"), out);
+ GetStringFromDatabase("BeautifyUnloadableHeaderEnd", _T("</font></b>"), buffer, SIZEOF(buffer));
+ BeautifyReport(beautify, buffer, headerHighlightEnd, out);
+ out.append( _T("\r\n"));
+ BeautifyReport(beautify, normalPluginsStart, _T(""), out);
+ out.append(GetListAsString(listUnloadablePlugins, flags, beautify));
+ BeautifyReport(beautify, normalPluginsEnd, _T(""), out);
+ }
+ AddInfoFooter(suppressHeader, forumStyle, beautify, out);
+ return out;
+}
+
+//========== Print functions =====
+
+void CVersionInfo::PrintInformationsToFile(const TCHAR *info)
+{
+ TCHAR buffer[MAX_PATH], outputFileName[MAX_PATH];
+ if (bFoldersAvailable) {
+ FoldersGetCustomPathT(hOutputLocation, buffer, SIZEOF(buffer), _T("%miranda_path%"));
+ _tcscat(buffer, _T("\\VersionInfo.txt"));
+ }
+ else GetStringFromDatabase("OutputFile", _T("VersionInfo.txt"), buffer, SIZEOF(buffer));
+
+ RelativePathToAbsolute(buffer, outputFileName, SIZEOF(buffer));
+
+ FILE *fp = _tfopen(outputFileName, _T("wb"));
+ if ( fp != NULL ) {
+ char* utf = mir_utf8encodeT( info );
+ fputs( "\xEF\xBB\xBF", fp);
+ fputs( utf, fp );
+ fclose(fp);
+
+ TCHAR mex[512];
+ mir_sntprintf(mex, SIZEOF(mex), TranslateT("Information successfully written to file: \"%s\"."), outputFileName);
+ Log(mex);
+ }
+ else {
+ TCHAR mex[512];
+ mir_sntprintf(mex, SIZEOF(mex), TranslateT("Error during the creation of file \"%s\". Disk may be full or write protected."), outputFileName);
+ Log(mex);
+ }
+}
+
+void CVersionInfo::PrintInformationsToFile()
+{
+ PrintInformationsToFile( GetInformationsAsString().c_str());
+}
+
+void CVersionInfo::PrintInformationsToMessageBox()
+{
+ MessageBox(NULL, GetInformationsAsString().c_str(), _T("VersionInfo"), MB_OK);
+}
+
+void CVersionInfo::PrintInformationsToOutputDebugString()
+{
+ OutputDebugString( GetInformationsAsString().c_str());
+}
+
+
+void CVersionInfo::PrintInformationsToDialogBox()
+{
+ HWND DialogBox = CreateDialogParam(hInst,
+ MAKEINTRESOURCE(IDD_DIALOGINFO),
+ NULL, DialogBoxProc, (LPARAM) this);
+
+ SetDlgItemText(DialogBox, IDC_TEXT, GetInformationsAsString().c_str());
+}
+
+void CVersionInfo::PrintInformationsToClipboard(bool showLog)
+{
+ if (GetOpenClipboardWindow()) {
+ Log( TranslateT("The clipboard is not available, retry."));
+ return;
+ }
+
+ OpenClipboard(NULL);
+ //Ok, let's begin, then.
+ EmptyClipboard();
+ //Storage data we'll use.
+ LPTSTR lptstrCopy;
+ std::tstring aux = GetInformationsAsString();
+ size_t length = aux.length() + 1;
+ HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, length*sizeof(TCHAR) + 5);
+ //Lock memory, copy it, release it.
+ lptstrCopy = (LPTSTR)GlobalLock(hData);
+ lstrcpy(lptstrCopy, aux.c_str());
+ lptstrCopy[length] = '\0';
+ GlobalUnlock(hData);
+ //Now set the clipboard data.
+
+ SetClipboardData(CF_UNICODETEXT, hData);
+
+ //Remove the lock on the clipboard.
+ CloseClipboard();
+ if (showLog)
+ Log( TranslateT("Information successfully copied into clipboard."));
+}
diff --git a/plugins/VersionInfo/src/CVersionInfo.h b/plugins/VersionInfo/src/CVersionInfo.h
new file mode 100644
index 0000000000..eb55b808fc
--- /dev/null
+++ b/plugins/VersionInfo/src/CVersionInfo.h
@@ -0,0 +1,115 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CVERSIONINFO_H
+#define CVERSIONINFO_H
+
+//#define STRICT
+#define WIN32_LEAN_AND_MEAN
+//#include "AggressiveOptimize.h"
+
+#define _CRT_SECURE_NO_DEPRECATE
+
+#ifndef PF_NX_ENABLED
+ #define PF_NX_ENABLED 12
+#endif
+
+#include <list>
+#include <string>
+//using namespace std;
+
+#include "CPlugin.h"
+
+class CVersionInfo
+{
+ private:
+ //Informations related to Miranda: main informations.
+ std::tstring lpzMirandaVersion;
+ std::tstring lpzMirandaPath;
+ std::tstring lpzProfilePath;
+ std::tstring lpzProfileSize;
+ std::tstring lpzProfileCreationDate;
+ std::tstring lpzNightly;
+ std::tstring lpzUnicodeBuild;
+ std::tstring lpzCPUName;
+ std::tstring lpzCPUIdentifier;
+ std::tstring lpzBuildTime;
+ std::tstring lpzShell;
+ std::tstring lpzIEVersion;
+ std::tstring lpzAdministratorPrivileges;
+ std::tstring lpzOSLanguages;
+ std::tstring lpzLangpackInfo;
+ std::tstring lpzLangpackModifiedDate;
+ //Informations related to plugins
+ std::list<CPlugin> listActivePlugins;
+ std::list<CPlugin> listInactivePlugins;
+ std::list<CPlugin> listUnloadablePlugins;
+ //OS and hardware informations.
+ std::tstring lpzOSVersion;
+ std::tstring lpzOSName;
+ unsigned int luiProcessors;
+ unsigned int luiRAM;
+ unsigned int luiFreeDiskSpace;
+ int bDEPEnabled;
+ BOOL bIsWOW64;
+ //Additional Miranda informations.
+ unsigned int luiContacts;
+ unsigned int luiEvents;
+ unsigned int luiUnreadEvents;
+ unsigned int luiDBSize;
+ bool bExpertSettingsOn;
+ //Configuration
+
+ bool GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules);
+
+ public:
+ //Constructor/Destructor
+ CVersionInfo();
+ ~CVersionInfo();
+ void Initialize();
+ //Miranda informations
+ bool GetMirandaVersion();
+ bool GetProfileSettings();
+ bool GetOSLanguages();
+ bool GetLangpackInfo();
+ bool GetPluginLists();
+ bool GetEventCount(); //TODO
+ //OSInformations
+ bool GetOSVersion();
+ bool GetHWSettings();
+ //Plugins
+ bool AddPlugin(CPlugin&, std::list<CPlugin>&);
+ //Prints
+
+ void PrintInformationsToFile();
+ void PrintInformationsToFile(const TCHAR *info);
+ void PrintInformationsToDialogBox();
+ void PrintInformationsToMessageBox();
+ void PrintInformationsToOutputDebugString();
+ void PrintInformationsToClipboard(bool);
+
+ std::tstring GetListAsString(std::list<CPlugin>&, DWORD flags, int beautify);
+ std::tstring GetInformationsAsString(int bDisableForumStyle = 0);
+ void BeautifyReport(int, LPCTSTR, LPCTSTR, std::tstring &);
+ void AddInfoHeader(int, int, int, std::tstring &);
+ void AddInfoFooter(int, int, int, std::tstring &);
+};
+
+#endif \ No newline at end of file
diff --git a/plugins/VersionInfo/src/common.h b/plugins/VersionInfo/src/common.h
new file mode 100644
index 0000000000..3182abc660
--- /dev/null
+++ b/plugins/VersionInfo/src/common.h
@@ -0,0 +1,96 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_VERSIONINFO_COMMON_H
+#define M_VERSIONINFO_COMMON_H
+
+#pragma warning(disable:4005)
+#define _CRT_SECURE_NO_DEPRECATE
+#pragma warning(default:4005)
+
+#define VIPF_NONE 0x0000
+#define VIPF_UNCERTAIN 0x0010
+
+#define VISF_FORUMSTYLE 0x0001
+#define VISF_SHOWUUID 0x0002
+#define VISF_SHOWFLAGS 0x0004
+
+#include <windows.h>
+#include <time.h>
+
+#include <commctrl.h>
+#include <list>
+#include <imagehlp.h>
+#include <winsock.h>
+
+#include <String>
+//using namespace std;
+
+#include "version.h"
+
+#include "m_versioninfo.h"
+#include "hooked_events.h"
+#include "services.h"
+#include "dlgHandlers.h"
+
+#include "newpluginapi.h"
+#include "m_system.h"
+#include "m_langpack.h"
+#include "m_database.h"
+#include "m_skin.h"
+#include "m_clist.h"
+#include "m_options.h"
+#include "m_popup.h"
+
+#include "m_utils.h"
+#include "m_folders.h"
+#include "win2k.h"
+
+#include "utils.h"
+
+#ifndef MS_DB_GETPROFILEPATH_BASIC //db3xSA
+#define MS_DB_GETPROFILEPATH_BASIC "DB/GetProfilePathBasic"
+#endif
+
+//main.cpp
+extern HINSTANCE hInst;
+
+//main.cpp
+extern HICON hiVIIcon;
+
+//main.cpp
+extern DWORD EnglishLocale;
+
+//for folders support
+extern BOOL bFoldersAvailable;
+extern HANDLE hOutputLocation;
+
+//services.cpp
+extern int bServiceMode;
+
+//main.cpp
+extern char ModuleName[];
+extern BOOL verbose;
+
+#define DEFAULT_UPLOAD_PORT 51234
+
+const MUUID UUID_NULL = {0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }};
+
+#endif \ No newline at end of file
diff --git a/plugins/VersionInfo/src/dlgHandlers.cpp b/plugins/VersionInfo/src/dlgHandlers.cpp
new file mode 100644
index 0000000000..a1a81e6a51
--- /dev/null
+++ b/plugins/VersionInfo/src/dlgHandlers.cpp
@@ -0,0 +1,589 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+#include "dlgHandlers.h"
+
+const char *szQuoteStrings[] = {"[quote] | [/quote]", "[code] | [/code]", ""};
+const char *szSizeStrings[] = {"[size=1] | [/size]", "[size=1px] | [/size]", "[size=12] | [/size]", "[size=80] | [/size]", ""};
+const char *szBoldStrings[] = {"[b] | [/b]", "[u] | [/u]", "[b][u] | [/u][/b]", "<b> | </b>", "<u> | </u>", "<b><u> | </u></b>"};
+const int nQuoteCount = SIZEOF(szQuoteStrings); //get the number of quote strings
+const int nSizeCount = SIZEOF(szSizeStrings); //get the number of size strings
+const int nBoldCount = SIZEOF(szBoldStrings); //get the number of bold strings
+
+#define MAX_TEXT 4096*4
+
+int AddInfoToComboboxes(HWND hWnd, int nQuotesComboBox, int nSizesComboBox, int nBoldComboBox)
+{
+ int i;
+ for (i = 0; i < nQuoteCount; i++)
+ SendDlgItemMessageA(hWnd, nQuotesComboBox, CB_ADDSTRING, 0, (LPARAM) szQuoteStrings[i]);
+
+ for (i = 0; i < nSizeCount; i++)
+ SendDlgItemMessageA(hWnd, nSizesComboBox, CB_ADDSTRING, 0, (LPARAM) szSizeStrings[i]);
+
+ for (i = 0; i < nBoldCount; i++)
+ SendDlgItemMessageA(hWnd, nBoldComboBox, CB_ADDSTRING, 0, (LPARAM) szBoldStrings[i]);
+
+ return 0;
+}
+
+void EnableAskComboboxes(HWND hWnd, int bEnable)
+{
+ EnableWindow(GetDlgItem(hWnd, IDC_ASK_BOLDCOMBOBOX), bEnable);
+ EnableWindow(GetDlgItem(hWnd, IDC_ASK_QUOTECOMBOBOX), bEnable);
+ EnableWindow(GetDlgItem(hWnd, IDC_ASK_SIZECOMBOBOX), bEnable);
+}
+
+INT_PTR CALLBACK AskDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ const int MAX_SIZE = 128;
+ static int oldFSFValue;
+ static TCHAR oldQuoteBegin[MAX_SIZE], oldQuoteEnd[MAX_SIZE];
+ static TCHAR oldSizeBegin[MAX_SIZE], oldSizeEnd[MAX_SIZE];
+ static TCHAR oldBoldBegin[MAX_SIZE], oldBoldEnd[MAX_SIZE];
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiVIIcon);
+
+ TranslateDialogDefault(hWnd);
+
+ oldFSFValue = DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", 1);
+
+ AddInfoToComboboxes(hWnd, IDC_ASK_QUOTECOMBOBOX, IDC_ASK_SIZECOMBOBOX, IDC_ASK_BOLDCOMBOBOX);
+
+ CheckDlgButton(hWnd, IDC_ASK_TODIALOGBOX, BST_CHECKED);
+
+ CheckDlgButton(hWnd, IDC_ASK_FORUMSTYLE, (oldFSFValue) ? BST_CHECKED : BST_UNCHECKED);
+ EnableAskComboboxes(hWnd, oldFSFValue);
+ {
+ TCHAR buffer[1024];
+ GetStringFromDatabase("QuoteBegin", _T("[quote]"), oldQuoteBegin, MAX_SIZE);
+ GetStringFromDatabase("QuoteEnd", _T("[/quote]"), oldQuoteEnd, MAX_SIZE);
+ mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldQuoteBegin, oldQuoteEnd);
+ SendDlgItemMessage(hWnd, IDC_ASK_QUOTECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer);
+
+ GetStringFromDatabase("SizeBegin", _T("[size=1]"), oldSizeBegin, MAX_SIZE);
+ GetStringFromDatabase("SizeEnd", _T("[/size]"), oldSizeEnd, MAX_SIZE);
+ mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldSizeBegin, oldSizeEnd);
+ SendDlgItemMessage(hWnd, IDC_ASK_SIZECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer);
+
+ GetStringFromDatabase("BoldBegin", _T("[b]"), oldBoldBegin, MAX_SIZE);
+ GetStringFromDatabase("BoldEnd", _T("[/b]"), oldBoldEnd, MAX_SIZE);
+ mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldBoldBegin, oldBoldEnd);
+ SendDlgItemMessage(hWnd, IDC_ASK_BOLDCOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer);
+ }
+
+ return TRUE;
+
+ case WM_CLOSE:
+ DestroyWindow(hWnd);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_ASK_FORUMSTYLE:
+ EnableAskComboboxes(hWnd, IsDlgButtonChecked(hWnd, IDC_ASK_FORUMSTYLE));
+ break;
+
+ case IDC_ASK_CANCEL:
+ DestroyWindow(hWnd);
+ break;
+
+ case IDC_ASK_OK:
+ TCHAR quoteBegin[MAX_SIZE], quoteEnd[MAX_SIZE];
+ TCHAR sizeBegin[MAX_SIZE], sizeEnd[MAX_SIZE];
+ TCHAR boldBegin[MAX_SIZE], boldEnd[MAX_SIZE];
+ TCHAR buffer[1024];
+
+ SendDlgItemMessage(hWnd, IDC_ASK_QUOTECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer);
+ SplitStringInfo(buffer, quoteBegin, quoteEnd);
+ SendDlgItemMessage(hWnd, IDC_ASK_SIZECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer);
+ SplitStringInfo(buffer, sizeBegin, sizeEnd);
+ SendDlgItemMessage(hWnd, IDC_ASK_BOLDCOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer);
+ SplitStringInfo(buffer, boldBegin, boldEnd);
+
+ int newFSFValue = IsDlgButtonChecked(hWnd, IDC_ASK_FORUMSTYLE);
+ if (newFSFValue != oldFSFValue)
+ DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", newFSFValue); //temporary store the new value
+
+ if (newFSFValue) {
+ DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", quoteBegin);
+ DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", quoteEnd);
+
+ DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", sizeBegin);
+ DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", sizeEnd);
+
+ DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", boldBegin);
+ DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", boldEnd);
+ }
+
+ int debugTo = TO_DIALOGBOX; //just to be safe
+ if (IsDlgButtonChecked(hWnd, IDC_ASK_TOFILE))
+ debugTo = TO_FILE;
+ if (IsDlgButtonChecked(hWnd, IDC_ASK_TOMESSAGEBOX))
+ debugTo = TO_MESSAGEBOX;
+ if (IsDlgButtonChecked(hWnd, IDC_ASK_TODIALOGBOX))
+ debugTo = TO_DIALOGBOX;
+ if (IsDlgButtonChecked(hWnd, IDC_ASK_TOOUTPUTDEBUGSTRING))
+ debugTo = TO_DEBUGSTRING;
+ if (IsDlgButtonChecked(hWnd, IDC_ASK_TOCLIPBOARD))
+ debugTo = TO_CLIPBOARD;
+ if (IsDlgButtonChecked(hWnd, IDC_ASK_TOUPLOAD))
+ debugTo = TO_UPLOAD;
+
+ DoDebugTo(debugTo);
+
+ if (newFSFValue != oldFSFValue)
+ DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", oldFSFValue);
+
+ if (newFSFValue) {
+ DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", oldQuoteBegin);
+ DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", oldQuoteEnd);
+
+ DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", oldSizeBegin);
+ DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", oldSizeEnd);
+
+ DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", oldBoldBegin);
+ DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", oldBoldEnd);
+ }
+
+ DestroyWindow(hWnd);
+ break;
+ }
+ break;
+ }
+ return 0;
+}
+
+int DoDebugTo(int debugTo)
+{
+ HWND parent = NULL;
+ HWND askDialog;
+ CVersionInfo myInfo;// = CVersionInfo();
+ if (verbose) PUShowMessage("I am going to read the information.", SM_NOTIFY);
+ if (debugTo != TO_ASK)
+ myInfo.Initialize();
+
+ if (verbose) PUShowMessage("I have read the information, I will now print them.", SM_NOTIFY);
+
+ switch(debugTo) {
+ case TO_ASK:
+ askDialog = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ASKDIALOG), parent, AskDlgProc);
+ ShowWindow(askDialog, SW_SHOW);
+ break;
+
+ case TO_FILE:
+ myInfo.PrintInformationsToFile();
+ break;
+
+ case TO_MESSAGEBOX:
+ myInfo.PrintInformationsToMessageBox();
+ break;
+
+ case TO_DIALOGBOX:
+ myInfo.PrintInformationsToDialogBox();
+ break;
+
+ case TO_DEBUGSTRING:
+ myInfo.PrintInformationsToOutputDebugString();
+ break;
+
+ case TO_CLIPBOARD:
+ myInfo.PrintInformationsToClipboard(true);
+ break;
+
+ default:
+ myInfo.PrintInformationsToFile();
+ break;
+ }
+
+ if ((debugTo != TO_CLIPBOARD) && (DBGetContactSettingByte(NULL, ModuleName, "ClipboardAlways", FALSE)))
+ myInfo.PrintInformationsToClipboard(false);
+
+ if ((bServiceMode) && (debugTo != TO_DIALOGBOX) && (debugTo != TO_ASK)) //close miranda if in service mode and no dialog was shown
+ PostQuitMessage(0);
+
+ return 0;
+}
+
+void EnableUploadSettings(HWND hWnd, int bEnable)
+{
+ EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_SERVER), bEnable);
+ EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_PORT), bEnable);
+ EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), bEnable);
+ EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), bEnable);
+}
+
+INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static int bOptionsInitializing = 0;
+ switch(msg) {
+ case WM_INITDIALOG:
+ bOptionsInitializing = 1;
+ TranslateDialogDefault(hWnd);
+ AddInfoToComboboxes(hWnd, IDC_QUOTECOMBOBOX, IDC_SIZECOMBOBOX, IDC_BOLDCOMBOBOX);
+
+ CheckDlgButton(hWnd, IDC_FORUMSTYLE, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", TRUE) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_DISABLEDTOO, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInactive", TRUE) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_SHOWUUIDS, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowUUIDs", FALSE) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_SHOWINSTALLEDLANGUAGES, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", FALSE) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_SUPPRESSHEADER, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "SuppressHeader", TRUE) ? BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hWnd, IDC_SHOWINTASKBAR, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInTaskbar", TRUE) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CLIPBOARDALSO, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ClipboardAlways", FALSE) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_BOLDVERSION, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CHECKUNLOADABLE, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "CheckForDependencies", TRUE) ? BST_CHECKED : BST_UNCHECKED);
+ SetFocus(GetDlgItem(hWnd, IDC_FORUMSTYLE));
+ {
+ DBVARIANT dbv = { 0 };
+ bOptionsInitializing = 1;
+ TCHAR buffer[1024];
+ TCHAR notFound[1024];
+
+ if (DBGetContactSettingTString(NULL, ModuleName, "OutputFile", &dbv) == 0)
+ RelativePathToAbsolute(dbv.ptszVal, notFound, SIZEOF(notFound));
+ else
+ RelativePathToAbsolute( _T("VersionInfo.txt"), notFound, SIZEOF(notFound));
+
+ if (bFoldersAvailable)
+ _tcscpy(buffer, TranslateT("Customize using folders plugin"));
+ else
+ _tcsncpy(buffer, notFound, SIZEOF(notFound));
+
+ SetDlgItemText(hWnd, IDC_FILENAME, buffer);
+
+ TCHAR start[256], end[256];
+ GetStringFromDatabase("QuoteBegin", _T("[quote]"), start, SIZEOF(start));
+ GetStringFromDatabase("QuoteEnd", _T("[/quote]"), end, SIZEOF(end));
+ mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end);
+ SendDlgItemMessage(hWnd, IDC_QUOTECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer);
+
+ GetStringFromDatabase("SizeBegin", _T("[size=1]"), start, SIZEOF(start));
+ GetStringFromDatabase("SizeEnd", _T("[/size]"), end, SIZEOF(end));
+ mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end);
+ SendDlgItemMessage(hWnd, IDC_SIZECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer);
+
+ GetStringFromDatabase("BoldBegin", _T("[b]"), start, SIZEOF(start));
+ GetStringFromDatabase("BoldEnd", _T("[/b]"), end, SIZEOF(end));
+ mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end);
+ SendDlgItemMessage(hWnd, IDC_BOLDCOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer);
+ //to add stuff
+
+ //upload server settings
+ GetStringFromDatabase("UploadServer", _T("vi.cass.cz"), buffer, SIZEOF(buffer));
+ SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_SERVER), buffer);
+
+ int port = DBGetContactSettingWord(NULL, ModuleName, "UploadPort", DEFAULT_UPLOAD_PORT);
+ _itot(port, buffer, 10);
+ SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PORT), buffer);
+
+ GetStringFromDatabase("UploadUser", _T(""), buffer, SIZEOF(buffer));
+ SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), buffer);
+
+ GetStringFromDatabase("UploadPassword", _T(""), buffer, SIZEOF(buffer));
+ CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(buffer), (LPARAM) buffer);
+ SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), buffer);
+ }
+
+ switch(DBGetContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX)) {
+ case TO_FILE:
+ CheckDlgButton(hWnd, IDC_TOFILE, BST_CHECKED);
+ break;
+
+ case TO_MESSAGEBOX:
+ CheckDlgButton(hWnd, IDC_TOMESSAGEBOX, BST_CHECKED);
+ break;
+
+ case TO_DIALOGBOX:
+ CheckDlgButton(hWnd, IDC_TODIALOGBOX, BST_CHECKED);
+ break;
+
+ case TO_DEBUGSTRING:
+ CheckDlgButton(hWnd, IDC_TODEBUGSTRING, BST_CHECKED);
+ break;
+
+ case TO_CLIPBOARD:
+ CheckDlgButton(hWnd, IDC_TOCLIPBOARD, BST_CHECKED);
+ break;
+
+ case TO_UPLOAD:
+ CheckDlgButton(hWnd, IDC_TOUPLOAD, BST_CHECKED);
+ break;
+
+ case TO_ASK:
+ CheckDlgButton(hWnd, IDC_ASKEVERYTIME, BST_CHECKED);
+ break;
+
+ default:
+ CheckDlgButton(hWnd, IDC_TODIALOGBOX, BST_CHECKED);
+ break;
+ }
+
+ EnableWindow(GetDlgItem(hWnd, IDC_QUOTECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only
+ EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only
+ EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only
+ EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE);//both forum style and bold version checked
+ EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box
+ EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins
+ EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard
+ EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE);
+ EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE);
+ {
+ OSVERSIONINFO osvi = { 0 };
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+
+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
+ EnableWindow(GetDlgItem(hWnd, IDC_CHECKUNLOADABLE), FALSE);
+ }
+
+ CheckDlgButton(hWnd, IDC_DEBUG, (BOOL) verbose == TRUE ? BST_CHECKED : BST_UNCHECKED);
+
+ SetFocus(GetDlgItem(hWnd, IDC_GETINFONOW));
+
+ bOptionsInitializing = 0;
+ break;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_ASKEVERYTIME:
+ case IDC_TOFILE:
+ case IDC_TOMESSAGEBOX:
+ case IDC_TODIALOGBOX:
+ case IDC_TODEBUGSTRING:
+ case IDC_TOCLIPBOARD:
+ case IDC_TOUPLOAD:
+ case IDC_FORUMSTYLE:
+ case IDC_BOLDVERSION:
+ EnableWindow(GetDlgItem(hWnd, IDC_QUOTECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only
+ EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only
+ EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only
+ EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE); //both forum style and bold version checked
+ EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE);
+ EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box
+ EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins
+ EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard
+ EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE);
+
+ case IDC_SHOWUUIDS:
+ if (IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) && MessageBox(hWnd,
+ TranslateT("Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it."),
+ TranslateT("Show plugin UUIDs ?"), MB_YESNO | MB_ICONWARNING) == IDNO)
+ {
+ CheckDlgButton(hWnd, IDC_SHOWUUIDS, FALSE);
+
+ break;
+ }//else fallthrough
+ case IDC_DISABLEDTOO:
+ case IDC_SHOWINTASKBAR:
+ case IDC_CLIPBOARDALSO:
+ case IDC_CHECKUNLOADABLE:
+ case IDC_SUPPRESSHEADER:
+ case IDC_SHOWINSTALLEDLANGUAGES:
+ EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), FALSE);
+
+ case IDC_QUOTECOMBOBOX:
+ case IDC_SIZECOMBOBOX:
+ case IDC_BOLDCOMBOBOX:
+ if (!bOptionsInitializing)
+ SendMessage(GetParent(hWnd), PSM_CHANGED,0,0);
+ break;
+
+ case IDC_FILENAME:
+ case IDC_UPLOAD_USERNAME:
+ case IDC_UPLOAD_PASSWORD:
+ case IDC_UPLOAD_PORT:
+ case IDC_UPLOAD_SERVER:
+ if ( HIWORD(wParam) == EN_CHANGE && !bOptionsInitializing) {
+ SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
+ EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), FALSE);
+ }
+ break;
+
+ case IDC_GETINFONOW:
+ //Call the plugin menu command routine.
+ PluginMenuCommand(0,0);
+ break;
+
+ case IDC_DEBUG:
+ verbose = !verbose;
+ break;
+ }
+
+ break;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ {
+ TCHAR buffer[1024];
+ TCHAR start[256], end[256];
+ SendDlgItemMessage(hWnd, IDC_QUOTECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer);
+ SplitStringInfo(buffer, start, end);
+ DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", start);
+ DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", end);
+ SendDlgItemMessage(hWnd, IDC_SIZECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer);
+ SplitStringInfo(buffer, start, end);
+ DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", start);
+ DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", end);
+ SendDlgItemMessage(hWnd, IDC_BOLDCOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer);
+ SplitStringInfo(buffer, start, end);
+ DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", start);
+ DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", end);
+ }
+
+ DBWriteContactSettingByte(NULL, ModuleName, "CheckForDependencies", IsDlgButtonChecked(hWnd, IDC_CHECKUNLOADABLE) ? TRUE : FALSE);
+ DBWriteContactSettingByte(NULL, ModuleName, "BoldVersionNumber", IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) ? TRUE : FALSE);
+ DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE);
+ DBWriteContactSettingByte(NULL, ModuleName, "ClipboardAlways", IsDlgButtonChecked(hWnd, IDC_CLIPBOARDALSO) ? TRUE : FALSE);
+ DBWriteContactSettingByte(NULL, ModuleName, "SuppressHeader", IsDlgButtonChecked(hWnd, IDC_SUPPRESSHEADER) ? TRUE : FALSE);
+ DBWriteContactSettingByte(NULL, ModuleName, "ShowUUIDs", IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) ? TRUE : FALSE);
+ DBWriteContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", IsDlgButtonChecked(hWnd, IDC_SHOWINSTALLEDLANGUAGES) ? TRUE : FALSE);
+
+ if (!bFoldersAvailable) {
+ TCHAR filePath[MAX_PATH], fileName[MAX_PATH];
+ GetDlgItemText(hWnd, IDC_FILENAME, fileName, MAX_PATH);
+ AbsolutePathToRelative(fileName, filePath, SIZEOF(filePath));
+
+ DBWriteContactSettingTString(NULL, ModuleName, "OutputFile", filePath); //store relative path
+ }
+ DBWriteContactSettingByte(NULL, ModuleName, "ShowInTaskbar", IsDlgButtonChecked(hWnd, IDC_SHOWINTASKBAR) ? TRUE : FALSE);
+ //Debug to:
+ if (IsDlgButtonChecked(hWnd, IDC_TOFILE))
+ DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_FILE);
+ else if (IsDlgButtonChecked(hWnd, IDC_TOMESSAGEBOX))
+ DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_MESSAGEBOX);
+ else if (IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX))
+ DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX);
+ else if (IsDlgButtonChecked(hWnd, IDC_TODEBUGSTRING))
+ DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_DEBUGSTRING);
+ else if (IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD))
+ DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_CLIPBOARD);
+ else if (IsDlgButtonChecked(hWnd, IDC_TOUPLOAD))
+ DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_UPLOAD);
+ else if (IsDlgButtonChecked(hWnd, IDC_ASKEVERYTIME))
+ DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_ASK);
+
+ EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), TRUE);
+ //Disabled plugins too?
+ DBWriteContactSettingByte(NULL, ModuleName, "ShowInactive", IsDlgButtonChecked(hWnd, IDC_DISABLEDTOO)?TRUE:FALSE);
+
+ GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK);
+ } }
+
+ break;
+ }
+ return 0;
+}
+
+INT_PTR CALLBACK DialogBoxProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static CVersionInfo *myInfo = NULL;
+ switch(msg) {
+ case WM_INITDIALOG:
+ SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiVIIcon);
+
+ myInfo = (CVersionInfo *) lParam;
+ if (DBGetContactSettingByte(NULL, ModuleName, "ShowInTaskbar", TRUE)) {
+ DWORD ws;
+ ws = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
+ SetWindowLongPtr(hWnd, GWL_EXSTYLE, ws | WS_EX_APPWINDOW);
+ //SetWindowLongPtr(hWnd, GWL_STYLE, ws | WS_DLGFRAME | WS_POPUPWINDOW);
+ }
+
+ TranslateDialogDefault(hWnd);
+ {
+ DBVARIANT dbv = { 0 };
+ LOGFONT lf = { 0 };
+
+ dbv.type = DBVT_BLOB;
+ if (DBGetContactSetting(NULL, "OptionFont", "Font", &dbv) == 0)
+ lf=*(LOGFONT*)dbv.pbVal;
+ else {
+ HFONT hFont = (HFONT)SendDlgItemMessage(hWnd,IDC_CLOSE,WM_GETFONT,0,0);
+ GetObject(hFont,sizeof(lf),&lf);
+ }
+ SendDlgItemMessage(hWnd,IDC_TEXT,WM_SETFONT,(WPARAM)CreateFontIndirect(&lf),0);
+ }
+
+ return TRUE;
+
+ case WM_CLOSE:
+ DestroyWindow(hWnd);
+ break;
+
+ case WM_COMMAND: {
+ switch(LOWORD(wParam)) {
+ case IDC_CLOSE:
+ DestroyWindow(hWnd);
+ break;
+
+ case IDC_COPYTEXT:
+ SetLastError(0);
+ if (GetOpenClipboardWindow())
+ Log( TranslateT("The clipboard is not available, retry."));
+ else {
+ OpenClipboard(hWnd);
+ //Ok, let's begin, then.
+ EmptyClipboard();
+ //Storage data we'll use.
+ TCHAR text[MAX_TEXT];
+ LPTSTR lptstrCopy;
+ GetDlgItemText(hWnd, IDC_TEXT, text, MAX_TEXT);
+ int length = lstrlen(text) + 1;
+ HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, (length + 5)*sizeof( TCHAR ));
+ //Lock memory, copy it, release it.
+ lptstrCopy = (LPTSTR)GlobalLock(hData);
+ lstrcpyn(lptstrCopy, text, length);
+ lptstrCopy[length] = '\0';
+ GlobalUnlock(hData);
+ //Now set the clipboard data.
+
+ SetClipboardData(CF_UNICODETEXT, hData);
+
+ //Remove the lock on the clipboard.
+ CloseClipboard();
+ }
+
+ break;
+
+ case IDC_SAVETOFILE:
+ TCHAR text[MAX_TEXT];
+ GetDlgItemText(hWnd, IDC_TEXT, text, MAX_TEXT);
+ myInfo->PrintInformationsToFile(text);
+ break;
+ }
+
+ break;
+ }
+ case WM_DESTROY:
+ DeleteObject((HFONT)SendDlgItemMessage(hWnd,IDC_TEXT,WM_GETFONT,0,0));
+ myInfo = NULL;
+ if (bServiceMode) //close miranda if in service mode
+ PostQuitMessage(0);
+
+ break;
+ }
+ return 0;
+}
diff --git a/plugins/VersionInfo/src/dlgHandlers.h b/plugins/VersionInfo/src/dlgHandlers.h
new file mode 100644
index 0000000000..bab1876ea2
--- /dev/null
+++ b/plugins/VersionInfo/src/dlgHandlers.h
@@ -0,0 +1,43 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_VERSIONINFO_DLGHEADERS_H
+#define M_VERSIONINFO_DLGHEADERS_H
+
+#include "resource.h"
+#include "CVersionInfo.h"
+
+#define TO_ASK 0
+#define TO_FILE 1
+#define TO_MESSAGEBOX 2
+#define TO_DIALOGBOX 3
+#define TO_DEBUGSTRING 4
+#define TO_CLIPBOARD 5
+#define TO_UPLOAD 6
+
+extern INT_PTR PluginMenuCommand(WPARAM, LPARAM);
+extern INT_PTR OptionsInitialise(WPARAM, LPARAM);
+
+
+int DoDebugTo(int debugTo);
+INT_PTR CALLBACK AskDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DialogBoxProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+#endif \ No newline at end of file
diff --git a/plugins/VersionInfo/src/hooked_events.cpp b/plugins/VersionInfo/src/hooked_events.cpp
new file mode 100644
index 0000000000..77d72e6a97
--- /dev/null
+++ b/plugins/VersionInfo/src/hooked_events.cpp
@@ -0,0 +1,80 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+#include "hooked_events.h"
+
+HANDLE hModulesLoaded;
+HANDLE hOptionsInitialize;
+
+#define HOST "http://eblis.tla.ro/projects"
+
+#define VERSIONINFO_VERSION_URL HOST "/miranda/VersionInfo/updater/VersionInfo.html"
+#define VERSIONINFO_UPDATE_URL HOST "/miranda/VersionInfo/updater/VersionInfo.zip"
+#define VERSIONINFO_VERSION_PREFIX "Version Information version "
+
+int HookEvents()
+{
+ hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise);
+ //hPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);
+
+ return 0;
+}
+
+int UnhookEvents()
+{
+ UnhookEvent(hModulesLoaded);
+ UnhookEvent(hOptionsInitialize);
+
+ return 0;
+}
+
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
+{
+
+ bFoldersAvailable = ServiceExists(MS_FOLDERS_REGISTER_PATH);
+ hOutputLocation = FoldersRegisterCustomPathT("VersionInfo", "Output folder", _T("%miranda_path%"));
+
+ GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK);
+ return 0;
+}
+
+static UINT uiExpertOnlyControls[] = { IDC_SHOWUUIDS, IDC_SHOWINSTALLEDLANGUAGES };
+
+int OnOptionsInitialise(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+ odp.cbSize = sizeof(odp);
+ odp.position = 100000000;
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_VERSIONINFO);
+ odp.pszTitle = LPGEN("Version Information");
+ odp.pszGroup = LPGEN("Services");
+ odp.groupPosition = 910000000;
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pfnDlgProc = DlgProcOpts;
+ odp.expertOnlyControls = uiExpertOnlyControls;
+ odp.nExpertOnlyControls = SIZEOF(uiExpertOnlyControls);
+
+ Options_AddPage(wParam, &odp);
+
+ return 0;
+} \ No newline at end of file
diff --git a/plugins/VersionInfo/src/hooked_events.h b/plugins/VersionInfo/src/hooked_events.h
new file mode 100644
index 0000000000..b75b5e59a8
--- /dev/null
+++ b/plugins/VersionInfo/src/hooked_events.h
@@ -0,0 +1,33 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_VERSIONINFO_HOOKED_EVENTS_H
+#define M_VERSIONINFO_HOOKED_EVENTS_H
+
+extern HANDLE hModulesLoaded;
+extern HANDLE hOptionsInitialise;
+
+int HookEvents();
+int UnhookEvents();
+
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam);
+int OnOptionsInitialise(WPARAM wParam, LPARAM lParam);
+
+#endif \ No newline at end of file
diff --git a/plugins/VersionInfo/src/main.cpp b/plugins/VersionInfo/src/main.cpp
new file mode 100644
index 0000000000..53c75be86f
--- /dev/null
+++ b/plugins/VersionInfo/src/main.cpp
@@ -0,0 +1,119 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#define STRICT
+#define WIN32_LEAN_AND_MEAN
+
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include "common.h"
+
+#include "CVersionInfo.h"
+
+HINSTANCE hInst;
+
+int hLangpack;
+
+HICON hiVIIcon;
+
+DWORD EnglishLocale;
+
+BOOL bFoldersAvailable = FALSE;
+HANDLE hOutputLocation = NULL; //for folders plugin
+
+void * (* MirandaMalloc)(size_t);
+void * (* MirandaRealloc)(void *, size_t);
+void (* MirandaFree)(void *);
+
+char ModuleName[] = "VersionInfo";
+
+#ifdef _DEBUG
+ BOOL verbose = FALSE;//TRUE;
+#else
+ BOOL verbose = FALSE;
+#endif
+
+PLUGININFOEX pluginInfo={
+ sizeof(PLUGININFOEX),
+ __PLUGIN_DISPLAY_NAME,
+ VERSION,
+ __DESC,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {2f174488-489c-4fe1-940d-596cf0f35e65}
+ {0x2f174488, 0x489c, 0x4fe1, {0x94, 0x0d, 0x59, 0x6c, 0xf0, 0xf3, 0x5e, 0x65}}
+};
+
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_VERSIONINFO, MIID_SERVICEMODE, MIID_LAST};
+
+bool WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
+{
+ hInst=hinstDLL;
+ if (fdwReason == DLL_PROCESS_ATTACH) DisableThreadLibraryCalls(hinstDLL);
+ EnglishLocale = MAKELCID(MAKELANGID(0x09, 0x01), SORT_DEFAULT); //create our english locale and use it everywhere it's needed
+ return TRUE;
+}
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+extern "C" int __declspec(dllexport) Load(void)
+{
+ mir_getLP(&pluginInfo);
+
+ InitServices();
+ HookEvents();
+
+ hiVIIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAIN));
+
+ //get the name of the dll itself
+ TCHAR filePath[512] = {0};
+ GetModuleFileName(hInst, filePath, SIZEOF(filePath));
+ TCHAR *fileName = NULL;
+ size_t i = _tcslen(filePath) - 1;
+ _tcslwr(filePath);
+
+ //Menu item
+ CLISTMENUITEM mi = { 0 };
+ mi.cbSize = sizeof(mi);
+ mi.position = mi.popupPosition = 2000089999;
+ mi.flags = 0;
+ mi.hIcon = hiVIIcon;
+ mi.pszName = Translate("Version Information");
+ mi.pszService = MS_VERSIONINFO_MENU_COMMAND;
+ Menu_AddMainMenuItem(&mi);
+
+ if (LoadLibraryA("RichEd32.dll") == NULL)
+ MessageBoxA(NULL, "d'oh", "d'oh", MB_OK);
+
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ UnhookEvents();
+ DestroyServices();
+ return 0;
+} \ No newline at end of file
diff --git a/plugins/VersionInfo/src/resource.h b/plugins/VersionInfo/src/resource.h
new file mode 100644
index 0000000000..b282e8bca6
--- /dev/null
+++ b/plugins/VersionInfo/src/resource.h
@@ -0,0 +1,71 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by resource.rc
+//
+#define IDD_DIALOG1 101
+#define IDD_OPT_VERSIONINFO 102
+#define IDD_DIALOGBOX 103
+#define IDD_DIALOGINFO 103
+#define IDI_ICON1 104
+#define IDI_MAIN 104
+#define IDD_ASKDIALOG 106
+#define IDC_MENUITEM 1000
+#define IDC_TOFILE 1001
+#define IDC_TOMESSAGEBOX 1002
+#define IDC_TODIALOGBOX 1003
+#define IDC_DISABLEDTOO 1004
+#define IDC_FILENAME 1005
+#define IDC_TEXT 1006
+#define IDC_TODEBUGSTRING 1006
+#define IDC_CLOSE 1007
+#define IDC_TOCLIPBOARD 1007
+#define IDC_GETINFONOW 1009
+#define IDC_TOUPLOAD 1010
+#define IDC_GETINFONOW2 1011
+#define IDC_COPYTEXT 1012
+#define IDC_DEBUG 1013
+#define IDC_FORUMSTYLE 1014
+#define IDC_CLIPBOARDALSO 1015
+#define IDC_SHOWINTASKBAR 1016
+#define IDC_QUOTECOMBOBOX 1017
+#define IDC_SIZECOMBOBOX 1018
+#define IDC_BOLDVERSION 1020
+#define IDC_CHECKUNLOADABLE 1021
+#define IDC_ASKEVERYTIME 1022
+#define IDC_ASK_TOFILE 1023
+#define IDC_ASK_TOMESSAGEBOX 1024
+#define IDC_ASK_TODIALOGBOX 1025
+#define IDC_ASK_TOOUTPUTDEBUGSTRING 1026
+#define IDC_ASK_TOCLIPBOARD 1027
+#define IDC_ASK_CANCEL 1028
+#define IDC_ASK_OK 1029
+#define IDC_BOLDCOMBOBOX 1030
+#define IDC_SUPPRESSHEADER 1031
+#define IDC_SHOWHARDWAREINFO 1033
+#define IDC_UPLOAD 1034
+#define IDC_ASK_UPLOAD 1036
+#define IDC_ASK_TOUPLOAD 1036
+#define IDC_UPLOAD_SERVER 1038
+#define IDC_UPLOAD_PORT 1039
+#define IDC_UPLOAD_USERNAME 1040
+#define IDC_UPLOAD_PASSWORD 1041
+#define IDC_TEMPORARY_FORUMSTYLE 1042
+#define IDC_ASK_FORUMSTYLE 1042
+#define IDC_ASK_QUOTECOMBOBOX 1043
+#define IDC_ASK_SIZECOMBOBOX 1044
+#define IDC_ASK_BOLDCOMBOBOX 1045
+#define IDC_SAVETOFILE 1046
+#define IDC_SHOWUUIDS 1048
+#define IDC_CHECK1 1049
+#define IDC_SHOWINSTALLEDLANGUAGES 1049
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 107
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1050
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/VersionInfo/src/services.cpp b/plugins/VersionInfo/src/services.cpp
new file mode 100644
index 0000000000..4efa482404
--- /dev/null
+++ b/plugins/VersionInfo/src/services.cpp
@@ -0,0 +1,76 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+#include "services.h"
+
+HANDLE hsMenuCommand;
+HANDLE hsGetInfo;
+HANDLE hsServiceMode;
+
+int bServiceMode = 0; //true only if plugin is running in service mode
+
+int InitServices()
+{
+ hsMenuCommand = CreateServiceFunction(MS_VERSIONINFO_MENU_COMMAND, PluginMenuCommand);
+ hsGetInfo = CreateServiceFunction(MS_VERSIONINFO_GETINFO, GetInfoService);
+ hsServiceMode = CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceModeService);
+ return 0;
+}
+
+int DestroyServices()
+{
+ DestroyServiceFunction(hsMenuCommand);
+ DestroyServiceFunction(hsGetInfo);
+ DestroyServiceFunction(hsServiceMode);
+ return 0;
+}
+
+INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam)
+{
+ int debugTo = DBGetContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX);
+ DoDebugTo(debugTo);
+ if (verbose) PUShowMessage("I have printed the information.", SM_NOTIFY);
+/* char *data;
+ CallService(MS_VERSIONINFO_GETINFO, 1, (LPARAM) &data); */
+ return 0;
+}
+
+INT_PTR GetInfoService(WPARAM wParam, LPARAM lParam)
+{
+ int result = 1; //failure
+ if (lParam != NULL) {
+ CVersionInfo myInfo;
+ myInfo.Initialize();
+ std::tstring VI = myInfo.GetInformationsAsString(wParam);
+ char **retData = (char **) lParam;
+ *retData = mir_utf8encodeT( VI.c_str());
+ if (*retData)
+ result = 0; //success
+ }
+ return result;
+}
+
+INT_PTR ServiceModeService(WPARAM wParam, LPARAM lParam)
+{
+ bServiceMode = 1;
+ DoDebugTo(TO_ASK);
+ return 0;
+}
diff --git a/plugins/VersionInfo/src/services.h b/plugins/VersionInfo/src/services.h
new file mode 100644
index 0000000000..38acbc7731
--- /dev/null
+++ b/plugins/VersionInfo/src/services.h
@@ -0,0 +1,31 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_VERSIONINFO_SERVICES_H
+#define M_VERSIONINFO_SERVICES_H
+
+int InitServices();
+int DestroyServices();
+
+INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR GetInfoService(WPARAM wParam, LPARAM lParam);
+INT_PTR ServiceModeService(WPARAM wParam, LPARAM lParam);
+
+#endif //M_VERSIONINFO_SERVICES_H \ No newline at end of file
diff --git a/plugins/VersionInfo/src/utils.cpp b/plugins/VersionInfo/src/utils.cpp
new file mode 100644
index 0000000000..9be552c8cc
--- /dev/null
+++ b/plugins/VersionInfo/src/utils.cpp
@@ -0,0 +1,526 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2006 Luca Santarelli, Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+//#define USE_LOG_FUNCTIONS
+
+#define STRICT
+#define WIN32_LEAN_AND_MEAN
+
+#include "common.h"
+#include "utils.h"
+
+/*
+My usual MessageBoxes :-)
+*/
+void MB(const TCHAR* message)
+{
+ if (verbose) MessageBox(NULL, message, _T("VersionInfo"), MB_OK | MB_ICONEXCLAMATION);
+}
+
+void Log(const TCHAR* message)
+{
+ if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
+ POPUPDATAT pu = {0};
+ pu.lchIcon = hiVIIcon;
+ _tcsncpy(pu.lptzContactName, TranslateT("Version Information"), MAX_CONTACTNAME);
+ _tcsncpy(pu.lptzText, message, MAX_SECONDLINE);
+ PUAddPopUpT(&pu);
+ }
+ else MessageBox(NULL, message, _T("VersionInfo"), MB_OK | MB_ICONINFORMATION);
+}
+
+int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndText)
+{
+ const TCHAR *pos = _tcschr(szWholeText, '|');
+ if (pos) {
+ size_t index = pos - szWholeText;
+ lstrcpyn(szStartText, szWholeText, (int)index);
+ szStartText[index] = '\0';
+ StrTrim(szStartText, _T(" "));
+ lstrcpyn(szEndText, pos + 1, (int)_tcslen(pos)); //copies the \0 as well ... :)
+ StrTrim(szEndText, _T(" "));
+ }
+ else szStartText[0] = szEndText[0] = '\0';
+
+ return 0;
+}
+
+int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, size_t size)
+{
+ DBVARIANT dbv = {0};
+ int res = 1;
+ size_t len;
+ if ( DBGetContactSettingTString(NULL, ModuleName, szSettingName, &dbv) == 0) {
+ res = 0;
+ size_t tmp = _tcslen(dbv.ptszVal);
+ len = (tmp < size - 1) ? tmp : size - 1;
+ _tcsncpy(szResult, dbv.ptszVal, len);
+ szResult[len] = '\0';
+ mir_free(dbv.ptszVal);
+ }
+ else {
+ res = 1;
+ size_t tmp = _tcslen(szError);
+ len = (tmp < size - 1) ? tmp : size - 1;
+ _tcsncpy(szResult, szError, len);
+ szResult[len] = '\0';
+ }
+ return res;
+}
+
+TCHAR *RelativePathToAbsolute(TCHAR *szRelative, TCHAR *szAbsolute, size_t size)
+{
+ if (size < MAX_PATH) {
+ TCHAR buffer[MAX_PATH]; //new path should be at least MAX_PATH chars
+ CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM) szRelative, (LPARAM) buffer);
+ _tcsncpy(szAbsolute, buffer, size);
+ }
+ else CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM) szRelative, (LPARAM) szAbsolute);
+
+ return szAbsolute;
+}
+
+TCHAR *AbsolutePathToRelative(TCHAR *szAbsolute, TCHAR *szRelative, size_t size)
+{
+ if (size < MAX_PATH) {
+ TCHAR buffer[MAX_PATH];
+ CallService(MS_UTILS_PATHTORELATIVET, (WPARAM) szAbsolute, (LPARAM) szRelative);
+ _tcsncpy(szRelative, buffer, size);
+ }
+ else CallService(MS_UTILS_PATHTORELATIVET, (WPARAM) szAbsolute, (LPARAM) szRelative);
+
+ return szRelative;
+}
+
+#define GetFacility(dwError) (HIWORD(dwError) && 0x0000111111111111)
+#define GetErrorCode(dwError) (LOWORD(dwError))
+
+void NotifyError(DWORD dwError, const TCHAR* szSetting, int iLine)
+{
+ TCHAR str[1024];
+ mir_sntprintf(str, SIZEOF(str), TranslateT("Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d"), szSetting, GetFacility(dwError), GetErrorCode(dwError), iLine);
+ Log(str);
+}
+
+TCHAR *StrTrim(TCHAR *szText, const TCHAR *szTrimChars)
+{
+ size_t i = _tcslen(szText) - 1;
+ while (i >= 0 && _tcschr(szTrimChars, szText[i]))
+ szText[i--] = '\0';
+
+ i = 0;
+ while (((unsigned int )i < _tcslen(szText)) && _tcschr(szTrimChars, szText[i]))
+ i++;
+
+ if (i) {
+ size_t size = _tcslen(szText);
+ size_t j;
+ for (j = i; j <= size; j++) //shift the \0 as well
+ szText[j - i] = szText[j];
+ }
+ return szText;
+}
+
+bool DoesDllExist(char *dllName)
+{
+ HMODULE dllHandle;
+ dllHandle = LoadLibraryExA(dllName, NULL, DONT_RESOLVE_DLL_REFERENCES);
+ if (dllHandle)
+ {
+ FreeLibrary(dllHandle);
+ return true;
+ }
+ return false;
+}
+
+//========== From Cyreve ==========
+PLUGININFOEX *GetPluginInfo(const TCHAR *filename,HINSTANCE *hPlugin)
+{
+ TCHAR szMirandaPath[MAX_PATH], szPluginPath[MAX_PATH];
+ PLUGININFOEX *(*MirandaPluginInfo)(DWORD);
+ PLUGININFOEX *pPlugInfo;
+ HMODULE hLoadedModule;
+ DWORD mirandaVersion = CallService(MS_SYSTEM_GETVERSION,0,0);
+
+ GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath));
+ TCHAR* str2 = _tcsrchr(szMirandaPath,'\\');
+ if(str2!=NULL) *str2=0;
+
+ hLoadedModule = GetModuleHandle(filename);
+ if(hLoadedModule!=NULL) {
+ *hPlugin=NULL;
+ MirandaPluginInfo=(PLUGININFOEX *(*)(DWORD))GetProcAddress(hLoadedModule,"MirandaPluginInfo");
+ return MirandaPluginInfo(mirandaVersion);
+ }
+ wsprintf(szPluginPath, _T("%s\\Plugins\\%s"), szMirandaPath, filename);
+ *hPlugin=LoadLibrary(szPluginPath);
+ if (*hPlugin==NULL) return NULL;
+ MirandaPluginInfo=(PLUGININFOEX *(*)(DWORD))GetProcAddress(*hPlugin,"MirandaPluginInfo");
+ if(MirandaPluginInfo==NULL) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;}
+ pPlugInfo=MirandaPluginInfo(mirandaVersion);
+ if(pPlugInfo==NULL) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;}
+ if(pPlugInfo->cbSize != sizeof(PLUGININFOEX)) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;}
+ return pPlugInfo;
+}
+
+//========== from Frank Cheng (wintime98) ==========
+// I've changed something to suit VersionInfo :-)
+#include <imagehlp.h>
+
+void TimeStampToSysTime(DWORD Unix,SYSTEMTIME* SysTime)
+{
+ SYSTEMTIME S;
+ DWORDLONG FileReal,UnixReal;
+ S.wYear=1970;
+ S.wMonth=1;
+ S.wDay=1;
+ S.wHour=0;
+ S.wMinute=0;
+ S.wSecond=0;
+ S.wMilliseconds=0;
+ SystemTimeToFileTime(&S,(FILETIME*)&FileReal);
+ UnixReal = Unix;
+ UnixReal*=10000000;
+ FileReal+=UnixReal;
+ FileTimeToSystemTime((FILETIME*)&FileReal,SysTime);
+}
+
+void GetModuleTimeStamp(TCHAR* ptszDate, TCHAR* ptszTime)
+{
+ TCHAR tszModule[MAX_PATH];
+ HANDLE mapfile,file;
+ DWORD timestamp,filesize;
+ LPVOID mapmem;
+ SYSTEMTIME systime;
+ GetModuleFileName(NULL,tszModule,SIZEOF(tszModule));
+ file = CreateFile(tszModule,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
+ filesize = GetFileSize(file,NULL);
+ mapfile = CreateFileMapping(file, NULL, PAGE_READONLY, 0, filesize, NULL);
+ mapmem = MapViewOfFile(mapfile, FILE_MAP_READ, 0, 0, 0);
+ timestamp = GetTimestampForLoadedLibrary((HINSTANCE)mapmem);
+ TimeStampToSysTime(timestamp,&systime);
+ GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systime, _T("HH':'mm':'ss"), ptszTime, 40 );
+ GetDateFormat(EnglishLocale, 0, &systime, _T("dd' 'MMMM' 'yyyy"), ptszDate, 40);
+ UnmapViewOfFile(mapmem);
+ CloseHandle(mapfile);
+ CloseHandle(file);
+}
+
+//From Egodust or Cyreve... I don't really know.
+PLUGININFOEX *CopyPluginInfo(PLUGININFOEX *piSrc)
+{
+ if(piSrc==NULL)
+ return NULL;
+
+ PLUGININFOEX *pi = (PLUGININFOEX *)malloc(sizeof(PLUGININFOEX));
+ *pi = *piSrc;
+
+ if (piSrc->cbSize >= sizeof(PLUGININFOEX))
+ pi->uuid = piSrc->uuid;
+ else
+ pi->uuid = UUID_NULL;
+
+ if (pi->author) pi->author = _strdup(pi->author);
+ if (pi->authorEmail) pi->authorEmail = _strdup(pi->authorEmail);
+ if (pi->copyright) pi->copyright = _strdup(pi->copyright);
+ if (pi->description) pi->description = _strdup(pi->description);
+ if (pi->homepage) pi->homepage = _strdup(pi->homepage);
+ if (pi->shortName) pi->shortName = _strdup(pi->shortName);
+ return pi;
+}
+
+void FreePluginInfo(PLUGININFOEX *pi)
+{
+ if (pi->author) free(pi->author);
+ if (pi->authorEmail) free(pi->authorEmail);
+ if (pi->copyright) free(pi->copyright);
+ if (pi->description) free(pi->description);
+ if (pi->homepage) free(pi->homepage);
+ if (pi->shortName) free(pi->shortName);
+ free(pi);
+}
+
+BOOL IsCurrentUserLocalAdministrator(void)
+{
+ BOOL fReturn = FALSE;
+ DWORD dwStatus;
+ DWORD dwAccessMask;
+ DWORD dwAccessDesired;
+ DWORD dwACLSize;
+ DWORD dwStructureSize = sizeof(PRIVILEGE_SET);
+ PACL pACL = NULL;
+ PSID psidAdmin = NULL;
+
+ HANDLE hToken = NULL;
+ HANDLE hImpersonationToken = NULL;
+
+ PRIVILEGE_SET ps;
+ GENERIC_MAPPING GenericMapping;
+
+ PSECURITY_DESCRIPTOR psdAdmin = NULL;
+ SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY;
+
+ /*
+ Determine if the current thread is running as a user that is a member of
+ the local admins group. To do this, create a security descriptor that
+ has a DACL which has an ACE that allows only local aministrators access.
+ Then, call AccessCheck with the current thread's token and the security
+ descriptor. It will say whether the user could access an object if it
+ had that security descriptor. Note: you do not need to actually create
+ the object. Just checking access against the security descriptor alone
+ will be sufficient.
+ */
+ const DWORD ACCESS_READ = 1;
+ const DWORD ACCESS_WRITE = 2;
+
+
+ __try
+ {
+
+ /*
+ AccessCheck() requires an impersonation token. We first get a primary
+ token and then create a duplicate impersonation token. The
+ impersonation token is not actually assigned to the thread, but is
+ used in the call to AccessCheck. Thus, this function itself never
+ impersonates, but does use the identity of the thread. If the thread
+ was impersonating already, this function uses that impersonation context.
+ */
+ if (!OpenThreadToken(GetCurrentThread(), TOKEN_DUPLICATE|TOKEN_QUERY, TRUE, &hToken))
+ {
+ if (GetLastError() != ERROR_NO_TOKEN)
+ __leave;
+
+ if (!OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE|TOKEN_QUERY, &hToken))
+ __leave;
+ }
+
+ if (!DuplicateToken (hToken, SecurityImpersonation, &hImpersonationToken))
+ __leave;
+
+
+ /*
+ Create the binary representation of the well-known SID that
+ represents the local administrators group. Then create the security
+ descriptor and DACL with an ACE that allows only local admins access.
+ After that, perform the access check. This will determine whether
+ the current user is a local admin.
+ */
+ if (!AllocateAndInitializeSid(&SystemSidAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &psidAdmin))
+ __leave;
+
+ psdAdmin = LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
+ if (psdAdmin == NULL)
+ __leave;
+
+ if (!InitializeSecurityDescriptor(psdAdmin, SECURITY_DESCRIPTOR_REVISION))
+ __leave;
+
+ // Compute size needed for the ACL.
+ dwACLSize = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(psidAdmin) - sizeof(DWORD);
+
+ pACL = (PACL)LocalAlloc(LPTR, dwACLSize);
+ if (pACL == NULL)
+ __leave;
+
+ if (!InitializeAcl(pACL, dwACLSize, ACL_REVISION2))
+ __leave;
+
+ dwAccessMask= ACCESS_READ | ACCESS_WRITE;
+
+ if (!AddAccessAllowedAce(pACL, ACL_REVISION2, dwAccessMask, psidAdmin))
+ __leave;
+
+ if (!SetSecurityDescriptorDacl(psdAdmin, TRUE, pACL, FALSE))
+ __leave;
+
+ /*
+ AccessCheck validates a security descriptor somewhat; set the group
+ and owner so that enough of the security descriptor is filled out to
+ make AccessCheck happy.
+ */
+ SetSecurityDescriptorGroup(psdAdmin, psidAdmin, FALSE);
+ SetSecurityDescriptorOwner(psdAdmin, psidAdmin, FALSE);
+
+ if (!IsValidSecurityDescriptor(psdAdmin))
+ __leave;
+
+ dwAccessDesired = ACCESS_READ;
+
+ /*
+ Initialize GenericMapping structure even though you
+ do not use generic rights.
+ */
+ GenericMapping.GenericRead = ACCESS_READ;
+ GenericMapping.GenericWrite = ACCESS_WRITE;
+ GenericMapping.GenericExecute = 0;
+ GenericMapping.GenericAll = ACCESS_READ | ACCESS_WRITE;
+
+ if (!AccessCheck(psdAdmin, hImpersonationToken, dwAccessDesired, &GenericMapping, &ps, &dwStructureSize, &dwStatus, &fReturn))
+ {
+ fReturn = FALSE;
+ __leave;
+ }
+ }
+ __finally
+ {
+ // Clean up.
+ if (pACL) LocalFree(pACL);
+ if (psdAdmin) LocalFree(psdAdmin);
+ if (psidAdmin) FreeSid(psidAdmin);
+ if (hImpersonationToken) CloseHandle (hImpersonationToken);
+ if (hToken) CloseHandle (hToken);
+ }
+
+ return fReturn;
+}
+
+BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize)
+{
+ OSVERSIONINFO vi = {0};
+ vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&vi);
+
+ TCHAR szShell[1024] = {0};
+ DWORD size = SIZEOF(szShell);
+
+ if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ {
+ HKEY hKey;
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\system.ini\\boot"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
+ {
+ RegQueryValueEx(hKey, _T("Shell"), NULL, NULL, (LPBYTE) szShell, &size);
+ _tcslwr(szShell);
+ HKEY hRootKey = ( _tcsstr(szShell, _T("sys:")) == szShell) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+ RegCloseKey(hKey);
+
+ _tcscpy(szShell, _T("<unknown>"));
+ if (RegOpenKeyEx(hRootKey, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
+ {
+ size = SIZEOF(szShell);
+ RegQueryValueEx(hKey, _T("Shell"), NULL, NULL, (LPBYTE) szShell, &size);
+ RegCloseKey(hKey);
+ }
+ }
+ }
+ else{
+ TCHAR szSystemIniPath[2048];
+ GetWindowsDirectory(szSystemIniPath, SIZEOF(szSystemIniPath));
+ size_t len = lstrlen(szSystemIniPath);
+ if (len > 0)
+ {
+ if (szSystemIniPath[len - 1] == '\\') { szSystemIniPath[--len] = '\0'; }
+ _tcscat(szSystemIniPath, _T("\\system.ini"));
+ GetPrivateProfileString( _T("boot"), _T("shell"), _T("<unknown>"), szShell, size, szSystemIniPath);
+ }
+ }
+
+ TCHAR *pos = _tcsrchr(szShell, '\\');
+ TCHAR *res = (pos) ? pos + 1 : szShell;
+ _tcsncpy(shellPath, res, shSize);
+
+ return TRUE;
+}
+
+BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize)
+{
+ HKEY hKey;
+ TCHAR ieVer[1024];
+ DWORD size = SIZEOF(ieVer);
+ TCHAR ieBuild[64] = {0};
+
+ _tcsncpy(ieVer, _T("<not installed>"), size);
+
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
+ {
+ if (RegQueryValueEx(hKey, _T("Version"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS)
+ {
+ TCHAR *pos = _tcschr(ieVer, '.');
+ if (pos)
+ {
+ pos = _tcschr(pos + 1, '.');
+ if (pos) { *pos = 0; }
+ _tcsncpy(ieBuild, pos + 1, SIZEOF(ieBuild));
+ pos = _tcschr(ieBuild, '.');
+ if (pos) { *pos = 0; }
+ }
+ }
+ else{
+ size = SIZEOF(ieVer);
+ if (RegQueryValueEx(hKey, _T("Build"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS)
+ {
+ TCHAR *pos = ieVer + 1;
+ _tcsncpy(ieBuild, pos, SIZEOF(ieBuild));
+ *pos = 0;
+ pos = _tcschr(ieBuild, '.');
+ if (pos) { *pos = 0; }
+ }
+ else{
+ _tcsncpy(ieVer, _T("<unknown version>"), size);
+ }
+ }
+ RegCloseKey(hKey);
+ }
+
+ _tcsncpy(ieVersion, ieVer, ieSize);
+ if ( ieBuild[0] )
+ {
+ _tcsncat(ieVersion, _T("."), ieSize);
+ _tcsncat(ieVersion, ieBuild, ieSize);
+ }
+
+ return TRUE;
+}
+
+
+TCHAR *GetLanguageName(LANGID language)
+{
+ LCID lc = MAKELCID(language, SORT_DEFAULT);
+ return GetLanguageName(lc);
+}
+
+extern TCHAR *GetLanguageName(LCID locale)
+{
+ static TCHAR name[1024];
+ GetLocaleInfo(locale, LOCALE_SENGLANGUAGE, name, SIZEOF(name));
+ return name;
+}
+
+BOOL UUIDToString(MUUID uuid, TCHAR *str, size_t len)
+{
+ if ( len < sizeof(MUUID) || !str )
+ return 0;
+
+ mir_sntprintf(str, len, _T("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), uuid.a, uuid.b, uuid.c, uuid.d[0], uuid.d[1], uuid.d[2], uuid.d[3], uuid.d[4], uuid.d[5], uuid.d[6], uuid.d[7]);
+ return 1;
+}
+
+BOOL IsUUIDNull(MUUID uuid)
+{
+ int i;
+ for (i = 0; i < sizeof(uuid.d); i++)
+ {
+ if (uuid.d[i])
+ {
+ return 0;
+ }
+ }
+
+ return ((uuid.a == 0) && (uuid.b == 0) && (uuid.c == 0));
+} \ No newline at end of file
diff --git a/plugins/VersionInfo/src/utils.h b/plugins/VersionInfo/src/utils.h
new file mode 100644
index 0000000000..5db4b1a811
--- /dev/null
+++ b/plugins/VersionInfo/src/utils.h
@@ -0,0 +1,49 @@
+#ifndef _M_VERSIONINFO_UTILS_H
+#define _M_VERSIONINFO_UTILS_H
+
+#include "common.h"
+
+//utils.cpp
+void MB(const TCHAR*);
+void Log(const TCHAR*);
+TCHAR *StrTrim(TCHAR *, const TCHAR *);
+
+//utils.cpp
+TCHAR *RelativePathToAbsolute(TCHAR *szRelative, TCHAR *szAbsolute, size_t size);
+TCHAR *AbsolutePathToRelative(TCHAR *szAbsolute, TCHAR *szRelative, size_t size);
+
+//returns a string from the database and uses MirandaFree to deallocate the string, leaving only the local copy
+//utils.cpp
+int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, size_t size);
+
+//a string of the form %s(start) | %s(end) is split into the two strings (start and end)
+//utils.cpp
+int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndText);
+
+//utils.cpp
+bool DoesDllExist(char *dllName);
+
+//utils.cpp
+void GetModuleTimeStamp(TCHAR*, TCHAR*);
+void NotifyError(DWORD, const TCHAR*, int);
+
+//utils.cpp
+PLUGININFOEX *GetPluginInfo(const char *,HINSTANCE *);
+PLUGININFOEX *CopyPluginInfo(PLUGININFOEX *);
+void FreePluginInfo(PLUGININFOEX *);
+
+//utils.cpp
+
+BOOL IsCurrentUserLocalAdministrator();
+
+TCHAR *GetLanguageName(LANGID language);
+TCHAR *GetLanguageName(LCID locale);
+
+BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize);
+BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize);
+
+BOOL UUIDToString(MUUID uuid, TCHAR *str, size_t len);
+
+BOOL IsUUIDNull(MUUID uuid);
+
+#endif \ No newline at end of file
diff --git a/plugins/VersionInfo/src/version.h b/plugins/VersionInfo/src/version.h
new file mode 100644
index 0000000000..7c0596e2c9
--- /dev/null
+++ b/plugins/VersionInfo/src/version.h
@@ -0,0 +1,44 @@
+/*
+Version information plugin for Miranda IM
+
+Copyright © 2002-2005 Luca Santarelli, © 2005-2008 Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_VERSIONINFO_VERSION_H
+#define M_VERSIONINFO_VERSION_H
+
+#define __MAJOR_VERSION 1
+#define __MINOR_VERSION 5
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 3
+
+#define VERSION PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM)
+
+#define __PLUGINVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __PLUGINVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
+#define __STRINGIFY_(x) #x
+#define __STRINGIFY(x) __STRINGIFY_(x)
+#define __VERSION_STRING __STRINGIFY(__PLUGINVERSION_STRING_DOTS)
+
+#define __DESC "Collects and prints information related to Miranda, the plugins and the OS."
+#define __AUTHOR "Luca Santarelli, Cristian Libotean, George Hazan"
+#define __AUTHOREMAIL "hrk@users.sourceforge.net, eblis102@yahoo.com, ghazan@miranda.im"
+#define __COPYRIGHT "© 2002-2005 Luca Santarelli, © 2005-2009 Cristian Libotean"
+#define __AUTHORWEB "http://nightly.miranda.im/"
+#define __PLUGIN_DISPLAY_NAME "Version Information"
+
+#endif //M_VERSIONINFO_VERSION_H