mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 10:15:47 -04:00
Initial community commit
This commit is contained in:
63
Src/replicant/service/api_service.h
Normal file
63
Src/replicant/service/api_service.h
Normal file
@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef _API_SERVICE_H
|
||||
#define _API_SERVICE_H
|
||||
|
||||
#include "../foundation/dispatch.h"
|
||||
#include "../foundation/types.h"
|
||||
#include "../foundation/guid.h"
|
||||
#include "../foundation/error.h"
|
||||
#include "../service/ifc_servicefactory.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// {6DD93387-6636-4479-B982-9FF5B91CF4B4}
|
||||
static const GUID service_api_service_guid =
|
||||
{ 0x6dd93387, 0x6636, 0x4479, { 0xb9, 0x82, 0x9f, 0xf5, 0xb9, 0x1c, 0xf4, 0xb4 } };
|
||||
|
||||
class NOVTABLE api_service : public Wasabi2::Dispatchable
|
||||
{
|
||||
protected:
|
||||
api_service() : Dispatchable(DISPATCHABLE_VERSION) {}
|
||||
~api_service() {}
|
||||
public:
|
||||
static GUID GetServiceGUID() { return service_api_service_guid; }
|
||||
int Register(ifc_serviceFactory *svc) { return Service_Register(svc); }
|
||||
int Unregister(ifc_serviceFactory *svc) { return Service_Unregister(svc); }
|
||||
size_t GetServiceCount(GUID svc_type) { return Service_GetServiceCount(svc_type); }
|
||||
ifc_serviceFactory *EnumService(GUID svc_type, size_t n) { return Service_EnumService(svc_type, n); }
|
||||
ifc_serviceFactory *EnumService(size_t n) { return Service_EnumService(n); }
|
||||
ifc_serviceFactory *GetServiceByGUID(GUID guid) { return Service_GetServiceByGUID(guid); }
|
||||
|
||||
/* called by a component when it returns NErr_TryAgain from one of the quit-phase functions */
|
||||
void ComponentDone() { Service_ComponentDone(); }
|
||||
|
||||
template <class _t>
|
||||
int GetService(_t **out_service)
|
||||
{
|
||||
ifc_serviceFactory *sf = Service_GetServiceByGUID(_t::GetServiceGUID());
|
||||
if (!sf)
|
||||
return NErr_ServiceUnavailable;
|
||||
|
||||
_t *service = reinterpret_cast<_t *>(sf->GetInterface());
|
||||
if (!service)
|
||||
return NErr_FailedCreate;
|
||||
|
||||
*out_service = service;
|
||||
return NErr_Success;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
DISPATCHABLE_VERSION,
|
||||
};
|
||||
protected:
|
||||
virtual int WASABICALL Service_Register(ifc_serviceFactory *svc)=0;
|
||||
virtual int WASABICALL Service_Unregister(ifc_serviceFactory *svc)=0;
|
||||
virtual size_t WASABICALL Service_GetServiceCount(GUID svc_type)=0;
|
||||
virtual ifc_serviceFactory * WASABICALL Service_EnumService(GUID svc_type, size_t n)=0;
|
||||
virtual ifc_serviceFactory * WASABICALL Service_EnumService(size_t n)=0;
|
||||
virtual ifc_serviceFactory * WASABICALL Service_GetServiceByGUID(GUID guid)=0;
|
||||
virtual void WASABICALL Service_ComponentDone()=0;
|
||||
};
|
||||
|
||||
#endif // !_API_SERVICE_H
|
44
Src/replicant/service/ifc_servicefactory.h
Normal file
44
Src/replicant/service/ifc_servicefactory.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "../foundation/dispatch.h"
|
||||
#include "../foundation/guid.h"
|
||||
#include "../nx/nxstring.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class NOVTABLE ifc_serviceFactory : public Wasabi2::Dispatchable
|
||||
{
|
||||
protected:
|
||||
ifc_serviceFactory() : Dispatchable(DISPATCHABLE_VERSION) {}
|
||||
~ifc_serviceFactory() {}
|
||||
|
||||
|
||||
public:
|
||||
GUID GetServiceType() { return ServiceFactory_GetServiceType(); }
|
||||
nx_string_t GetServiceName() { return ServiceFactory_GetServiceName(); }
|
||||
GUID GetGUID() { return ServiceFactory_GetGUID(); }
|
||||
void *GetInterface() { return ServiceFactory_GetInterface(); }
|
||||
int ServiceNotify(int msg, intptr_t param1 = 0, intptr_t param2 = 0) { return ServiceFactory_ServiceNotify(msg, param1, param2); }
|
||||
|
||||
// serviceNotify enums
|
||||
enum
|
||||
{
|
||||
ONREGISTERED=0, // init yourself here -- not all other services are registered yet
|
||||
ONSTARTUP=1, // everyone is initialized, safe to talk to other services
|
||||
ONAPPRUNNING=2, // app is showing and processing events
|
||||
ONBEFORESHUTDOWN=3, // system is about to shutdown, call WASABI2_API_APP->main_cancelShutdown() to cancel
|
||||
ONSHUTDOWN=4, // studio is shutting down, release resources from other services
|
||||
ONUNREGISTERED=5, // bye bye
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
DISPATCHABLE_VERSION,
|
||||
};
|
||||
protected:
|
||||
virtual GUID WASABICALL ServiceFactory_GetServiceType()=0;
|
||||
virtual nx_string_t WASABICALL ServiceFactory_GetServiceName()=0;
|
||||
virtual GUID WASABICALL ServiceFactory_GetGUID()=0;
|
||||
virtual void *WASABICALL ServiceFactory_GetInterface()=0;
|
||||
virtual int WASABICALL ServiceFactory_ServiceNotify(int msg, intptr_t param1 = 0, intptr_t param2 = 0)=0;
|
||||
};
|
38
Src/replicant/service/svccb.h
Normal file
38
Src/replicant/service/svccb.h
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "syscb/ifc_syscallback.h"
|
||||
#include "foundation/mkncc.h"
|
||||
|
||||
namespace Service
|
||||
{
|
||||
// {215CDE06-22A6-424F-9C64-DEDC45D84455}
|
||||
static const GUID event_type =
|
||||
{ 0x215cde06, 0x22a6, 0x424f, { 0x9c, 0x64, 0xde, 0xdc, 0x45, 0xd8, 0x44, 0x55 } };
|
||||
static const int on_register = 0;
|
||||
static const int on_deregister = 1;
|
||||
|
||||
class SystemCallback : public ifc_sysCallback
|
||||
{
|
||||
protected:
|
||||
GUID WASABICALL SysCallback_GetEventType() { return event_type; }
|
||||
int WASABICALL SysCallback_Notify(int msg, intptr_t param1, intptr_t param2)
|
||||
{
|
||||
const GUID *service_id;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case on_register:
|
||||
service_id = (const GUID *)param1;
|
||||
return ServiceSystemCallback_OnRegister(*service_id, (void *)param2);
|
||||
case on_deregister:
|
||||
service_id = (const GUID *)param1;
|
||||
return ServiceSystemCallback_OnDeregister(*service_id, (void *)param2);
|
||||
default:
|
||||
return NErr_Success;
|
||||
}
|
||||
}
|
||||
virtual int WASABICALL ServiceSystemCallback_OnRegister(GUID service_id, void *service) { return NErr_Success; }
|
||||
virtual int WASABICALL ServiceSystemCallback_OnDeregister(GUID service_id, void *service) { return NErr_Success; }
|
||||
};
|
||||
|
||||
}
|
5
Src/replicant/service/types.h
Normal file
5
Src/replicant/service/types.h
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
#include "../foundation/guid.h"
|
||||
|
||||
static const GUID SVC_TYPE_UNIQUE = { 0x3ffe7079, 0x2467, 0x495e, { 0x88, 0x18, 0x61, 0x64, 0x22, 0xb6, 0x51, 0x20 } };
|
||||
static const GUID SVC_TYPE_OBJECT = { 0x175b4de2, 0x8330, 0x48ce, { 0xb2, 0xab, 0xe9, 0x45, 0x49, 0x0b, 0x73, 0x14 } };
|
Reference in New Issue
Block a user