diff options
author | George Hazan <george.hazan@gmail.com> | 2012-05-26 14:47:04 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-05-26 14:47:04 +0000 |
commit | 1d9dd615e5f1a43d3b78f37b5aaae836dfac1c4d (patch) | |
tree | dd3dd64e8c60cccb072e5acae857c9c55203e86d /plugins/Svc_vi/CVersionInfo.cpp | |
parent | 32abe163ec316671ec5a0a3bbec68ec13f71cb92 (diff) |
- plugin converted to Unicode
- old bug fixed with the profile path
git-svn-id: http://svn.miranda-ng.org/main/trunk@182 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Svc_vi/CVersionInfo.cpp')
-rw-r--r-- | plugins/Svc_vi/CVersionInfo.cpp | 1187 |
1 files changed, 532 insertions, 655 deletions
diff --git a/plugins/Svc_vi/CVersionInfo.cpp b/plugins/Svc_vi/CVersionInfo.cpp index 43087c3837..b68c5c1832 100644 --- a/plugins/Svc_vi/CVersionInfo.cpp +++ b/plugins/Svc_vi/CVersionInfo.cpp @@ -34,12 +34,12 @@ BOOL (WINAPI *MyGlobalMemoryStatusEx)(LPMEMORYSTATUSEX lpBuffer) = NULL; LANGID (WINAPI *MyGetUserDefaultUILanguage)() = NULL;
LANGID (WINAPI *MyGetSystemDefaultUILanguage)() = NULL;
-static int ValidExtension(char *fileName, char *extension)
+static int ValidExtension(TCHAR *fileName, TCHAR *extension)
{
- char *dot = strrchr(fileName, '.');
- if ((dot != NULL) && (lstrcmpiA(dot + 1, extension) == 0))
+ TCHAR *dot = _tcschr(fileName, '.');
+ if ((dot != NULL) && (lstrcmpi(dot + 1, extension) == 0))
{
- if (dot[strlen(extension) + 1] == 0)
+ if (dot[lstrlen(extension) + 1] == 0)
{
return 1;
}
@@ -94,54 +94,53 @@ int IsPluginDisabled(char *fileName) }
*/
-void FillLocalTime(std::string &output, FILETIME *fileTime)
+void FillLocalTime(std::tstring &output, FILETIME *fileTime)
{
TIME_ZONE_INFORMATION tzInfo = {0};
FILETIME local = {0};
SYSTEMTIME sysTime;
- char date[1024];
- char time[256];
-
- FileTimeToLocalFileTime(fileTime, &local);
- FileTimeToSystemTime(&local, &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);
- GetDateFormat(EnglishLocale, 0, &sysTime, "dd' 'MMM' 'yyyy", date, sizeof(date));
- GetTimeFormat(NULL, TIME_FORCE24HOURFORMAT, &sysTime, "HH':'mm':'ss", time, sizeof(time)); //americans love 24hour format ;)
- output = std::string(date) + " at " + std::string(time);
-
int res = GetTimeZoneInformation(&tzInfo);
char tzName[32] = {0};
- char tzOffset[64] = {0};
+ TCHAR tzOffset[64] = {0};
int offset = 0;
- switch (res)
- {
- case TIME_ZONE_ID_DAYLIGHT:
+ switch (res) {
+ case TIME_ZONE_ID_DAYLIGHT:
{
offset = -(tzInfo.Bias + tzInfo.DaylightBias);
- WideCharToMultiByte(CP_ACP, 0, tzInfo.DaylightName, -1, tzName, sizeof(tzName), NULL, NULL);
-
+ WideCharToMultiByte(CP_ACP, 0, tzInfo.DaylightName, -1, tzName, SIZEOF(tzName), NULL, NULL);
+
break;
}
-
- case TIME_ZONE_ID_STANDARD:
+
+ case TIME_ZONE_ID_STANDARD:
{
- WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, sizeof(tzName), NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL);
offset = -(tzInfo.Bias + tzInfo.StandardBias);
-
+
break;
}
-
- case TIME_ZONE_ID_UNKNOWN:
+
+ case TIME_ZONE_ID_UNKNOWN:
{
- WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, sizeof(tzName), NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL);
offset = -tzInfo.Bias;
-
+
break;
}
}
-
- sprintf(tzOffset, "UTC %+02d:%02d", offset / 60, offset % 60);
- output += " (" /*+ std::string(tzName) + ", " */ + std::string(tzOffset) + ")";
+
+ wsprintf(tzOffset, _T("UTC %+02d:%02d"), offset / 60, offset % 60);
+ output += _T(" (") + std::tstring(tzOffset) + _T(")");
}
CVersionInfo::CVersionInfo() {
@@ -202,179 +201,145 @@ void CVersionInfo::Initialize() { #endif
}
-bool CVersionInfo::GetMirandaVersion() {
+bool CVersionInfo::GetMirandaVersion()
+{
+ //Miranda version
const BYTE str_size = 64;
char str[str_size];
- //Miranda version
-
- CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)str_size, (LPARAM)(char*)str);
- this->lpzMirandaVersion = std::string(str);
+ CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)str_size, (LPARAM)str);
+ this->lpzMirandaVersion = _A2T(str);
//Is it a nightly?
- if (lpzMirandaVersion.find("alpha",0) != std::string::npos)
- lpzNightly = "Yes";
+ if (lpzMirandaVersion.find( _T("alpha"),0) != std::string::npos)
+ lpzNightly = _T("Yes");
else
- lpzNightly = "No";
- if (lpzMirandaVersion.find("Unicode", 0) != std::string::npos)
- {
- lpzUnicodeBuild = "Yes";
- }
- else{
- lpzUnicodeBuild = "No";
- }
- char time[128], date[128];
+ 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::string(time) + " on " + std::string(date);
+ lpzBuildTime = std::tstring(time) + _T(" on ") + std::tstring(date);
return TRUE;
}
-bool CVersionInfo::GetOSVersion() {
+bool CVersionInfo::GetOSVersion()
+{
//Operating system informations
- OSVERSIONINFO osvi;
- ZeroMemory(&osvi, sizeof(osvi));
+ OSVERSIONINFO osvi = { 0 };
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx(&osvi);
+
//Now fill the private members.
- char aux[256];
- wsprintf(aux, "%d.%d.%d %s", osvi.dwMajorVersion, osvi.dwMinorVersion, LOWORD(osvi.dwBuildNumber), osvi.szCSDVersion);
- lpzOSVersion = std::string(aux);
+ 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;
- char szKey[MAX_PATH], szValue[MAX_PATH];
+ 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(), "RegQueryValueEx()", __LINE__);
+ lpzCPUIdentifier = _T("<Error in RegQueryValueEx()>");
+ }
- lstrcpyn(szKey, "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("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';
+ #endif
- lstrcpyn(szValue, "Identifier", MAX_PATH);
- result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size);
- if (result == ERROR_SUCCESS)
- {
- char *aux = (char *) malloc(size);
- result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size);
- lpzCPUIdentifier = std::string(aux);
- free(aux);
- }
- else{
- NotifyError(GetLastError(), "RegQueryValueEx()", __LINE__);
- lpzCPUIdentifier = "<Error in RegQueryValueEx()>";
- }
- lstrcpyn(szValue, "ProcessorNameString", MAX_PATH);
- result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); //get the size
- if (result == ERROR_SUCCESS)
- {
-// MessageBox(0, "ProcessorNameString available in the registry", "Info", 0);
- char *aux = (char *) malloc(size);
- result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size);
- lpzCPUName = std::string(aux);
- free(aux);
- }
- else{ //else try to use cpuid instruction to get the proc name
- char szName[49] = "<cpuid extension N/A>";
- #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';
- #endif
- if (strlen(szName) == 0)
- {
- lpzCPUName = "<name N/A>";
- }
- else{
- lpzCPUName = std::string(szName);
- }
- }
+ if ( !szName[0] )
+ lpzCPUName = _T("<name N/A>");
+ else
+ lpzCPUName = _A2T(szName);
}
+ }
bDEPEnabled = IsProcessorFeaturePresent(PF_NX_ENABLED);
- /*
- if (!bDEPEnabled)
- {
- int x = 0;
- __asm
- {
- push eax
- push ebx
- push ecx
- push edx
-
- mov eax, 0x80000001
- cpuid
- mov eax, 1
- shl eax, 20
- xor edx, eax
- cmp edx, 0
- je end_DEP
- mov x, 1
-
- end_DEP:
- pop edx
- pop ecx
- pop ebx
- pop eax
- }
- bDEPEnabled = x;
- }
- */
- switch (osvi.dwPlatformId) {
- case VER_PLATFORM_WIN32_WINDOWS:
- lstrcpyn(szKey, "Software\\Microsoft\\Windows\\CurrentVersion", MAX_PATH);
- lstrcpyn(szValue, "Version", MAX_PATH);
- break;
- case VER_PLATFORM_WIN32_NT:
- lstrcpyn(szKey, "Software\\Microsoft\\Windows NT\\CurrentVersion", MAX_PATH);
- lstrcpyn(szValue, "ProductName", MAX_PATH);
- break;
+ 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);
@@ -385,38 +350,38 @@ bool CVersionInfo::GetOSVersion() { (LPDWORD)&size);
if (result == ERROR_SUCCESS) {
//Read it.
- char *aux = (char*)malloc(size);
+ TCHAR *aux = new TCHAR[size+1];
result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)aux,(LPDWORD)&size);
- lpzOSName = std::string(aux);
- free(aux);
+ lpzOSName = aux;
+ delete[] aux;
}
else {
NotifyError(GetLastError(), "RegQueryValueEx()", __LINE__);
- lpzOSName = "<Error in RegQueryValueEx()>";
+ lpzOSName = _T("<Error in RegQueryValueEx()>");
}
}
else {
NotifyError(GetLastError(), "RegOpenKeyEx()", __LINE__);
- lpzOSName = "<Error in RegOpenKeyEx()>";
+ lpzOSName = _T("<Error in RegOpenKeyEx()>");
}
//Now we can improve it if we can.
switch (LOWORD(osvi.dwBuildNumber)) {
- case 950: lpzOSName = "Microsoft Windows 95"; break;
- case 1111: lpzOSName = "Microsoft Windows 95 OSR2"; break;
- case 1998: lpzOSName = "Microsoft Windows 98"; break;
- case 2222: lpzOSName = "Microsoft Windows 98 SE"; break;
- case 3000: lpzOSName = "Microsoft Windows ME"; break; //Even if this is wrong, we have already read it in the registry.
- case 1381: lpzOSName = "Microsoft Windows NT"; break; //What about service packs?
- case 2195: lpzOSName = "Microsoft Windows 2000"; break; //What about service packs?
- case 2600: lpzOSName = "Microsoft Windows XP"; break;
+ 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 = "Microsoft Windows 2003 R2";
+ lpzOSName = _T("Microsoft Windows 2003 R2");
}
else{
- lpzOSName = "Microsoft Windows 2003";
+ lpzOSName = _T("Microsoft Windows 2003");
}
break; //added windows 2003 info
@@ -428,16 +393,21 @@ bool CVersionInfo::GetOSVersion() { bool CVersionInfo::GetHWSettings() {
//Free space on Miranda Partition.
- char szMirandaPath[MAX_PATH] = { 0 };
- { char *str2;
- GetModuleFileName(GetModuleHandle(NULL),szMirandaPath,sizeof(szMirandaPath));
- str2=strrchr(szMirandaPath,'\\');
- if(str2!=NULL) *str2=0;
+ TCHAR szMirandaPath[MAX_PATH] = { 0 };
+ {
+ GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath));
+ TCHAR* str2 = _tcsrchr(szMirandaPath,'\\');
+ if ( str2 != NULL) *str2=0;
}
HMODULE hKernel32;
- hKernel32 = LoadLibrary("kernel32.dll");
+ hKernel32 = LoadLibraryA("kernel32.dll");
if (hKernel32) {
- MyGetDiskFreeSpaceEx = (BOOL (WINAPI *)(LPCTSTR,PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER))GetProcAddress(hKernel32, "GetDiskFreeSpaceExA");
+ #if defined( _UNICODE )
+ MyGetDiskFreeSpaceEx = (BOOL (WINAPI *)(LPCTSTR,PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER))GetProcAddress(hKernel32, "GetDiskFreeSpaceExW");
+ #else
+ MyGetDiskFreeSpaceEx = (BOOL (WINAPI *)(LPCTSTR,PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER))GetProcAddress(hKernel32, "GetDiskFreeSpaceExA");
+ #endif
+
MyIsWow64Process = (BOOL (WINAPI *) (HANDLE, PBOOL)) GetProcAddress(hKernel32, "IsWow64Process");
MyGetSystemInfo = (void (WINAPI *) (LPSYSTEM_INFO)) GetProcAddress(hKernel32, "GetNativeSystemInfo");
MyGlobalMemoryStatusEx = (BOOL (WINAPI *) (LPMEMORYSTATUSEX)) GetProcAddress(hKernel32, "GlobalMemoryStatusEx");
@@ -460,23 +430,19 @@ bool CVersionInfo::GetHWSettings() { luiFreeDiskSpace = 0;
}
- char szInfo[1024];
- GetWindowsShell(szInfo, sizeof(szInfo));
+ TCHAR szInfo[1024];
+ GetWindowsShell(szInfo, SIZEOF(szInfo));
lpzShell = szInfo;
- GetInternetExplorerVersion(szInfo, sizeof(szInfo));
+ GetInternetExplorerVersion(szInfo, SIZEOF(szInfo));
lpzIEVersion = szInfo;
- lpzAdministratorPrivileges = (IsCurrentUserLocalAdministrator()) ? "Yes" : "No";
+ lpzAdministratorPrivileges = (IsCurrentUserLocalAdministrator()) ? _T("Yes") : _T("No");
bIsWOW64 = 0;
if (MyIsWow64Process)
- {
if (!MyIsWow64Process(GetCurrentProcess(), &bIsWOW64))
- {
bIsWOW64 = 0;
- }
- }
SYSTEM_INFO sysInfo = {0};
GetSystemInfo(&sysInfo);
@@ -492,7 +458,6 @@ bool CVersionInfo::GetHWSettings() { }
else{
MEMORYSTATUS ms = {0};
- ZeroMemory(&ms, sizeof(ms));
ms.dwLength = sizeof(ms);
GlobalMemoryStatus(&ms);
luiRAM = (ms.dwTotalPhys/(1024*1024))+1; //Ugly hack!!!!
@@ -503,58 +468,41 @@ bool CVersionInfo::GetHWSettings() { bool CVersionInfo::GetProfileSettings()
{
- char profileName[MAX_PATH] = {0};
- char profilePath[MAX_PATH] = {0};
- ServiceExists(MS_DB_GETPROFILEPATH_BASIC) ? CallService(MS_DB_GETPROFILEPATH_BASIC, MAX_PATH, (LPARAM) profilePath) : CallService(MS_DB_GETPROFILEPATH, MAX_PATH, (LPARAM) profilePath); //get the profile path
- CallService(MS_DB_GETPROFILENAME, MAX_PATH, (LPARAM) profileName); //get the profile name
-// strcat(profileName, ".dat"); //add the .dat extension to the profile name
- lpzProfilePath = std::string(profilePath); //save the profile path
-
- strcat(profilePath, "\\"); //add the last \\ to the path
- strcat(profilePath, profileName); //now profilePath is drive:\path\profilename.dat
- HANDLE fin = CreateFile(profilePath, FILE_READ_ATTRIBUTES | FILE_READ_EA | STANDARD_RIGHTS_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (fin == INVALID_HANDLE_VALUE) { fin = CreateFile(profilePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); }
- if (fin != INVALID_HANDLE_VALUE)
- {
- DWORD size;
- FILETIME creation, modified, accessed;
- size = GetFileSize(fin, NULL);
- TCHAR number[1024];
- char tmp[1024];
- double fileSize = (double) size / 1024;
-
- sprintf(tmp, "%f", fileSize);
- GetNumberFormat(EnglishLocale, NULL, tmp, NULL, number, 1024);
-
- lpzProfileSize = std::string(number) + " KBytes";
- GetFileTime(fin, &creation, &accessed, &modified);
- FillLocalTime(lpzProfileCreationDate, &creation);
-
- CloseHandle(fin);
- }
- else{
- DWORD error = GetLastError();
- char tmp[1024];
- sprintf(tmp, "%d", error);
- lpzProfileCreationDate = "<error " + std::string(tmp) + " at FileOpen>" + std::string(profilePath);
- lpzProfileSize = "<error " + std::string(tmp) + " at FileOpen>" + std::string(profilePath);
- }
-
+ 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 char szSystemLocales[4096] = {0};
+static TCHAR szSystemLocales[4096] = {0};
static WORD systemLangID;
#define US_LANG_ID 0x00000409
-BOOL CALLBACK EnumSystemLocalesProc(char *szLocale)
+BOOL CALLBACK EnumSystemLocalesProc(TCHAR *szLocale)
{
- DWORD locale = atoi(szLocale);
- char *name = GetLanguageName(locale);
- if (!strstr(szSystemLocales, name))
+ DWORD locale = _ttoi(szLocale);
+ TCHAR *name = GetLanguageName(locale);
+ if (!_tcsstr(szSystemLocales, name))
{
- strcat(szSystemLocales, name);
- strcat(szSystemLocales, ", ");
+ _tcscat(szSystemLocales, name);
+ _tcscat(szSystemLocales, _T(", "));
}
return TRUE;
@@ -573,7 +521,7 @@ BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszNam bool CVersionInfo::GetOSLanguages()
{
- lpzOSLanguages = "(UI | Locale (User/System)) : ";
+ lpzOSLanguages = _T("(UI | Locale (User/System)) : ");
LANGID UILang;
@@ -586,7 +534,7 @@ bool CVersionInfo::GetOSLanguages() {
if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) //Win NT
{
- HMODULE hLib = LoadLibrary("ntdll.dll");
+ HMODULE hLib = LoadLibraryA("ntdll.dll");
if (hLib)
{
@@ -621,25 +569,25 @@ bool CVersionInfo::GetOSLanguages() }
else{ //Win 95-Me
HKEY hKey = NULL;
- char szLangID[128] = "0x";
- DWORD size = sizeof(szLangID) - 2;
- char err[512];
+ TCHAR szLangID[128] = _T("0x");
+ DWORD size = SIZEOF(szLangID) - 2;
+ TCHAR err[512];
- if (RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop\\ResourceLocale", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Desktop\\ResourceLocale"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
{
- if (RegQueryValueEx(hKey, "", 0, NULL, (LPBYTE) &szLangID + 2, &size) == ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, _T(""), 0, NULL, (LPBYTE) &szLangID + 2, &size) == ERROR_SUCCESS)
{
- sscanf(szLangID, "%lx", &systemLangID);
+ _tscanf(szLangID, _T("%lx"), &systemLangID);
}
else{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL);
- MessageBox(0, err, "Error at RegQueryValueEx()", MB_OK);
+ 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, "Error at RegOpenKeyEx()", MB_OK);
+ MessageBox(0, err, _T("Error at RegOpenKeyEx()"), MB_OK);
}
}
@@ -651,7 +599,7 @@ bool CVersionInfo::GetOSLanguages() case 5: //Win 2000, XP
default:
{
- HMODULE hKernel32 = LoadLibrary("kernel32.dll");
+ HMODULE hKernel32 = LoadLibraryA("kernel32.dll");
if (hKernel32)
{
MyGetUserDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetUserDefaultUILanguage");
@@ -664,46 +612,45 @@ bool CVersionInfo::GetOSLanguages() {
UILang = MyGetUserDefaultUILanguage();
lpzOSLanguages += GetLanguageName(UILang);
- lpzOSLanguages += "/";
+ lpzOSLanguages += _T("/");
UILang = MyGetSystemDefaultUILanguage();
lpzOSLanguages += GetLanguageName(UILang);
}
else{
- lpzOSLanguages += "Missing functions in kernel32.dll (GetUserDefaultUILanguage, GetSystemDefaultUILanguage)";
+ lpzOSLanguages += _T("Missing functions in kernel32.dll (GetUserDefaultUILanguage, GetSystemDefaultUILanguage)");
}
break;
}
}
- lpzOSLanguages += " | ";
+ lpzOSLanguages += _T(" | ");
lpzOSLanguages += GetLanguageName(LOCALE_USER_DEFAULT);
- lpzOSLanguages += "/";
+ lpzOSLanguages += _T("/");
lpzOSLanguages += GetLanguageName(LOCALE_SYSTEM_DEFAULT);
if (DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", 0))
{
szSystemLocales[0] = '\0';
- lpzOSLanguages += " [";
+ lpzOSLanguages += _T(" [");
EnumSystemLocales(EnumSystemLocalesProc, LCID_INSTALLED);
- if (strlen(szSystemLocales) > 2)
- {
- szSystemLocales[strlen(szSystemLocales) - 2] = '\0';
- }
+ if (_tcslen(szSystemLocales) > 2)
+ szSystemLocales[ _tcslen(szSystemLocales) - 2] = '\0';
+
lpzOSLanguages += szSystemLocales;
- lpzOSLanguages += "]";
+ lpzOSLanguages += _T("]");
}
return true;
}
-int SaveInfo(const char *data, const char *lwrData, const char *search, char *dest, int size)
+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)
{
- strncpy(dest, &data[strlen(search)], size);
+ _tcsncpy(dest, _A2T(&data[strlen(search)]), size);
res = 0;
}
@@ -712,57 +659,51 @@ int SaveInfo(const char *data, const char *lwrData, const char *search, char *de bool CVersionInfo::GetLangpackInfo()
{
- char langpackPath[MAX_PATH] = {0};
- char search[MAX_PATH] = {0};
- char *p;
- lpzLangpackModifiedDate = "";
- GetModuleFileName(GetModuleHandle(NULL), langpackPath, sizeof(langpackPath));
- p = strrchr(langpackPath, '\\');
+ 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';
- strcpy(search, langpackPath);
- strcat(search, "langpack_*.txt");
+ _tcscpy(search, langpackPath);
+ _tcscat(search, _T("langpack_*.txt"));
hLangpack = FindFirstFile(search, &data);
if (hLangpack != INVALID_HANDLE_VALUE)
{
char buffer[1024];
char temp[1024];
- //FILETIME localWriteTime;
- //SYSTEMTIME sysTime;
FillLocalTime(lpzLangpackModifiedDate, &data.ftLastWriteTime);
- char locale[128] = {0};
- char language[128] = {0};
- char version[128] = {0};
- strcpy(version, "N/A");
- char *p;
- strncpy(temp, data.cFileName, sizeof(temp));
- p = strrchr(temp, '.');
- p[0] = '\0';
- strncpy(language, strchr(temp, '_') + 1, sizeof(language));
+ TCHAR locale[128] = {0};
+ TCHAR language[128] = {0};
+ TCHAR version[128] = {0};
+ _tcscpy(version, _T("N/A"));
- strcat(langpackPath, data.cFileName);
- FILE *fin = fopen(langpackPath, "rt");
+ _tcsncpy(language, data.cFileName, SIZEOF(language));
+ p = _tcsrchr(language, '.');
+ p[0] = '\0';
- if (fin)
- {
+ _tcscat(langpackPath, data.cFileName);
+ FILE *fin = _tfopen(langpackPath, _T("rt"));
+ if (fin) {
size_t len;
- while (!feof(fin))
- {
- fgets(buffer, sizeof(buffer), fin);
+ 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));
+ strncpy(temp, buffer, SIZEOF(temp));
_strlwr(temp);
- if (SaveInfo(buffer, temp, "language: ", language, sizeof(language)))
+ if (SaveInfo(buffer, temp, "language: ", language, SIZEOF(language)))
{
- if (SaveInfo(buffer, temp, "locale: ", locale, sizeof(locale)))
+ if (SaveInfo(buffer, temp, "locale: ", locale, SIZEOF(locale)))
{
- p = strstr(buffer, "; FLID: ");
+ char* p = strstr(buffer, "; FLID: ");
if (p)
{
int ok = 1;
@@ -781,55 +722,51 @@ bool CVersionInfo::GetLangpackInfo() p = strrchr(temp, ' ');
if ((ok) && (p))
{
- strncpy(version, &buffer[p - temp + 1], sizeof(version));
+ _tcsncpy(version, _A2T(&buffer[p - temp + 1]), SIZEOF(version));
}
else{
- strncpy(version, "<unknown>", sizeof(version));
+ _tcsncpy(version, _T("<unknown>"), SIZEOF(version));
}
}
}
}
}
- lpzLangpackInfo = std::string(language) + " [" + std::string(locale) + "]";
- if (strlen(version) > 0)
- {
- lpzLangpackInfo += " v. " + std::string(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 = "<error> Could not open file " + std::string(data.cFileName);
+ lpzLangpackInfo = _T("<error> Could not open file " + std::tstring(data.cFileName));
}
FindClose(hLangpack);
}
- else{
- lpzLangpackInfo = "No language pack installed";
- }
+ else lpzLangpackInfo = _T("No language pack installed");
}
return true;
}
-std::string GetPluginTimestamp(FILETIME *fileTime)
+std::tstring GetPluginTimestamp(FILETIME *fileTime)
{
SYSTEMTIME sysTime;
FileTimeToSystemTime(fileTime, &sysTime); //convert the file tyme to system time
+
//char time[256];
- char date[256]; //lovely
- GetDateFormat(EnglishLocale, 0, &sysTime, "dd' 'MMM' 'yyyy", date, sizeof(date));
- //GetTimeFormat(NULL, TIME_FORCE24HOURFORMAT, &sysTime, "HH':'mm':'ss", time, sizeof(time)); //americans love 24hour format :)
- std::string timedate(date);
- return timedate;
+ TCHAR date[256]; //lovely
+ GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date));
+ return date;
}
-bool CVersionInfo::GetPluginLists() {
-
+bool CVersionInfo::GetPluginLists()
+{
HANDLE hFind;
- char szMirandaPath[MAX_PATH] = { 0 }, szSearchPath[MAX_PATH] = { 0 }; //For search purpose
+ TCHAR szMirandaPath[MAX_PATH] = { 0 }, szSearchPath[MAX_PATH] = { 0 }; //For search purpose
WIN32_FIND_DATA fd;
- char szMirandaPluginsPath[MAX_PATH] = { 0 }, szPluginPath[MAX_PATH] = { 0 }; //For info reading purpose
+ 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.
@@ -837,101 +774,79 @@ bool CVersionInfo::GetPluginLists() { DWORD mirandaVersion = 0;
BOOL asmCheckOK = FALSE;
DWORD loadError;
-// SYSTEMTIME sysTime; //for timestamp
+ // SYSTEMTIME sysTime; //for timestamp
mirandaVersion=(DWORD)CallService(MS_SYSTEM_GETVERSION,0,0);
-
- { char *str2;
- GetModuleFileName(GetModuleHandle(NULL),szMirandaPath,sizeof(szMirandaPath));
- str2=strrchr(szMirandaPath,'\\');
+ {
+ GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath));
+ TCHAR* str2 = _tcsrchr(szMirandaPath,'\\');
if(str2!=NULL) *str2=0;
}
- lpzMirandaPath = std::string(szMirandaPath);
+ 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,"\\Plugins\\*.dll");
-
+ lstrcat(szSearchPath, _T("\\Plugins\\*.dll"));
+
lstrcpyn(szMirandaPluginsPath, szMirandaPath, MAX_PATH);
- lstrcat(szMirandaPluginsPath,"\\Plugins\\");
-
+ lstrcat(szMirandaPluginsPath, _T("\\Plugins\\"));
+
hFind=FindFirstFile(szSearchPath,&fd);
LogToFile("Starting to load plugins");
if(hFind != INVALID_HANDLE_VALUE) {
do {
- if (verbose) PUShowMessage(fd.cFileName, SM_NOTIFY);
- if (!ValidExtension(fd.cFileName, "dll"))
- {
+ 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;
- LogToFile("Plugin '%s' is enabled and loaded", fd.cFileName);
- }
- else{
- PluginIsEnabled = 0;
- LogToFile("Plugin '%s' is not loaded, going to load it", fd.cFileName);
- 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);
-/*
- PluginIsEnabled = !(
- DBGetContactSettingByte(NULL, "PluginDisable", fd.cFileName, FALSE)
- || DBGetContactSettingByte(NULL, "PluginDisable", CharUpper(fd.cFileName), FALSE)
- || DBGetContactSettingByte(NULL, "PluginDisable", CharLower(fd.cFileName), FALSE)
-
- }; //If the DB does not contain that value, the plugin is enabled => default: FALSE; action: !read
-*/
- //Let's read the informations.
-/*
- }
- if (PluginIsEnabled) {
- hInstPlugin = GetModuleHandle(fd.cFileName);
+ {
+ PluginIsEnabled = 1;
+ LogToFile("Plugin '%s' is enabled and loaded", fd.cFileName);
}
- else{
+ else{
+ PluginIsEnabled = 0;
+ LogToFile("Plugin '%s' is not loaded, going to load it", fd.cFileName);
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::string 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))
- {
- LogToFile("Plugin %s has unresolved dependencies, adding to unloadable list", szPluginPath);
- std::string time = GetPluginTimestamp(&fd.ftLastWriteTime);
- CPlugin thePlugin = CPlugin(std::string(fd.cFileName), "<unknown>", UUID_NULL, "", 0, time, linkedModules);
- AddPlugin(thePlugin, listUnloadablePlugins);
- bUnknownError = 0; //we know why the plugin didn't load
- }
- }
- if (bUnknownError) //if cause is unknown then report it
- {
- LogToFile("Plugin %s doesn't load", szPluginPath);
- std::string time = GetPluginTimestamp(&fd.ftLastWriteTime);
- char buffer[4096];
- char error[2048];
- //DWORD_PTR arguments[2] = {loadError, 0};
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, loadError, 0, error, sizeof(error), NULL);
- sprintf(buffer, " Error %ld - %s", loadError, error);
- CPlugin thePlugin = CPlugin(std::string(fd.cFileName), "<unknown>", UUID_NULL, "", 0, time, buffer);
+ LogToFile("Plugin %s has unresolved dependencies, adding to unloadable list", szPluginPath);
+ 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
+ {
+ LogToFile("Plugin %s doesn't load", szPluginPath);
+ 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.
LogToFile("Plugin '%s' was loaded successfully", fd.cFileName);
@@ -944,7 +859,7 @@ bool CVersionInfo::GetPluginLists() { continue;
}
else {
- //It's a valid plugin, since we could find MirandaPluginInfo
+ //It's a valid plugin, since we could find MirandaPluginInfo
#if (!defined(WIN64) && !defined(_WIN64))
asmCheckOK = FALSE;
__asm {
@@ -956,9 +871,7 @@ bool CVersionInfo::GetPluginLists() { cmp eax, mirandaVersion
jne a1
mov asmCheckOK, 0xffffffff
- // jmp a2
- a1:
- // a2:
+ a1:
}
#else
asmCheckOK = TRUE;
@@ -967,7 +880,7 @@ bool CVersionInfo::GetPluginLists() { pluginInfo = CopyPluginInfo(MirandaPluginInfo(mirandaVersion));
else {
ZeroMemory(&pluginInfo, sizeof(pluginInfo));
- MessageBox(NULL, fd.cFileName, "Invalid plugin", MB_OK);
+ MessageBox(NULL, fd.cFileName, _T("Invalid plugin"), MB_OK);
}
}
}
@@ -976,17 +889,15 @@ bool CVersionInfo::GetPluginLists() { if (pluginInfo != NULL) {
LogToFile("Plugin '%s' is a miranda plugin", fd.cFileName);
//We have loaded the informations into pluginInfo.
- std::string timedate = GetPluginTimestamp(&fd.ftLastWriteTime);
- CPlugin thePlugin = CPlugin(std::string(fd.cFileName),std::string(pluginInfo->shortName), pluginInfo->uuid, std::string((pluginInfo->flags & 1) ? "Unicode aware" : ""), (DWORD) pluginInfo->version, timedate, "");
+ 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(" Plugin does not have an UUID and will not work with Miranda 0.8.\r\n");
+ thePlugin.SetErrorMessage( _T(" Plugin does not have an UUID and will not work with Miranda 0.8.\r\n"));
AddPlugin(thePlugin, listUnloadablePlugins);
}
else{
@@ -996,29 +907,28 @@ bool CVersionInfo::GetPluginLists() { }
FreePluginInfo(pluginInfo);
MirandaPluginInfo = NULL;
-#ifdef _DEBUG
- if (verbose)
- {
- char szMsg[4096] = { 0 };
- wsprintf(szMsg, "Done with: %s", fd.cFileName);
- PUShowMessage(szMsg, SM_NOTIFY);
- }
-#endif
+ #ifdef _DEBUG
+ if (verbose)
+ {
+ TCHAR szMsg[4096] = { 0 };
+ wsprintf(szMsg, _T("Done with: %s"), fd.cFileName);
+ PUShowMessageT(szMsg, SM_NOTIFY);
+ }
+ #endif
}
else{//pluginINFO == NULL
LogToFile("Plugin '%s' refuses to load", fd.cFileName);
pluginInfo = CopyPluginInfo(MirandaPluginInfo(PLUGIN_MAKE_VERSION(9, 9, 9, 9))); //let's see if the plugin likes this miranda version
char *szShortName = "<unknown>";
- std::string time = GetPluginTimestamp(&fd.ftLastWriteTime); //get the plugin timestamp;
+ std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); //get the plugin timestamp;
DWORD version = 0;
- if (pluginInfo)
- {
+ if (pluginInfo) {
szShortName = pluginInfo->shortName;
version = pluginInfo->version;
}
- CPlugin thePlugin = CPlugin(std::string(fd.cFileName), std::string(szShortName), (pluginInfo) ? (pluginInfo->uuid) : UUID_NULL, std::string(((pluginInfo) && (pluginInfo->flags & 1)) ? "Unicode aware" : ""), version, time, " Plugin refuses to load. Miranda version too old.");
-
+ 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)
{
@@ -1067,81 +977,78 @@ static char *GetStringFromRVA(DWORD RVA, const LOADED_IMAGE *image) return moduleName;
}
-bool CVersionInfo::GetLinkedModulesInfo(char *moduleName, std::string &linkedModules)
+bool CVersionInfo::GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules)
{
LogToFile("Checking dll %s for unresolved dll dependencies ...", moduleName);
LOADED_IMAGE image;
ULONG importTableSize;
IMAGE_IMPORT_DESCRIPTOR *importData;
//HMODULE dllModule;
- linkedModules = "";
+ linkedModules = _T("");
bool result = false;
-// LogToFile(" Before LoadLibraryEx", moduleName);
-// dllModule = LoadLibraryEx(moduleName, NULL, DONT_RESOLVE_DLL_REFERENCES);
- //dllModule = 0;
- //LogToFile(" Before MapAndLoad (dll handle %ld)", moduleName, dllModule);
- if (MapAndLoad(moduleName, NULL, &image, TRUE, TRUE) == FALSE)
- {
- char tmp[20];
- sprintf(tmp, "%d", GetLastError());
- LogToFile(" MapAndLoad failed with error %s", tmp);
- linkedModules = "<error " + std::string(tmp) + " at MapAndLoad()>\r\n";
-// FreeLibrary(dllModule);
- return result;
- }
+ TCHAR szError[20];
+ char* szModuleName = mir_t2a(moduleName);
+ if (MapAndLoad(szModuleName, NULL, &image, TRUE, TRUE) == FALSE)
+ {
+ wsprintf(szError, _T("%d"), GetLastError());
+ LogToFile(" MapAndLoad failed with error %S", szError);
+ mir_free( szModuleName );
+ linkedModules = _T("<error ") + std::tstring(szError) + _T(" at MapAndLoad()>\r\n");
+ return result;
+ }
+ mir_free( szModuleName );
LogToFile(" Before ImageDirectoryEntryToData (base address %ld)", image.MappedAddress);
importData = (IMAGE_IMPORT_DESCRIPTOR *) ImageDirectoryEntryToData(image.MappedAddress, FALSE, IMAGE_DIRECTORY_ENTRY_IMPORT, &importTableSize);
if (!importData)
+ {
+ wsprintf(szError, _T("%d"), GetLastError());
+ LogToFile(" ImageDirectoryEntryToData failed with error %s", szError);
+ linkedModules = _T("<error ") + std::tstring(szError) + _T(" at ImageDirectoryEntryToDataEx()>\r\n");
+ }
+ else{
+ LogToFile(" Checking dll dependencies");
+ while (importData->Name)
{
- char tmp[20];
- sprintf(tmp, "%d", GetLastError());
- LogToFile(" ImageDirectoryEntryToData failed with error %s", tmp);
- linkedModules = "<error " + std::string(tmp) + " at ImageDirectoryEntryToDataEx()>\r\n";
- }
- else{
- LogToFile(" Checking dll dependencies");
- while (importData->Name)
- {
- char *moduleName;
- moduleName = GetStringFromRVA(importData->Name, &image);
- LogToFile(" Checking link to dll %s", moduleName);
- if (!DoesDllExist(moduleName))
- {
- LogToFile(" Dll %s not found, adding to list", moduleName);
- linkedModules.append(" Plugin statically links to missing dll file: " + std::string(moduleName) + "\r\n");
- result = true;
- }
- else{
- LogToFile(" Dll %s found", moduleName);
- }
- LogToFile(" Moving to next import entry");
- importData++; //go to next record
- }
+ char *moduleName;
+ moduleName = GetStringFromRVA(importData->Name, &image);
+ LogToFile(" Checking link to dll %s", moduleName);
+ if (!DoesDllExist(moduleName))
+ {
+ LogToFile(" Dll %s not found, adding to list", moduleName);
+ linkedModules.append( _T(" Plugin statically links to missing dll file: ") + std::tstring(_A2T(moduleName)) + _T("\r\n"));
+ result = true;
+ }
+ else{
+ LogToFile(" Dll %s found", moduleName);
+ }
+ LogToFile(" Moving to next import entry");
+ importData++; //go to next record
}
+ }
LogToFile(" Done checking dependencies");
LogToFile(" Cleaning up; before {FreeLibrary()} and UnMapAndLoad");
-// FreeLibrary(dllModule);
+ // FreeLibrary(dllModule);
UnMapAndLoad(&image); //unload the image
return result;
}
-std::string CVersionInfo::GetListAsString(std::list<CPlugin> &aList, DWORD flags, int beautify) {
+std::tstring CVersionInfo::GetListAsString(std::list<CPlugin> &aList, DWORD flags, int beautify) {
std::list<CPlugin>::iterator pos = aList.begin();
- std::string out = "";
+ std::tstring out = _T("");
#ifdef _DEBUG
if (verbose) PUShowMessage("CVersionInfo::GetListAsString, begin.", SM_NOTIFY);
#endif
- char szHeader[32] = {0};
- char szFooter[32] = {0};
+ TCHAR szHeader[32] = {0};
+ TCHAR szFooter[32] = {0};
if ((((flags & VISF_FORUMSTYLE) == VISF_FORUMSTYLE) || beautify) && (DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE)))
{
- GetStringFromDatabase("BoldBegin", "[b]", szHeader, sizeof(szHeader));
- GetStringFromDatabase("BoldEnd", "[/b]", szFooter, sizeof(szFooter));
+ GetStringFromDatabase("BoldBegin", _T("[b]"), szHeader, SIZEOF(szHeader));
+ GetStringFromDatabase("BoldEnd", _T("[/b]"), szFooter, SIZEOF(szFooter));
}
while (pos != aList.end()) {
- out.append(std::string((*pos).getInformations(flags, szHeader, szFooter)));
+ out.append(std::tstring((*pos).getInformations(flags, szHeader, szFooter)));
pos++;
}
#ifdef _DEBUG
@@ -1150,159 +1057,140 @@ std::string CVersionInfo::GetListAsString(std::list<CPlugin> &aList, DWORD flags return out;
};
-void CVersionInfo::BeautifyReport(int beautify, char *szBeautifyText, char *szNonBeautifyText, std::string &out)
+void CVersionInfo::BeautifyReport(int beautify, LPCTSTR szBeautifyText, LPCTSTR szNonBeautifyText, std::tstring &out)
{
if (beautify)
- {
- out.append(szBeautifyText);
- }
- else{
- out.append(szNonBeautifyText);
- }
+ out.append(szBeautifyText);
+ else
+ out.append(szNonBeautifyText);
}
-void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautify, std::string &out)
+void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautify, std::tstring &out)
{
if (forumStyle) //forum style
- {
- char szSize[256];
- char szQuote[256];
+ {
+ 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("");
- GetStringFromDatabase("SizeBegin", "[size=1]", szSize, sizeof(szSize));
- GetStringFromDatabase("QuoteBegin", "[quote]", szQuote, sizeof(szQuote));
- out.append(szQuote);
- out.append(szSize);
- }
- else{
- out = "";
- }
if (!suppressHeader)
+ {
+ out.append( _T("Miranda IM - VersionInformation plugin by Hrk, modified by Eblis\r\n"));
+ if (!forumStyle)
{
- out.append("Miranda IM - VersionInformation plugin by Hrk, modified by Eblis\r\n");
- if (!forumStyle)
- {
- out.append("Miranda's homepage: http://www.miranda-im.org/\r\n"); //changed homepage
- out.append("Miranda tools: http://miranda-im.org/download/\r\n\r\n"); //was missing a / before download
- }
+ out.append( _T("Miranda's homepage: http://www.miranda-im.org/\r\n")); //changed homepage
+ out.append( _T("Miranda tools: http://miranda-im.org/download/\r\n\r\n")); //was missing a / before download
}
- char buffer[1024]; //for beautification
- GetStringFromDatabase("BeautifyHorizLine", "<hr />", buffer, sizeof(buffer));
- BeautifyReport(beautify, buffer, "", out);
- GetStringFromDatabase("BeautifyBlockStart", "<blockquote>", buffer, sizeof(buffer));
- BeautifyReport(beautify, buffer, "", out);
+ }
+
+ 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:
- char lpzTime[12]; GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL,"HH':'mm':'ss",lpzTime, sizeof(lpzTime));
- char lpzDate[32]; GetDateFormat(EnglishLocale, 0, NULL,"dd' 'MMMM' 'yyyy",lpzDate, sizeof(lpzDate));
- out.append("Report generated at: " + std::string(lpzTime) + " on " + std::string(lpzDate) + "\r\n\r\n");
+ 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("CPU: " + lpzCPUName + " [" + lpzCPUIdentifier + "]");
+ out.append(_T("CPU: ") + lpzCPUName + _T(" [") + lpzCPUIdentifier + _T("]"));
if (bDEPEnabled)
- {
- out.append(" [DEP enabled]");
- }
- if (luiProcessors > 1)
- {
- char noProcs[128];
- sprintf(noProcs, " [%d CPUs]", luiProcessors);
- out.append(noProcs);
- }
- out.append("\r\n");
+ 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
- char szRAM[64]; wsprintf(szRAM, "%d", luiRAM);
- out.append("Installed RAM: " + std::string(szRAM) + " MBytes\r\n");
+ TCHAR szRAM[64]; wsprintf(szRAM, _T("%d"), luiRAM);
+ out.append( _T("Installed RAM: ") + std::tstring(szRAM) + _T(" MBytes\r\n"));
//operating system
- out.append("Operating System: " + lpzOSName + " [version: " + lpzOSVersion + "]\r\n");
+ out.append( _T("Operating System: ") + lpzOSName + _T(" [version: ") + lpzOSVersion + _T("]\r\n"));
//shell, IE, administrator
- out.append("Shell: " + lpzShell + ", Internet Explorer " + lpzIEVersion + "\r\n");
- out.append("Administrator privileges: " + lpzAdministratorPrivileges + "\r\n");
+ out.append( _T("Shell: ") + lpzShell + _T(", Internet Explorer ") + lpzIEVersion + _T("\r\n"));
+ out.append( _T("Administrator privileges: ") + lpzAdministratorPrivileges + _T("\r\n"));
//languages
- out.append("OS Languages: " + lpzOSLanguages + "\r\n");
+ out.append( _T("OS Languages: ") + lpzOSLanguages + _T("\r\n"));
//FreeDiskSpace
if (luiFreeDiskSpace) {
- char szDiskSpace[64]; wsprintf(szDiskSpace, "%d", luiFreeDiskSpace);
- out.append("Free disk space on Miranda partition: " + std::string(szDiskSpace) + " MBytes\r\n");
+ 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("Miranda path: " + lpzMirandaPath + "\r\n");
-
- out.append("Miranda IM version: " + lpzMirandaVersion);
+ out.append( _T("Miranda path: ") + lpzMirandaPath + _T("\r\n"));
+ out.append( _T("Miranda IM version: ") + lpzMirandaVersion);
if (bIsWOW64)
- {
- out.append(" [running inside WOW64]");
- }
+ out.append( _T(" [running inside WOW64]"));
if (bServiceMode)
- {
- out.append(" [service mode]");
- }
- out.append("\r\nBuild time: " + lpzBuildTime + "\r\n");
- out.append("Profile path: " + lpzProfilePath + "\r\n");
- //if (lpzProfileSize.find("error", 0) == std::string::npos) //only show the profile size of no error occured
- //{
- out.append("Profile size: " + lpzProfileSize + "\r\n");
- out.append("Profile creation date: " + lpzProfileCreationDate + "\r\n");
- //}
- out.append("Language pack: " + lpzLangpackInfo);
- out.append((lpzLangpackModifiedDate.size() > 0) ? ", modified: " + lpzLangpackModifiedDate : "");
- out.append("\r\n");
+ 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("Nightly: " + lpzNightly + "\r\n");
- out.append("Unicode core: " + lpzUnicodeBuild);
+ out.append( _T("Nightly: ") + lpzNightly + _T("\r\n"));
+ out.append( _T("Unicode core: ") + lpzUnicodeBuild);
- GetStringFromDatabase("BeautifyBlockEnd", "</blockquote>", buffer, sizeof(buffer));
- BeautifyReport(beautify, buffer, "\r\n", out);
- //out.append("\r\n");
+ GetStringFromDatabase("BeautifyBlockEnd", _T("</blockquote>"), buffer, SIZEOF(buffer));
+ BeautifyReport(beautify, buffer, _T("\r\n"), out);
}
-void CVersionInfo::AddInfoFooter(int suppressFooter, int forumStyle, int beautify, std::string &out)
+void CVersionInfo::AddInfoFooter(int suppressFooter, int forumStyle, int beautify, std::tstring &out)
{
//End of report
- char buffer[1024]; //for beautification purposes
- GetStringFromDatabase("BeautifyHorizLine", "<hr />", buffer, sizeof(buffer));
- if (!suppressFooter)
- {
- BeautifyReport(beautify, buffer, "\r\n", out);
- out.append("\r\nEnd of report.\r\n");
- }
- if (!forumStyle)
- {
- if (!suppressFooter)
- {
- out.append(Translate("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{
- char szSize[256];
- char szQuote[256];
+ 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"));
+ }
- GetStringFromDatabase("SizeEnd", "[/size]", szSize, sizeof(szSize));
- GetStringFromDatabase("QuoteEnd", "[/quote]", szQuote, sizeof(szQuote));
- out.append(szSize);
- out.append(szQuote);
- }
+ 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, char *listText, std::string &out)
+static void AddSectionAndCount(std::list<CPlugin> list, LPCTSTR listText, std::tstring &out)
{
- char tmp[64];
- sprintf(tmp, " (%u)", list.size());
+ TCHAR tmp[64];
+ wsprintf(tmp, _T(" (%u)"), list.size());
out.append(listText);
- out.append(tmp);
- out.append(":");
+ out.append( tmp );
+ out.append( _T(":"));
}
-std::string CVersionInfo::GetInformationsAsString(int bDisableForumStyle) {
+std::tstring CVersionInfo::GetInformationsAsString(int bDisableForumStyle) {
//Begin of report
- std::string out;
+ 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);
@@ -1311,96 +1199,91 @@ std::string CVersionInfo::GetInformationsAsString(int bDisableForumStyle) { DWORD flags = (forumStyle) | (showUUID << 1);
AddInfoHeader(suppressHeader, forumStyle, beautify, out);
- char normalPluginsStart[1024]; //for beautification purposes, for normal plugins text (start)
- char normalPluginsEnd[1024]; //for beautification purposes, for normal plugins text (end)
- char horizLine[1024]; //for beautification purposes
- char buffer[1024]; //for beautification purposes
-
- char headerHighlightStart[10] = "";
- char headerHighlightEnd[10] = "";
- if (forumStyle)
- {
- char start[128], end[128];
- GetStringFromDatabase("BoldBegin", "[b]", start, sizeof(start));
- GetStringFromDatabase("BoldEnd", "[/b]", end, sizeof(end));
- strncpy(headerHighlightStart, start, sizeof(headerHighlightStart));
- strncpy(headerHighlightEnd, end, sizeof(headerHighlightEnd));
- }
+ 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", "<hr />", horizLine, sizeof(horizLine));
- BeautifyReport(beautify, horizLine, "\r\n", out);
- GetStringFromDatabase("BeautifyActiveHeaderBegin", "<b><font size=\"-1\" color=\"DarkGreen\">", buffer, sizeof(buffer));
+ 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, "Active Plugins", out);
- GetStringFromDatabase("BeautifyActiveHeaderEnd", "</font></b>", buffer, sizeof(buffer));
+ AddSectionAndCount(listActivePlugins, _T("Active Plugins"), out);
+ GetStringFromDatabase("BeautifyActiveHeaderEnd", _T("</font></b>"), buffer, SIZEOF(buffer));
BeautifyReport(beautify, buffer, headerHighlightEnd, out);
- out.append("\r\n");
-
- GetStringFromDatabase("BeautifyPluginsBegin", "<font size=\"-2\" color=\"black\">", normalPluginsStart, sizeof(normalPluginsStart));
- BeautifyReport(beautify, normalPluginsStart, "", 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", "</font>", normalPluginsEnd, sizeof(normalPluginsEnd));
- BeautifyReport(beautify, normalPluginsEnd, "", out);
+ 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, "\r\n", out);
- GetStringFromDatabase("BeautifyInactiveHeaderBegin", "<b><font size=\"-1\" color=\"DarkRed\">", buffer, sizeof(buffer));
+ 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, "Inactive Plugins", out);
- GetStringFromDatabase("BeautifyInactiveHeaderEnd", "</font></b>", buffer, sizeof(buffer));
+ AddSectionAndCount(listInactivePlugins, _T("Inactive Plugins"), out);
+ GetStringFromDatabase("BeautifyInactiveHeaderEnd", _T("</font></b>"), buffer, SIZEOF(buffer));
BeautifyReport(beautify, buffer, headerHighlightEnd, out);
- out.append("\r\n");
- BeautifyReport(beautify, normalPluginsStart, "", out);
+ out.append( _T("\r\n"));
+ BeautifyReport(beautify, normalPluginsStart, _T(""), out);
out.append(GetListAsString(listInactivePlugins, flags, beautify));
- BeautifyReport(beautify, normalPluginsEnd, "", out);
+ 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);
}
- if (listUnloadablePlugins.size() > 0)
- {
- //out.append("\r\n");
- BeautifyReport(beautify, horizLine, "\r\n", out);
- GetStringFromDatabase("BeautifyUnloadableHeaderBegin", "<b><font size=\"-1\"><font color=\"Red\">", buffer, sizeof(buffer));
- BeautifyReport(beautify, buffer, headerHighlightStart, out);
- AddSectionAndCount(listUnloadablePlugins, "Unloadable Plugins", out);
- GetStringFromDatabase("BeautifyUnloadableHeaderEnd", "</font></b>", buffer, sizeof(buffer));
- BeautifyReport(beautify, buffer, headerHighlightEnd, out);
- out.append("\r\n");
- BeautifyReport(beautify, normalPluginsStart, "", out);
- out.append(GetListAsString(listUnloadablePlugins, flags, beautify));
- BeautifyReport(beautify, normalPluginsEnd, "", out);
- }
AddInfoFooter(suppressHeader, forumStyle, beautify, out);
return out;
}
//========== Print functions =====
-void CVersionInfo::PrintInformationsToFile(const char *info)
+void CVersionInfo::PrintInformationsToFile(const TCHAR *info)
{
- char buffer[MAX_PATH];
- char outputFileName[MAX_PATH];
- if (bFoldersAvailable)
- {
- FoldersGetCustomPath(hOutputLocation, buffer, sizeof(buffer), "%miranda_path%");
- strcat(buffer, "\\VersionInfo.txt");
- }
- else{
- GetStringFromDatabase("OutputFile", "VersionInfo.txt", buffer, sizeof(buffer));
+ 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));
+ RelativePathToAbsolute(buffer, outputFileName, SIZEOF(buffer));
- FILE *fp = fopen(outputFileName, "wb");
- if (fp != NULL) {
- fprintf(fp, info);
+ FILE *fp = _tfopen(outputFileName, _T("wb"));
+ if ( fp != NULL ) {
+ char* utf = mir_utf8encodeT( info );
+ fputs( "\xEF\xBB\xBF", fp);
+ fputs( utf, fp );
fclose(fp);
char mex[512];
- mir_snprintf(mex, sizeof(mex), Translate("Information successfully written to file: \"%s\"."), outputFileName);
+ mir_snprintf(mex, SIZEOF(mex), Translate("Information successfully written to file: \"%s\"."), outputFileName);
Log(mex);
}
else {
char mex[512];
- mir_snprintf(mex, sizeof(mex), Translate("Error during the creation of file \"%s\". Disk may be full or write protected."), outputFileName);
+ mir_snprintf(mex, SIZEOF(mex), Translate("Error during the creation of file \"%s\". Disk may be full or write protected."), outputFileName);
Log(mex);
}
}
@@ -1410,7 +1293,7 @@ void CVersionInfo::PrintInformationsToFile() { }
void CVersionInfo::PrintInformationsToMessageBox() {
- MessageBox(NULL, (*this).GetInformationsAsString().c_str(), ModuleName, MB_OK);
+ MessageBox(NULL, (*this).GetInformationsAsString().c_str(), _T("VersionInfo"), MB_OK);
return;
}
@@ -1444,12 +1327,12 @@ void CVersionInfo::PrintInformationsToClipboard(bool showLog) { EmptyClipboard();
//Storage data we'll use.
LPTSTR lptstrCopy;
- std::string aux = (*this).GetInformationsAsString();
+ std::tstring aux = GetInformationsAsString();
size_t length = aux.length() + 1;
- HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, length + 5);
+ HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, length*sizeof(TCHAR) + 5);
//Lock memory, copy it, release it.
lptstrCopy = (LPTSTR)GlobalLock(hData);
- memcpy(lptstrCopy, aux.c_str(), length);
+ lstrcpy(lptstrCopy, aux.c_str());
lptstrCopy[length] = '\0';
GlobalUnlock(hData);
//Now set the clipboard data.
@@ -1563,26 +1446,20 @@ DWORD WINAPI UploadWorkerTread(LPVOID param) return 0;
}
-void CVersionInfo::UploadToSite(char *text){
-
+void CVersionInfo::UploadToSite(LPTSTR text)
+{
DWORD threadID;
HANDLE thread;
char *data = NULL;
if (!text)
- {
- data = _strdup(GetInformationsAsString().c_str());
- }
- else{
- data = _strdup(text);
- }
-
+ data = mir_utf8encodeT( GetInformationsAsString().c_str());
+ else
+ data = mir_utf8encodeT( text );
+
thread = CreateThread(NULL, NULL, UploadWorkerTread, data, 0, &threadID); //the thread will free the buffer
if (!thread)
- {
- MB("Upload worker thread could not be created");
- }
- if ((thread != NULL) && (thread != INVALID_HANDLE_VALUE))
- {
+ MB("Upload worker thread could not be created");
+
+ if ( thread != NULL && thread != INVALID_HANDLE_VALUE)
CloseHandle(thread);
- }
-}
\ No newline at end of file +}
|