diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/auth/Loginbox/templateInfo.cpp | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/auth/Loginbox/templateInfo.cpp')
-rw-r--r-- | Src/auth/Loginbox/templateInfo.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/Src/auth/Loginbox/templateInfo.cpp b/Src/auth/Loginbox/templateInfo.cpp new file mode 100644 index 00000000..cf36621c --- /dev/null +++ b/Src/auth/Loginbox/templateInfo.cpp @@ -0,0 +1,100 @@ +#include "./templateInfo.h" +#include "./pageInfo.h" +#include "./common.h" + +LoginTemplateInfo::LoginTemplateInfo() + : ref(1), title(NULL), message(NULL) +{ +} + +LoginTemplateInfo::~LoginTemplateInfo() +{ + LoginBox_FreeString(title); + LoginBox_FreeString(message); +} + +HRESULT LoginTemplateInfo::CreateInstance(LoginTemplateInfo **instance) +{ + if (NULL == instance) return E_POINTER; + *instance = new LoginTemplateInfo(); + if (NULL == *instance) return E_OUTOFMEMORY; + return S_OK; +} + +ULONG LoginTemplateInfo::AddRef() +{ + return InterlockedIncrement((LONG*)&ref); +} + +ULONG LoginTemplateInfo::Release() +{ + if (0 == ref) + return ref; + + LONG r = InterlockedDecrement((LONG*)&ref); + if (0 == r) + delete(this); + + return r; +} + +HRESULT LoginTemplateInfo::GetType(GUID *templateUid) +{ + if (NULL == templateUid) return E_INVALIDARG; + *templateUid = LTUID_INFO; + return S_OK; +} + +HRESULT LoginTemplateInfo::SetParameter(LPCWSTR pszKey, LPCWSTR pszValue) +{ + if (S_OK == LoginBox_IsStrEqInvI(pszKey, L"title")) + { + LoginBox_FreeString(title); + title = LoginBox_CopyString(pszValue); + } + else if (S_OK == LoginBox_IsStrEqInvI(pszKey, L"message")) + { + LoginBox_FreeString(message); + message = LoginBox_CopyString(pszValue); + } + return S_OK; +} + +HRESULT LoginTemplateInfo::IsValid() +{ + return S_OK; +} + +HRESULT LoginTemplateInfo::IsIdentical(LoginTemplate *test) +{ + if (NULL == test) + return E_INVALIDARG; + + GUID typeId; + if (FAILED(test->GetType(&typeId)) || FALSE == IsEqualGUID(LTUID_INFO, typeId)) + return S_FALSE; + + LoginTemplateInfo *testInfo = (LoginTemplateInfo*)test; + + if(S_OK != LoginBox_IsStrEq(title, testInfo->title) || + S_OK != LoginBox_IsStrEq(message, testInfo->message)) + { + return S_FALSE; + } + + return S_OK; +} + +HWND LoginTemplateInfo::CreatePage(HWND hLoginbox, HWND hParent) +{ + HWND hPage = LoginPageInfo::CreatePage(hLoginbox, hParent); + if (NULL == hPage) return NULL; + + if (NULL != title) + LoginPage_SetTitle(hPage, title); + + if (NULL != message) + LoginPageInfo_SetMessage(hPage, message); + + return hPage; +}
\ No newline at end of file |