diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Winamp/winampApi.cpp | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Winamp/winampApi.cpp')
-rw-r--r-- | Src/Winamp/winampApi.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/Src/Winamp/winampApi.cpp b/Src/Winamp/winampApi.cpp new file mode 100644 index 00000000..a6b7be28 --- /dev/null +++ b/Src/Winamp/winampApi.cpp @@ -0,0 +1,83 @@ +#include "main.h" +#include "./winampApi.h" + + +WinampApi::WinampApi() +{} +WinampApi::~WinampApi() +{} + +HRESULT WinampApi::CreateInstance(WinampApi **instance) +{ + if (NULL == instance) return E_POINTER; + *instance = new WinampApi(); + if (NULL == *instance) return E_OUTOFMEMORY; + return S_OK; +} + +const char *WinampApi::getServiceName() +{ + return "Winamp API"; +} + +const GUID WinampApi::getServiceGuid() +{ + return winampApiGuid; +} + +size_t WinampApi::AddRef() +{ + return _ref.fetch_add( 1 ); +} + +size_t WinampApi::Release() +{ + if ( _ref.load() == 0 ) + return _ref.load(); + + LONG r = _ref.fetch_sub( 1 ); + if (0 == r) + delete(this); + + return r; +} + +int WinampApi::QueryInterface(GUID interface_guid, void **object) +{ + if (NULL == object) return E_POINTER; + *object = NULL; + return E_NOINTERFACE; +} + +HWND WinampApi::GetMainWindow(void) +{ + return hMainWindow; +} + +HWND WinampApi::GetDlgParent(void) +{ + return (g_dialog_box_parent) ? g_dialog_box_parent : hMainWindow; +} + +HRESULT WinampApi::OpenUrl(HWND hwnd, const wchar_t *url) +{ + myOpenURL(hwnd, (wchar_t*)url); + return S_OK; +} + +int WinampApi::GetRegVer() +{ + return 2; +} + +#define CBCLASS WinampApi +START_DISPATCH; +CB(ADDREF, AddRef) +CB(RELEASE, Release) +CB(QUERYINTERFACE, QueryInterface) +CB(API_GETMAINWINDOW, GetMainWindow) +CB(API_GETDLGPARENT, GetDlgParent) +CB(API_OPENURL, OpenUrl) +CB(API_GETREGVER, GetRegVer) +END_DISPATCH; +#undef CBCLASS |