| OLD | NEW |
| 1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
| 2 | 2 |
| 3 // Internet / FTP | |
| 4 #include <wininet.h> | |
| 5 | |
| 6 // IP adapter | |
| 7 #include <iphlpapi.h> | |
| 8 | |
| 9 #include "PluginSystem.h" | 3 #include "PluginSystem.h" |
| 10 #include "PluginClient.h" | 4 #include "PluginClient.h" |
| 11 #include "PluginSettings.h" | |
| 12 | 5 |
| 13 | 6 std::wstring GetBrowserLanguage() |
| 14 // IP adapter | |
| 15 #pragma comment(lib, "IPHLPAPI.lib") | |
| 16 | |
| 17 // IE functions | |
| 18 #pragma comment(lib, "iepmapi.lib") | |
| 19 | |
| 20 // Internet / FTP | |
| 21 #pragma comment(lib, "wininet.lib") | |
| 22 | |
| 23 CPluginSystem* CPluginSystem::s_instance = NULL; | |
| 24 CComAutoCriticalSection CPluginSystem::s_criticalSection; | |
| 25 | |
| 26 CPluginSystem::CPluginSystem() | |
| 27 { | 7 { |
| 28 s_instance = NULL; | 8 LANGID lcid = GetUserDefaultLangID(); |
| 29 } | |
| 30 | |
| 31 | |
| 32 CPluginSystem::~CPluginSystem() | |
| 33 { | |
| 34 s_instance = NULL; | |
| 35 } | |
| 36 | |
| 37 | |
| 38 | |
| 39 CPluginSystem* CPluginSystem::GetInstance() | |
| 40 { | |
| 41 CPluginSystem* system; | |
| 42 | |
| 43 s_criticalSection.Lock(); | |
| 44 { | |
| 45 if (!s_instance) | |
| 46 { | |
| 47 // We cannot copy the client directly into the instance variable | |
| 48 // If the constructor throws we do not want to alter instance | |
| 49 CPluginSystem* systemInstance = new CPluginSystem(); | |
| 50 | |
| 51 s_instance = systemInstance; | |
| 52 } | |
| 53 | |
| 54 system = s_instance; | |
| 55 } | |
| 56 s_criticalSection.Unlock(); | |
| 57 | |
| 58 return system; | |
| 59 } | |
| 60 | |
| 61 CString CPluginSystem::GetBrowserLanguage() const | |
| 62 { | |
| 63 LANGID lcid = ::GetUserDefaultLangID(); | |
| 64 wchar_t language[128]; | 9 wchar_t language[128]; |
| 65 memset(language, 0, sizeof(language)); | 10 memset(language, 0, sizeof(language)); |
| 66 | |
| 67 wchar_t country[128]; | 11 wchar_t country[128]; |
| 68 memset(language, 0, sizeof(country)); | 12 memset(language, 0, sizeof(country)); |
| 69 | 13 |
| 70 CString lang; | 14 std::wstring lang; |
| 71 | 15 int res = GetLocaleInfoW(lcid, LOCALE_SISO639LANGNAME, language, 127); |
| 72 int res = ::GetLocaleInfo(lcid, LOCALE_SISO639LANGNAME, language, 127); | |
| 73 if (res == 0) | 16 if (res == 0) |
| 74 { | 17 { |
| 75 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSINFO
_BROWSER_LANGUAGE, "System::GetBrowserLang - Failed"); | 18 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSINFO
_BROWSER_LANGUAGE, "System::GetBrowserLang - Failed"); |
| 76 } | 19 } |
| 77 else | 20 else |
| 78 { | 21 { |
| 79 lang.Append(language); | 22 lang += language; |
| 80 } | 23 } |
| 81 | 24 lang += L"-"; |
| 82 lang.Append(L"-"); | 25 res = GetLocaleInfoW(lcid, LOCALE_SISO3166CTRYNAME, country, 127); |
| 83 | |
| 84 | |
| 85 res = ::GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME, country, 127); | |
| 86 if (res == 0) | 26 if (res == 0) |
| 87 { | 27 { |
| 88 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSINFO
_BROWSER_LANGUAGE, "System::GetBrowserLang - failed to retrieve country"); | 28 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSINFO
_BROWSER_LANGUAGE, "System::GetBrowserLang - failed to retrieve country"); |
| 89 } | 29 } |
| 90 else | 30 else |
| 91 { | 31 { |
| 92 lang.Append(country); | 32 lang += country; |
| 93 } | 33 } |
| 94 | |
| 95 return lang; | 34 return lang; |
| 96 } | 35 } |
| OLD | NEW |