aboutsummaryrefslogtreecommitdiff
path: root/Src/filereader/main.cpp
blob: 749e510abb5467b95d4fab32562e980d70f56cf8 (plain) (blame)
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
#include "api__filereader.h"
#include "WA5_FileReader.h"
#ifdef _WIN32
#include "ResourceReaderFactory.h"
#endif
#include "HTTPReaderFactory.h"
#include <bfc/platform/export.h>

#ifdef _WIN32
ResourceReaderFactory resourceReaderFactory;
#endif

HTTPReaderFactory httpReaderFactory;
WA5_FileReader wa5_FileReader;
api_service *WASABI_API_SVC=0;
api_application *WASABI_API_APP=0;
api_config *AGAVE_API_CONFIG=0;

void WA5_FileReader::RegisterServices(api_service *service)
{
  WASABI_API_SVC = service;
  waServiceFactory *sf = WASABI_API_SVC->service_getServiceByGuid(applicationApiServiceGuid);
	if (sf)
		WASABI_API_APP = (api_application *)sf->getInterface();
	sf =  WASABI_API_SVC->service_getServiceByGuid(AgaveConfigGUID);
	if (sf)
		AGAVE_API_CONFIG = (api_config *)sf->getInterface();
	
  if (WASABI_API_APP && AGAVE_API_CONFIG)
    WASABI_API_SVC->service_register(&httpReaderFactory);
	
#ifdef _WIN32
  WASABI_API_SVC->service_register(&resourceReaderFactory);
#endif
}

int WA5_FileReader::RegisterServicesSafeModeOk()
{
	return 1;
}

void WA5_FileReader::DeregisterServices(api_service *service)
{
  
  if (WASABI_API_APP && AGAVE_API_CONFIG)
		service->service_deregister(&httpReaderFactory);
#ifdef _WIN32
  service->service_deregister(&resourceReaderFactory);
#endif
	waServiceFactory *sf=0;    
  if (WASABI_API_APP)
  {
    sf = WASABI_API_SVC->service_getServiceByGuid(applicationApiServiceGuid);
    if (sf)
      sf->releaseInterface(WASABI_API_APP);
  }
  
  if (AGAVE_API_CONFIG)
  {
    sf =  WASABI_API_SVC->service_getServiceByGuid(AgaveConfigGUID);
    if (sf)
      sf->releaseInterface(AGAVE_API_CONFIG);
  }
}

extern "C" DLLEXPORT ifc_wa5component *GetWinamp5SystemComponent()
{
	return &wa5_FileReader;
}

#define CBCLASS WA5_FileReader
START_DISPATCH;
VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
CB(15, RegisterServicesSafeModeOk)
VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
END_DISPATCH;
#undef CBCLASS