aboutsummaryrefslogtreecommitdiff
path: root/Src/auth/Loginbox/commandWinampAuth.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/auth/Loginbox/commandWinampAuth.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/auth/Loginbox/commandWinampAuth.cpp')
-rw-r--r--Src/auth/Loginbox/commandWinampAuth.cpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/Src/auth/Loginbox/commandWinampAuth.cpp b/Src/auth/Loginbox/commandWinampAuth.cpp
new file mode 100644
index 00000000..fdcad77f
--- /dev/null
+++ b/Src/auth/Loginbox/commandWinampAuth.cpp
@@ -0,0 +1,125 @@
+#include "./commandWinampAuth.h"
+#include "./resultWinampAuth.h"
+
+
+LoginCommandWinampAuth::LoginCommandWinampAuth()
+ : ref(1)
+{
+}
+
+LoginCommandWinampAuth::~LoginCommandWinampAuth()
+{
+
+}
+
+HRESULT LoginCommandWinampAuth::CreateInstance(LoginCommandWinampAuth **instance)
+{
+ if (NULL == instance) return E_POINTER;
+ *instance = new LoginCommandWinampAuth();
+ if (NULL == *instance) return E_OUTOFMEMORY;
+ return S_OK;
+}
+
+ULONG LoginCommandWinampAuth::AddRef()
+{
+ return InterlockedIncrement((LONG*)&ref);
+}
+
+ULONG LoginCommandWinampAuth::Release()
+{
+ if (0 == ref)
+ return ref;
+
+ LONG r = InterlockedDecrement((LONG*)&ref);
+ if (0 == r)
+ delete(this);
+
+ return r;
+}
+
+HRESULT LoginCommandWinampAuth::GetType(GUID *commandUid)
+{
+ if (NULL == commandUid) return E_INVALIDARG;
+ *commandUid = LCUID_WINAMPAUTH;
+ return S_OK;
+}
+
+HRESULT LoginCommandWinampAuth::SetParameter(LPCWSTR pszKey, LPCWSTR pszValue)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT LoginCommandWinampAuth::IsValid()
+{
+ return S_OK;
+}
+
+HRESULT LoginCommandWinampAuth::IsIdentical(LoginCommand *test)
+{
+ if (NULL == test)
+ return E_INVALIDARG;
+
+ GUID typeId;
+ if (FAILED(test->GetType(&typeId)) || FALSE == IsEqualGUID(LCUID_WINAMPAUTH, typeId))
+ return S_FALSE;
+
+ return S_OK;
+}
+
+
+HRESULT LoginCommandWinampAuth::BeginLogin(LoginData *data, LoginResult::Callback callback, void *user, LoginResult **result)
+{
+ LoginResultWinampAuth *winampAuth;
+ HRESULT hr = LoginResultWinampAuth::CreateInstance(data, callback, user, &winampAuth);
+ if (SUCCEEDED(hr))
+ {
+ if (NULL != result)
+ *result = winampAuth;
+ else
+ winampAuth->Release();
+ }
+ else
+ {
+ if (NULL != result)
+ *result = NULL;
+ }
+
+ return hr;
+}
+
+HRESULT LoginCommandWinampAuth::EndLogin(LoginResult *result, INT *authCode, LoginCredentials **credentials)
+{
+ if (NULL == result)
+ return E_INVALIDARG;
+
+ HRESULT hr = result->IsCompleted();
+ if (S_OK != hr)
+ {
+ HANDLE completed;
+ hr = result->GetWaitHandle(&completed);
+ if (SUCCEEDED(hr))
+ {
+ WaitForSingleObjectEx(completed, INFINITE, TRUE);
+ CloseHandle(completed);
+ }
+ }
+
+ if (SUCCEEDED(hr))
+ {
+ LoginResultWinampAuth *winampAuth;
+ hr = result->QueryInterface(LCUID_WINAMPAUTH, (void**)&winampAuth);
+ if(SUCCEEDED(hr))
+ {
+ hr = winampAuth->GetResult(authCode, credentials);
+ winampAuth->Release();
+ }
+ }
+
+ return hr;
+}
+
+HRESULT LoginCommandWinampAuth::RequestAbort(LoginResult *result, BOOL drop)
+{
+ if (NULL == result) return E_INVALIDARG;
+ return result->RequestAbort(drop);
+}