resultWinampAuth.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef NULLSOFT_AUTH_LOGINRESULT_WINAMPAUTH_HEADER
  2. #define NULLSOFT_AUTH_LOGINRESULT_WINAMPAUTH_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include "./loginResult.h"
  7. #include "../auth/ifc_authcallback.h"
  8. #include "../auth/api_auth.h"
  9. class LoginData;
  10. class LoginCredentials;
  11. class LoginDataCredentials;
  12. class LoginResultWinampAuth : public LoginResult,
  13. public ifc_authcallback
  14. {
  15. protected:
  16. LoginResultWinampAuth(api_auth *auth, LoginDataCredentials *pInput, Callback callback, void *user);
  17. ~LoginResultWinampAuth();
  18. public:
  19. static HRESULT CreateInstance(LoginData *input, Callback callback, void *user, LoginResultWinampAuth **instance);
  20. public:
  21. /* IUnknown */
  22. STDMETHOD(QueryInterface)(REFIID riid, PVOID *ppvObject);
  23. STDMETHOD_(ULONG, AddRef)(void);
  24. STDMETHOD_(ULONG, Release)(void);
  25. /* LoginResult */
  26. HRESULT GetWaitHandle(HANDLE *handle);
  27. HRESULT GetUser(void **pUser);
  28. HRESULT RequestAbort(BOOL fDrop);
  29. HRESULT IsCompleted();
  30. HRESULT IsAborting();
  31. HRESULT GetLoginData(LoginData **loginData);
  32. public:
  33. HRESULT GetResult(INT *authCode, LoginCredentials **credentials);
  34. protected:
  35. /* Dispatchable */
  36. size_t Wasabi_AddRef();
  37. size_t Wasabi_Release();
  38. int Wasabi_QueryInterface(GUID iid, void **object);
  39. /*ifc_authcallback*/
  40. int Event_AuthConnecting();
  41. int Event_AuthSending();
  42. int Event_AuthReceiving();
  43. int Event_AuthIdle();
  44. private:
  45. HRESULT Start();
  46. DWORD ThreadProc();
  47. HRESULT IsAbortingEx(UINT waitMs);
  48. LPWSTR MakeAuthParam(LPCWSTR pszInput, INT cchInput, INT min, INT max, BOOL removeSpaces, BOOL firstLetter, WORD typeMask, INT errorBase, INT *authError);
  49. LPWSTR GetUsername(LPCWSTR pszInput, INT *authError);
  50. LPWSTR GetPassword(LPCWSTR pszInput, INT *authError);
  51. LPWSTR GetPasscode(LPCWSTR pszInput, INT *authError);
  52. friend static DWORD WINAPI WinampAuth_ThreadProcCallback(void *param);
  53. protected:
  54. ULONG ref;
  55. LoginDataCredentials *input;
  56. Callback callback;
  57. void *user;
  58. api_auth *authApi;
  59. HANDLE thread;
  60. HANDLE abort;
  61. HANDLE completed;
  62. LoginCredentials *credentials;
  63. INT authCode;
  64. CRITICAL_SECTION lock;
  65. UINT statusCookie;
  66. protected:
  67. RECVS_DISPATCH;
  68. };
  69. #endif //NULLSOFT_AUTH_LOGINRESULT_WINAMPAUTH_HEADER