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

Delta Between Two Patch Sets: src/plugin/PluginUserSettings.cpp

Issue 11043057: First run page triggering (Closed)
Left Patch Set: Comments addressed Created July 20, 2013, 8:11 p.m.
Right Patch Set: Minor refactoring. Renaming and a small cleanup. Created July 26, 2013, 12:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/PluginTabBase.cpp ('k') | src/plugin/PluginUtil.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 "../shared/Dictionary.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";
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 return settings->GetSubscription(); 96 return settings->GetSubscription();
97 } 97 }
98 98
99 99
100 CStringW sGetMessage(const CString& key) 100 CStringW sGetMessage(const CString& section, const CString& key)
101 { 101 {
102 Dictionary* dictionary = Dictionary::GetInstance(); 102 Dictionary* dictionary = Dictionary::GetInstance();
103 return CString(dictionary->Lookup("settings", std::string(CW2A(key))).c_str()) ; 103 return CStringW(dictionary->Lookup(std::string(CW2A(section)), std::string(CW2 A(key))).c_str());
104 } 104 }
105 105
106 std::wstring sGetMessage(const std::string& key) 106 std::wstring sGetMessage(const std::string& section, const std::string& key)
107 { 107 {
108 Dictionary* dictionary = Dictionary::GetInstance(); 108 Dictionary* dictionary = Dictionary::GetInstance();
109 return dictionary->Lookup("settings", key); 109 return dictionary->Lookup(section, key);
110 } 110 }
111 111
112 112
113 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,
114 EXCEPINFO* pExcepinfo, UINT* pArgErr) 114 EXCEPINFO* pExcepinfo, UINT* pArgErr)
115 { 115 {
116 if (!pDispparams) 116 if (!pDispparams)
117 return E_POINTER; 117 return E_POINTER;
118 118
119 if (!pExcepinfo) 119 if (!pExcepinfo)
120 return E_POINTER; 120 return E_POINTER;
121 121
122 if (pDispparams->cNamedArgs) 122 if (pDispparams->cNamedArgs)
123 return DISP_E_NONAMEDARGS; 123 return DISP_E_NONAMEDARGS;
124 124
125 CPluginSettings* settings = CPluginSettings::GetInstance(); 125 CPluginSettings* settings = CPluginSettings::GetInstance();
126 126
127 if (dispidMember < 0 || dispidMember >= countof(s_Methods)) 127 if (dispidMember < 0 || dispidMember >= countof(s_Methods))
128 return DISP_E_BADINDEX; 128 return DISP_E_BADINDEX;
129 129
130 const CString& method = s_Methods[dispidMember]; 130 const CString& method = s_Methods[dispidMember];
131 131
132 if (s_GetMessage == method) 132 if (s_GetMessage == method)
133 { 133 {
134 if (1 != pDispparams->cArgs) 134 if (2 != pDispparams->cArgs)
135 return DISP_E_BADPARAMCOUNT; 135 return DISP_E_BADPARAMCOUNT;
136 136
137 if (VT_BSTR != pDispparams->rgvarg[0].vt) 137 if (VT_BSTR != pDispparams->rgvarg[0].vt)
138 return DISP_E_TYPEMISMATCH; 138 return DISP_E_TYPEMISMATCH;
139 139
140 if (pVarResult) 140 if (pVarResult)
141 { 141 {
142 CComBSTR key = pDispparams->rgvarg[0].bstrVal; 142 CComBSTR key = pDispparams->rgvarg[0].bstrVal;
143 CStringW message = sGetMessage((BSTR)key); 143 CComBSTR section = pDispparams->rgvarg[1].bstrVal;
144 CStringW message = sGetMessage((BSTR)section, (BSTR)key);
144 145
145 pVarResult->vt = VT_BSTR; 146 pVarResult->vt = VT_BSTR;
146 pVarResult->bstrVal = SysAllocString(message); 147 pVarResult->bstrVal = SysAllocString(message);
147 } 148 }
148 } 149 }
149 else if (s_GetLanguageCount == method) 150 else if (s_GetLanguageCount == method)
150 { 151 {
151 if (pDispparams->cArgs) 152 if (pDispparams->cArgs)
152 return DISP_E_BADPARAMCOUNT; 153 return DISP_E_BADPARAMCOUNT;
153 154
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 { 304 {
304 settings->RemoveWhiteListedDomain((BSTR)domain); 305 settings->RemoveWhiteListedDomain((BSTR)domain);
305 } 306 }
306 } 307 }
307 else 308 else
308 return DISP_E_MEMBERNOTFOUND; 309 return DISP_E_MEMBERNOTFOUND;
309 310
310 return S_OK; 311 return S_OK;
311 } 312 }
312 313
LEFTRIGHT

Powered by Google App Engine
This is Rietveld