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

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

Issue 11013110: Cleanup (Closed)
Patch Set: Minor CallEngine refactoring Created July 26, 2013, 2:12 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
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 #include "PluginUserSettings.h" 2 #include "PluginUserSettings.h"
3 #include <algorithm> 3 #include <algorithm>
4 #include "PluginSettings.h" 4 #include "PluginSettings.h"
5 #include "PluginClient.h" 5 #include "PluginClient.h"
6 #include "PluginIniFileW.h" 6 #include "../shared/Dictionary.h"
7 7
8 static const CString s_GetMessage = L"GetMessage"; 8 static const CString s_GetMessage = L"GetMessage";
9 static const CString s_GetLanguageCount = L"GetLanguageCount"; 9 static const CString s_GetLanguageCount = L"GetLanguageCount";
10 static const CString s_GetLanguageByIndex = L"GetLanguageByIndex"; 10 static const CString s_GetLanguageByIndex = L"GetLanguageByIndex";
11 static const CString s_GetLanguageTitleByIndex = L"GetLanguageTitleByIndex"; 11 static const CString s_GetLanguageTitleByIndex = L"GetLanguageTitleByIndex";
12 static const CString s_SetLanguage = L"SetLanguage"; 12 static const CString s_SetLanguage = L"SetLanguage";
13 static const CString s_GetLanguage = L"GetLanguage"; 13 static const CString s_GetLanguage = L"GetLanguage";
14 static const CString s_GetWhitelistDomains = L"GetWhitelistDomains"; 14 static const CString s_GetWhitelistDomains = L"GetWhitelistDomains";
15 static const CString s_AddWhitelistDomain = L"AddWhitelistDomain"; 15 static const CString s_AddWhitelistDomain = L"AddWhitelistDomain";
16 static const CString s_RemoveWhitelistDomain = L"RemoveWhitelistDomain"; 16 static const CString s_RemoveWhitelistDomain = L"RemoveWhitelistDomain";
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 *rgdispid = indxMethod; 87 *rgdispid = indxMethod;
88 88
89 return S_OK; 89 return S_OK;
90 } 90 }
91 91
92 92
93 static CString sGetLanguage() 93 static CString sGetLanguage()
94 { 94 {
95 CPluginSettings* settings = CPluginSettings::GetInstance(); 95 CPluginSettings* settings = CPluginSettings::GetInstance();
96 96 return settings->GetSubscription();
97 return settings->GetString(SETTING_LANGUAGE);
98 }
99
100
101 static bool sReadSettingsPageFile(CPluginIniFileW& iniFile)
102 {
103 return iniFile.HasSection(sGetLanguage());
104 }
105
106
107 static CPluginIniFileW& sReadSettingsPageFile(bool& readOK)
108 {
109 static CPluginIniFileW iniFile(CPluginSettings::GetDataPath(SETTING_PAGE_INI_F ILE));
110 static bool s_readOK = iniFile.Read();
111
112 readOK = s_readOK;
113
114 return iniFile;
115 } 97 }
116 98
117 99
118 CStringW sGetMessage(const CString& key) 100 CStringW sGetMessage(const CString& key)
119 { 101 {
120 bool readOK = false; 102 Dictionary* dictionary = Dictionary::GetInstance();
121 CPluginIniFileW& iniFile = sReadSettingsPageFile(readOK); 103 return CString(dictionary->Lookup("settings", std::string(CW2A(key))).c_str()) ;
104 }
122 105
123 return iniFile.GetValue(sGetLanguage(), key); 106 std::wstring sGetMessage(const std::string& key)
107 {
108 Dictionary* dictionary = Dictionary::GetInstance();
109 return dictionary->Lookup("settings", key);
124 } 110 }
125 111
126 112
127 STDMETHODIMP CPluginUserSettings::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispparams, VARIANT* pVarResult, 113 STDMETHODIMP CPluginUserSettings::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispparams, VARIANT* pVarResult,
128 EXCEPINFO* pExcepinfo, UINT* pArgErr) 114 EXCEPINFO* pExcepinfo, UINT* pArgErr)
129 { 115 {
130 if (!pDispparams) 116 if (!pDispparams)
131 return E_POINTER; 117 return E_POINTER;
132 118
133 if (!pExcepinfo) 119 if (!pExcepinfo)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 { 303 {
318 settings->RemoveWhiteListedDomain((BSTR)domain); 304 settings->RemoveWhiteListedDomain((BSTR)domain);
319 } 305 }
320 } 306 }
321 else 307 else
322 return DISP_E_MEMBERNOTFOUND; 308 return DISP_E_MEMBERNOTFOUND;
323 309
324 return S_OK; 310 return S_OK;
325 } 311 }
326 312
OLDNEW

Powered by Google App Engine
This is Rietveld