1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#include "api.h"
#include "../Agave/Component/ifc_wa5component.h"
#include "CoverDirectory.h"
class CoverDirectoryComponent : public ifc_wa5component
{
public:
void RegisterServices(api_service *service);
void DeregisterServices(api_service *service);
protected:
RECVS_DISPATCH;
};
api_service *WASABI_API_SVC=0;
api_application *WASABI_API_APP =0;
api_config *AGAVE_API_CONFIG = 0;
api_memmgr *WASABI_API_MEMMGR=0;
api_metadata *AGAVE_API_METADATA = 0;
static AlbumArtFactory albumArtFactory;
template <class api_T>
void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
{
if (WASABI_API_SVC)
{
waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
if (factory)
api_t = (api_T *)factory->getInterface();
}
}
template <class api_T>
void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
{
if (WASABI_API_SVC)
{
waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
if (factory)
factory->releaseInterface(api_t);
}
api_t = NULL;
}
void CoverDirectoryComponent::RegisterServices(api_service *service)
{
WASABI_API_SVC = service;
ServiceBuild(WASABI_API_APP, applicationApiServiceGuid);
ServiceBuild(AGAVE_API_CONFIG, AgaveConfigGUID);
ServiceBuild(WASABI_API_MEMMGR, memMgrApiServiceGuid);
ServiceBuild(AGAVE_API_METADATA, api_metadataGUID);
WASABI_API_SVC->service_register(&albumArtFactory);
/* uncomment if we need it
WASABI_API_LNG = GetService<api_language>(languageApiGUID);
// need to have this initialised before we try to do anything with localisation features
WASABI_API_START_LANG(hModule,playlistLangGUID);
*/
}
void CoverDirectoryComponent::DeregisterServices(api_service *service)
{
ServiceRelease(WASABI_API_APP, applicationApiServiceGuid);
ServiceRelease(AGAVE_API_CONFIG, AgaveConfigGUID);
ServiceRelease(WASABI_API_MEMMGR, memMgrApiServiceGuid);
ServiceRelease(AGAVE_API_METADATA, api_metadataGUID);
WASABI_API_SVC->service_deregister(&albumArtFactory);
/* uncomment if we need it
ReleaseService(languageApiGUID, WASABI_API_LNG);
*/
}
static CoverDirectoryComponent coverDirectoryComponent;
extern "C" __declspec(dllexport) ifc_wa5component *GetWinamp5SystemComponent()
{
return &coverDirectoryComponent;
}
#define CBCLASS CoverDirectoryComponent
START_DISPATCH;
VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
END_DISPATCH;
#undef CBCLASS
|