Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginSystem.cpp

Issue 4772743157383168: Issue #276 - eliminate CString from GetBrowserLanguage (Closed)
Patch Set: Created July 30, 2014, 8:50 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/PluginSystem.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/PluginSystem.cpp
===================================================================
--- a/src/plugin/PluginSystem.cpp
+++ b/src/plugin/PluginSystem.cpp
@@ -1,96 +1,35 @@
-#include "PluginStdAfx.h"
-
-// Internet / FTP
-#include <wininet.h>
-
-// IP adapter
-#include <iphlpapi.h>
+#include "PluginStdAfx.h"
#include "PluginSystem.h"
#include "PluginClient.h"
-#include "PluginSettings.h"
-
-// IP adapter
-#pragma comment(lib, "IPHLPAPI.lib")
-
-// IE functions
-#pragma comment(lib, "iepmapi.lib")
-
-// Internet / FTP
-#pragma comment(lib, "wininet.lib")
-
-CPluginSystem* CPluginSystem::s_instance = NULL;
-CComAutoCriticalSection CPluginSystem::s_criticalSection;
-
-CPluginSystem::CPluginSystem()
+std::wstring GetBrowserLanguage()
{
- s_instance = NULL;
-}
-
-
-CPluginSystem::~CPluginSystem()
-{
- s_instance = NULL;
-}
-
-
-
-CPluginSystem* CPluginSystem::GetInstance()
-{
- CPluginSystem* system;
-
- s_criticalSection.Lock();
- {
- if (!s_instance)
- {
- // We cannot copy the client directly into the instance variable
- // If the constructor throws we do not want to alter instance
- CPluginSystem* systemInstance = new CPluginSystem();
-
- s_instance = systemInstance;
- }
-
- system = s_instance;
- }
- s_criticalSection.Unlock();
-
- return system;
-}
-
-CString CPluginSystem::GetBrowserLanguage() const
-{
- LANGID lcid = ::GetUserDefaultLangID();
+ LANGID lcid = GetUserDefaultLangID();
wchar_t language[128];
memset(language, 0, sizeof(language));
-
wchar_t country[128];
memset(language, 0, sizeof(country));
- CString lang;
-
- int res = ::GetLocaleInfo(lcid, LOCALE_SISO639LANGNAME, language, 127);
+ std::wstring lang;
+ int res = GetLocaleInfoW(lcid, LOCALE_SISO639LANGNAME, language, 127);
if (res == 0)
{
DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSINFO_BROWSER_LANGUAGE, "System::GetBrowserLang - Failed");
}
else
{
- lang.Append(language);
+ lang += language;
}
-
- lang.Append(L"-");
-
-
- res = ::GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME, country, 127);
+ lang += L"-";
+ res = GetLocaleInfoW(lcid, LOCALE_SISO3166CTRYNAME, country, 127);
if (res == 0)
{
DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSINFO_BROWSER_LANGUAGE, "System::GetBrowserLang - failed to retrieve country");
}
else
{
- lang.Append(country);
+ lang += country;
}
-
return lang;
}
« no previous file with comments | « src/plugin/PluginSystem.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld