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

Side by Side Diff: src/plugin/PluginSettings.cpp

Issue 4772743157383168: Issue #276 - eliminate CString from GetBrowserLanguage (Closed)
Patch Set: Created July 30, 2014, 8:50 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/plugin/PluginSettings.h ('k') | src/plugin/PluginSystem.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include <Wbemidl.h> 3 #include <Wbemidl.h>
4 #include <time.h> 4 #include <time.h>
5 #include "PluginSettings.h" 5 #include "PluginSettings.h"
6 #include "PluginClient.h" 6 #include "PluginClient.h"
7 #include "PluginSystem.h" 7 #include "PluginSystem.h"
8 #ifdef SUPPORT_FILTER 8 #ifdef SUPPORT_FILTER
9 #include "PluginFilter.h" 9 #include "PluginFilter.h"
10 #endif 10 #endif
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 s_criticalSectionLocal.Lock(); 93 s_criticalSectionLocal.Lock();
94 { 94 {
95 hasInstance = s_instance != NULL; 95 hasInstance = s_instance != NULL;
96 } 96 }
97 s_criticalSectionLocal.Unlock(); 97 s_criticalSectionLocal.Unlock();
98 98
99 return hasInstance; 99 return hasInstance;
100 } 100 }
101 101
102
103
104 CString CPluginSettings::GetDataPath(const CString& filename) 102 CString CPluginSettings::GetDataPath(const CString& filename)
105 { 103 {
106 std::wstring path = ::GetAppDataPath() + L"\\" + static_cast<LPCWSTR>(filename ); 104 std::wstring path = ::GetAppDataPath() + L"\\" + static_cast<LPCWSTR>(filename );
107 return CString(path.c_str()); 105 return CString(path.c_str());
108 } 106 }
109 107
110 CString CPluginSettings::GetSystemLanguage()
111 {
112 CString language;
113 CString country;
114
115 DWORD bufSize = 256;
116 int ccBuf = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO639LANGNAME, langu age.GetBufferSetLength(bufSize), bufSize);
117 ccBuf = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO3166CTRYNAME, country. GetBufferSetLength(bufSize), bufSize);
118
119 if ((country.IsEmpty()) || (language.IsEmpty()))
120 {
121 return CString();
122 }
123 CString lang;
124 lang.Append(language);
125 lang.Append(L"-");
126 lang.Append(country);
127
128 return lang;
129
130 }
131
132
133 bool CPluginSettings::IsPluginEnabled() const 108 bool CPluginSettings::IsPluginEnabled() const
134 { 109 {
135 return GetPluginEnabled(); 110 return GetPluginEnabled();
136 } 111 }
137 112
138
139 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList() const 113 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList() const
140 { 114 {
141 std::vector<SubscriptionDescription> subscriptions = CPluginClient::GetInstanc e()->FetchAvailableSubscriptions(); 115 std::vector<SubscriptionDescription> subscriptions = CPluginClient::GetInstanc e()->FetchAvailableSubscriptions();
142 116
143 std::map<CString, CString> filterList; 117 std::map<CString, CString> filterList;
144 for (size_t i = 0; i < subscriptions.size(); i ++) 118 for (size_t i = 0; i < subscriptions.size(); i ++)
145 { 119 {
146 SubscriptionDescription it = subscriptions[i]; 120 SubscriptionDescription it = subscriptions[i];
147 filterList.insert(std::make_pair(CString(it.url.c_str()), CString(it.title.c _str()))); 121 filterList.insert(std::make_pair(CString(it.url.c_str()), CString(it.title.c _str())));
148 } 122 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (subscription->url != aaUrl) 283 if (subscription->url != aaUrl)
310 { 284 {
311 return CString(subscription->url.c_str()); 285 return CString(subscription->url.c_str());
312 } 286 }
313 } 287 }
314 return CString(L""); 288 return CString(L"");
315 } 289 }
316 290
317 CString CPluginSettings::GetAppLocale() 291 CString CPluginSettings::GetAppLocale()
318 { 292 {
319 return CPluginSystem::GetInstance()->GetBrowserLanguage(); 293 return to_CString(GetBrowserLanguage());
320 } 294 }
321 295
322 CString CPluginSettings::GetDocumentationLink() 296 CString CPluginSettings::GetDocumentationLink()
323 { 297 {
324 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str()); 298 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str());
325 } 299 }
326 300
327 301
328 302
329 #endif // SUPPORT_WHITELIST 303 #endif // SUPPORT_WHITELIST
OLDNEW
« no previous file with comments | « src/plugin/PluginSettings.h ('k') | src/plugin/PluginSystem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld