diff options
Diffstat (limited to 'Src/Wasabi/api/service')
113 files changed, 7720 insertions, 0 deletions
diff --git a/Src/Wasabi/api/service/api_service.cpp b/Src/Wasabi/api/service/api_service.cpp new file mode 100644 index 00000000..6d67c16d --- /dev/null +++ b/Src/Wasabi/api/service/api_service.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:56:11 2003] +// +// File : api_service.cpp +// Class : api_service +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include <precomp.h> +#include "api_service.h" + +api_service *serviceApi = NULL;
\ No newline at end of file diff --git a/Src/Wasabi/api/service/api_service.h b/Src/Wasabi/api/service/api_service.h new file mode 100644 index 00000000..0d309000 --- /dev/null +++ b/Src/Wasabi/api/service/api_service.h @@ -0,0 +1,184 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:56:11 2003] +// +// File : api_service.h +// Class : api_service +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __API_SERVICE_H +#define __API_SERVICE_H + +#include "bfc/dispatch.h" +#include "bfc/platform/types.h" + +namespace SvcNotify +{ + enum + { + ONREGISTERED = 100, // init yourself here -- not all other services are registered yet + ONSTARTUP = 200, // everyone is initialized, safe to talk to other services + ONAPPRUNNING = 210, // app is showing and processing events + ONSHUTDOWN = 300, // studio is shutting down, release resources from other services + ONDEREGISTERED = 400, // bye bye + ONDBREADCOMPLETE = 500, // after db is read in (happens asynchronously after ONSTARTUP) + ONBEFORESHUTDOWN = 600, // system is about to shutdown, call WASABI_API_APP->main_cancelShutdown() to cancel + }; +} + + class waServiceFactory; + +// ---------------------------------------------------------------------------- + + class NOVTABLE api_service : public Dispatchable + { + protected: + api_service() {} + ~api_service() {} + + public: + int service_register( waServiceFactory *svc ); + int service_deregister( waServiceFactory *svc ); + + size_t service_getNumServices( FOURCC svc_type ); + waServiceFactory *service_enumService( FOURCC svc_type, size_t n ); + + waServiceFactory *service_getServiceByGuid( GUID guid ); + + int service_lock( waServiceFactory *owner, void *svcptr ); + int service_clientLock( void *svcptr ); + int service_release( void *svcptr ); + const char *service_getTypeName( FOURCC svc_type ); + +#ifdef WASABI_COMPILE_COMPONENTS + GUID service_getOwningComponent( void *svcptr ); + GUID service_getLockingComponent( void *svcptr ); +#endif // WASABI_COMPILE_COMPONENTS + + int service_unlock( void *svcptr ); + int service_isvalid( FOURCC svctype, waServiceFactory *service ); + // removes "me" from the services list and finds a second service with the same GUID and puts it in the same position + // this is used by the lazy loader service factory - you shouldn't need it for any other purposes. + // returns 0 if compaction actually happened + int service_compactDuplicates( waServiceFactory *me ); + + protected: + enum + { + API_SERVICE_SERVICE_REGISTER = 10, + API_SERVICE_SERVICE_DEREGISTER = 20, + API_SERVICE_SERVICE_GETNUMSERVICES = 30, + API_SERVICE_SERVICE_ENUMSERVICE = 40, + API_SERVICE_SERVICE_GETSERVICEBYGUID = 50, + API_SERVICE_SERVICE_LOCK = 60, + API_SERVICE_SERVICE_CLIENTLOCK = 70, + API_SERVICE_SERVICE_RELEASE = 80, + API_SERVICE_SERVICE_GETTYPENAME = 90, + +#ifdef WASABI_COMPILE_COMPONENTS + API_SERVICE_SERVICE_GETOWNINGCOMPONENT = 100, + API_SERVICE_SERVICE_GETLOCKINGCOMPONENT = 110, +#endif // WASABI_COMPILE_COMPONENTS + + API_SERVICE_SERVICE_UNLOCK = 120, + API_SERVICE_ISVALID = 130, + API_SERVICE_COMPACT_DUPLICATES = 140, + }; + }; + +// ---------------------------------------------------------------------------- + + inline int api_service::service_register( waServiceFactory *svc ) + { + int __retval = _call( API_SERVICE_SERVICE_REGISTER, (int)0, svc ); + return __retval; + } + + inline int api_service::service_deregister( waServiceFactory *svc ) + { + int __retval = _call( API_SERVICE_SERVICE_DEREGISTER, (int)0, svc ); + return __retval; + } + + inline size_t api_service::service_getNumServices( FOURCC svc_type ) + { + int __retval = _call( API_SERVICE_SERVICE_GETNUMSERVICES, (int)0, svc_type ); + return __retval; + } + + inline waServiceFactory *api_service::service_enumService( FOURCC svc_type, size_t n ) + { + waServiceFactory *__retval = _call( API_SERVICE_SERVICE_ENUMSERVICE, (waServiceFactory *)0, svc_type, n ); + return __retval; + } + + inline waServiceFactory *api_service::service_getServiceByGuid( GUID guid ) + { + waServiceFactory *__retval = _call( API_SERVICE_SERVICE_GETSERVICEBYGUID, (waServiceFactory *)0, guid ); + return __retval; + } + + inline int api_service::service_lock( waServiceFactory *owner, void *svcptr ) + { + int __retval = _call( API_SERVICE_SERVICE_LOCK, (int)0, owner, svcptr ); + return __retval; + } + + inline int api_service::service_clientLock( void *svcptr ) + { + int __retval = _call( API_SERVICE_SERVICE_CLIENTLOCK, (int)0, svcptr ); + return __retval; + } + + inline int api_service::service_release( void *svcptr ) + { + int __retval = _call( API_SERVICE_SERVICE_RELEASE, (int)0, svcptr ); + return __retval; + } + + inline const char *api_service::service_getTypeName( FOURCC svc_type ) + { + const char *__retval = _call( API_SERVICE_SERVICE_GETTYPENAME, (const char *)0, svc_type ); + return __retval; + } + +#ifdef WASABI_COMPILE_COMPONENTS + inline GUID api_service::service_getOwningComponent( void *svcptr ) + { + GUID __retval = _call( API_SERVICE_SERVICE_GETOWNINGCOMPONENT, INVALID_GUID, svcptr ); + return __retval; + } + + inline GUID api_service::service_getLockingComponent( void *svcptr ) + { + GUID __retval = _call( API_SERVICE_SERVICE_GETLOCKINGCOMPONENT, INVALID_GUID, svcptr ); + return __retval; + } +#endif // WASABI_COMPILE_COMPONENTS + + inline int api_service::service_unlock( void *svcptr ) + { + int __retval = _call( API_SERVICE_SERVICE_UNLOCK, (int)0, svcptr ); + return __retval; + } + + inline int api_service::service_isvalid( FOURCC svctype, waServiceFactory *service ) + { + int __retval = _call( API_SERVICE_ISVALID, (int)0, svctype, service ); + return __retval; + } + + inline int api_service::service_compactDuplicates( waServiceFactory *me ) + { + return _call( API_SERVICE_COMPACT_DUPLICATES, (int)1, me ); + } +// ---------------------------------------------------------------------------- + + +extern api_service *serviceApi; + +#ifndef WASABI_API_SVC +#define WASABI_API_SVC serviceApi +#endif // !WASABI_API_SVC + +#endif // __API_SERVICE_H diff --git a/Src/Wasabi/api/service/api_servicei.cpp b/Src/Wasabi/api/service/api_servicei.cpp new file mode 100644 index 00000000..e5cae440 --- /dev/null +++ b/Src/Wasabi/api/service/api_servicei.cpp @@ -0,0 +1,83 @@ +#include <precomp.h> +#ifndef NOSVCMGR +//<?#include "<class data="implementationheader"/>" +#include "api_servicei.h" +//?> + +#include <api/api.h> +#include <api/service/svcmgr.h> + +api_service *serviceApi = NULL; + +api_serviceI::api_serviceI() { +} + +api_serviceI::~api_serviceI() { + ServiceManager::onShutdown(); +} + +int api_serviceI::service_register(waServiceFactory *svc) { +#ifdef WASABI_COMPILE_COMPONENTS + int r = ServiceManager::registerService(svc, WASABI_API_COMPONENT->getThisGuid()); +#else + int r = ServiceManager::registerService(svc, WASABI_API_APP->main_getGUID()); +#endif + return r; +} + +int api_serviceI::service_deregister(waServiceFactory *svc) { + int r = ServiceManager::deregisterService(svc); + return r; +} + +int api_serviceI::service_getNumServices(FOURCC svc_type) { + return ServiceManager::getNumServices(svc_type); +} + +waServiceFactory *api_serviceI::service_enumService(FOURCC svc_type, int n) { + return ServiceManager::enumService(svc_type, n); +} + +waServiceFactory *api_serviceI::service_getServiceByGuid(GUID guid) { + return ServiceManager::getServiceByGuid(guid); +} + + +int api_serviceI::service_lock(waServiceFactory *owner, void *svcptr) { + return ServiceManager::lock(owner, svcptr); +} + +int api_serviceI::service_clientLock(void *svcptr) { +#ifdef WASABI_COMPILE_COMPONENTS + return ServiceManager::clientLock(svcptr, WASABI_API_COMPONENT->getThisGuid()); +#else + return ServiceManager::clientLock(svcptr, WASABI_API_APP->main_getGUID()); +#endif +} + +int api_serviceI::service_release(void *svcptr) { + return ServiceManager::release(svcptr); +} + +const char *api_serviceI::service_getTypeName(FOURCC svc_type) { + return ServiceManager::getServiceTypeName(svc_type); +} + +#ifdef WASABI_COMPILE_COMPONENTS +GUID api_serviceI::service_getOwningComponent(void *svcptr) { + return ServiceManager::getOwningComponent(svcptr); +} + +GUID api_serviceI::service_getLockingComponent(void *svcptr) { + return ServiceManager::getLockingComponent(svcptr); +} +#endif + +int api_serviceI::service_unlock(void *svcptr) { + return ServiceManager::unlock(svcptr); +} + +int api_serviceI::service_isvalid(FOURCC svctype, waServiceFactory *service) { + return ServiceManager::isValidService(svctype, service); +} +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/service/api_servicei.h b/Src/Wasabi/api/service/api_servicei.h new file mode 100644 index 00000000..f50ceaa6 --- /dev/null +++ b/Src/Wasabi/api/service/api_servicei.h @@ -0,0 +1,150 @@ +#ifndef __SERVICE_APII_IMPL_H +#define __SERVICE_APII_IMPL_H + +/*<?<autoheader/>*/ +#include "api_service.h" +#include "api_servicex.h" + +class waServiceFactory; +/*?>*/ + +class api_serviceI : public api_serviceX { +public: + NODISPATCH api_serviceI(); + NODISPATCH virtual ~api_serviceI(); + +// services + /** + Register a service. Service registration is done + on creation of the WAC. + + @see WAComponentClient + @ret 1, success; 0, failure. + @param p Pointer to your service factory. + */ + DISPATCH(10) int service_register(waServiceFactory *svc); + + /** + Deregister a service. Service deregistration is done + on destruction of the WAC. + + @see WAComponentClient + @ret 1, success; 0, failure. + @param p Pointer to your service factory. + */ + DISPATCH(20) int service_deregister(waServiceFactory *svc); + + /** + Get the number of services registered for a specific + service type. This should only be called after + Wasabi is fully started (after WAC creation). + + @see FOURCC + @ret Number of services present in that service type. + @param svc_type Service type. + */ + DISPATCH(30) int service_getNumServices(FOURCC svc_type); // see common/svc_enum.h + + // enumerate by family + /** + Enumerate services by family. This should only + be called after Wasabi is fully started (after WAC creation). + + @see FOURCC + @ret Requested service. + @param svc_type Service type. + @param n Number of the service. + */ + DISPATCH(40) waServiceFactory *service_enumService(FOURCC svc_type, int n); + + // fetch by GUID + /** + Get a service by it's GUID. This should only + be called after Wasabi is fully started (after WAC creation). + + @ret Requested service. + @param guid Service GUID. + */ + DISPATCH(50) waServiceFactory *service_getServiceByGuid(GUID guid); + + // service owner calls this when it issues a service * + /** + Lock a service. Service owner must call this when + it issues a new service pointer to a client. + + @ret 1, success; 0, failure; + @param owner Service owner. + @param svcptr Service pointer returned to client. + */ + DISPATCH(60) int service_lock(waServiceFactory *owner, void *svcptr); + + // service client calls this when it uses a service * + /** + ClientLock a service. Service client must call + this before using the service. + + @ret 1, success; 0, failure; + @param svcptr Service pointer. + */ + DISPATCH(70) int service_clientLock(void *svcptr); + + // service client calls this when done w/ service * + /** + Release a service. Service client must call this + when he's finished using the service. If the service + is NOT released it will cause improper shutdown of + the service. + + @ret 1, success; 0, failure; + */ + DISPATCH(80) int service_release(void *svcptr); + /** + Get the pretty printed type name of a service type based + on it's FOURCC. + + @see FOURCC + @ret Service name (readable). + @param svc_type Service type. + */ + DISPATCH(90) const char *service_getTypeName(FOURCC svc_type); + +#ifdef WASABI_COMPILE_COMPONENTS + +/*[interface.service_getOwningComponent.cpp]#ifdef WASABI_COMPILE_COMPONENTS*/ +/*[interface.service_getOwningComponent.h]#ifdef WASABI_COMPILE_COMPONENTS*/ +/*[dispatchable.service_getOwningComponent.enum]#ifdef WASABI_COMPILE_COMPONENTS*/ +/*[dispatchable.service_getOwningComponent.bridge]#ifdef WASABI_COMPILE_COMPONENTS*/ + /** + Get the owning component of a service from + a service pointer. + + @ret GUID of the owning component. + @param svcptr Service pointer. + */ + DISPATCH(100) GUID service_getOwningComponent(void *svcptr); + + /** + Get the locking component for a service from + a service pointer. + + @ret GUID of the locking component. + @param svcptr Service pointer. + */ + DISPATCH(110) GUID service_getLockingComponent(void *svcptr); + +/*[interface.service_unlock.cpp]#endif // WASABI_COMPILE_COMPONENTS*/ +/*[interface.service_unlock.h]#endif // WASABI_COMPILE_COMPONENTS*/ +/*[dispatchable.service_unlock.enum]#endif // WASABI_COMPILE_COMPONENTS*/ +/*[dispatchable.service_unlock.bridge]#endif // WASABI_COMPILE_COMPONENTS*/ +#endif + + DISPATCH(120) int service_unlock(void *svcptr); + + DISPATCH(130) int service_isvalid(FOURCC svctype, waServiceFactory *service); +}; + +/*[interface.footer.h] +extern api_service *serviceApi; +*/ + +#endif // __SERVICE_APII_IMPL_H diff --git a/Src/Wasabi/api/service/api_servicex.cpp b/Src/Wasabi/api/service/api_servicex.cpp new file mode 100644 index 00000000..cc275b3f --- /dev/null +++ b/Src/Wasabi/api/service/api_servicex.cpp @@ -0,0 +1,35 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:56:11 2003] +// +// File : api_servicex.cpp +// Class : api_service +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include <precomp.h> +#ifndef NOSVCMGR +#include "api_servicex.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS api_serviceX +START_DISPATCH; + CB(API_SERVICE_SERVICE_REGISTER, service_register); + CB(API_SERVICE_SERVICE_DEREGISTER, service_deregister); + CB(API_SERVICE_SERVICE_GETNUMSERVICES, service_getNumServices); + CB(API_SERVICE_SERVICE_ENUMSERVICE, service_enumService); + CB(API_SERVICE_SERVICE_GETSERVICEBYGUID, service_getServiceByGuid); + CB(API_SERVICE_SERVICE_LOCK, service_lock); + CB(API_SERVICE_SERVICE_CLIENTLOCK, service_clientLock); + CB(API_SERVICE_SERVICE_RELEASE, service_release); + CB(API_SERVICE_SERVICE_GETTYPENAME, service_getTypeName); + #ifdef WASABI_COMPILE_COMPONENTS + CB(API_SERVICE_SERVICE_GETOWNINGCOMPONENT, service_getOwningComponent); + CB(API_SERVICE_SERVICE_GETLOCKINGCOMPONENT, service_getLockingComponent); + #endif // WASABI_COMPILE_COMPONENTS + CB(API_SERVICE_SERVICE_UNLOCK, service_unlock); + CB(API_SERVICE_ISVALID, service_isvalid); +END_DISPATCH; +#undef CBCLASS +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/service/api_servicex.h b/Src/Wasabi/api/service/api_servicex.h new file mode 100644 index 00000000..650d6b97 --- /dev/null +++ b/Src/Wasabi/api/service/api_servicex.h @@ -0,0 +1,44 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:56:11 2003] +// +// File : api_servicex.h +// Class : api_service +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __API_SERVICEX_H +#define __API_SERVICEX_H + +#include "api_service.h" + +class waServiceFactory; + + + +// ---------------------------------------------------------------------------- + +class api_serviceX : public api_service { + protected: + api_serviceX() {} + public: + virtual int service_register(waServiceFactory *svc)=0; + virtual int service_deregister(waServiceFactory *svc)=0; + virtual int service_getNumServices(FOURCC svc_type)=0; + virtual waServiceFactory *service_enumService(FOURCC svc_type, int n)=0; + virtual waServiceFactory *service_getServiceByGuid(GUID guid)=0; + virtual int service_lock(waServiceFactory *owner, void *svcptr)=0; + virtual int service_clientLock(void *svcptr)=0; + virtual int service_release(void *svcptr)=0; + virtual const char *service_getTypeName(FOURCC svc_type)=0; + #ifdef WASABI_COMPILE_COMPONENTS + virtual GUID service_getOwningComponent(void *svcptr)=0; + virtual GUID service_getLockingComponent(void *svcptr)=0; + #endif // WASABI_COMPILE_COMPONENTS + virtual int service_unlock(void *svcptr)=0; + virtual int service_isvalid(FOURCC svctype, waServiceFactory *service)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __API_SERVICEX_H diff --git a/Src/Wasabi/api/service/service.h b/Src/Wasabi/api/service/service.h new file mode 100644 index 00000000..4ef710a6 --- /dev/null +++ b/Src/Wasabi/api/service/service.h @@ -0,0 +1,16 @@ +#ifndef _SERVICE_H +#define _SERVICE_H + +// this file defines the wasabi service factory class. this isn't the actual +// service, just the interface to get the service pointer + +#include <bfc/dispatch.h> +#include "services.h" + +#include "waservicefactory.h" +#include "waservicefactorybase.h" +#include "waservicefactoryt.h" +#include "waservicefactorytsingle.h" + + +#endif diff --git a/Src/Wasabi/api/service/servicei.cpp b/Src/Wasabi/api/service/servicei.cpp new file mode 100644 index 00000000..e3d87fca --- /dev/null +++ b/Src/Wasabi/api/service/servicei.cpp @@ -0,0 +1,5 @@ + +#include <precomp.h> +#include "servicei.h" + + diff --git a/Src/Wasabi/api/service/servicei.h b/Src/Wasabi/api/service/servicei.h new file mode 100644 index 00000000..9d2bcc1b --- /dev/null +++ b/Src/Wasabi/api/service/servicei.h @@ -0,0 +1,180 @@ +#ifndef _SERVICEI_H +#define _SERVICEI_H + +// here is where we define some helper implementations of the service factory +// interface + +#include "service.h" + +#include "waservicefactoryi.h" +#include "waservicefactorybase.h" +#include "waservicefactoryt.h" +#include "waservicefactorytsingle.h" +#include <bfc/ptrlist.h> +#include <bfc/foreach.h> + +// DEPRECATED +#define waService waServiceFactory +#define waServiceT waServiceFactoryT +#define waServiceTSingle waServiceFactoryTSingle + +// Declaring services via macros +// ie: +// BEGIN_SERVICES(YourClass_Svc) +// DECLARE_SERVICE(SomeSvcCreator<YourServiceClass1>); +// DECLARE_SERVICE(SomeSvcCreator<YourServiceClass2>); +// DECLARE_SERVICE(SomeSvcCreator<YourServiceClass3>); +// DECLARE_SERVICETMULTI(svc_serviceclass, YourMultiInstanceServiceClass1>); +// DECLARE_SERVICETMULTI(svc_serviceclass, YourMultiInstanceServiceClass2>); +// DECLARE_SERVICETMULTI(svc_serviceclass, YourMultiInstanceServiceClass3>); +// DECLARE_SERVICETSINGLE(svc_serviceclass, YourSingleInstanceServiceClass1>); +// DECLARE_SERVICETSINGLE(svc_serviceclass, YourSingleInstanceServiceClass2>); +// DECLARE_SERVICETSINGLE(svc_serviceclass, YourSingleInstanceServiceClass3>); +// END_SERVICES(YourClass_Svc, _YourClass_Svc); + +// The macro DECLARE_MODULE_SVCMGR should be defined in your main cpp file if you are compiling +// a standalone exe without using the Application class. In this case you should also add +// MODULE_SVCMGR_ONINIT(); in your app startup and MODULE_SVCMGR_ONSHUTDOWN() in your app shutdown +// (class Application does this already) + +// You can use BEGIN_SYS_SERVICES to declare a service that is initialized in priority and +// shutdown late (normal version inits late, shutdowns early) + + +class StaticServices { + public: + virtual void registerServices()=0; + virtual void unregisterServices()=0; +}; + +class AutoServiceList : public PtrList<StaticServices> { + public: + AutoServiceList() + { +#ifdef _WIN32 // PORT ME + OutputDebugStringA(">\n"); +#endif + } +}; + +class StaticServiceMgr { + public: + AutoServiceList __m_modules; + AutoServiceList __m_modules2; +}; + +#define DECLARE_MODULE_SVCMGR StaticServiceMgr *staticServiceMgr = NULL; + +extern StaticServiceMgr *staticServiceMgr; + +#define MODULE_SVCMGR_ONINIT() { \ +foreach(staticServiceMgr->__m_modules) \ + staticServiceMgr->__m_modules.getfor()->registerServices(); \ +endfor; \ +} + +#define MODULE_SVCMGR_ONINIT2() { \ +foreach(staticServiceMgr->__m_modules2) \ + staticServiceMgr->__m_modules2.getfor()->registerServices(); \ +endfor; \ +} + +#define MODULE_SVCMGR_ONSHUTDOWN() { \ +foreach(staticServiceMgr->__m_modules) \ + staticServiceMgr->__m_modules.getfor()->unregisterServices(); \ +endfor; \ +} + +#define MODULE_SVCMGR_ONSHUTDOWN2() { \ +foreach(staticServiceMgr->__m_modules2) \ + staticServiceMgr->__m_modules2.getfor()->unregisterServices(); \ +endfor; \ +} + +#define INIT_MODULE_SVCMGR() \ + if (!staticServiceMgr) staticServiceMgr = new StaticServiceMgr; + +#define BEGIN_SERVICES(CLASSNAME) \ +class CLASSNAME : public StaticServices { \ +public: \ + CLASSNAME() { \ + INIT_MODULE_SVCMGR() \ + staticServiceMgr->__m_modules.addItem(this); \ + } \ + virtual ~CLASSNAME() {} \ + virtual void registerServices() { \ + ASSERT(staticServiceMgr); + +#define BEGIN_SERVICES_DEBUG(CLASSNAME, TEXT) \ +class CLASSNAME : public StaticServices { \ +public: \ + CLASSNAME() { \ + INIT_MODULE_SVCMGR() \ + OutputDebugString("Registering "); \ + OutputDebugString(TEXT); \ + OutputDebugString("\n"); \ + staticServiceMgr->__m_modules.addItem(this); \ + } \ + virtual ~CLASSNAME() {} \ + virtual void registerServices() { \ + ASSERT(staticServiceMgr); + +#define BEGIN_SYS_SERVICES(CLASSNAME) \ +class CLASSNAME : public StaticServices { \ +public: \ + CLASSNAME() { \ + INIT_MODULE_SVCMGR() \ + staticServiceMgr->__m_modules2.addItem(this); \ + } \ + virtual ~CLASSNAME() {} \ + virtual void registerServices() { + +#define DECLARE_SERVICE(INSTANTIATIONCODE) \ + registerService(new INSTANTIATIONCODE); + +#define DECLARE_SERVICE_DEBUG(INSTANTIATIONCODE, TEXT) \ + OutputDebugString("Starting "); \ + OutputDebugString(TEXT); \ + OutputDebugString("\n"); \ + registerService(new INSTANTIATIONCODE); + +#define DECLARE_SERVICETMULTI(SVCTYPE, SVCCLASS) \ + registerService(new waServiceFactoryT<SVCTYPE, SVCCLASS>); + +#define DECLARE_SERVICETMULTI_DEBUG(SVCTYPE, SVCCLASS, TEXT) \ + OutputDebugString("Starting "); \ + OutputDebugString(TEXT); \ + OutputDebugString("\n"); \ + registerService(new waServiceFactoryT<SVCTYPE, SVCCLASS>); + +#define DECLARE_SERVICETSINGLE(SVCTYPE, SVCCLASS) \ + registerService(new waServiceFactoryTSingle<SVCTYPE, SVCCLASS>); + +#define DECLARE_SERVICETSINGLE_DEBUG(SVCTYPE, SVCCLASS, TEXT) \ + OutputDebugString("Starting "); \ + OutputDebugString(TEXT); \ + OutputDebugString("\n"); \ + registerService(new waServiceFactoryTSingle<SVCTYPE, SVCCLASS>, TEXT); + +#define END_SERVICES(CLASSNAME, INSTANCENAME) \ + } \ + virtual void unregisterServices() { \ + foreach(services) \ + waServiceFactoryI *svc = services.getfor(); \ + WASABI_API_SVC->service_deregister(svc); \ + delete svc; \ + endfor; \ + services.removeAll();\ + } \ +private: \ + void registerService(waServiceFactoryI *svc) { \ + if (svc != NULL) { \ + services.addItem(svc); \ + WASABI_API_SVC->service_register(svc); \ + } \ + } \ + PtrList<waServiceFactoryI> services; \ +}; \ +CLASSNAME INSTANCENAME; + +#endif diff --git a/Src/Wasabi/api/service/services.h b/Src/Wasabi/api/service/services.h new file mode 100644 index 00000000..ab044459 --- /dev/null +++ b/Src/Wasabi/api/service/services.h @@ -0,0 +1,76 @@ +#ifndef _SERVICES_H +#define _SERVICES_H + +#include "bfc/std_mkncc.h" // for MKnCC() + +// lower-case service names are reserved by Nullsoft for future use +// upper-case service names are for 3rd parties to extend the service system + +// if you have a service that is unique to a component, make it type +// UNIQUE and register it by GUID + + +namespace WaSvc +{ + enum + { + NONE = MK4CC( 'n', 'o', 'n', 'e' ), + UNIQUE = MK4CC( 'u', 'n', 'i', 'q' ), // for unique services, enumed by GUID + OBJECT = MK4CC( 'o', 'b', 'j', 'f' ), // for unique objects, enumed by GUID + CONTEXTCMD = MK4CC( 'c', 'c', 'm', 'd' ), // context menu command svc_contextCmd.h + DEVICE = MK3CC( 'd', 'e', 'v' ), // portable device svc_device.h + FILEREADER = MK4CC( 'f', 's', 'r', 'd' ), // file system reader (disk, zip, http) + FILESELECTOR = MK4CC( 'f', 's', 'e', 'l' ), // file selector svc_filesel.h + STORAGEVOLENUM = MK4CC( 'f', 's', 'e', 'n' ), // storage volume enumerator. + IMAGEGENERATOR = MK4CC( 'i', 'm', 'g', 'n' ), // image generator svc_imggen.h + IMAGELOADER = MK4CC( 'i', 'm', 'g', 'l' ), // image loader svc_imgload.h + IMAGEWRITER = MK4CC( 'i', 'm', 'g', 'w' ), // image writer + ITEMMANAGER = MK4CC( 'i', 'm', 'g', 'r' ), // item manager svc_itemmgr.h + PLAYLISTREADER = MK4CC( 'p', 'l', 'r', 'd' ), // playlist reader - DEPRECATED - only for wa3 + PLAYLISTWRITER = MK4CC( 'p', 'l', 'w', 'r' ), // playlist writer - DEPRECATED - only for wa3 + MEDIACONVERTER = MK4CC( 'c', 'o', 'n', 'v' ), // media converter + MEDIACORE = MK4CC( 'c', 'o', 'r', 'e' ), // media core + MEDIARECORDER = MK4CC( 'm', 'r', 'e', 'c' ), // media recorder + SCRIPTOBJECT = MK4CC( 'm', 'a', 'k', 'i' ), // third party script object + // TRANSLATOR=MK4CC('x','l','a','t'), // text translator + WINDOWCREATE = MK4CC( 'w', 'n', 'd', 'c' ), // window creator + XMLPROVIDER = MK4CC( 'x', 'm', 'l', 'p' ), // xml provider + DB = MK2CC( 'd', 'b' ), // database + SKINFILTER = MK4CC( 'f', 'l', 't', 'r' ), // bitmap/colorref skin filter + METADATA = MK4CC( 'm', 't', 'd', 't' ), // play item meta data + METATAG = MK4CC( 'm', 't', 't', 'g' ), // metadata tagging of play items + EVALUATOR = MK4CC( 'e', 'v', 'a', 'l' ), // evaluate a string + MINIBROWSER = MK2CC( 'm', 'b' ), // minibrowser + TOOLTIPSRENDERER = MK4CC( 't', 't', 'i', 'p' ), // tooltips renderer + XUIOBJECT = MK4CC( 'x', 'u', 'i', 'o' ), // xml gui objects + STRINGCONVERTER = MK4CC( 'u', 't', 'f', '8' ), // unicode string conversion + ACTION = MK3CC( 'a', 'c', 't' ), // custom actions (ie: for buttons) + COREADMIN = MK4CC( 'c', 'a', 'd', 'm' ), // core administrator + DROPTARGET = MK4CC( 'd', 'r', 'o', 'p' ), // drop targets + OBJECTDIR = MK4CC( 'o', 'b', 'j', 'd' ), // object directory + TEXTFEED = MK4CC( 't', 'x', 't', 'f' ), // text feed, to send text to various XUI objects (ie: <Text> by using display="textfeedid" + ACCESSIBILITY = MK4CC( 'a', 'c', 'c', 's' ), // accessibility service + ACCESSIBILITYROLESERVER = MK4CC( 'r', 'o', 'l', 'e' ), // accessibility roleServer services + EXPORTER = MK3CC( 'e', 'x', 'p' ), // exporter + COLLECTION = MK4CC( 'c', 'l', 'c', 't' ), // named xml overridable collection + REDIRECT = MK4CC( 'r', 'e', 'd', 'r' ), // filename redirect + FONTRENDER = MK4CC( 'f', 'o', 'n', 't' ), // font renderer (bitmap/truetype/freetype) + SRCCLASSFACTORY = MK4CC( 'c', 'l', 'f', 'a' ), // source code class factory + SRCEDITOR = MK4CC( 's', 'e', 'd', 't' ), // source code editor + MP4AUDIODECODER = MK4CC( 'm', '4', 'a', 'd' ), // mp4 audio decoder + MP4VIDEODECODER = MK4CC( 'm', '4', 'v', 'd' ), // mp4 audio decoder + PLAYLISTREADER_WA5 = MK4CC( 'p', 'l', 'r', '5' ), // playlist reader + PLAYLISTWRITER_WA5 = MK4CC( 'p', 'l', 'w', '5' ), // playlist writer + PLAYLISTHANDLER = MK3CC( 'p', 'l', 'h' ), // playlist handler + TAGPROVIDER = MK4CC( 't', 'a', 'g', 'z' ), // tag provider (for ATF engine) + NSVFACTORY = MK4CC( 'n', 's', 'v', 'f' ), // NSV factory (to create NSV objects) + JSAPI2_APICREATOR = MK4CC( 'j', 's', 'a', 'c' ), // API Creator for the Javascript API + MKVDECODER = MK3CC( 'm', 'k', 'v' ), // MKV factory (to create MKV decoder objects) + FLVDECODER = MK3CC( 'f', 'l', 'v' ), // FLV factory (to create FLV decoder objects) + AVIDECODER = MK3CC( 'a', 'v', 'i' ), // AVI factory (to create AVI decoder objects) + OGGDECODER = MK3CC( 'o', 'g', 'g' ), // Ogg factory (to create Ogg decoder objects) + MP4DECODER = MK3CC( 'm', 'p', '4' ), // MP4 factory (to create MP4 decoder objects) + }; +}; + +#endif diff --git a/Src/Wasabi/api/service/svc_enum.cpp b/Src/Wasabi/api/service/svc_enum.cpp new file mode 100644 index 00000000..8ca8a1af --- /dev/null +++ b/Src/Wasabi/api/service/svc_enum.cpp @@ -0,0 +1,2 @@ +#include <precomp.h> +#include "svc_enum.h" diff --git a/Src/Wasabi/api/service/svc_enum.h b/Src/Wasabi/api/service/svc_enum.h new file mode 100644 index 00000000..40f5c651 --- /dev/null +++ b/Src/Wasabi/api/service/svc_enum.h @@ -0,0 +1,24 @@ +#ifndef _SVC_ENUM_H +#define _SVC_ENUM_H + +// try to use this one, it does a clientLock for you +#include <api/service/waservicefactory.h> +template <class T> +class castService { +public: + castService(waServiceFactory *w, int global_lock=TRUE) : was(w), gl(global_lock) { } + operator T *() { + if (was == NULL) return NULL; + T *ret = static_cast<T *>(was->getInterface(gl)); + return ret; + } +private: + waServiceFactory *was; + int gl; +}; + +#include "svcenumbyguid.h" +#include "svcenum.h" +#include "svcenumt.h" + +#endif diff --git a/Src/Wasabi/api/service/svccache.cpp b/Src/Wasabi/api/service/svccache.cpp new file mode 100644 index 00000000..af3e47cf --- /dev/null +++ b/Src/Wasabi/api/service/svccache.cpp @@ -0,0 +1,35 @@ +#include <precomp.h> +#include "svccache.h" +#include <bfc/string/bfcstring.h> + +#if !defined(WASABI_API_SVC) +#error no no +#endif + +SvcCache::SvcCache(FOURCC type) { + int p = 0; + list.setAutoSort(FALSE); + for (;;) { + waServiceFactory *svc = WASABI_API_SVC->service_enumService(type, p++); + if (svc == NULL) break; + const wchar_t *teststr = svc->getTestString(); + if (teststr == NULL || *teststr == '\0') continue; +//CUT DebugString("cachin %s\n", teststr); + list.addItem(svc); + } + list.setAutoSort(TRUE); +} + +waServiceFactory *SvcCache::findServiceFactory(const wchar_t *searchval) { + return list.findItem(searchval); +} + +int SvcCache::waServiceFactoryCompare::compareItem(waServiceFactory *p1, waServiceFactory* p2) { + int r = WCSICMP(p1->getTestString(), p2->getTestString()); + if (r == 0) return CMP3(p1, p2); + return r; +} + +int SvcCache::waServiceFactoryCompare::compareAttrib(const wchar_t *attrib, waServiceFactory *item) { + return WCSICMP(attrib, item->getTestString()); +} diff --git a/Src/Wasabi/api/service/svccache.h b/Src/Wasabi/api/service/svccache.h new file mode 100644 index 00000000..1e989e57 --- /dev/null +++ b/Src/Wasabi/api/service/svccache.h @@ -0,0 +1,43 @@ +#ifndef _SVC_CACHE_H +#define _SVC_CACHE_H + +#include <api/service/svc_enum.h> +#include <bfc/ptrlist.h> + +/** + This is a caching version of SvcEnum. Upon creation, it enumerates all + service factories in the family and keeps them in a list. Then you can + call findService() with a search string to quickly find the service you + want. If you don't have a search string, you can still use a SvcEnum. +*/ + +class SvcCache { +protected: + SvcCache(FOURCC type); + +public: + waServiceFactory *findServiceFactory(const wchar_t *searchval); + +private: + class waServiceFactoryCompare { + public: + static int compareItem(waServiceFactory *p1, waServiceFactory* p2); + static int compareAttrib(const wchar_t *attrib, waServiceFactory *item); + }; + PtrListQuickSorted<waServiceFactory, waServiceFactoryCompare> list; +}; + +template <class T> +class SvcCacheT : public SvcCache { +public: + SvcCacheT() : SvcCache(T::getServiceType()) { } + + T *findService(const char *key, int global_lock=TRUE) { + waServiceFactory *sf = findServiceFactory(key); + if (sf == NULL) return NULL; + T *ret = castService<T>(sf, global_lock); + return ret; + } +}; + +#endif diff --git a/Src/Wasabi/api/service/svcenum.cpp b/Src/Wasabi/api/service/svcenum.cpp new file mode 100644 index 00000000..f9219654 --- /dev/null +++ b/Src/Wasabi/api/service/svcenum.cpp @@ -0,0 +1,45 @@ +#include <precomp.h> + +//<?#include "<class data="implementationheader"/>" +#include "svcenum.h" +//?> + + +#include <api/service/services.h> +#include <api/service/waservicefactory.h> +#include <bfc/bfc_assert.h> + +SvcEnum::SvcEnum() : type(WaSvc::NONE), factory(NULL) { + reset(); +} + +void *SvcEnum::_getNext(int global_lock) { + if (WASABI_API_SVC == NULL) return NULL; + for (;;) { + factory = WASABI_API_SVC->service_enumService(type, pos++); + if (factory == NULL) return NULL; + void *s = factory->getInterface(FALSE);// get but don't lock + if (s) + { + if (_testService(s)) { + if (global_lock) + WASABI_API_SVC->service_lock(factory, s); // lock in sys tables + return s; + } + factory->releaseInterface(s); + } + } +} + +void SvcEnum::reset() { + pos = 0; + factory = NULL; +} + +int SvcEnum::release(void *ptr) { + return WASABI_API_SVC->service_release(ptr); +} + +waServiceFactory *SvcEnum::getLastFactory() { + return factory; +} diff --git a/Src/Wasabi/api/service/svcenum.h b/Src/Wasabi/api/service/svcenum.h new file mode 100644 index 00000000..bdfbb7df --- /dev/null +++ b/Src/Wasabi/api/service/svcenum.h @@ -0,0 +1,37 @@ +#ifndef _SVCENUM_H +#define _SVCENUM_H + + +/*<?<autoheader/>*/ +class waServiceFactory; +/*?>*/ + +// abstract base class +class NOVTABLE SvcEnum { +protected: + SvcEnum(); + + void *_getNext(int global_lock = TRUE); + void reset(); + + virtual int _testService(void *)=0; + +public: +#ifdef ASSERTS_ENABLED + static int release(waServiceFactory *ptr) { ASSERTALWAYS("never ever call release() with a waServiceFactory * !!!"); return 0; } +#endif + static int release(void *ptr); + + waServiceFactory *getLastFactory(); + +protected: + FOURCC type; + +private: + int pos; + waServiceFactory * factory; +}; + + +#endif // _SVCENUM_H + diff --git a/Src/Wasabi/api/service/svcenumbyguid.cpp b/Src/Wasabi/api/service/svcenumbyguid.cpp new file mode 100644 index 00000000..28b315a0 --- /dev/null +++ b/Src/Wasabi/api/service/svcenumbyguid.cpp @@ -0,0 +1,5 @@ +#include <precomp.h> +//<?#include "<class data="implementationheader"/>" +#include "svcenumbyguid.h" +//?> + diff --git a/Src/Wasabi/api/service/svcenumbyguid.h b/Src/Wasabi/api/service/svcenumbyguid.h new file mode 100644 index 00000000..412523c3 --- /dev/null +++ b/Src/Wasabi/api/service/svcenumbyguid.h @@ -0,0 +1,37 @@ +#ifndef _SVCENUMBYGUID_H +#define _SVCENUMBYGUID_H + +/*<?<autoheader/>*/ +/*?>*/ + +#include "svc_enum.h" + +/* + * this is a helper class to fetch a service * by GUID + * usage: svc_something *svc = SvcEnumByGuid<svc_something>(svcguid); + * @short: Helper class to fetch unique service by GUID +*/ +template <class SERVICETYPE> +class SvcEnumByGuid { +public: +/** +@param _guid The GUID of the service factory to fetch the service from. +*/ + SvcEnumByGuid() : guid(SERVICETYPE::getServiceGuid()) {} + SvcEnumByGuid(GUID _guid) : guid(_guid) {} + +/** +@return The pointer to the service. +*/ + SERVICETYPE *getInterface() { + waServiceFactory *svc = WASABI_API_SVC->service_getServiceByGuid(guid); + return castService<SERVICETYPE>(svc); + } + + operator SERVICETYPE *() { return getInterface(); } + +private: + GUID guid; +}; + +#endif // _SVCENUMBYGUID_H diff --git a/Src/Wasabi/api/service/svcenumt.cpp b/Src/Wasabi/api/service/svcenumt.cpp new file mode 100644 index 00000000..2fa45792 --- /dev/null +++ b/Src/Wasabi/api/service/svcenumt.cpp @@ -0,0 +1,5 @@ +#include <precomp.h> +//<?#include "<class data="implementationheader"/>" +#include "svcenumt.h" +//?> + diff --git a/Src/Wasabi/api/service/svcenumt.h b/Src/Wasabi/api/service/svcenumt.h new file mode 100644 index 00000000..e423b542 --- /dev/null +++ b/Src/Wasabi/api/service/svcenumt.h @@ -0,0 +1,30 @@ +#ifndef _SVCENUMT_H +#define _SVCENUMT_H + +#include "svcenum.h" + +template <class T> +class SvcEnumT : private SvcEnum { +protected: + SvcEnumT() { type = T::getServiceType(); } + +public: + void reset() { SvcEnum::reset(); } + T *getFirst(int global_lock = TRUE) { reset(); return getNext(global_lock); } + T *getNext(int global_lock = TRUE) { return static_cast<T*>(_getNext(global_lock)); } + + // these would just be 'using' but msvc.net sucks butt + inline int release(void *ptr) { return SvcEnum::release(ptr); } + inline waServiceFactory *getLastFactory() { return SvcEnum::getLastFactory(); } + +protected: + // override this one (or don't if you want to return all of them) + virtual int testService(T *svc) { return TRUE; } + +private: + virtual int _testService(void *svc) { + return testService(static_cast<T *>(svc)); + } +}; + +#endif // _SVCENUMT_H diff --git a/Src/Wasabi/api/service/svcmgr.cpp b/Src/Wasabi/api/service/svcmgr.cpp new file mode 100644 index 00000000..78eec802 --- /dev/null +++ b/Src/Wasabi/api/service/svcmgr.cpp @@ -0,0 +1,365 @@ +#include <precomp.h> +#ifndef NOSVCMGR +#include "svcmgr.h" + +#ifdef WASABI_COMPILE_COMPONENTS +#include <api/wac/wac.h> +#include <api/wac/compon.h> +#endif + +#ifdef WASABI_COMPILE_SYSCB +#include <api/syscb/cbmgr.h> +#include <api/syscb/callbacks/syscb.h> +#include <api/syscb/callbacks/svccb.h> +#endif + +#include <bfc/multimap.h> +#include <bfc/map.h> +#include <bfc/critsec.h> + +static MultiMap<FOURCC, waServiceFactory> services;// list of factories by class +static Map<waServiceFactory*, GUID> ownermap; // who presented it +static Map<GUID, waServiceFactory*> services_by_guid;// unique services +static Map<void *, waServiceFactory*> lockmap; // who to tell when it's unlocked +//CUTstatic Map<void *, GUID> clientmap; // who locked it + +static CriticalSection cs; + +int ServiceManager::registerService(waServiceFactory *service, GUID owner) { + ASSERT(owner != INVALID_GUID); + if (owner == INVALID_GUID) return 0; + FOURCC svctype = service->getServiceType(); + cs.enter(); + if (!services.multiHaveItem(svctype, service)) { + services.multiAddItem(svctype, service); + + ownermap.addItem(service, owner); + + GUID svcguid = service->getGuid(); + if (svcguid != INVALID_GUID) services_by_guid.addItem(svcguid, service); + } + cs.leave(); + + service->serviceNotify(SvcNotify::ONREGISTERED); + + #ifdef WASABI_COMPILE_SYSCB + CallbackManager::issueCallback(SysCallback::SERVICE, + SvcCallback::ONREGISTER, + (int)svctype, reinterpret_cast<int>(service)); + #endif + + return 1; +} + +int ServiceManager::deregisterService(waServiceFactory *service, int internal) { + FOURCC svctype = service->getServiceType(); + // make sure it was there + cs.enter(); + if (services.multiHaveItem(svctype, service)) { + // make sure there aren't still services issued by this guy +// ASSERT(internal || !lockmap.reverseGetItem(service)); + services.multiDelItem(svctype, service); + ownermap.delItem(service); + services_by_guid.reverseDelItem(service); + } + cs.leave(); + service->serviceNotify(SvcNotify::ONDEREGISTERED); + + #ifdef WASABI_COMPILE_SYSCB + CallbackManager::issueCallback(SysCallback::SERVICE, + SvcCallback::ONDEREGISTER, + (int)svctype, reinterpret_cast<int>(service)); + #endif + + return 1; +} + +int ServiceManager::getNumServices(FOURCC svc_type) { + INCRITICALSECTION(cs); + return services.multiGetNumItems(svc_type); +} + +int ServiceManager::getNumServices() { + return services.getNumItems(); +} + +waServiceFactory *ServiceManager::enumService(int n) { + return services_by_guid.enumItemByPos(n, NULL); +} + +int ServiceManager::getNumOwners() { + return ownermap.getNumItems(); +} + +int ServiceManager::getNumServicesByGuid() { + return services_by_guid.getNumItems(); +} + +int ServiceManager::getNumLocks() { + return lockmap.getNumItems(); +} + +waServiceFactory *ServiceManager::enumService(FOURCC svc_type, int n) { + INCRITICALSECTION(cs); + waServiceFactory *ret = NULL; + services.multiGetItem(svc_type, n, &ret); + return ret; +} + +waServiceFactory *ServiceManager::getServiceByGuid(GUID guid) { + INCRITICALSECTION(cs); + if (guid == INVALID_GUID) return NULL; + waServiceFactory *ret=NULL; + services_by_guid.getItem(guid, &ret); + return ret; +} + +void ServiceManager::sendNotification(int msg, int param1, int param2) { + cs.enter(); + for (int x = 0; x < services.multiGetNumPairs(); x++) { + for (int y = 0; ; y++) { + waServiceFactory *svc; + if (!services.multiGetItemDirect(x, y, &svc)) { + break; + } + svc->serviceNotify(msg, param1, param2); + } + } + cs.leave(); +#ifdef WASABI_COMPILE_COMPONENTS + // also notify components + for (int i = 0; ; i++) { + WaComponent *wac = ComponentManager::enumComponent(i); + if (wac == NULL) break; + wac->onNotify(WAC_NOTIFY_SERVICE_NOTIFY, msg, param1, param2); + } +#endif + #ifdef WASABI_COMPILE_SYSCB + // and syscallbacks + CallbackManager::issueCallback(SysCallback::RUNLEVEL, msg); + #endif +} + +int ServiceManager::lock(waServiceFactory *owner, void *svcptr) { + INCRITICALSECTION(cs); + if (owner == NULL || svcptr == NULL) return 0; + // we allow multiple entries for same service + lockmap.addItem(svcptr, owner); + return 1; +} + +int ServiceManager::unlock(void *svcptr) { + if (svcptr == NULL) return 0; + + waServiceFactory *wsvc = NULL; + cs.enter(); + if (!lockmap.getItem(svcptr, &wsvc)) { + cs.leave(); + DebugString("WARNING: got unlock with no lock record!"); + return 0; + } + + int r = lockmap.delItem(svcptr); + ASSERT(r); + +//CUT // this might fail, client locking isn't enforceable +//CUT clientmap.delItem(svcptr); + + cs.leave(); + + return 1; +} + +int ServiceManager::clientLock(void *svcptr, GUID lockedby) { +//CUT INCRITICALSECTION(cs); +//CUT ASSERT(svcptr != NULL); +//CUT if (svcptr == NULL) return 0; +//CUT ASSERT(lockedby != INVALID_GUID); +//CUT if (lockedby == INVALID_GUID) return 0; +//CUT clientmap.addItem(svcptr, lockedby); + return 1; +} + +int ServiceManager::release(void *svcptr) { + if (svcptr == NULL) return 0; + + waServiceFactory *wsvc = NULL; + cs.enter(); // note cs getting locked twice via release+unlock + if (!lockmap.getItem(svcptr, &wsvc)) { + cs.leave(); + DebugString("WARNING: got release with no lock record!"); + return 0; + } + unlock(svcptr); + cs.leave(); + + ASSERT(wsvc != NULL); + return wsvc->releaseInterface(svcptr); +} + +#ifdef WASABI_COMPILE_COMPONENTS +GUID ServiceManager::getOwningComponent(void *svcptr) { + INCRITICALSECTION(cs); + GUID ret = INVALID_GUID; + waServiceFactory *svc=NULL; + if (lockmap.getItem(svcptr, &svc)) ownermap.getItem(svc, &ret); + return ret; +} + +GUID ServiceManager::getLockingComponent(void *svcptr) { + INCRITICALSECTION(cs); + GUID ret = INVALID_GUID; +//CUT clientmap.getItem(svcptr, &ret); + return ret; +} +#endif + +using namespace WaSvc; + +static struct { + FOURCC type; + const char *name; +} svc_names[] = { + { DEVICE, "Portable Device" }, + { FILEREADER, "File Reader" }, + { FILESELECTOR, "File Selector" }, + { IMAGEGENERATOR, "Image Generator" }, + { IMAGELOADER, "Image Loader" }, + { ITEMMANAGER, "Item Manager" }, + { MEDIACONVERTER, "Media Converter" }, + { MEDIACORE, "Media Core" }, + { PLAYLISTREADER, "Playlist Reader" }, + { PLAYLISTWRITER, "Playlist Writer" }, + { SCRIPTOBJECT, "Script Class" }, + { XMLPROVIDER, "XML Provider" }, + { DB, "Database" }, + { EVALUATOR, "Evaluator" }, + { COREADMIN, "Core Administrator" }, + { NONE, NULL }, // this one has to be last +}; + +const char *ServiceManager::getServiceTypeName(FOURCC svc_type) { + for (int i = 0; ; i++) { + if (svc_names[i].name == NULL) break; + if (svc_names[i].type == svc_type) return svc_names[i].name; + } + return NULL; +} + +FOURCC ServiceManager::safe_getServiceType(waServiceFactory *was) { +#ifndef _DEBUG + return 0; +#endif + FOURCC type = 0; + _TRY + { + type = was->getServiceType(); + } + _EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + OutputDebugString("EXCEPTION_EXECUTE_HANDLER\n"); + } + return type; +} + +const char *ServiceManager::safe_getServiceName(waServiceFactory *was) { +#ifndef _DEBUG + return 0; +#endif + const char *name = NULL; + _TRY + { + name = was->getServiceName(); + } + _EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + OutputDebugString("EXCEPTION_EXECUTE_HANDLER\n"); + } + return name; +} + +void ServiceManager::onShutdown() { +/* + ownermap.purge(); + services.purge(); + services_by_guid.purge(); + clientmap.purge(); +*/ + + int nlocks = lockmap.getNumPairs(); + if (nlocks <= 0) { + //lockmap.purge(); + #ifdef GEN_FF // i need this to have clean session restart, feel free to remove the ifdef if you fgeel that should always be done + ownermap.deleteAll(); + services.multiRemoveAll(); + services_by_guid.deleteAll(); + lockmap.deleteAll(); + #endif + return; + } + +#ifndef _DEBUG + DebugString("-----------------\n"); + for (int i = 0; i < nlocks; i++) { + void *ptr = lockmap.enumIndexByPos(i, NULL); ASSERT(ptr != NULL); + StringPrintf s("lock: %d type:'", (int)ptr); + +// GUID g = lockermap.enumItemByPos(i, INVALID_GUID);ASSERT(g != INVALID_GUID); +// s += g; +// WaComponent *wac = ComponentManager::getComponentFromGuid(g); + + waServiceFactory *was=NULL; + was = lockmap.enumItemByPos(i, NULL); + ASSERT(was != NULL); + FOURCC type = safe_getServiceType(was); + const char *tname = ServiceManager::getServiceTypeName(type); + if (tname != NULL) { + s += tname; + } else { + FOURCC v = BSWAP(type); + unsigned char bleh[5]=" "; + MEMCPY(bleh, &v, 4); + s += String((char *)bleh); + } + s += "' from service:'"; + s += safe_getServiceName(was); + +// s += " wac:"; +// if (wac) s += wac->getName(); +#ifdef WASABI_COMPILE_COMPONENTS + s += "' owned by:'"; + + GUID g = INVALID_GUID; + ownermap.getItem(was, &g); + if (g != INVALID_GUID) { + s += g; + WaComponent *wac = ComponentManager::getComponentFromGuid(g); + if (wac) s += wac->getName(); + } else s += "(unregistered)"; +#else + GUID g; +#endif + + s += "' registered lock to '"; + g = INVALID_GUID; + //clientmap.getItem(ptr, &g); + s += g; + + s += "'\n"; + DebugString(s.v()); + } + DebugString("-----------------\n"); +#endif +#ifdef GEN_FF // i need this to have clean session restart, feel free to remove the ifdef if you fgeel that should always be done + ownermap.deleteAll(); + services.multiRemoveAll(); + services_by_guid.deleteAll(); + lockmap.deleteAll(); +#endif +} + +int ServiceManager::isValidService(FOURCC svctype, waServiceFactory *service) { + INCRITICALSECTION(cs); + return services.multiHaveItem(svctype, service); +} +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/service/svcmgr.h b/Src/Wasabi/api/service/svcmgr.h new file mode 100644 index 00000000..a9bcdc66 --- /dev/null +++ b/Src/Wasabi/api/service/svcmgr.h @@ -0,0 +1,41 @@ +#ifndef _SVCMGR_H +#define _SVCMGR_H + +#include <api/service/service.h> + +class ServiceManager { +public: + static int registerService(waServiceFactory *service, GUID owner); + static int deregisterService(waServiceFactory *service, int internal = 0); + + static int getNumServices(FOURCC svc_type); + static waServiceFactory *enumService(FOURCC svc_type, int n); + + static waServiceFactory *getServiceByGuid(GUID guid); + + static void sendNotification(int msg, int param1 = 0, int param2 = 0); + + static int lock(waServiceFactory *owner, void *svcptr); + static int unlock(void *svcptr); + static int clientLock(void *svcptr, GUID lockedby); + static int release(void *svcptr); + + static GUID getOwningComponent(void *svcptr); + static GUID getLockingComponent(void *svcptr); + static const char *getServiceTypeName(FOURCC svc_type); + + static void onShutdown(); + + static FOURCC safe_getServiceType(waServiceFactory *was); + static const char *safe_getServiceName(waServiceFactory *was); + + static int getNumServices(); + static waServiceFactory *enumService(int n); + static int getNumServicesByGuid(); + static int getNumOwners(); + static int getNumLocks(); + + static int isValidService(FOURCC svctype, waServiceFactory *service); +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_accessibility.cpp b/Src/Wasabi/api/service/svcs/svc_accessibility.cpp new file mode 100644 index 00000000..37e6287b --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_accessibility.cpp @@ -0,0 +1,10 @@ +#include <precomp.h> +#include "svc_accessibility.h" + +#define CBCLASS svc_accessibilityI +START_DISPATCH; + CB(SVC_ACCESSIBILITY_CREATEACCESSIBLEOBJECT, createAccessibleObject); +END_DISPATCH; +#undef CBCLASS + + diff --git a/Src/Wasabi/api/service/svcs/svc_accessibility.h b/Src/Wasabi/api/service/svcs/svc_accessibility.h new file mode 100644 index 00000000..60ad0c30 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_accessibility.h @@ -0,0 +1,43 @@ +#ifndef _SVC_ACCESSIBILITY_H +#define _SVC_ACCESSIBILITY_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class Accessible; +class ifc_window; + +class NOVTABLE svc_accessibility : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::ACCESSIBILITY; } + + Accessible *createAccessibleObject(ifc_window *w); + + enum { + SVC_ACCESSIBILITY_CREATEACCESSIBLEOBJECT=10, + }; +}; + +inline Accessible *svc_accessibility::createAccessibleObject(ifc_window *w) { + return _call(SVC_ACCESSIBILITY_CREATEACCESSIBLEOBJECT, (Accessible *)NULL, w); +} + +class NOVTABLE svc_accessibilityI: public svc_accessibility { + public: + virtual Accessible *createAccessibleObject(ifc_window *w)=0; + + protected: + RECVS_DISPATCH; +}; + +#include <api/service/servicei.h> +template <class T> +class AccessibilityCreatorSingle : public waServiceFactoryTSingle<svc_accessibility, T> { +public: + svc_accessibility *getHandler() { + return waServiceFactoryTSingle<svc_accessibility, T>::getSingleService(); + } +}; + + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_accroleserver.cpp b/Src/Wasabi/api/service/svcs/svc_accroleserver.cpp new file mode 100644 index 00000000..84bbaabf --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_accroleserver.cpp @@ -0,0 +1,70 @@ +#include <precomp.h> + +#include "svc_accroleserver.h" +#include <api/script/objects/guiobject.h> +#include <api/wnd/api_window.h> + +#define CBCLASS svc_accRoleServerI +START_DISPATCH; + CB(RS_HANDLEROLE, handleRole); + CB(RS_CREATEOBJECT, createObject); + VCB(RS_DESTROYOBJECT, destroyObject); +END_DISPATCH; +#undef CBCLASS + + +#define CBCLASS roleServerObjectI +START_DISPATCH; + CB(RSO_WNDPROC, wndProc); + CB(RSO_GETHWND, gethWnd); + CB(RSO_FLATTENCONTENT, flattenContent); +END_DISPATCH; +#undef CBCLASS + + +roleServerObjectI::roleServerObjectI(HWND par, api_window *w) { + wnd = w; + hwnd = NULL; + parent = par; + triedyet = 0; +} + +roleServerObjectI::~roleServerObjectI() { + if (hwnd != NULL) + DestroyWindow(hwnd); +} + +api_window *roleServerObjectI::getWnd() { + return wnd; +} + +HWND roleServerObjectI::gethWnd() { + if (!triedyet) { + triedyet = 1; + hwnd = createWindow(parent); + if (hwnd !=NULL) + oldproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC); + else + oldproc = NULL; + } + return hwnd; +} + +ScriptObject *roleServerObjectI::getScriptObject() { + if (wnd == NULL) return NULL; + GuiObject *go = wnd->getGuiObject(); + if (go == NULL) return NULL; + return go->guiobject_getScriptObject(); +} + +WNDPROC roleServerObjectI::getOldProc() { + return oldproc; +} + +int roleServerObjectI::wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + return CallWindowProc(oldproc, hWnd, uMsg, wParam, lParam); +} + +int roleServerObjectI::flattenContent(HWND *w) { + return FLATTENFLAG_ASKPARENT; +} diff --git a/Src/Wasabi/api/service/svcs/svc_accroleserver.h b/Src/Wasabi/api/service/svcs/svc_accroleserver.h new file mode 100644 index 00000000..ad40c149 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_accroleserver.h @@ -0,0 +1,132 @@ +#ifndef __SVC_ROLESERVER_H +#define __SVC_ROLESERVER_H + +#include <bfc/dispatch.h> +#include <bfc/string/string.h> +#include <bfc/ptrlist.h> +#include <api/service/services.h> +#include <api/script/scriptobj.h> + +class ifc_window; + +#define FLATTENFLAG_FLATTEN 1 +#define FLATTENFLAG_UNFLATTEN -1 +#define FLATTENFLAG_ASKPARENT 0 + +class NOVTABLE roleServerObject : public Dispatchable { + public: + int wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + HWND gethWnd(); + int flattenContent(HWND *w); + + enum { + RSO_WNDPROC=0, + RSO_GETHWND=10, + RSO_FLATTENCONTENT=20, + }; +}; + +inline int roleServerObject::wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + return _call(RSO_WNDPROC, 0, hWnd, uMsg, wParam, lParam); +} + +inline HWND roleServerObject::gethWnd() { + return _call(RSO_GETHWND, (HWND)NULL); +} + +inline int roleServerObject::flattenContent(HWND *w) { + return _call(RSO_FLATTENCONTENT, 0, w); +} + +class roleServerObjectI : public roleServerObject { + public: + + roleServerObjectI(HWND parent, ifc_window *w); + virtual ~roleServerObjectI(); + + virtual int wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + virtual HWND createWindow(HWND parent)=0; + virtual int flattenContent(HWND *w); + + protected: + + ScriptObject *getScriptObject(); + virtual ifc_window *getWnd(); + virtual HWND gethWnd(); + WNDPROC getOldProc(); + + HWND hwnd, parent; + ifc_window *wnd; + long (__stdcall *oldproc)(struct HWND__ *,unsigned int,unsigned int,long); + int triedyet; + + RECVS_DISPATCH; +}; + +class NOVTABLE svc_accRoleServer : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::ACCESSIBILITYROLESERVER; } + + int handleRole(int role); + roleServerObject *createObject(HWND parent, ifc_window *attached_wnd); + void destroyObject(roleServerObject *obj); + + enum { + RS_HANDLEROLE=10, + RS_CREATEOBJECT=20, + RS_DESTROYOBJECT=30 + }; + +}; + +inline int svc_accRoleServer::handleRole(int role) { + return _call(RS_HANDLEROLE, 0, role); +} + +inline roleServerObject *svc_accRoleServer::createObject(HWND parent, ifc_window *attached_wnd) { + return _call(RS_CREATEOBJECT, (roleServerObject *)NULL, parent, attached_wnd); +} + +inline void svc_accRoleServer::destroyObject(roleServerObject *obj) { + _voidcall(RS_DESTROYOBJECT, obj); +} + + + +class svc_accRoleServerI : public svc_accRoleServer { + + public: + + virtual int handleRole(int role)=0; + virtual roleServerObject *createObject(HWND parent, ifc_window *attached_wnd)=0; + virtual void destroyObject(roleServerObject *obj)=0; + + protected: + RECVS_DISPATCH; +}; + +#include <api/service/servicei.h> +template <class T> +class AccRoleServerCreatorSingle : public waServiceFactoryTSingle<svc_accRoleServer, T> { +public: + svc_accRoleServer *getHandler() { + return getSingleService(); + } +}; + +#include <api/service/svc_enum.h> +#include <bfc/string/string.h> + +class AccRoleServerEnum : public SvcEnumT<svc_accRoleServer> { +public: + AccRoleServerEnum(int role) : roletest(role) { } +protected: + virtual int testService(svc_accRoleServer *svc) { + return (svc->handleRole(roletest)); + } +private: + int roletest; +}; + + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_action.cpp b/Src/Wasabi/api/service/svcs/svc_action.cpp new file mode 100644 index 00000000..bb6954de --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_action.cpp @@ -0,0 +1,38 @@ +#include <precomp.h> + +#include "svc_action.h" + +#define CBCLASS svc_actionI +START_DISPATCH; +CB(HASACTION, hasAction); +CB(ONACTION, onAction); +END_DISPATCH; +#undef CBCLASS + +svc_actionI::~svc_actionI() +{ + actions.deleteAll(); +} + +void svc_actionI::registerAction(const wchar_t *actionid, int pvtid) +{ + ASSERT(actionid != NULL); + actions.addItem(new ActionEntry(actionid, pvtid)); +} + +int svc_actionI::hasAction(const wchar_t *name) +{ + if (name == NULL) return FALSE; + return (actions.findItem(name) != NULL); +} + +int svc_actionI::onAction(const wchar_t *action, const wchar_t *param, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source) +{ + if (action == NULL) return 0; + int pos = -1; + if (actions.findItem(action, &pos)) + { + return onActionId(actions.enumItem(pos)->getId(), action, param, p1, p2, data, datalen, source); + } + return 0; +}
\ No newline at end of file diff --git a/Src/Wasabi/api/service/svcs/svc_action.h b/Src/Wasabi/api/service/svcs/svc_action.h new file mode 100644 index 00000000..45b87004 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_action.h @@ -0,0 +1,154 @@ +#ifndef _SVC_ACTION_H +#define _SVC_ACTION_H + +#include <bfc/dispatch.h> +#include <bfc/string/bfcstring.h> +#include <bfc/ptrlist.h> + +#include <api/service/services.h> + +class ifc_window; + +class NOVTABLE svc_action : public Dispatchable { +protected: + svc_action() { } + +public: + static FOURCC getServiceType() { return WaSvc::ACTION; } + + int hasAction(const wchar_t *name); + int onAction(const wchar_t *action, const wchar_t *param=NULL, intptr_t p1=0, intptr_t p2=0, void *data=NULL, size_t datalen=0, ifc_window *source=NULL); + + enum { + HASACTION=10, + ONACTION=20, + }; + +}; + +inline int svc_action::hasAction(const wchar_t *name) { + return _call(HASACTION, 0, name); +} + +inline int svc_action::onAction(const wchar_t *action, const wchar_t *param, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source) { + return _call(ONACTION, 0, action, param, p1, p2, data, datalen, source); +} + +class ActionEntry { + public: + ActionEntry(const wchar_t *_action, int _id) : action(_action), id(_id) {} + virtual ~ActionEntry() { } + + const wchar_t *getAction() { return action; } + int getId() { return id; } + + private: + StringW action; + int id; +}; + +class SortActions { +public: + static int compareItem(ActionEntry *p1, ActionEntry *p2) { + return WCSICMP(p1->getAction(), p2->getAction()); + } + static int compareAttrib(const wchar_t *attrib, ActionEntry *item) { + return WCSICMP(attrib, item->getAction()); + } +}; + +class NOVTABLE svc_actionI : public svc_action { +public: + virtual ~svc_actionI(); + void registerAction(const wchar_t *actionid, int pvtid); + virtual int onActionId(int pvtid, const wchar_t *action, const wchar_t *param=NULL, int p1=0, int p2=0, void *data=NULL, int datalen=0, ifc_window *source=NULL)=0; + +protected: + virtual int hasAction(const wchar_t *name); + virtual int onAction(const wchar_t *action, const wchar_t *param=NULL, intptr_t p1=0, intptr_t p2=0, void *data=NULL, size_t datalen=0, ifc_window *source=NULL); + + PtrListQuickSorted<ActionEntry, SortActions> actions; + + RECVS_DISPATCH; +}; +#include <api/service/servicei.h> +template <class T> +class ActionCreator : public waServiceFactoryT<svc_action, T> {}; +template <class T> +class ActionCreatorSingle : public waServiceFactoryTSingle<svc_action, T> { +public: + svc_action *getHandler() { + return waServiceFactoryT<svc_action, T>::getSingleService(); + } +}; + +#include <api/service/svc_enum.h> +#include <bfc/string/StringW.h> + +class ActionEnum : public SvcEnumT<svc_action> { +public: + ActionEnum(const wchar_t *_action) : action(_action) { } +protected: + virtual int testService(svc_action *svc) { + return (!action.isempty() && svc->hasAction(action)); + } +private: + StringW action; +}; + +class FireAction { +public: + enum { + ACTION_NOT_HANDLED = 0x80000000 + }; + /** + Fire a named action out into the system with the given parameters. + + This method will only send the action to the first registered handler for that action. + + This prevents the action from being overridden or handled by newer wacs. + + The content and syntax of the generalized params are defined by the handler of the action string. + + Read: Using Wasabi: General Development: Actions + + @see svc_actionI + @param action The action string. + @param param A string parameter to the action. + @param p1 The first integer parameter to the action. + @param p2 The second integer parameter to the action. + @param data An untyped data buffer parameter to the action. + @param datalen The size in bytes of the data buffer parameter. + @param source A window object that can be given as the source object, if the action handler is expecting one. Actions bound to guiobjects use that guiobject's rootwnd pointer as the source. + @param apply_to_all Send the action to everyone. (If false only sends to first registered) + */ + FireAction(const wchar_t *action, const wchar_t *param = NULL, intptr_t p1 = 0, intptr_t p2 = 0, void *data = NULL, size_t datalen = 0, ifc_window *source = NULL, int apply_to_all = TRUE) { + lastretval = ACTION_NOT_HANDLED; + ActionEnum ae(action); + svc_action *act; + while ((act = ae.getNext()) != NULL) { + lastretval = act->onAction(action, param, p1, p2, data, datalen, source); + ae.release(act); + if (!apply_to_all) break; + } + } + /** + More robust retval handling is needed. + + I ought to be grabbing all of the return values into a list an exposing that. + + Later. + + Read: Using Wasabi: General Development: Actions + + @see svc_actionI + @ret The return code of the action sent. + */ + int getLastReturnValue() { + return lastretval; + } +private: + int lastretval; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_burner.cpp b/Src/Wasabi/api/service/svcs/svc_burner.cpp new file mode 100644 index 00000000..896a984b --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_burner.cpp @@ -0,0 +1,70 @@ +#include <precomp.h> +#include "svc_burner.h" +#include <api/api.h> + +#define CBCLASS svc_mediaRecorderI +START_DISPATCH; + CB(ISSESSIONSUPPORTED,isSessionSupported) + CB(ISMEDIASUPPORTED,isMediaSupported) + CB(GETNUMDEVICES,getNumDevices) + CB(ENUMDEVICE,enumDevice) + VCB(REFRESHDEVICES,refreshDevices) +END_DISPATCH; +#undef CBCLASS + +#define CBCLASS MediaRecorder::DeviceI +START_DISPATCH; + CB(GETDEPENDENCYPTR,getDependencyPtr) + CB(GETDEVICENAME,getDeviceName) + CB(GETDEVICETYPE,getDeviceType) + CB(GETDEVICEDESCRIPTION,getDeviceDescription) + CB(ENUMDEVICESPEEDS,enumDeviceSpeeds) + CB(GETMEDIASIZE,getMediaSize) + CB(GETMEDIAFREE,getMediaFree) + VCB(CLEARSESSIONS,clearSessions) + CB(ADDSESSION,addSession) + CB(GETSESSION,getSession) + CB(SETRECORDSPEED,setRecordSpeed) + CB(SETTEST,setTest) + CB(SETCLOSEDISC,setCloseDisc) + CB(CANBURNNOW,canBurnNow) + CB(CANCANCEL,canCancel) + CB(BEGIN,begin) + CB(END,end) + CB(CANCEL,cancel) + CB(GETSTATUS,getStatus) + CB(GETPROGRESS,getProgress) + CB(GETSTATUSTEXT,getStatusText) + CB(GETLASTERROR,getLastError) +END_DISPATCH; +#undef CBCLASS + +#define CBCLASS MediaRecorder::SessionI +START_DISPATCH; + CB(GETSESSIONTYPE,getSessionType) + CB(CLOSESESSION,closeSession) + CB(GETNUMENTRIES,getNumEntries) + CB(ENUMENTRY,enumEntry) + CB(GETTOTALBYTES,getTotalBytes) + CB(GETTOTALTIME,getTotalTime) +END_DISPATCH; +#undef CBCLASS + +const char *MediaRecorder::RedbookSession::enumEntry(int n) { + if( n>=getNumEntries()) return NULL; + return m_tracks[n]->getValue(); +} + +int MediaRecorder::RedbookSession::getTotalBytes() { + double length=(double)getTotalTime(); + return (int)(length*(44100*4)/1000); //always 44khz 16bps stereo +} + +int MediaRecorder::RedbookSession::getTotalTime() { + int total=0; + for(int i=0;i<getNumEntries();i++) { + int length=0; + if((length=api->metadb_getLength(m_tracks[i]->getValue()))!=-1) total+=length; + } + return total; +} diff --git a/Src/Wasabi/api/service/svcs/svc_burner.h b/Src/Wasabi/api/service/svcs/svc_burner.h new file mode 100644 index 00000000..88f690af --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_burner.h @@ -0,0 +1,243 @@ +#ifndef _SVC_BURNER_H +#define _SVC_BURNER_H + +#include <bfc/dispatch.h> +#include <bfc/depend.h> +#include <bfc/string/string.h> +#include <api/service/services.h> + +namespace MediaRecorder { + +class Session : public Dispatchable { +protected: + Session() {} // protect constructor + +public: + int getSessionType() { return _call(GETSESSIONTYPE,0); } + enum { + Session_REDBOOK, Session_DATA, Session_ISO + }; + int closeSession() { return _call(CLOSESESSION,0); } + int getNumEntries() { return _call(GETNUMENTRIES,0); } + const char *enumEntry(int n) { return _call(ENUMENTRY,(const char *)NULL,n); } + int getTotalBytes() { return _call(GETTOTALBYTES,0); } + int getTotalTime() { return _call(GETTOTALTIME,0); } + + enum { + GETSESSIONTYPE=10, + CLOSESESSION=20, + GETNUMENTRIES=30, + ENUMENTRY=40, + GETTOTALBYTES=50, + GETTOTALTIME=60, + }; +}; + +// this represents one session on the cd +// normal audio cds have 1 redbook session, mixed mode has 2 (or more), with +// 1 audio followed by 1 or more data +class SessionI : public Session { +public: + virtual int getSessionType()=0; + + virtual int closeSession()=0; + virtual int getNumEntries()=0; + virtual const char *enumEntry(int n)=0; + virtual int getTotalBytes()=0; //total space used in bytes + virtual int getTotalTime()=0; //total time used in ms + +protected: + RECVS_DISPATCH; +}; + +class RedbookSession : public SessionI { +public: + virtual ~RedbookSession() { m_tracks.deleteAll(); } + + int getSessionType() { return Session_REDBOOK; } + + int closeSession() { return 1; } + + void addEntry(const char *file) { m_tracks.addItem(new String(file)); } + int getNumEntries() { return m_tracks.getNumItems(); } + void removeEntry(int n) { m_tracks.deleteItem(n); } + void clearEntries() { m_tracks.deleteAll(); } + + const char *enumEntry(int n); + int getTotalBytes(); + int getTotalTime(); + +protected: + PtrList<String> m_tracks; +}; + +// this is the physical device +class Device : public Dispatchable { +protected: + Device() {} // protect constructor + +public: + static const GUID *depend_getClassGuid() { + // {23F48039-455D-4348-86D5-0A82754678FC} + static const GUID ret = + { 0x23f48039, 0x455d, 0x4348, { 0x86, 0xd5, 0xa, 0x82, 0x75, 0x46, 0x78, 0xfc } }; + return &ret; + } + + api_dependent *getDependencyPtr() { return _call(GETDEPENDENCYPTR,(api_dependent *)NULL); } + + const char *getDeviceName() { return _call(GETDEVICENAME,(const char *)NULL); } + const char *getDeviceType() { return _call(GETDEVICETYPE,(const char *)NULL); } + const char *getDeviceDescription() { return _call(GETDEVICEDESCRIPTION,(const char *)NULL); } + + int enumDeviceSpeeds(int n) { return _call(ENUMDEVICESPEEDS,0,n); } + + int getMediaSize() { return _call(GETMEDIASIZE,0); } + int getMediaFree() { return _call(GETMEDIAFREE,0); } + + void clearSessions() { _voidcall(CLEARSESSIONS); } + int addSession(Session *session) { return _call(ADDSESSION,0,session); } + Session *getSession(int num) { return _call(GETSESSION,(Session *)NULL,num); } + + int setRecordSpeed(int kbps) { return _call(SETRECORDSPEED,0,kbps); } + int setTest(int testmode) { return _call(SETTEST,0,testmode); } + int setCloseDisc(int closedisc) { return _call(SETCLOSEDISC,0,closedisc); } + + int canBurnNow() { return _call(CANBURNNOW,0); } + int canCancel() { return _call(CANCANCEL,0); } + + int begin() { return _call(BEGIN,0); } + int end() { return _call(END,0); } + int cancel() { return _call(CANCEL,0); } + + int getStatus() { return _call(GETSTATUS,0); } + enum { + Status_IDLE, Status_PREPARING, Status_BURNING, Status_DONE, + }; + + int getProgress() { return _call(GETPROGRESS,0); } + const char *getStatusText() { return _call(GETSTATUSTEXT,(const char *)NULL); } + + const char *getLastError() { return _call(GETLASTERROR,(const char *)NULL); } + + enum { + Event_PREPAREBEGIN=100, + Event_MEDIATRANSCODED=200, // params is item # + Event_PREPAREEND=300, + Event_BURNBEGIN=400, + Event_ENTRYCOMPLETE=500, // param is the position in bytes + Event_SESSIONCOMPLETE=600, + Event_BURNEND=700, + Event_ERROR=800, + Event_MEDIACHANGE=900, // user put in a different disc + }; + + enum { + GETDEPENDENCYPTR=10, + GETDEVICENAME=20, + GETDEVICETYPE=30, + GETDEVICEDESCRIPTION=40, + ENUMDEVICESPEEDS=50, + GETMEDIASIZE=60, + GETMEDIAFREE=70, + CLEARSESSIONS=80, + ADDSESSION=90, + GETSESSION=100, + SETRECORDSPEED=110, + SETTEST=120, + SETCLOSEDISC=130, + CANBURNNOW=140, + CANCANCEL=150, + BEGIN=160, + END=170, + CANCEL=180, + GETSTATUS=190, + GETPROGRESS=200, + GETSTATUSTEXT=210, + GETLASTERROR=220, + }; +}; + +class DeviceI : public Device { +public: + virtual api_dependent *getDependencyPtr()=0; // for events + + virtual const char *getDeviceName()=0; // internal device name + virtual const char *getDeviceType()=0; // "CD-R", "CD-RW", "DVD-R" etc + virtual const char *getDeviceDescription()=0; // user readable string + + virtual int enumDeviceSpeeds(int n)=0; // in kb/s + + virtual int getMediaSize()=0; // total space in bytes + virtual int getMediaFree()=0; // free space in bytes + + virtual void clearSessions()=0; + virtual int addSession(Session *session)=0; + virtual Session *getSession(int num)=0; + + virtual int setRecordSpeed(int kbps)=0; //kbps==0 means max speed + virtual int setTest(int testmode)=0; // if true, don't really burn + virtual int setCloseDisc(int closedisc)=0; // if true, close entire disc at end + + virtual int canBurnNow()=0; // return 1 if everything's ready + virtual int canCancel()=0; // return 1 if we can cancel (during burning) + + virtual int begin()=0; + virtual int end()=0; + virtual int cancel()=0; + + virtual int getStatus()=0; + virtual int getProgress()=0; // # of bytes written + virtual const char *getStatusText()=0; // like "xx% complete" or something + + virtual const char *getLastError()=0; + +protected: + RECVS_DISPATCH; +}; + +}; // end namespace MediaRecorder + +//don't override this one +class NOVTABLE svc_mediaRecorder : public Dispatchable { +protected: + svc_mediaRecorder() {} // protect constructor + +public: + static FOURCC getServiceType() { return WaSvc::MEDIARECORDER; } + + int isSessionSupported(MediaRecorder::Session *session) { return _call(ISSESSIONSUPPORTED,0,session); } + int isMediaSupported(const char *medianame) { return _call(ISMEDIASUPPORTED,0,medianame); } + + int getNumDevices() { return _call(GETNUMDEVICES,0); } + MediaRecorder::Device *enumDevice(int n) { return _call(ENUMDEVICE,(MediaRecorder::Device*)NULL,n); } + + void refreshDevices() { _voidcall(REFRESHDEVICES); } + + enum { + ISSESSIONSUPPORTED=10, + ISMEDIASUPPORTED=20, + GETNUMDEVICES=30, + ENUMDEVICE=40, + REFRESHDEVICES=50, + }; +}; + +// this should be implemented by a given burning lib +class NOVTABLE svc_mediaRecorderI : public svc_mediaRecorder { +public: + static FOURCC getServiceType() { return WaSvc::MEDIARECORDER; } + + virtual int isSessionSupported(MediaRecorder::Session *session)=0; + virtual int isMediaSupported(const char *medianame)=0;// "CD-R", "DVD-R", etc. + + virtual int getNumDevices()=0; + virtual MediaRecorder::Device *enumDevice(int n)=0; + + virtual void refreshDevices()=0; + +protected: + RECVS_DISPATCH; +}; + +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/service/svcs/svc_collection.cpp b/Src/Wasabi/api/service/svcs/svc_collection.cpp new file mode 100644 index 00000000..9e9e3a67 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_collection.cpp @@ -0,0 +1,194 @@ +#include <precomp.h> + +#include "svc_collection.h" + +// an named xml overridable collection of objects + +#define CBCLASS svc_collectionI +START_DISPATCH; + CB(COLLECTION_TESTTAG, testTag); + VCB(COLLECTION_ADDELEMENT, addElement); + VCB(COLLECTION_REMOVEELEMENT, removeElement); + VCB(COLLECTION_REMOVEALLELEMENTS, removeAllElements); + CB(COLLECTION_GETNUMELEMENTS, getNumElements); + CB(COLLECTION_GETNUMELEMENTSUNIQUE, getNumElementsUnique); + CB(COLLECTION_ENUMELEMENT, enumElement); + CB(COLLECTION_ENUMELEMENTUNIQUE, enumElementUnique); + CB(COLLECTION_GETELEMENT, getElement); +END_DISPATCH; +#undef CBCLASS + +#define CBCLASS CollectionElementI +START_DISPATCH; + CB(COLLECTIONELEMENT_GETID, getId); + CB(COLLECTIONELEMENT_GETPARAMVALUE, getParamValue); + CB(COLLECTIONELEMENT_GETPARAMVALUEINT, getParamValueInt); + CB(COLLECTIONELEMENT_GETINCLUDEPATH, getIncludePath); +END_DISPATCH; +#undef CBCLASS + + +svc_collectionI::svc_collectionI() { + count = 0; + elements.setAutoSort(1); +} + +svc_collectionI::~svc_collectionI() { +} + +void svc_collectionI::addElement(const char *id, const char *includepath, int incrementalremovalid, skin_xmlreaderparams *params) { + CollectionElementI *cei = new CollectionElementI(this, id, params, incrementalremovalid, includepath); + elements.addItem(cei); +} + +void svc_collectionI::removeElement(int removalid) { + for (int i=0;i<elements.getNumItems();i++) { + CollectionElementI *e = elements.enumItem(i); + if (e->getSecCount() == removalid) { + elements.removeItem(e); + delete e; + i--; + } + } +} + +void svc_collectionI::removeAllElements() { + elements.deleteAll(); +} + +int svc_collectionI::getNumElements() { + return elements.getNumItems(); +} + +int svc_collectionI::getNumElementsUnique() { + int i=0; + int n=0; + const char *previous = NULL; + for (i=0;i<elements.getNumItems();i++) { + const char *id = elements.enumItem(i)->getId(); + if (!STRCASEEQLSAFE(id, previous)) + n++; + previous = id; + } + return n; +} + +CollectionElement *svc_collectionI::enumElementUnique(int n, int *ancestor) { + int i=0; + int _n=-1; + CollectionElement *e=NULL; + CollectionElement *previous = NULL; + elements.sort(1); + for (i=0;i<elements.getNumItems();i++) { + CollectionElement *c = elements.enumItem(i); + if (!STRCASEEQLSAFE(c->getId(), previous ? previous->getId() : NULL)) { + if (_n == n) + break; + _n++; + } + previous = c; + } + if (_n == n) + e = previous; + else + e = NULL; + if (ancestor != NULL) { + if (e != NULL) { + int pos=-1; + elements.findItem(static_cast<CollectionElementI*>(e), &pos); + if (pos > 0) { + CollectionElement *f = elements.enumItem(pos-1); + if (!STRCASEEQLSAFE(f ? f->getId() : NULL, e->getId())) *ancestor = -1; + } else { + *ancestor = -1; + e = NULL; + } + } else + *ancestor = -1; + } + return e; +} + +CollectionElement *svc_collectionI::enumElement(int n, int *ancestor) { + CollectionElement *e = elements.enumItem(n); + if (ancestor != NULL) { + CollectionElement *a = elements.enumItem(n-1); + if (!STRCASEEQL(a->getId(), e->getId())) *ancestor = -1; + *ancestor = n-1; + } + return e; +} + +CollectionElement *svc_collectionI::getElement(const char *id, int *ancestor) { + int pos=-1; + CollectionElement *e = elements.findLastItem(id, &pos); + if (ancestor != NULL) { + CollectionElement *a = elements.enumItem(pos-1); + if (!STRCASEEQL(a->getId(), e->getId())) *ancestor = -1; + *ancestor = pos-1; + } + return e; +} + +CollectionElement *svc_collectionI::getAncestor(CollectionElement *e) { + int pos=-1; + CollectionElementI *ei = static_cast<CollectionElementI *>(e); + elements.findItem(ei, &pos); + if (pos >= 0) { + pos--; + if (STRCASEEQL(elements.enumItem(pos)->getId(), e->getId())) return elements.enumItem(pos); + } + return NULL; +} + +CollectionElementI::CollectionElementI(svc_collectionI *col, const char *_id, skin_xmlreaderparams *p, int _seccount, const char *_path) { + id = _id; + for (int i=0;i<p->getNbItems();i++) { + Pair < String, String > *pr = new Pair < String, String >("",""); + pr->a = p->getItemName(i); + pr->b = p->getItemValue(i); + params.addItem(pr); + } + seccount = _seccount; + collection = col; + path = _path; +} + +CollectionElementI::~CollectionElementI() { + params.deleteAll(); +} + +const char *CollectionElementI::getId() { + return id; +} + +const char *CollectionElementI::getParamValue(const char *param, CollectionElement **item){ + CollectionElement *e = getAncestor(); + const char *a = e ? e->getParamValue(param) : NULL; + Pair<String, String> *p = params.findItem(param); + a = p ? p->b.getValue() : a; + if (item && p != NULL) *item = this; + return a; +} + +int CollectionElementI::getParamValueInt(const char *param){ + const char *a = getParamValue(param); + return ATOI(a); +} + +int CollectionElementI::getSecCount() { + return seccount; +} + +CollectionElement *CollectionElementI::getAncestor() { + return collection->getAncestor(this); +} + +const char *CollectionElementI::getIncludePath(const char *param/* =NULL */) { + if (param == NULL) return path; + CollectionElement *i; + if (!getParamValue(param, &i)) return NULL; + if (i != NULL) + return i->getIncludePath(NULL); + return NULL; +}
\ No newline at end of file diff --git a/Src/Wasabi/api/service/svcs/svc_collection.h b/Src/Wasabi/api/service/svcs/svc_collection.h new file mode 100644 index 00000000..9769d5a3 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_collection.h @@ -0,0 +1,226 @@ +#ifndef _SVC_COLLECTION_H +#define _SVC_COLLECTION_H + +#include <bfc/dispatch.h> +#include <bfc/ptrlist.h> +#include <bfc/pair.h> +#include <api/xml/xmlreader.h> +#include <api/service/services.h> + +class CollectionElement; +class svc_collectionI; + +class NOVTABLE svc_collection : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::COLLECTION; } + int testTag(const wchar_t *xmltag); + void addElement(const wchar_t *id, const wchar_t *includepath, int removalid, skin_xmlreaderparams *params); + void removeElement(int recored_value); + void removeAllElements(); + int getNumElements(); + int getNumElementsUnique(); + CollectionElement *enumElement(int n, int *ancestor); + CollectionElement *enumElementUnique(int n, int *ancestor); + CollectionElement *getElement(const wchar_t *id, int *ancestor); + CollectionElement *getAncestor(CollectionElement *e); + + enum + { + COLLECTION_TESTTAG=10, + COLLECTION_ADDELEMENT=20, + COLLECTION_REMOVEELEMENT=30, + COLLECTION_REMOVEALLELEMENTS=35, + COLLECTION_GETNUMELEMENTS=40, + COLLECTION_GETNUMELEMENTSUNIQUE=50, + COLLECTION_ENUMELEMENT=60, + COLLECTION_ENUMELEMENTUNIQUE=70, + COLLECTION_GETELEMENT=80, + }; +}; + +inline int svc_collection::testTag(const wchar_t *xmltag) { + return _call(COLLECTION_TESTTAG, 0, xmltag); +} + +inline void svc_collection::addElement(const wchar_t *id, const wchar_t *includepath, int incrementalremovalid, skin_xmlreaderparams *params) { + _voidcall(COLLECTION_ADDELEMENT, id, includepath, incrementalremovalid, params); +} + +inline void svc_collection::removeElement(int removalid) { + _voidcall(COLLECTION_REMOVEELEMENT, removalid); +} + +inline void svc_collection::removeAllElements() { + _voidcall(COLLECTION_REMOVEALLELEMENTS); +} + +inline int svc_collection::getNumElements() { + return _call(COLLECTION_GETNUMELEMENTS, 0); +} + +inline int svc_collection::getNumElementsUnique() { + return _call(COLLECTION_GETNUMELEMENTSUNIQUE, 0); +} + +inline CollectionElement *svc_collection::enumElement(int n, int *ancestor) { + return _call(COLLECTION_ENUMELEMENT, (CollectionElement *)NULL, n, ancestor); +} + +inline CollectionElement *svc_collection::enumElementUnique(int n, int *ancestor) { + return _call(COLLECTION_ENUMELEMENTUNIQUE, (CollectionElement *)NULL, n, ancestor); +} + +inline CollectionElement *svc_collection::getElement(const wchar_t *id, int *ancestor) { + return _call(COLLECTION_GETELEMENT, (CollectionElement *)NULL, id, ancestor); +} + +class SortPairString { +public: + static int compareItem(Pair<StringW, StringW> *p1, Pair<StringW, StringW> *p2) { + return WCSICMP(p1->a, p2->a); + } + static int compareAttrib(const wchar_t *attrib, Pair<StringW, StringW> *item) { + return WCSICMP(attrib, item->a); + } +}; + +class CollectionElement : public Dispatchable { + public: + const wchar_t *getId(); + const wchar_t *getParamValue(const wchar_t *param, CollectionElement **item=NULL); + int getParamValueInt(const wchar_t *param); + const wchar_t *getIncludePath(const wchar_t *param=NULL); + CollectionElement *getAncestor(); + + enum { + COLLECTIONELEMENT_GETID=10, + COLLECTIONELEMENT_GETPARAMVALUE=20, + COLLECTIONELEMENT_GETPARAMVALUEINT=30, + COLLECTIONELEMENT_GETANCESTOR=40, + COLLECTIONELEMENT_GETINCLUDEPATH=50, + }; +}; + +inline const wchar_t *CollectionElement::getId() { + return _call(COLLECTIONELEMENT_GETID, (const wchar_t *)NULL); +} + +inline const wchar_t *CollectionElement::getParamValue(const wchar_t *param, CollectionElement **item) { + return _call(COLLECTIONELEMENT_GETPARAMVALUE, (const wchar_t *)NULL, param, item); +} + +inline int CollectionElement::getParamValueInt(const wchar_t *param) { + return _call(COLLECTIONELEMENT_GETPARAMVALUEINT, 0, param); +} + +inline CollectionElement *CollectionElement::getAncestor() { + return _call(COLLECTIONELEMENT_GETANCESTOR, (CollectionElement *)NULL); +} + +inline const wchar_t *CollectionElement::getIncludePath(const wchar_t *param) { + return _call(COLLECTIONELEMENT_GETINCLUDEPATH, (const wchar_t *)NULL, param); +} + +class CollectionElementI : public CollectionElement { + public: + CollectionElementI(svc_collectionI *collectionI, const wchar_t *id, skin_xmlreaderparams *params, int seccount, const wchar_t *includepath); + virtual ~CollectionElementI(); + + virtual const wchar_t *getId(); + virtual const wchar_t *getParamValue(const wchar_t *param, CollectionElement **item=NULL); + virtual int getParamValueInt(const wchar_t *param); + virtual CollectionElement *getAncestor(); + const wchar_t *getIncludePath(const wchar_t *param=NULL); // null returns last override's include path + + int getSecCount(); + + protected: + RECVS_DISPATCH; + + PtrListQuickSorted < Pair < StringW, StringW >, SortPairString > params; + StringW id; + int seccount; + svc_collectionI *collection; + StringW path; +}; + +class SortCollectionElementsI { +public: + static int compareItem(CollectionElementI *p1, CollectionElementI *p2) { + int r = WCSICMP(p1->getId(), p2->getId()); + if (r == 0) { + if (p1->getSecCount() < p2->getSecCount()) return -1; + if (p1->getSecCount() > p2->getSecCount()) return 1; + return 0; + } + return r; + } + static int compareAttrib(const wchar_t *attrib, CollectionElementI *item) { + return WCSICMP(attrib, item->getId()); + } +}; + +// derive from this one +class svc_collectionI : public svc_collection { +public: + svc_collectionI(); + virtual ~svc_collectionI(); + virtual int testTag(const wchar_t *xmltag)=0; + virtual void addElement(const wchar_t *id, const wchar_t *includepath, int incrementalremovalid, skin_xmlreaderparams *params); + virtual void removeElement(int removalid); + virtual void removeAllElements(); + virtual int getNumElements(); + virtual int getNumElementsUnique(); + virtual CollectionElement *enumElement(int n, int *ancestor); + virtual CollectionElement *enumElementUnique(int n, int *ancestor); + virtual CollectionElement *getElement(const wchar_t *id, int *ancestor); + virtual CollectionElement *getAncestor(CollectionElement *e); + +protected: + RECVS_DISPATCH; + + PtrListQuickMultiSorted < CollectionElementI, SortCollectionElementsI > elements; + int count; +}; + +#include <api/service/servicei.h> +template <class T> +class CollectionCreator : public waServiceFactoryTSingle<svc_collection, T> {}; + +template <wchar_t TAG[]> +class CollectionSvc : public svc_collectionI { + public: + int testTag(const wchar_t *xmltag) { + if (!WCSICMP(xmltag, TAG)) return 1; + return 0; + } + static const char *getServiceName() { return StringPrintf("Collection Service for \"%S\"", TAG); } +}; + +template <class T> +class CollectionSvc2 : public svc_collectionI { + public: + int testTag(const wchar_t *xmltag) { + if (STRCASEEQL(xmltag, T::collection_getXmlTag())) return 1; + return 0; + } + static const char *getServiceName() { return StringPrintf("Collection Service for \"%S\"", T::collection_getXmlTag()); } +}; + + +#include <api/service/svc_enum.h> +#include <bfc/string/StringW.h> +class CollectionSvcEnum : public SvcEnumT<svc_collection> +{ +public: + CollectionSvcEnum(const wchar_t *xmltag) : tag(xmltag) {} +protected: + virtual int testService(svc_collection *svc) { + return (svc->testTag(tag)); + } +private: + StringW tag; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_console.cpp b/Src/Wasabi/api/service/svcs/svc_console.cpp new file mode 100644 index 00000000..c34bb156 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_console.cpp @@ -0,0 +1,10 @@ + +#include <svc_console.h> + +#define CBCLASS svc_consoleI +START_DISPATCH; + CB(ACTIVATED, activated); + CB(OUTPUTSTRING, outputString); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_console.h b/Src/Wasabi/api/service/svcs/svc_console.h new file mode 100644 index 00000000..696b7897 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_console.h @@ -0,0 +1,36 @@ +#ifndef _SVC_CONSOLE_H +#define _SVC_CONSOLE_H + +#include <bfc/dispatch.h> + +class NOVTABLE svc_console : public Dispatchable +{ +public: + int activated(); + int outputString(int severity, const char *string); + + enum { + ACTIVATED=10, + OUTPUTSTRING=20, + }; +}; + +inline int svc_console::activated() { + return _call(ACTIVATED, 0); +} + +inline int svc_console::outputString(int severity, const char *string) { + return _call(OUTPUTSTRING, 0, severity, string); +} + +// derive from this one +class svc_consoleI : public svc_console { +public: + virtual int activated()=0; + virtual int outputString(int severity, const char *string)=0; + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_contextCmd.cpp b/Src/Wasabi/api/service/svcs/svc_contextCmd.cpp new file mode 100644 index 00000000..da220cfa --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_contextCmd.cpp @@ -0,0 +1,16 @@ +#include <precomp.h> + +#include "svc_contextcmd.h" + +#define CBCLASS svc_contextCmdI +START_DISPATCH; + CB(TESTITEM, testItem); + CB(GETSUBMENU, getSubMenu); + CB(GETSUBMENUTEXT, getSubMenuText); + CB(GETCOMMAND, getCommand); + CB(GETENABLED, getEnabled); + CB(GETCHECKED, getChecked); + CB(GETSORTVAL, getSortVal); + VCB(ONCOMMAND, onCommand); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_contextCmd.h b/Src/Wasabi/api/service/svcs/svc_contextCmd.h new file mode 100644 index 00000000..06a0aff5 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_contextCmd.h @@ -0,0 +1,127 @@ +#ifndef _SVC_CONTEXTCMD_H +#define _SVC_CONTEXTCMD_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +namespace ContextCmdSortVal { + enum ContextCmdSortVal { + BEGINNING = 0, + MIDDLE = 32767, + END = 65535, + }; +}; + +class DragItem; + +class NOVTABLE svc_contextCmd : public Dispatchable { +protected: + svc_contextCmd() {} + ~svc_contextCmd() {} +public: + static FOURCC getServiceType() { return WaSvc::CONTEXTCMD; } + + int testItem(DragItem *item, const wchar_t *menu_path); + + int getSubMenu(DragItem *item, const wchar_t *menu_path); + const wchar_t *getSubMenuText(const wchar_t *menu_path); + + const wchar_t *getCommand(DragItem *item, int n); + + int getEnabled(DragItem *item, int n); + int getChecked(DragItem *item, int n); + int getSortVal(DragItem *item, int n); + + void onCommand(DragItem *item, int n); + +protected: + enum { + TESTITEM, + GETSUBMENU, + GETSUBMENUTEXT, + GETCOMMAND, + GETENABLED, + GETCHECKED, + GETSORTVAL, + ONCOMMAND, + }; +}; + +inline int svc_contextCmd::testItem(DragItem *item, const wchar_t *menu_path) { + return _call(TESTITEM, 0, item, menu_path); +} + +inline +int svc_contextCmd::getSubMenu(DragItem *item, const wchar_t *menu_path) { + return _call(GETSUBMENU, 0, item, menu_path); +} + +inline +const wchar_t *svc_contextCmd::getSubMenuText(const wchar_t *menu_path) { + return _call(GETSUBMENUTEXT, (const wchar_t *)NULL, menu_path); +} + +inline const wchar_t *svc_contextCmd::getCommand(DragItem *item, int n) { + return _call(GETCOMMAND, (const wchar_t *)0, item, n); +} + +inline int svc_contextCmd::getEnabled(DragItem *item, int n) { + return _call(GETENABLED, TRUE, item, n); +} + +inline int svc_contextCmd::getChecked(DragItem *item, int n) { + return _call(GETCHECKED, FALSE, item, n); +} + +inline int svc_contextCmd::getSortVal(DragItem *item, int n) { + return _call(GETSORTVAL, ContextCmdSortVal::MIDDLE, item, n); +} + +inline void svc_contextCmd::onCommand(DragItem *item, int n) { + _voidcall(ONCOMMAND, item, n); +} + +class NOVTABLE svc_contextCmdI : public svc_contextCmd { +public: + virtual int testItem(DragItem *item, const wchar_t *menu_path)=0; + + virtual int getSubMenu(DragItem *item, const wchar_t *menu_path) { return 0; } + virtual const wchar_t *getSubMenuText(const wchar_t *menu_path) { return NULL; } + + virtual const wchar_t *getCommand(DragItem *item, int n)=0; + + // override these as needed + virtual int getEnabled(DragItem *item, int n) { return TRUE; } + virtual int getChecked(DragItem *item, int n) { return FALSE; } + virtual int getSortVal(DragItem *item, int n) { return ContextCmdSortVal::MIDDLE; } + + virtual void onCommand(DragItem *item, int n)=0; + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/servicei.h> + +template <class T> +class ContextCmdCreator : public waServiceFactoryT<svc_contextCmd, T> { }; + +#include <api/service/svc_enum.h> +#include <bfc/string/stringW.h> + +class ContextCmdEnum : public SvcEnumT<svc_contextCmd> { +public: + ContextCmdEnum(DragItem *_item, const wchar_t *_menu_path) + : item(_item), menu_path(_menu_path) {} + +protected: + virtual int testService(svc_contextCmd *svc) { + return svc->testItem(item, menu_path); + } + +private: + DragItem *item; + StringW menu_path; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_coreadmin.cpp b/Src/Wasabi/api/service/svcs/svc_coreadmin.cpp new file mode 100644 index 00000000..5b7890e9 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_coreadmin.cpp @@ -0,0 +1,70 @@ +#include <precomp.h> + +#include "svc_coreadmin.h" + +#define CBCLASS svc_coreAdminI +START_DISPATCH; + CB(CREATECORE,createCore) + CB(NAMETOTOKEN,nameToToken) + CB(FREECOREBYTOKEN,freeCoreByToken) + CB(FREECOREBYNAME,freeCoreByName) + CB(VERIFYTOKEN,verifyToken) + + CB(GETSUPPORTEDEXTENSIONS,getSupportedExtensions) + CB(GETEXTSUPPORTEDEXTENSIONS,getExtSupportedExtensions) + VCB(REGISTEREXTENSION,registerExtension) + CB(GETEXTENSIONFAMILY, getExtensionFamily); + VCB(UNREGISTEREXTENSION,unregisterExtension) + + CB(SETNEXTFILE,setNextFile) + CB(SETNEXTFILEOLD,setNextFile) + + CB(GETSTATUS,getStatus) + CB(GETCURRENT,getCurrent) + CB(GETCURPLAYBACKNUMBER,getCurPlaybackNumber) + CB(GETNUMTRACKS, getNumTracks); + CB(GETPOSITION,getPosition) + CB(GETWRITEPOSITION,getWritePosition) + CB(GETLENGTH,getLength) + CB(GETPLUGINDATA,getPluginData) + CB(GETVOLUME,getVolume) + CB(GETPAN,getPan) + CB(GETVISDATA,getVisData) + CB(GETLEFTVUMETER,getLeftVuMeter) + CB(GETRIGHTVUMETER,getRightVuMeter) + CB(GETEQSTATUS,getEqStatus) + CB(GETEQPREAMP,getEqPreamp) + CB(GETEQBAND,getEqBand) + CB(GETEQAUTO,getEqAuto) + CB(GETMUTE,getMute) + + CB(SETPOSITION,setPosition) + VCB(SETVOLUME,setVolume) + VCB(SETPAN,setPan) + VCB(SETEQSTATUS,setEqStatus) + VCB(SETEQPREAMP,setEqPreamp) + VCB(SETEQBAND,setEqBand) + VCB(SETEQAUTO,setEqAuto) + VCB(SETMUTE,setMute) + CB(GETTITLE,getTitle); + + VCB(ADDCALLBACK,addCallback) + VCB(DELCALLBACK,delCallback) + + CB(REGISTERSEQUENCER,registerSequencer) + CB(DEREGISTERSEQUENCER,deregisterSequencer) + CB(GETSEQUENCER,getSequencer) + + VCB(USERBUTTON,userButton) + + VCB(SETCUSTOMMSG, setCustomMsg) + + VCB(SETPRIORITY, setPriority) + CB(GETPRIORITY, getPriority) + + VCB(REBUILDCONVERTERSCHAIN, rebuildConvertersChain) + CB(SENDCONVERTERSMSG, sendConvertersMsg) + +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_coreadmin.h b/Src/Wasabi/api/service/svcs/svc_coreadmin.h new file mode 100644 index 00000000..276b48c2 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_coreadmin.h @@ -0,0 +1,230 @@ +#ifndef _SVC_COREADMIN_H +#define _SVC_COREADMIN_H + +#include <bfc/dispatch.h> +#include <api/core/corehandle.h> +#include <api/core/sequence.h> +#include <api/service/services.h> + +// There is only ONE INSTANCE of the coreadmin running in the application +class NOVTABLE svc_coreAdmin : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::COREADMIN; } + + // create a new playback core + CoreToken createCore(const char *name=NULL) { return _call(CREATECORE,0,name); } + + // (CoreToken)0 is the maincore + // "main" is the maincore + CoreToken nameToToken(const char *name) { return _call(NAMETOTOKEN,0,name); } + + int freeCoreByToken(CoreToken core) { return _call(FREECOREBYTOKEN,0,core); } + int freeCoreByName(const char *name) { return _call(FREECOREBYNAME,0,name); } + + // returns 1 if present, 0 if non existent + int verifyToken(CoreToken token) { return _call(VERIFYTOKEN,0,token); } + + //just the *.mp3 or whatever + const char *getSupportedExtensions() { return _call(GETSUPPORTEDEXTENSIONS,(const char *)0); } + // including names + const char *getExtSupportedExtensions() { return _call(GETEXTSUPPORTEDEXTENSIONS,(const char *)0); } + void registerExtension(const char *extensions, const char *extension_name, const char *family=NULL) { _voidcall(REGISTEREXTENSION,extensions,extension_name,family); } + const char *getExtensionFamily(const char *extension) { + return _call(GETEXTENSIONFAMILY, (const char *)0, extension); + } + void unregisterExtension(const char *extensions) { _voidcall(UNREGISTEREXTENSION,extensions); } + + int setNextFile(CoreToken core, const char *playstring, const char *destination=NULL) { return _call(SETNEXTFILE,0,core,playstring,destination); } + // returns -1 if paused, 0 if stopped and 1 if playing + int getStatus(CoreToken core) { return _call(GETSTATUS,0,core); } + const char *getCurrent(CoreToken core) { return _call(GETCURRENT,(const char *)0,core); } + int getCurPlaybackNumber(CoreToken core) { return _call(GETCURPLAYBACKNUMBER,-1,core); } + int getNumTracks(CoreToken core) { return _call(GETNUMTRACKS, -1, core); } + int getPosition(CoreToken core) { return _call(GETPOSITION,0,core); } + int getWritePosition(CoreToken core) { return _call(GETWRITEPOSITION,0,core); } + int setPosition(CoreToken core, int ms) { return _call(SETPOSITION,0,core,ms); } + int getLength(CoreToken core) { return _call(GETLENGTH,-1,core); } + // this method queries the core plugins directly, bypassing the db + // returns size of data + int getPluginData(const char *playstring, const char *name, + char *data, int data_len, int data_type=0) { return _call(GETPLUGINDATA,0,playstring,name,data,data_len,data_type); } + unsigned int getVolume(CoreToken core) { return _call(GETVOLUME,0,core); } + // 0..255 + void setVolume(CoreToken core, unsigned int vol) { _voidcall(SETVOLUME,core,vol); } + // -127..127 + int getPan(CoreToken core) { return _call(GETPAN,0,core); } + // -127..127 + void setPan(CoreToken core, int bal) { _voidcall(SETPAN,core,bal); } + + void setMute(CoreToken core, int mute) { _voidcall(SETMUTE,core,mute); } + int getMute(CoreToken core) { return _call(GETMUTE,0,core); } + + // register here for general callbacks in core status. + void addCallback(CoreToken core, CoreCallback *cb) { _voidcall(ADDCALLBACK,core,cb); } + void delCallback(CoreToken core, CoreCallback *cb) { _voidcall(DELCALLBACK,core,cb); } + // get visualization data, returns 0 if you should blank out + int getVisData(CoreToken core, void *dataptr, int sizedataptr) { return _call(GETVISDATA,0,core,dataptr,sizedataptr); } + int getLeftVuMeter(CoreToken core) { return _call(GETLEFTVUMETER,0,core); } + int getRightVuMeter(CoreToken core) { return _call(GETRIGHTVUMETER,0,core); } + + int registerSequencer(CoreToken core, ItemSequencer *seq) { return _call(REGISTERSEQUENCER,0,core,seq); } + int deregisterSequencer(CoreToken core, ItemSequencer *seq) { return _call(DEREGISTERSEQUENCER,0,core,seq); } + ItemSequencer *getSequencer(CoreToken core) { return _call(GETSEQUENCER, (ItemSequencer*)NULL,core); } + // see buttons.h + void userButton(CoreToken core, int button) { _voidcall(USERBUTTON,core,button); } + + // returns 1 if on, 0 if off + int getEqStatus(CoreToken core) { return _call(GETEQSTATUS,0,core); } + void setEqStatus(CoreToken core, int enable) { _voidcall(SETEQSTATUS,core,enable); } + // -127 to 127 (-20db to +20db) + int getEqPreamp(CoreToken core) { return _call(GETEQPREAMP,0,core); } + void setEqPreamp(CoreToken core, int pre) { _voidcall(SETEQPREAMP,core,pre); } + // band=0-9 + int getEqBand(CoreToken core, int band) { return _call(GETEQBAND,0,core,band); } + void setEqBand(CoreToken core, int band, int val) { _voidcall(SETEQBAND,core,band,val); } + // returns 1 if on, 0 if off + int getEqAuto(CoreToken core) { return _call(GETEQAUTO,0,core); } + void setEqAuto(CoreToken core, int enable) { _voidcall(SETEQAUTO,core,enable); } + + // for status msgs + void setCustomMsg(CoreToken core, const char *text) { _voidcall(SETCUSTOMMSG,core,text); } + + void setPriority(CoreToken core, int priority) { _voidcall(SETPRIORITY,core,priority); } + int getPriority(CoreToken core) { return _call(GETPRIORITY,0,core); } + + void rebuildConvertersChain(CoreToken core) { _voidcall(REBUILDCONVERTERSCHAIN,core); } + + int sendConvertersMsg(CoreToken core, const char *msg, const char *value) { return _call(SENDCONVERTERSMSG,0,core,msg,value); } + const char *getTitle(CoreToken core) { return _call(GETTITLE,(const char *)NULL, core); } + + enum { + CREATECORE=10, + NAMETOTOKEN=20, + FREECOREBYTOKEN=30, + FREECOREBYNAME=40, + VERIFYTOKEN=50, + + GETSUPPORTEDEXTENSIONS=100, + GETEXTSUPPORTEDEXTENSIONS=110, + REGISTEREXTENSION=121, //120 retired + GETEXTENSIONFAMILY=122, + UNREGISTEREXTENSION=130, + + SETNEXTFILEOLD=200, + SETNEXTFILE=210, + + GETSTATUS=300, + GETCURRENT=310, + GETCURPLAYBACKNUMBER=315, + GETNUMTRACKS=317, + GETPOSITION=320, + GETWRITEPOSITION=330, + GETLENGTH=340, + GETPLUGINDATA=350, + GETVOLUME=360, + GETPAN=370, + GETVISDATA=380, + GETLEFTVUMETER=390, + GETRIGHTVUMETER=400, + GETEQSTATUS=410, + GETEQPREAMP=420, + GETEQBAND=430, + GETEQAUTO=440, + GETMUTE=450, + + SETPOSITION=500, + SETVOLUME=510, + SETPAN=520, + SETEQSTATUS=530, + SETEQPREAMP=540, + SETEQBAND=550, + SETEQAUTO=560, + SETMUTE=570, + + ADDCALLBACK=700, + DELCALLBACK=710, + + REGISTERSEQUENCER=800, + DEREGISTERSEQUENCER=810, + GETSEQUENCER=812, + + USERBUTTON=820, + + SETCUSTOMMSG=900, + + SETPRIORITY=1000, + GETPRIORITY=1100, + + REBUILDCONVERTERSCHAIN=1200, + + SENDCONVERTERSMSG=1300, + GETTITLE=1400, + }; +}; + +class NOVTABLE svc_coreAdminI : public svc_coreAdmin { +public: + virtual CoreToken createCore(const char *name=NULL)=0; + virtual CoreToken nameToToken(const char *name)=0; + virtual int freeCoreByToken(CoreToken core)=0; + virtual int freeCoreByName(const char *name)=0; + + virtual int verifyToken(CoreToken token)=0; + + virtual const char *getSupportedExtensions()=0; + virtual const char *getExtSupportedExtensions()=0; + virtual void registerExtension(const char *extensions, const char *extension_name, const char *family=NULL)=0; + virtual const char *getExtensionFamily(const char *extension)=0; + virtual void unregisterExtension(const char *extensions)=0; + + virtual int setNextFile(CoreToken core, const char *playstring, const char *destination)=0; + virtual int getStatus(CoreToken core)=0; + virtual const char *getCurrent(CoreToken core)=0; + virtual int getCurPlaybackNumber(CoreToken core)=0; + virtual int getNumTracks(CoreToken core)=0; + virtual int getPosition(CoreToken core)=0; + virtual int getWritePosition(CoreToken core)=0; + virtual int setPosition(CoreToken core, int ms)=0; + virtual int getLength(CoreToken core)=0; + virtual int getPluginData(const char *playstring, const char *name, char *data, int data_len, int data_type=0)=0; + virtual unsigned int getVolume(CoreToken core)=0; + virtual void setVolume(CoreToken core, unsigned int vol)=0; + virtual int getPan(CoreToken core)=0; + virtual void setPan(CoreToken core, int bal)=0; + virtual void addCallback(CoreToken core, CoreCallback *cb)=0; + virtual void delCallback(CoreToken core, CoreCallback *cb)=0; + virtual int getVisData(CoreToken core, void *dataptr, int sizedataptr)=0; + virtual int getLeftVuMeter(CoreToken core)=0; + virtual int getRightVuMeter(CoreToken core)=0; + virtual void setMute(CoreToken core, int mute)=0; + virtual int getMute(CoreToken core)=0; + + virtual int registerSequencer(CoreToken core, ItemSequencer *seq)=0; + virtual int deregisterSequencer(CoreToken core, ItemSequencer *seq)=0; + virtual ItemSequencer *getSequencer(CoreToken core)=0; + virtual void userButton(CoreToken core, int button)=0; + + virtual int getEqStatus(CoreToken core)=0; + virtual void setEqStatus(CoreToken core, int enable)=0; + virtual int getEqPreamp(CoreToken core)=0; + virtual void setEqPreamp(CoreToken core, int pre)=0; + virtual int getEqBand(CoreToken core, int band)=0; + virtual void setEqBand(CoreToken core, int band, int val)=0; + virtual int getEqAuto(CoreToken core)=0; + virtual void setEqAuto(CoreToken core, int enable)=0; + + virtual void setCustomMsg(CoreToken core, const char *text)=0; + + virtual void setPriority(CoreToken core, int priority)=0; + virtual int getPriority(CoreToken core)=0; + + virtual void rebuildConvertersChain(CoreToken core)=0; + + virtual int sendConvertersMsg(CoreToken core, const char *msg, const char *value)=0; + virtual const char *getTitle(CoreToken core)=0; + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_db.cpp b/Src/Wasabi/api/service/svcs/svc_db.cpp new file mode 100644 index 00000000..7a5852b2 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_db.cpp @@ -0,0 +1,78 @@ +#include <precomp.h> + +#include "svc_db.h" + +#define CBCLASS svc_dbI +START_DISPATCH; + CB(OPENTABLE, openTable); + VCB(CLOSETABLE, closeTable); + CB(TESTQUERYFORMAT, testQueryFormat); +END_DISPATCH; +#undef CBCLASS + + +#define CBCLASS dbSvcTableI +START_DISPATCH; + CB(GETSCANNER, getScanner); + CB(NEWSCANNER, newScanner); + VCB(DELETESCANNER, deleteScanner); + VCB(CBNEW, _new); + VCB(CBINSERT, insert); + VCB(CBCANCEL, cancel); + VCB(CBEDIT, edit); + VCB(CBPOST, post); + VCB(CBDELETE, _delete); + CB(EDITING, editing); + VCB(SETFIELDBYNAME, setFieldByName); + VCB(SETFIELDBYID, setFieldById); + VCB(DELETEFIELDBYNAME, deleteFieldByName); + VCB(DELETEFIELDBYID, deleteFieldById); + VCB(ADDCOLUMN, addColumn); + VCB(ADDINDEXBYNAME, addIndexByName); + VCB(ADDINDEXBYID, addIndexById); + VCB(DROPINDEXBYNAME, dropIndexByName); + VCB(DROPINDEXBYID, dropIndexById); + VCB(SYNC, sync); +END_DISPATCH; +#undef CBCLASS + +#define CBCLASS dbSvcScannerI +START_DISPATCH; + VCB(CBFIRST, first); + VCB(CBLAST, last); + VCB(CBNEXT, block_next); + VCB(CBPREVIOUS, block_previous); + CB(CBNEXT2, next); + CB(CBPREVIOUS2, previous); + VCB(CBPUSH, push); + VCB(CBPOP, pop); + CB(CBEOF, eof); + CB(CBBOF, bof); + CB(GETNUMROWS, getNumRows); + VCB(MOVETOROW, moveToRow); + CB(GETCURROW, getCurRow); + CB(LOCATEBYNAME, locateByName); + CB(LOCATEBYID, locateById); + CB(GETNUMCOLS, getNumCols); + CB(ENUMCOL, enumCol); + CB(GETCOLBYNAME, getColByName); + CB(GETCOLBYID, getColByName); + CB(GETFIELDBYNAME, getFieldByName); + CB(GETFIELDBYID, getFieldById); + VCB(SETINDEXBYNAME, setIndexByName); + VCB(SETINDEXBYID, setIndexById); + CB(UNIQUEBYNAME, newUniqueScannerByName); + CB(UNIQUEBYID, newUniqueScannerById); + VCB(DELETEUNIQUE, deleteUniqueScanner); + CB(QUERY, query); + VCB(CANCELQUERY, cancelQuery); + CB(INDEXCHANGED, hasIndexChanged); + VCB(CLEARDIRTYBIT, clearDirtyBit); + VCB(JOINSCANNER, joinScanner); + VCB(UNJOINSCANNER, unjoinScanner); + CB(GETLASTQUERY, getLastQuery); + VCB(SETBLOCKING, setBlocking); +END_DISPATCH; +#undef CBCLASS + + diff --git a/Src/Wasabi/api/service/svcs/svc_db.h b/Src/Wasabi/api/service/svcs/svc_db.h new file mode 100644 index 00000000..6ea5b8d4 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_db.h @@ -0,0 +1,512 @@ +#ifndef _SVC_DB_H +#define _SVC_DB_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +typedef enum { + DBSVC_DATATYPE_UNKNOWN = 0, + DBSVC_DATATYPE_INT = 1, + DBSVC_DATATYPE_STRING = 2, + DBSVC_DATATYPE_BINARY = 3, + DBSVC_DATATYPE_GUID = 4, + DBSVC_DATATYPE_FLOAT = 5, +} dbSvcDatatypeEnum; + +typedef struct { + void *data; + dbSvcDatatypeEnum datatype; + int datalen; +} dbSvcDatachunk; + +typedef struct { + const char *name; + dbSvcDatatypeEnum datatype; + int id; + int indexed; + int uniques_indexed; +} dbSvcColInfo; + +class dbSvcScanner; + +class NOVTABLE dbSvcScanner : public Dispatchable { + + public: + + void first(); + void last(); + void block_next(); // blocking call for baclkward compat + void block_previous(); // blocking call for baclkward compat + int next(); // if non blocking, returns 0 for "HOLD ON!" and 1 for "GOT A ROW!" + int previous(); // if non blocking, returns 0 for "HOLD ON!" and 1 for "GOT A ROW!" + void push(); + void pop(); + int eof(); + int bof(); + + int getNumRows(); + void moveToRow(int row); + int getCurRow(); + + int locateByName(const char *col, int from_row, dbSvcDatachunk *data); + int locateById(int id, int from_row, dbSvcDatachunk *data); + + int getNumCols(); + dbSvcColInfo *enumCol(int n); + dbSvcColInfo *getColById(int n); + dbSvcColInfo *getColByName(const char *col); + + dbSvcDatachunk *getFieldByName(const char *col); + dbSvcDatachunk *getFieldById(int id); + + void setIndexByName(const char *col); + void setIndexById(int id); + + dbSvcScanner *newUniqueScannerByName(const char *col); + dbSvcScanner *newUniqueScannerById(int colid); + void deleteUniqueScanner(dbSvcScanner *); + + int query(const char *query); + const char *getLastQuery(); + void cancelQuery(); + int hasIndexChanged(); + void clearDirtyBit(); + + void joinScanner(dbSvcScanner *scanner, const char *field); + void unjoinScanner(dbSvcScanner *scanner); + + void setBlocking(int b); // blocking is the default behavior + + enum { + CBFIRST = 100, + CBLAST = 110, + CBNEXT = 120, // retired + CBPREVIOUS = 130, // retired + CBNEXT2 = 121, + CBPREVIOUS2 = 131, + CBPUSH = 140, + CBPOP = 150, + CBEOF = 160, + CBBOF = 170, + GETNUMROWS = 180, + MOVETOROW = 190, + GETCURROW = 200, + LOCATEBYNAME = 210, + LOCATEBYID = 220, + GETNUMCOLS = 230, + ENUMCOL = 240, + GETCOLBYID = 250, + GETCOLBYNAME = 260, + GETFIELDBYNAME = 270, + GETFIELDBYID = 280, + SETINDEXBYNAME = 290, + SETINDEXBYID = 300, + QUERY = 310, + CANCELQUERY = 320, + INDEXCHANGED = 330, + CLEARDIRTYBIT = 340, + UNIQUEBYNAME = 350, + UNIQUEBYID = 360, + DELETEUNIQUE = 370, + GETLASTQUERY = 380, + JOINSCANNER = 390, + UNJOINSCANNER = 400, + SETBLOCKING = 410, + }; +}; + + +inline void dbSvcScanner::first() { + _voidcall(CBFIRST); +} + +inline void dbSvcScanner::last() { + _voidcall(CBLAST); +} + +inline void dbSvcScanner::block_next() { + _voidcall(CBNEXT); +} + +inline int dbSvcScanner::next() { + return _call(CBNEXT2, 0); +} + +inline void dbSvcScanner::block_previous() { + _voidcall(CBPREVIOUS); +} + +inline int dbSvcScanner::previous() { + return _call(CBPREVIOUS2, 0); +} + +inline void dbSvcScanner::push() { + _voidcall(CBPUSH); +} + +inline void dbSvcScanner::pop() { + _voidcall(CBPOP); +} + +inline int dbSvcScanner::eof() { + return _call(CBEOF, 0); +} + +inline int dbSvcScanner::bof() { + return _call(CBBOF, 0); +} + +inline int dbSvcScanner::getNumRows() { + return _call(GETNUMROWS, 0); +} + +inline void dbSvcScanner::moveToRow(int row) { + _voidcall(MOVETOROW, row); +} + +inline int dbSvcScanner::getCurRow() { + return _call(GETCURROW, 0); +} + +inline int dbSvcScanner::locateByName(const char *col, int from_row, dbSvcDatachunk *data) { + return _call(LOCATEBYNAME, 0, col, from_row, data); +} + +inline int dbSvcScanner::locateById(int colid, int from_row, dbSvcDatachunk *data) { + return _call(LOCATEBYNAME, 0, colid, from_row, data); +} + +inline int dbSvcScanner::getNumCols() { + return _call(GETNUMCOLS, 0); +} + +inline dbSvcColInfo *dbSvcScanner::enumCol(int n) { + return _call(ENUMCOL, ((dbSvcColInfo *)NULL), n); +} + +inline dbSvcColInfo *dbSvcScanner::getColByName(const char *col) { + return _call(GETCOLBYNAME, ((dbSvcColInfo *)NULL), col); +} + +inline dbSvcColInfo *dbSvcScanner::getColById(int colid) { + return _call(GETCOLBYID, ((dbSvcColInfo *)NULL), colid); +} + +inline dbSvcDatachunk *dbSvcScanner::getFieldByName(const char *col) { + return _call(GETFIELDBYNAME, ((dbSvcDatachunk *)NULL), col); +} + +inline dbSvcDatachunk *dbSvcScanner::getFieldById(int colid) { + return _call(GETFIELDBYNAME, ((dbSvcDatachunk *)NULL), colid); +} + +inline void dbSvcScanner::setIndexByName(const char *col) { + _voidcall(SETINDEXBYNAME, col); +} + +inline void dbSvcScanner::setIndexById(int colid) { + _voidcall(SETINDEXBYID, colid); +} + +inline dbSvcScanner *dbSvcScanner::newUniqueScannerByName(const char *col) { + return _call(UNIQUEBYNAME, (dbSvcScanner *)NULL, col); +} + +inline dbSvcScanner *dbSvcScanner::newUniqueScannerById(int colid) { + return _call(UNIQUEBYID, (dbSvcScanner *)NULL, colid); +} + +inline void dbSvcScanner::deleteUniqueScanner(dbSvcScanner *s) { + _voidcall(DELETEUNIQUE, s); +} + +inline int dbSvcScanner::query(const char *q) { + return _call(QUERY, 0, q); +} + +inline void dbSvcScanner::cancelQuery() { + _voidcall(CANCELQUERY); +} + +inline int dbSvcScanner::hasIndexChanged() { + return _call(INDEXCHANGED, 0); +} + +inline void dbSvcScanner::clearDirtyBit() { + _voidcall(CLEARDIRTYBIT); +} + +inline const char *dbSvcScanner::getLastQuery() { + return _call(GETLASTQUERY, (const char *)NULL); +} + +inline void dbSvcScanner::joinScanner(dbSvcScanner *scanner, const char *field) { + _voidcall(JOINSCANNER, scanner, field); +} + +inline void dbSvcScanner::unjoinScanner(dbSvcScanner *scanner) { + _voidcall(UNJOINSCANNER, scanner); +} + +inline void dbSvcScanner::setBlocking(int b) { + _voidcall(SETBLOCKING, b); +} + +class NOVTABLE dbSvcScannerI : public dbSvcScanner { +public: + virtual void first()=0; + virtual void last()=0; + virtual void block_next()=0; + virtual void block_previous()=0; + virtual int next()=0; + virtual int previous()=0; + virtual void push()=0; + virtual void pop()=0; + virtual int eof()=0; + virtual int bof()=0; + virtual int getNumRows()=0; + virtual void moveToRow(int row)=0; + virtual int getCurRow()=0; + virtual int locateByName(const char *col, int from_row, dbSvcDatachunk *data)=0; + virtual int locateById(int id, int from_row, dbSvcDatachunk *data)=0; + virtual int getNumCols()=0; + virtual dbSvcColInfo *enumCol(int n)=0; + virtual dbSvcColInfo *getColById(int n)=0; + virtual dbSvcColInfo *getColByName(const char *col)=0; + virtual dbSvcDatachunk *getFieldByName(const char *col)=0; + virtual dbSvcDatachunk *getFieldById(int id)=0; + virtual void setIndexByName(const char *col)=0; + virtual void setIndexById(int id)=0; + virtual dbSvcScanner *newUniqueScannerByName(const char *col)=0; + virtual dbSvcScanner *newUniqueScannerById(int colid)=0; + virtual void deleteUniqueScanner(dbSvcScanner *)=0; + virtual int query(const char *query)=0; + virtual void cancelQuery()=0; + virtual int hasIndexChanged()=0; + virtual void clearDirtyBit()=0; + virtual const char *getLastQuery()=0; + virtual void joinScanner(dbSvcScanner *scanner, const char *field)=0; + virtual void unjoinScanner(dbSvcScanner *scanner)=0; + virtual void setBlocking(int block)=0; + +protected: + RECVS_DISPATCH; +}; + +class NOVTABLE dbSvcTable : public Dispatchable { +public: + dbSvcScanner *getScanner(); + dbSvcScanner *newScanner(); + void deleteScanner(dbSvcScanner *scanner); + void _new(); + void insert(); + void cancel(); + void edit(); + void post(); + void _delete(); + int editing(); + void setFieldByName(const char *col, dbSvcDatachunk *data); + void setFieldById(int colid, dbSvcDatachunk *data); + void deleteFieldByName(const char *col); + void deleteFieldById(int colid); + void addColumn(const char *colname, int colid, int datatype, int uniques_indexed); + void addIndexByName(const char *col); + void addIndexById(int colid); + void dropIndexByName(const char *col); + void dropIndexById(int colid); + void sync(); + + enum { + GETSCANNER = 100, + NEWSCANNER = 110, + DELETESCANNER = 111, + CBNEW = 120, + CBINSERT = 130, + CBCANCEL = 140, + CBEDIT = 150, + CBPOST = 160, + CBDELETE = 170, + EDITING = 180, + SETFIELDBYNAME = 190, + SETFIELDBYID = 200, + DELETEFIELDBYNAME = 210, + DELETEFIELDBYID = 220, + ADDCOLUMN = 230, + ADDINDEXBYNAME = 240, + ADDINDEXBYID = 250, + SYNC = 260, + DROPINDEXBYNAME = 270, + DROPINDEXBYID = 280, + }; +}; + +inline dbSvcScanner *dbSvcTable::getScanner() { + return _call(GETSCANNER, static_cast<dbSvcScanner *>(NULL)); +} + +inline dbSvcScanner *dbSvcTable::newScanner() { + return _call(NEWSCANNER, static_cast<dbSvcScanner *>(NULL)); +} + +inline void dbSvcTable::deleteScanner(dbSvcScanner *scanner) { + _voidcall(DELETESCANNER, scanner); +} + +inline void dbSvcTable::_new() { + _voidcall(CBNEW); +} + +inline void dbSvcTable::insert() { + _voidcall(CBINSERT); +} + +inline void dbSvcTable::cancel() { + _voidcall(CBCANCEL); +} + +inline void dbSvcTable::edit() { + _voidcall(CBEDIT); +} + +inline void dbSvcTable::post() { + _voidcall(CBPOST); +} + +inline void dbSvcTable::_delete() { + _voidcall(CBDELETE); +} + +inline int dbSvcTable::editing() { + return _call(EDITING, 0); +} + +inline void dbSvcTable::setFieldByName(const char *col, dbSvcDatachunk *data) { + _voidcall(SETFIELDBYNAME, col, data); +} + +inline void dbSvcTable::setFieldById(int colid, dbSvcDatachunk *data) { + _voidcall(SETFIELDBYID, colid, data); +} + +inline void dbSvcTable::deleteFieldByName(const char *col) { + _voidcall(DELETEFIELDBYNAME, col); +} + +inline void dbSvcTable::deleteFieldById(int colid) { + _voidcall(DELETEFIELDBYID, colid); +} + +inline void dbSvcTable::addColumn(const char *colname, int colid, int datatype, int index_uniques) { + _voidcall(ADDCOLUMN, colname, colid, datatype, index_uniques); +} + +inline void dbSvcTable::addIndexByName(const char *col) { + _voidcall(ADDINDEXBYNAME, col); +} + +inline void dbSvcTable::addIndexById(int colid) { + _voidcall(ADDINDEXBYID, colid); +} + +inline void dbSvcTable::dropIndexByName(const char *col) { + _voidcall(DROPINDEXBYNAME, col); +} + +inline void dbSvcTable::dropIndexById(int colid) { + _voidcall(DROPINDEXBYID, colid); +} + +inline void dbSvcTable::sync() { + _voidcall(SYNC); +} + +class NOVTABLE dbSvcTableI : public dbSvcTable { +public: + virtual dbSvcScanner *getScanner()=0; + virtual dbSvcScanner *newScanner()=0; + virtual void deleteScanner(dbSvcScanner *scanner)=0; + virtual void _new()=0; + virtual void insert()=0; + virtual void cancel()=0; + virtual void edit()=0; + virtual void post()=0; + virtual void _delete()=0; + virtual int editing()=0; + virtual void setFieldByName(const char *col, dbSvcDatachunk *data)=0; + virtual void setFieldById(int colid, dbSvcDatachunk *data)=0; + virtual void deleteFieldByName(const char *col)=0; + virtual void deleteFieldById(int colid)=0; + virtual void addColumn(const char *colname, int colid, int datatype, int index_uniques)=0; + virtual void addIndexByName(const char *col)=0; + virtual void addIndexById(int colid)=0; + virtual void dropIndexByName(const char *col)=0; + virtual void dropIndexById(int colid)=0; + virtual void sync()=0; + +protected: + RECVS_DISPATCH; +}; + +class NOVTABLE svc_db : public Dispatchable { +protected: + svc_db() {} + ~svc_db() {} +public: + static FOURCC getServiceType() { return WaSvc::DB; } + + int testQueryFormat(int queryformat); + + dbSvcTable *openTable(const char *tablefilename, int create_if_not_exist, int cache_in_memory); + void closeTable(dbSvcTable *table); + + enum { + TESTQUERYFORMAT = 10, + OPENTABLE = 20, + CLOSETABLE = 30, + }; +}; + +inline int svc_db::testQueryFormat(int queryformat) { + return _call(TESTQUERYFORMAT, 0, queryformat); +} + +inline dbSvcTable *svc_db::openTable(const char *tablename, int create_if_not_exist, int cache_in_memory) { + return _call(OPENTABLE, static_cast<dbSvcTable *>(NULL), tablename, create_if_not_exist, cache_in_memory); +} + +inline void svc_db::closeTable(dbSvcTable *table) { + _voidcall(CLOSETABLE, table); +} + +// derive from this one +class NOVTABLE svc_dbI : public svc_db{ +public: + virtual int testQueryFormat(int queryformat)=0; + virtual dbSvcTable *openTable(const char *filename, int create_if_not_exist, int cache_in_memory)=0; + virtual void closeTable(dbSvcTable *table)=0; + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/svc_enum.h> + +enum { + DBQFORMAT_MINIQUERY =1, + DBQFORMAT_SQL =2, +}; + +class DatabaseEnum : public SvcEnumT<svc_db> { +public: + DatabaseEnum(int queryformat=DBQFORMAT_MINIQUERY) : + query_format(queryformat) {} +protected: + virtual int testService(svc_db *svc) { + return svc->testQueryFormat(query_format); + } + +private: + int query_format; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_debuggerui.cpp b/Src/Wasabi/api/service/svcs/svc_debuggerui.cpp new file mode 100644 index 00000000..240baad2 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_debuggerui.cpp @@ -0,0 +1,10 @@ +#include <precomp.h> + +#include "svc_debuggerui.h" + +#define CBCLASS svc_debuggerUII +START_DISPATCH; + CB(CREATEUI, createUI); + VCB(DESTROYUI, destroyUI); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_debuggerui.h b/Src/Wasabi/api/service/svcs/svc_debuggerui.h new file mode 100644 index 00000000..5e96a15f --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_debuggerui.h @@ -0,0 +1,44 @@ +#ifndef _SVC_DEBUGGERUI_H +#define _SVC_DEBUGGERUI_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class DebuggerUI; + +// {8B055A0D-9A57-428c-BCFC-88F75AEF2CAD} +static const GUID SERVICE_DEBUGGERUI = +{ 0x8b055a0d, 0x9a57, 0x428c, { 0xbc, 0xfc, 0x88, 0xf7, 0x5a, 0xef, 0x2c, 0xad } }; + +class svc_debuggerUI : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::UNIQUE; } + + DebuggerUI *createUI(); + void destroyUI(DebuggerUI *ui); + +protected: + enum { + CREATEUI=10, + DESTROYUI=20, + }; +}; + +inline DebuggerUI *svc_debuggerUI::createUI() { + return _call(CREATEUI, (DebuggerUI *)NULL); +} + +inline void svc_debuggerUI::destroyUI(DebuggerUI *ui) { + _voidcall(DESTROYUI, ui); +} + +class svc_debuggerUII : public svc_debuggerUI { +public: + virtual DebuggerUI *createUI()=0; + virtual void destroyUI(DebuggerUI *ui)=0; + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_device.h b/Src/Wasabi/api/service/svcs/svc_device.h new file mode 100644 index 00000000..9a75f2b0 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_device.h @@ -0,0 +1,54 @@ +#ifndef _SVC_DEVICE_H +#define _SVC_DEVICE_H + +#include <bfc/dispatch.h> + +// not done at all :) BU + +class NOVTABLE svc_device : public Dispatchable { +public: + const char *getDeviceName(); + const char *getDeviceUID(); // some kind of unique per-device id if possible + + // return total storage space and + int getDeviceSpace(unsigned int *space, unsigned int *spacefree); + // return (estimated) # of seconds stored/available + int getDeviceTime(unsigned int *time, unsigned int *timefree); + + // high-level stuff + // give us a filename we should use if we transfer object to you + // this name will be used as the media conversion pipeline's output + // filename so your transfer filter will kick in... of course something + // like d:\music\blah.mp3 is fine too + int getTargetFilename(const char *playstring, char *fn, int buflen); + + // file/directory enumeration +// int opendir(const char *path); +// int readdir(const char *path); + +#if 0 + // return a handle like C-style open + int openFile(const char *filename, const char *mode); + void closeFile(int handle); + + int writeToFile(int handle, const void *data, int length); + int seek(int handle, int + + int putFile(const char *filename, const void *data, unsigned int length); + int readFile(const char *filename, void *buffer, unsigned int offset, unsigned int length)=0; + int getFileAttrib(const char *filename, const char *name, char *buf, int len); + int setFileAttrib(const char *filename, const char *name, const char *buf, int len); +#endif + + // playlist manipulation + int playlistCreate(const char *playlist_name); + int playlistDelete(const char *playlist_name); + + int playlistGetNumItems(const char *playlist_name); + int playlistEnumItem(const char *playlist_name, char *playstring, int len); + + int playlistAppendItem(const char *playlist_name, const char *playstring); + int playlistRemoveItem(const char *playlist_name, int position); +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_droptarget.cpp b/Src/Wasabi/api/service/svcs/svc_droptarget.cpp new file mode 100644 index 00000000..42ff876e --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_droptarget.cpp @@ -0,0 +1,11 @@ +#include <precomp.h> + +#include "svc_droptarget.h" + +#define CBCLASS svc_dropTargetI +START_DISPATCH; + CB(TESTTARGET, testTarget); + CB(GETDRAGINTERFACEFORTYPE, getDragInterfaceForType); + CB(RELEASEDRAGINTERFACE, releaseDragInterface); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_droptarget.h b/Src/Wasabi/api/service/svcs/svc_droptarget.h new file mode 100644 index 00000000..73b4b6aa --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_droptarget.h @@ -0,0 +1,82 @@ +#ifndef _SVC_DROPTARGET_H +#define _SVC_DROPTARGET_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class DragInterface; // see bfc/drag.h + +class NOVTABLE svc_dropTarget : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::DROPTARGET; } + + int testTarget(FOURCC type); + + DragInterface *getDragInterfaceForType(FOURCC type); + int releaseDragInterface(DragInterface *di); + +protected: + enum { + TESTTARGET=100, + GETDRAGINTERFACEFORTYPE=200, + RELEASEDRAGINTERFACE=210, + }; +}; + +inline +int svc_dropTarget::testTarget(FOURCC type) { + return _call(TESTTARGET, 0, type); +} + +inline +DragInterface *svc_dropTarget::getDragInterfaceForType(FOURCC type) { + return _call(GETDRAGINTERFACEFORTYPE, (DragInterface*)NULL, type); +} + +inline +int svc_dropTarget::releaseDragInterface(DragInterface *di) { + return _call(RELEASEDRAGINTERFACE, 0, di); +} + +class svc_dropTargetI : public svc_dropTarget { +public: + virtual int testTarget(FOURCC type)=0; + + virtual DragInterface *getDragInterfaceForType(FOURCC type)=0; + virtual int releaseDragInterface(DragInterface *di)=0; + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/servicei.h> + +template <class T> +class DropTargetCreator : public waServiceFactoryTSingle<svc_dropTarget, T> { }; + +#include <api/service/svc_enum.h> +#include <api/wnd/drag.h> + +class DropTargetEnum : public SvcEnumT<svc_dropTarget> { +public: + DropTargetEnum(FOURCC type) : dt_type(type) {} + static int throwDrop(FOURCC type, ifc_window *sourceWnd, int x=0, int y=0) { + DropTargetEnum dte(type); + svc_dropTarget *sdt = dte.getFirst(); + if (sdt == NULL) return 0; + DragInterface *di = sdt->getDragInterfaceForType(type); + int r = 0; + if (di != NULL) r = di->dragDrop(sourceWnd, 0, 0); + sdt->releaseDragInterface(di); + return r; + } +protected: + virtual int testService(svc_dropTarget *svc) { + return (svc->testTarget(dt_type)); + } +private: + FOURCC dt_type; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_eval.cpp b/Src/Wasabi/api/service/svcs/svc_eval.cpp new file mode 100644 index 00000000..cb03f2de --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_eval.cpp @@ -0,0 +1,11 @@ +#include <precomp.h> + +#include "svc_eval.h" + +#define CBCLASS svc_evaluatorI +START_DISPATCH + CB(GETEVALTYPE, getEvalType); + CB(SETEVALSTRING, setEvalString); + CB(EVALUATE, evaluate); +END_DISPATCH +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_eval.h b/Src/Wasabi/api/service/svcs/svc_eval.h new file mode 100644 index 00000000..d198c1d1 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_eval.h @@ -0,0 +1,64 @@ +#ifndef _SVC_EVAL_H +#define _SVC_EVAL_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class NOVTABLE svc_evaluator : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::EVALUATOR; } + + const char *getEvalType(); // "php", "perl", "math", "xmlgen", etc. + +// these are for future optimization -- BU + // void assignVar(const char *name, const char *value); + // const char *getVarValue(const char *name); + // int getVarIndex(const char *name); + // const char *getVarValueByIndex(int pos); + + int setEvalString(const char *string, int length, BOOL isBinary); + // free the returned memory with api->sysFree() + const char *evaluate(int *length, BOOL *isBinary); + +protected: + enum { + GETEVALTYPE, ASSIGNVAR, GETVARVALUE, GETVARINDEX, GETVARVALUEBYINDEX, + SETEVALSTRING, EVALUATE + }; +}; + +inline +const char *svc_evaluator::getEvalType() { + return _call(GETEVALTYPE, (const char *)NULL); +} + +inline +int svc_evaluator::setEvalString(const char *string, int length, BOOL isBinary){ + return _call(SETEVALSTRING, FALSE, string, length, isBinary); +} + +inline +const char *svc_evaluator::evaluate(int *length, BOOL *isBinary) { + return _call(EVALUATE, (const char *)NULL, length, isBinary); +} + +// implementor derives from this one +class NOVTABLE svc_evaluatorI : public svc_evaluator { +public: + virtual const char *getEvalType()=0; + +// void assignVar(const char *name, const char *value); +// const char *getVarValue(const char *name); +// int getVarIndex(const char *name); +// const char *getVarValueByIndex(int pos); + + // implementor should make a copy of the string (if needed) + virtual int setEvalString(const char *string, int length, BOOL isBinary)=0; + // implementor should alloc returned mem w/ api->sysMalloc() + virtual const char *evaluate(int *length, BOOL *isBinary)=0; + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_export.h b/Src/Wasabi/api/service/svcs/svc_export.h new file mode 100644 index 00000000..4b6085f1 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_export.h @@ -0,0 +1,32 @@ +#ifndef _SVC_EXPORT_H +#define _SVC_EXPORT_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class svc_fileReader; + +class svc_exporter /*: public Dispatchable*/ { +public: + static FOURCC getServiceType() { return WaSvc::EXPORTER; } + + virtual int isMine(const char *exportid, const char *family)=0; + + virtual svc_fileReader *open()=0; + virtual close(svc_fileReader *reader)=0; +}; + +class ExporterEnum : public SvcEnumT<svc_exporter> { +public: + ExporterEnum(const char *exportid, const char *family=NULL) : + id(exportid), fam(family) { } + + virtual int testService(svc_exporter *svc) { + return svc->isMine(id, fam); + } + +private: + String id, fam; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_fileread.cpp b/Src/Wasabi/api/service/svcs/svc_fileread.cpp new file mode 100644 index 00000000..95fbfd5a --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fileread.cpp @@ -0,0 +1,30 @@ +#include <precomp.h> + +#include <api/filereader/svc_filereadI.h> + +#define CBCLASS svc_fileReaderI +START_DISPATCH; + CB(ISMINE, isMine); + CB(OPEN, open); + CB(READ, read); + CB(WRITE, write); + VCB(CLOSE, close); + VCB(ABORT, abort); + CB(GETLENGTH, getLength); + CB(GETPOS, getPos); + CB(CANSEEK, canSeek); + CB(SEEK, seek); + CB(HASHEADERS,hasHeaders); + CB(GETHEADER,getHeader); + CB(EXISTS,exists); + CB(REMOVE,remove); + CB(REMOVEUNDOABLE,removeUndoable); + CB(MOVE,move); + CB(BYTESAVAILABLE,bytesAvailable); + VCB(SETMETADATACALLBACK,setMetaDataCallback); + CB(CANPREFETCH,canPrefetch); + CB(CANSETEOF, canSetEOF); + CB(SETEOF, setEOF); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_fileread.h b/Src/Wasabi/api/service/svcs/svc_fileread.h new file mode 100644 index 00000000..c26007dc --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fileread.h @@ -0,0 +1,199 @@ +#ifndef _SVC_FILEREAD_H +#define _SVC_FILEREAD_H + +#include <bfc/dispatch.h> +#include <bfc/platform/types.h> +#include <api/service/services.h> +#include <stdint.h> + +namespace SvcFileReader +{ + enum { + READ = 1, + WRITE = 2, + APPEND = 4, + PLUS = 8, + BINARY = 16, + TEXT = 32, + }; +}; + +class api_readercallback; + +class NOVTABLE svc_fileReader : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::FILEREADER; } + + int isMine(const wchar_t *filename, int mode = SvcFileReader::READ); //don't really open. returns -1 if "don't know until I open it" + int open(const wchar_t *filename, int mode = SvcFileReader::READ); + size_t read(int8_t *buffer, size_t length); + size_t write(const int8_t *buffer, size_t length); + void close(); // safe to call even when not open + + int canSetEOF(); + /** + Asks the file reader to change the file length to newlen. Will fail if file + was not opened for writing. + @ret 1 on success, 0 on failure, -1 if operation is unsupported by this reader. + */ + int setEOF(uint64_t newlen); + + void abort(); + + uint64_t getLength(); + uint64_t getPos(); + + int canSeek(); + int seek(uint64_t position); + uint64_t bytesAvailable(uint64_t requested); + + int hasHeaders(); + const char *getHeader(const char *header); + + int exists(const wchar_t *filename); + + int remove(const wchar_t *filename); + + int removeUndoable(const wchar_t *filename); + + int move(const wchar_t *filename, const wchar_t *destfilename); + + int canPrefetch(); + + void setMetaDataCallback(api_readercallback *cb); + + enum + { + ISMINE = 0, + OPEN = 10, + READ = 20, + WRITE = 30, + CLOSE = 40, + ABORT = 50, + GETLENGTH = 60, + GETPOS = 70, + CANSEEK = 80, + SEEK = 90, + HASHEADERS = 100, + GETHEADER = 110, + EXISTS = 120, + REMOVE = 130, + REMOVEUNDOABLE = 135, + BYTESAVAILABLE = 140, + SETMETADATACALLBACK = 150, + MOVE = 160, + CANPREFETCH = 170, + CANSETEOF = 180, + SETEOF = 190, + }; +}; + +inline +int svc_fileReader::isMine(const wchar_t *filename, int mode) +{ + return _call(ISMINE, -1, filename, mode); +} + +inline int svc_fileReader::open(const wchar_t *filename, int mode) +{ + return _call(OPEN, 0, filename, mode); +} + +inline size_t svc_fileReader::read(int8_t *buffer, size_t length) +{ + return _call(READ, 0, buffer, length); +} + +inline size_t svc_fileReader::write(const int8_t *buffer, size_t length) +{ + return _call(WRITE, 0, buffer, length); +} + +inline void svc_fileReader::close() +{ + _voidcall(CLOSE); +} + +inline int svc_fileReader::canSetEOF() +{ + return _call(CANSETEOF, 0); +} + +inline int svc_fileReader::setEOF(uint64_t newlen) +{ + return _call(SETEOF, -1, newlen); +} + +inline void svc_fileReader::abort() +{ + _voidcall(ABORT); +} + +inline uint64_t svc_fileReader::getLength() +{ + return _call(GETLENGTH, (uint64_t)-1); +} + +inline uint64_t svc_fileReader::getPos() +{ + return _call(GETPOS, (uint64_t)0); +} + +inline int svc_fileReader::canSeek() +{ + return _call(CANSEEK, 0); +} + +inline int svc_fileReader::seek(uint64_t position) +{ + return _call(SEEK, 0, position); +} + +inline uint64_t svc_fileReader::bytesAvailable(uint64_t requested) +{ + return _call(BYTESAVAILABLE, requested, requested); +} + +inline int svc_fileReader::hasHeaders() +{ + return _call(HASHEADERS, 0); +} + +inline const char *svc_fileReader::getHeader(const char *header) +{ + return _call(GETHEADER, (const char *)NULL, header); +} + +inline int svc_fileReader::exists(const wchar_t *filename) +{ + return _call(EXISTS, -1, filename); +} + +inline int svc_fileReader::remove(const wchar_t *filename) +{ + return _call(REMOVE, 0, filename); +} + +inline +int svc_fileReader::removeUndoable(const wchar_t *filename) +{ + return _call(REMOVEUNDOABLE, -1, filename); +} + +inline int svc_fileReader::move(const wchar_t *filename, const wchar_t *destfilename) +{ + return _call(MOVE, 0, filename, destfilename); +} + +inline void svc_fileReader::setMetaDataCallback(api_readercallback *cb) +{ + _voidcall(SETMETADATACALLBACK, cb); +} + +inline int svc_fileReader::canPrefetch() +{ + return _call(CANPREFETCH, 1); +} + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_filesel.cpp b/Src/Wasabi/api/service/svcs/svc_filesel.cpp new file mode 100644 index 00000000..fc8826b5 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_filesel.cpp @@ -0,0 +1,15 @@ +#include <precomp.h> + +#include "svc_filesel.h" + +#define CBCLASS svc_fileSelectorI +START_DISPATCH; + CB(TESTPREFIX, testPrefix); + CB(GETPREFIX, getPrefix); + CB(SETEXTLIST, setExtList); + CB(RUNSELECTOR, runSelector); + CB(GETNUMFILESSELECTED, getNumFilesSelected); + CB(ENUMFILENAME, enumFilename); + CB(GETDIRECTORY, getDirectory); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_filesel.h b/Src/Wasabi/api/service/svcs/svc_filesel.h new file mode 100644 index 00000000..870a18cc --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_filesel.h @@ -0,0 +1,89 @@ +#ifndef _SVC_FILESEL_H +#define _SVC_FILESEL_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class ifc_window; + +class NOVTABLE svc_fileSelector : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::FILESELECTOR; } + + int testPrefix(const wchar_t *prefix) { + return _call(TESTPREFIX, 0, prefix); + } + const wchar_t *getPrefix() { + return _call(GETPREFIX, L""); + } + int setTitle(const wchar_t *title) { + return _call(SETTITLE, 0, title); + } + int setExtList(const wchar_t *ext) { + return _call(SETEXTLIST, 0, ext); + } + int runSelector(ifc_window *parWnd, int type, int allow_multiple, const wchar_t *ident=NULL, const wchar_t *default_dir=NULL) { + return _call(RUNSELECTOR, 0, parWnd, type, allow_multiple, ident, default_dir); + } + int getNumFilesSelected() { + return _call(GETNUMFILESSELECTED, 0); + } + const wchar_t *enumFilename(int n) { + return _call(ENUMFILENAME, L"", n); + } + const wchar_t *getDirectory() { + return _call(GETDIRECTORY, L""); + } + +protected: + enum { + TESTPREFIX=0, + GETPREFIX=10, + SETTITLE=20, + SETEXTLIST=30, + RUNSELECTOR=40, + GETNUMFILESSELECTED=50, + ENUMFILENAME=60, + GETDIRECTORY=70, + }; +}; + +namespace FileSel { + enum { + OPEN=1, SAVEAS=2, + }; +}; + + +class NOVTABLE svc_fileSelectorI : public svc_fileSelector { +public: + virtual int testPrefix(const wchar_t *prefix)=0; + virtual const wchar_t *getPrefix()=0; + virtual int setTitle(const wchar_t *title) { return 0; } + virtual int setExtList(const wchar_t *ext) { return 0; } + virtual int runSelector(ifc_window *parWnd, int type, int allow_multiple, const wchar_t *ident=NULL, const wchar_t *default_dir=NULL)=0; + virtual int getNumFilesSelected()=0; + virtual const wchar_t *enumFilename(int n)=0; + virtual const wchar_t *getDirectory()=0; + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/svc_enum.h> +#include <bfc/string/StringW.h> + +class FileSelectorEnum : public SvcEnumT<svc_fileSelector> { +public: + FileSelectorEnum(const wchar_t *_prefix=L"files") : prefix(_prefix) { } + +protected: + virtual int testService(svc_fileSelector *svc) { + return prefix.isempty() || svc->testPrefix(prefix); + } + +private: + StringW prefix; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_font.cpp b/Src/Wasabi/api/service/svcs/svc_font.cpp new file mode 100644 index 00000000..61c77d5d --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_font.cpp @@ -0,0 +1,27 @@ +#include <precomp.h> +#include <api/font/svc_fonti.h> + +#define CBCLASS svc_fontI +START_DISPATCH + VCB(TEXTOUT, textOut); + VCB(TEXTOUT2, textOut2); + VCB(TEXTOUTELLIPSED, textOutEllipsed); + VCB(TEXTOUTWRAPPED, textOutWrapped); + VCB(TEXTOUTWRAPPEDPATHED, textOutWrappedPathed); + VCB(TEXTOUTCENTERED, textOutCentered); + CB(GETTEXTWIDTH, getTextWidth); + CB(GETTEXTHEIGHT, getTextHeight); + CB(GETTEXTHEIGHT2, getTextHeight2); + VCB(GETTEXTEXTENT, getTextExtent); + VCB(SETFONTID, setFontId); + CB(GETFONTID, getFontId); + CB(GETFACENAME_, getFaceName); + CB(ISBITMAP, isBitmap); + CB(GETSCRIPTID, getScriptId); + VCB(SETSCRIPTID, setScriptId); + VCB(SETFONTFACE, setFontFace); + CB(ADDFONTRESOURCE, addFontResource); + CB(ADDFONTRESOURCE2, addFontResource2); + CB(GETFONTSVCNAME, getFontSvcName); +END_DISPATCH +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_font.h b/Src/Wasabi/api/service/svcs/svc_font.h new file mode 100644 index 00000000..9e301489 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_font.h @@ -0,0 +1,178 @@ +#ifndef _SVC_FONT_H +#define _SVC_FONT_H + +#include <bfc/dispatch.h> +#include <bfc/std_file.h> +#include <stdio.h> +#include <api/service/services.h> +//#include <api/service/servicei.h> + +class ifc_canvas; + +#ifdef _WIN32 +enum +{ + STDFONT_LEFT = DT_LEFT, + STDFONT_RIGHT = DT_RIGHT, + STDFONT_CENTER = DT_CENTER, +}; +#else +#warning TODO: find good values for these +enum +{ + STDFONT_RIGHT = 1, + STDFONT_CENTER = 2, + STDFONT_LEFT = 4, +}; +#endif + +class NOVTABLE svc_font : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::FONTRENDER; } + + void textOut(ifc_canvas *c, int x, int y, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); // abstract interface + void textOut(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); + void textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); + void textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); + void textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); + void textOutCentered(ifc_canvas *c, RECT *r, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); + int getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias); + int getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias); + int getTextHeight(ifc_canvas *c, int size, int bold, int underline, int italic, int antialias); + void getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialias); + + void setFontId(const wchar_t *id); + const wchar_t *getFontId(); + const wchar_t *getFaceName(); + int isBitmap(); + int getScriptId(); + void setScriptId(int id); + + void setFontFace(const wchar_t *face); + int addFontResource(HANDLE f, const wchar_t *name); + int addFontResource2(void *mem, int datalen, const wchar_t *name); + + const wchar_t *getFontSvcName(); + +protected: + enum { + TEXTOUT, + TEXTOUT2, + TEXTOUTELLIPSED, + TEXTOUTWRAPPED, + TEXTOUTWRAPPEDPATHED, + TEXTOUTCENTERED, + GETTEXTWIDTH, + GETTEXTHEIGHT, + GETTEXTHEIGHT2, + GETTEXTEXTENT, + SETFONTID, + GETFONTID, + GETFACENAME_, // GETFACENAME is taken in win32 + ISBITMAP, + GETSCRIPTID, + SETSCRIPTID, + SETFONTFACE, + ADDFONTRESOURCE, + ADDFONTRESOURCE2, + GETFONTSVCNAME, + }; +}; + +inline void svc_font::textOut(ifc_canvas *c, int x, int y, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUT, c, x, y, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, antialias); +} + +inline void svc_font::textOut(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUT2, c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias); +} + +inline void svc_font::textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUTELLIPSED, c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias); +} + +inline void svc_font::textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUTWRAPPED, c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias); +} + +inline void svc_font::textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUTWRAPPEDPATHED, c, x, y, w, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias); +} + +inline void svc_font::textOutCentered(ifc_canvas *c, RECT *r, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUTCENTERED, c, r, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias); +} + +inline int svc_font::getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias) +{ + return _call(GETTEXTWIDTH, (int)0, c, text, size, bold, underline, italic, antialias); +} + +inline int svc_font::getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias) { + return _call(GETTEXTHEIGHT, (int)0, c, text, size, bold, underline, italic, antialias); +} + +inline int svc_font::getTextHeight(ifc_canvas *c, int size, int bold, int underline, int italic, int antialias) { + return _call(GETTEXTHEIGHT, (int)0, c, size, bold, underline, italic, antialias); +} + +inline void svc_font::getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialias) { + _voidcall(GETTEXTEXTENT, c, text, w, h, size, bold, underline, italic, antialias); +} + +inline void svc_font::setFontId(const wchar_t *id) { + _voidcall(SETFONTID, id); +} + +inline const wchar_t *svc_font::getFontId() +{ + return _call(GETFONTID, (const wchar_t *)0); +} + +inline const wchar_t *svc_font::getFaceName() +{ + return _call(GETFACENAME_, (const wchar_t *)0); +} + +inline int svc_font::isBitmap() { + return _call(ISBITMAP, (int)0); +} + +inline int svc_font::getScriptId() { + return _call(GETSCRIPTID, (int)0); +} + +inline void svc_font::setScriptId(int id) { + _voidcall(SETSCRIPTID, id); +} + +inline void svc_font::setFontFace(const wchar_t *face) +{ + _voidcall(SETFONTFACE, face); +} + +inline int svc_font::addFontResource(HANDLE f, const wchar_t *name) { + return _call(ADDFONTRESOURCE, (int)0, f, name); +} + +inline int svc_font::addFontResource2(void *mem, int datalen, const wchar_t *name) { + return _call(ADDFONTRESOURCE2, (int)0, mem, datalen, name); +} + +inline const wchar_t *svc_font::getFontSvcName() { + return _call(GETFONTSVCNAME, (const wchar_t *)0); +} + + + + + + +#endif // _SVC_FONT_H diff --git a/Src/Wasabi/api/service/svcs/svc_fontmaker.cpp b/Src/Wasabi/api/service/svcs/svc_fontmaker.cpp new file mode 100644 index 00000000..5003d8fe --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fontmaker.cpp @@ -0,0 +1,9 @@ +#include "svc_fontmaker.h" + +#define CBCLASS svc_fontMakerI +START_DISPATCH + CB(GETFONTMAKERNAME, getFontMakerName); + CB(NEWTRUETYPEFONT, newTrueTypeFont); + CB(DELETETRUETYPEFONT, deleteTrueTypeFont); +END_DISPATCH +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_fontmaker.h b/Src/Wasabi/api/service/svcs/svc_fontmaker.h new file mode 100644 index 00000000..5ea25875 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fontmaker.h @@ -0,0 +1,73 @@ +#ifndef _SVC_FONTMAKER_H +#define _SVC_FONTMAKER_H + +#include <bfc/dispatch.h> +#include <bfc/string/string.h> +#include <api/service/svc_enum.h> +#include <api/service/services.h> +#include <api/service/servicei.h> + +class svc_font; + +// +// This class doesn't do anything fantastic. It's just the way +// you make your OS-Specific font class available to the system. + +class NOVTABLE svc_fontMaker : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::FONTRENDER; } + + // You implement these: + const char *getFontMakerName(); + svc_font *newTrueTypeFont(); + int deleteTrueTypeFont(svc_font *font); + +protected: + enum { + GETFONTMAKERNAME, + NEWTRUETYPEFONT, + DELETETRUETYPEFONT, + }; +}; + + +inline const char *svc_fontMaker::getFontMakerName() { + return _call(GETFONTMAKERNAME, (const char *)0); +} + +inline svc_font *svc_fontMaker::newTrueTypeFont() { + return _call(NEWTRUETYPEFONT, (svc_font *)0); +} + +inline int svc_fontMaker::deleteTrueTypeFont(svc_font *font) { + return _call(DELETETRUETYPEFONT, (int)0, font); +} + +// implementor derives from this one +class NOVTABLE svc_fontMakerI : public svc_fontMaker { +public: + virtual const char *getFontMakerName() = 0; + virtual svc_font *newTrueTypeFont() = 0; + virtual int deleteTrueTypeFont(svc_font *font) = 0; + +protected: + RECVS_DISPATCH; +}; + +class FontMakerEnum : public SvcEnumT<svc_fontMaker> { +public: + FontMakerEnum(const char *_maker_name = NULL) : maker_name(_maker_name) {} +protected: + virtual int testService(svc_fontMaker *svc) { + if (!maker_name.len()) return 1; // blank name returns all services. + return (STRCASEEQL(svc->getFontMakerName(),maker_name)); + } +private: + String maker_name; +}; + +template <class T> +class FontMakerCreator : public waServiceFactoryTSingle<svc_fontMaker, T> {}; + + +#endif // _SVC_FONTMAKER_H diff --git a/Src/Wasabi/api/service/svcs/svc_fontrender.cpp b/Src/Wasabi/api/service/svcs/svc_fontrender.cpp new file mode 100644 index 00000000..67577fd2 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fontrender.cpp @@ -0,0 +1,16 @@ +#include "svc_fontrender.h" + +#define CBCLASS svc_fontRenderI +START_DISPATCH + CB(ISNAMED, isNamed); + VCB(INSTALLTRUETYPEFONT, installTrueTypeFont); + VCB(INSTALLBITMAPFONT, installBitmapFont); + VCB(UNINSTALLALL, uninstallAll); + VCB(UNINSTALLBYSCRIPTID, uninstallByScriptId); + CB(REQUESTSKINFONT, requestSkinFont); + VCB(DISPATCHTEXTOUT, dispatchTextOut); + CB(DISPATCHGETINFO, dispatchGetInfo); + CB(USETRUETYPEOVERRIDE, useTrueTypeOverride); + CB(GETTRUETYPEOVERRIDE, getTrueTypeOverride); +END_DISPATCH +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_fontrender.h b/Src/Wasabi/api/service/svcs/svc_fontrender.h new file mode 100644 index 00000000..a377e76c --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fontrender.h @@ -0,0 +1,126 @@ +#ifndef _svc_fONTRENDER_H +#define _svc_fONTRENDER_H + +#include <bfc/dispatch.h> +#include <bfc/string/string.h> +#include <api/service/svc_enum.h> +#include <api/service/services.h> +#include <api/service/servicei.h> + +class svc_font; +class ifc_canvas; + +class NOVTABLE svc_fontRender : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::FONTRENDER; } + + // test the type. + int isNamed(const char *renderer_name); + + // static methods from Font:: + void installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid); // call this to install a new font + void installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid); + void uninstallAll(); + void uninstallByScriptId(int scriptid); + svc_font *requestSkinFont(const char *id); // call this to get a Font pointer to a font id + void dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt); + int dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h); + int useTrueTypeOverride(); + const char *getTrueTypeOverride(); + + +protected: + enum { + ISNAMED, + INSTALLTRUETYPEFONT, + INSTALLBITMAPFONT, + UNINSTALLALL, + UNINSTALLBYSCRIPTID, + REQUESTSKINFONT, + DISPATCHTEXTOUT, + DISPATCHGETINFO, + USETRUETYPEOVERRIDE, + GETTRUETYPEOVERRIDE, + }; +}; + + +inline int svc_fontRender::isNamed(const char *renderer_name) { + return _call(ISNAMED, (int)0, renderer_name); +} + +inline void svc_fontRender::installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid) { + _voidcall(INSTALLTRUETYPEFONT, filename, path, id, scriptid); +} + +inline void svc_fontRender::installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid) { + _voidcall(INSTALLBITMAPFONT, filename, path, id, charwidth, charheight, hspacing, vspacing, scriptid); +} + +inline void svc_fontRender::uninstallAll() { + _voidcall(UNINSTALLALL); +} + +inline void svc_fontRender::uninstallByScriptId(int scriptid) { + _voidcall(UNINSTALLBYSCRIPTID, scriptid); +} + +inline svc_font *svc_fontRender::requestSkinFont(const char *id) { + return _call(REQUESTSKINFONT, (svc_font *)0, id); +} + +inline void svc_fontRender::dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt) { + _voidcall(DISPATCHTEXTOUT, c, style, x, y, w, h, txt); +} + +inline int svc_fontRender::dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h) { + return _call(DISPATCHGETINFO, (int)0, c, font, infoid, txt, w, h ); +} + +inline int svc_fontRender::useTrueTypeOverride() { + return _call(USETRUETYPEOVERRIDE, (int)0); +} + +inline const char *svc_fontRender::getTrueTypeOverride() { + return _call(GETTRUETYPEOVERRIDE, (const char *)0); +} + +// implementor derives from this one +class NOVTABLE svc_fontRenderI : public svc_fontRender { +public: + + // test the type + virtual int isNamed(const char *renderer_name) = 0; + + // static methods from Font:: + virtual void installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid) = 0; + virtual void installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid) = 0; + virtual void uninstallAll() = 0; + virtual void uninstallByScriptId(int scriptid) = 0; + virtual svc_font *requestSkinFont(const char *id) = 0; // call this to get a Font pointer to a font id + virtual void dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt) = 0; + virtual int dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h) = 0; + virtual int useTrueTypeOverride() = 0; + virtual const char *getTrueTypeOverride() = 0; + + +protected: + RECVS_DISPATCH; +}; + +class FontRenderEnum : public SvcEnumT<svc_fontRender> { +public: + FontRenderEnum(const char *_renderer_name = NULL) : renderer_name(_renderer_name) {} +protected: + virtual int testService(svc_fontRender *svc) { + return (svc->isNamed(renderer_name)); + } +private: + String renderer_name; +}; + +template <class T> +class FontRenderCreator : public waServiceFactoryTSingle<svc_fontRender, T> {}; + + +#endif // _svc_fONTRENDER_H diff --git a/Src/Wasabi/api/service/svcs/svc_imggen.cpp b/Src/Wasabi/api/service/svcs/svc_imggen.cpp new file mode 100644 index 00000000..44f25d24 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_imggen.cpp @@ -0,0 +1,11 @@ +#include <precomp.h> + +#include "svc_imggen.h" + +#define CBCLASS svc_imageGeneratorI +START_DISPATCH; + CB(TESTDESC, testDesc); + CB(GENIMAGE, genImage); + CB(OUTPUTCACHEABLE, outputCacheable); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_imggen.h b/Src/Wasabi/api/service/svcs/svc_imggen.h new file mode 100644 index 00000000..a36377c8 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_imggen.h @@ -0,0 +1,68 @@ +#ifndef _SVC_IMGGEN_H +#define _SVC_IMGGEN_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + + +class NOVTABLE svc_imageGenerator : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::IMAGEGENERATOR; } + int testDesc(const wchar_t *desc); + ARGB32 *genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params = NULL); + int outputCacheable(); + + enum { + TESTDESC = 10, + GENIMAGE = 30, + OUTPUTCACHEABLE = 40, + }; +}; + +inline int svc_imageGenerator::testDesc(const wchar_t *desc) +{ + return _call(TESTDESC, 0, desc); +} + +inline ARGB32 *svc_imageGenerator::genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params) +{ + return _call(GENIMAGE, (ARGB32 *)0, desc, has_alpha, w, h, params); +} + +inline int svc_imageGenerator::outputCacheable() +{ + return _call(OUTPUTCACHEABLE, 0); +} + +// derive from this one +class NOVTABLE svc_imageGeneratorI : public svc_imageGenerator +{ +public: + virtual int testDesc(const wchar_t *desc) = 0; + virtual ARGB32 *genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params = NULL) = 0; + virtual int outputCacheable() { return 0; } + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/svc_enum.h> +#include <bfc/string/StringW.h> + +class ImgGeneratorEnum : public SvcEnumT<svc_imageGenerator> +{ +public: + ImgGeneratorEnum(const wchar_t *_desc) : desc(_desc) { } + +protected: + virtual int testService(svc_imageGenerator *svc) + { + return svc->testDesc(desc); + } + +private: + StringW desc; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_imgload.cpp b/Src/Wasabi/api/service/svcs/svc_imgload.cpp new file mode 100644 index 00000000..d8eb3cfc --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_imgload.cpp @@ -0,0 +1,14 @@ +#include <precomp.h> + +#include "svc_imgload.h" + +#define CBCLASS svc_imageLoaderI +START_DISPATCH; + CB(ISMINE, isMine); + CB(TESTDATA, testData); + CB(GETHEADERSIZE, getHeaderSize); + CB(GETDIMENSIONS, getDimensions); + CB(LOADIMAGE, loadImage); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_imgload.h b/Src/Wasabi/api/service/svcs/svc_imgload.h new file mode 100644 index 00000000..22f3851c --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_imgload.h @@ -0,0 +1,101 @@ +#ifndef _SVC_IMGLOAD_H +#define _SVC_IMGLOAD_H + +#include <api/service/services.h> +#include <bfc/platform/platform.h> +#include <bfc/dispatch.h> + + +class ifc_xmlreaderparams; + +class NOVTABLE svc_imageLoader : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::IMAGELOADER; } + + // assuming there is an extension of this type, is it yours? + int isMine(const wchar_t *filename); + + // returns the mime type for this type of image + const wchar_t *mimeType(); + + // returns how many bytes needed to get image info + int getHeaderSize(); + + // test image data, return TRUE if you can load it + int testData(const void *data, int datalen); + + // just gets the width and height from the data, if possible + int getDimensions(const void *data, int datalen, int *w, int *h); + + // converts the data into pixels + premultiply, use api->sysFree to deallocate + ARGB32 *loadImage(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL);\ + + // converts the data into pixels, use api->sysFree to deallocate + ARGB32 *loadImageData(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL); + + enum { + ISMINE=50, + MIMETYPE=75, + GETHEADERSIZE=100, + TESTDATA=200, + GETDIMENSIONS=300, + LOADIMAGE=400, + LOADIMAGEDATA=500, + }; +}; + +inline int svc_imageLoader::isMine(const wchar_t *filename) { + return _call(ISMINE, 0, filename); +} + +inline const wchar_t *svc_imageLoader::mimeType() { + return _call(MIMETYPE, L""); +} + +inline int svc_imageLoader::getHeaderSize() { + return _call(GETHEADERSIZE, -1); +} + +inline int svc_imageLoader::testData(const void *data, int datalen) { + return _call(TESTDATA, 0, data, datalen); +} + +inline int svc_imageLoader::getDimensions(const void *data, int datalen, int *w, int *h) { + return _call(GETDIMENSIONS, 0, data, datalen, w, h); +} + +inline ARGB32 *svc_imageLoader::loadImage(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params) { + return _call(LOADIMAGE, (ARGB32*)0, data, datalen, w, h, params); +} + +inline ARGB32 *svc_imageLoader::loadImageData(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params) { + return _call(LOADIMAGEDATA, (ARGB32*)0, data, datalen, w, h, params); +} + +// derive from this one +class NOVTABLE svc_imageLoaderI : public svc_imageLoader +{ +public: + virtual int isMine(const wchar_t *filename)=0; + virtual const wchar_t *mimeType(void)=0; + // return the header size needed to get w/h and determine if it can be loaded + virtual int getHeaderSize() { return -1; }//don't know + // test image data, return TRUE if you can load it + virtual int testData(const void *data, int datalen)=0; + // just gets the width and height from the data, if possible + virtual int getDimensions(const void *data, int datalen, int *w, int *h) { return 0; } + // converts the data into pixels + premultiply, use api->sysFree to deallocate + virtual ARGB32 *loadImage(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL)=0; +#if 0 + // converts the data into pixels, use api->sysFree to deallocate + virtual ARGB32 *loadImageData(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL)=0; +#endif + +protected: + RECVS_DISPATCH; +}; + + + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_imgwrite.h b/Src/Wasabi/api/service/svcs/svc_imgwrite.h new file mode 100644 index 00000000..e699bc57 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_imgwrite.h @@ -0,0 +1,101 @@ +#ifndef _SVC_IMGWRITE_H +#define _SVC_IMGWRITE_H + +#include <api/service/services.h> +#include <bfc/platform/platform.h> +#include <bfc/dispatch.h> + +class NOVTABLE svc_imageWriter : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::IMAGEWRITER; } + + // returns a human readable string about the format. eg "JPEG" + const wchar_t * getImageTypeName(); + + // returns a semi-colon delimited list of file extensions for this format. eg "jpg;jpeg" + // MUST BE LOWER CASE + const wchar_t * getExtensions(); + + // valid items include "quality" for jpeg files with value "0" to "100" + // return value is 1 if the config item is supported, 0 if it is not. + int setConfig(const wchar_t * item, const wchar_t * value); + + // valid items include "quality" for jpeg files with value "0" to "100", "lossless" returns "1" if it is "0" otherwise + // return value is 1 if the config item is supported, 0 if it is not. + int getConfig(const wchar_t * item, wchar_t * value, int valuelen); + + // returns 1 if the bit depth is supported (eg 32 for ARGB32, 24 for RGB24) + // ARGB32 MUST be supported + int bitDepthSupported(int depth); + + // returns the image in our format, free the returned buffer with api_memmgr::sysFree() + void * convert(const void *pixels, int bitDepth, int w, int h, int *length); + + enum { + GETIMAGETYPENAME=10, + GETEXTENSIONS=20, + SETCONFIG=30, + GETCONFIG=40, + BITDEPTHSUPPORTED=50, + CONVERT=60, + }; +}; + +inline const wchar_t *svc_imageWriter::getImageTypeName() { + return _call(GETIMAGETYPENAME, L""); +} + +inline const wchar_t *svc_imageWriter::getExtensions() { + return _call(GETEXTENSIONS, L""); +} + +inline int svc_imageWriter::setConfig(const wchar_t * item, const wchar_t * value) { + return _call(SETCONFIG, (int)0, item, value); +} + +inline int svc_imageWriter::getConfig(const wchar_t * item, wchar_t * value, int valuelen) { + return _call(GETCONFIG, (int)0, item, value, valuelen); +} + +inline int svc_imageWriter::bitDepthSupported(int depth) { + return _call(BITDEPTHSUPPORTED, (int)0, depth); +} + +inline void * svc_imageWriter::convert(const void *pixels, int bitDepth, int w, int h, int *length) { + return _call(CONVERT, (void*)0, pixels, bitDepth, w, h, length); +} + +// derive from this one +class NOVTABLE svc_imageWriterI : public svc_imageWriter { +public: + virtual const wchar_t * getExtensions()=0; + virtual const wchar_t * getImageTypeName()=0; + virtual int setConfig(const wchar_t * item, const wchar_t * value){return 0;} + virtual int getConfig(const wchar_t * item, wchar_t * value, int valuelen){return 0;} + virtual int bitDepthSupported(int depth)=0; + virtual void * convert(const void *pixels, int bitDepth, int w, int h, int *length)=0; +protected: + RECVS_DISPATCH; +}; + +/* do we still use svc_enum? +#include <bfc/svc_enum.h> + +class ImgWriterEnum : public SvcEnumT<svc_imageWriter> { +public: + ImgWriterEnum(const char *_ext=NULL) : ext(_ext) { } + +protected: + virtual int testService(svc_imageWriter *svc) { + if (ext.isempty()) return 1; + else { + PathParser pp(svc->getExtensions(), ";"); + for (int i = 0; i < pp.getNumStrings(); i++) + if (STRCASEEQL(ext, pp.enumString(i))) return 1; + return 0; + } + } + String ext; +}; +*/ +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_itemmgr.cpp b/Src/Wasabi/api/service/svcs/svc_itemmgr.cpp new file mode 100644 index 00000000..3cadb94e --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_itemmgr.cpp @@ -0,0 +1,20 @@ +#include <precomp.h> + +#include "svc_itemmgr.h" + +#define CBCLASS svc_itemMgrI +START_DISPATCH; + CB(ISMINE, isMine); + CB(OPTIMIZEPLAYSTRING, optimizePlaystring); + CB(CREATEINITIALNAME, createInitialName); + CB(OPTIMIZEFILEDATA, optimizeFileData); + CB(ONDATABASEADD, onDatabaseAdd); + CB(ONDATABASEDEL, onDatabaseDel); + CB(ONTITLECHANGE, onTitleChange); + CB(ONTITLE2CHANGE, onTitle2Change); + VCB(ONNEXTFILE, onNextFile); + VCB(ONFILECOMPLETE, onFileComplete); + CB(WANTSCANDATA, wantScanData); + CB(GETSORTORDER, getSortOrder); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_itemmgr.h b/Src/Wasabi/api/service/svcs/svc_itemmgr.h new file mode 100644 index 00000000..c2e3e416 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_itemmgr.h @@ -0,0 +1,112 @@ +#ifndef _SVC_ITEMMGR_H +#define _SVC_ITEMMGR_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class NOVTABLE svc_itemMgr : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::ITEMMANAGER; } + + int isMine(const char *playstring) { return _call(ISMINE, 0, playstring); } + + int optimizePlaystring(char *playstring) { + return _call(OPTIMIZEPLAYSTRING, 0, playstring); + } + int createInitialName(const char *playstring, char *buf, int buflen) { + return _call(CREATEINITIALNAME, 0, playstring, buf, buflen); + } + int optimizeFileData(const char *playstring, const char *fieldname, int datatype, char *data, int datalen) { + return _call(OPTIMIZEFILEDATA, -1, playstring, fieldname, datatype, data, datalen); + } + + int onDatabaseAdd(const char *playstring) { + return _call(ONDATABASEADD, 0, playstring); + } + int onDatabaseDel(const char *playstring) { + return _call(ONDATABASEDEL, 0, playstring); + } + + //return 1 if changed + int onTitleChange(const char *playstring, const char *newtitle) { + return _call(ONTITLECHANGE, 0, playstring, newtitle); + } + int onTitle2Change(const char *playstring, const char *newtitle) { + return _call(ONTITLE2CHANGE, 0, playstring, newtitle); + } + + void onNextFile(const char *playstring) { + _voidcall(ONNEXTFILE, playstring); + } + + void onFileComplete(const char *playstring) { + _voidcall(ONFILECOMPLETE, playstring); + } + + int wantScanData(const char *playstring) { + return _call(WANTSCANDATA, 1, playstring); + } + + int getSortOrder() { + return _call(GETSORTORDER, 0); + } + + enum { + ISMINE=100, + OPTIMIZEPLAYSTRING=200, + OPTIMIZEFILEDATA=211, //210 retired + CREATEINITIALNAME=300, + ONDATABASEADD=400, + ONDATABASEDEL=401, + ONTITLECHANGE=600, + ONTITLE2CHANGE=601, + ONNEXTFILE=700, + ONFILECOMPLETE=800, + WANTSCANDATA=900, + GETSORTORDER=1000, + }; +}; + +// derive from this one +class NOVTABLE svc_itemMgrI : public svc_itemMgr { +public: + virtual int isMine(const char *playstring)=0; + virtual int optimizePlaystring(char *playstring) { return 0; } + virtual int createInitialName(const char *playstring, char *buf, int buflen) { return 0; } + virtual int optimizeFileData(const char *playstring, const char *fieldname, int datatype, char *data, int datalen) { return -1; } + virtual int onDatabaseAdd(const char *playstring) { return 0; } + virtual int onDatabaseDel(const char *playstring) { return 0; } + virtual int onTitleChange(const char *playstring, const char *newtitle) { return 0; } + virtual int onTitle2Change(const char *playstring, const char *newtitle) { return 0; } + virtual void onNextFile(const char *playstring) { } + virtual void onFileComplete(const char *playstring) { } + + virtual int wantScanData(const char *playstring) { return 1; } + + virtual int getSortOrder() { return 0; } + +protected: + RECVS_DISPATCH; +}; + +#include <bfc/named.h> +#include <api/service/svc_enum.h> + +class ItemMgrEnum : private Named, public SvcEnumT<svc_itemMgr> { +public: + ItemMgrEnum(const char *ps) : Named(ps) { } + + void setPlaystring(const char *ps) { Named::setName(ps); } + +protected: + virtual int testService(svc_itemMgr *svc) { + return svc->isMine(getName()); + } +}; + +#include <api/service/servicei.h> + +template <class T> +class ItemMgrCreator : public waServiceFactoryTSingle<svc_itemMgr, T> { }; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_loadlib.h b/Src/Wasabi/api/service/svcs/svc_loadlib.h new file mode 100644 index 00000000..25a72a06 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_loadlib.h @@ -0,0 +1,16 @@ +#ifndef _LOADLIB_H +#define _LOADLIB_H + +//UNDER CONSTRUCTION + +class NOVTABLE svc_loadLib +{ +public: + int isMine(const char *filename); + + int load(const char *filename); + void unload(); + void *getProcAddress(const char *name); +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_mediaconverter.cpp b/Src/Wasabi/api/service/svcs/svc_mediaconverter.cpp new file mode 100644 index 00000000..98ab19f0 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_mediaconverter.cpp @@ -0,0 +1,23 @@ +#include <precomp.h> + +#include "svc_mediaconverter.h" + +#define CBCLASS svc_mediaConverterNI +START_DISPATCH; + CB(CANCONVERTFROM,canConvertFrom) + CB(GETCONVERTERTO,getConverterTo) + CB(GETINFOS,getInfos) + CB(SETINFOS,setInfos) + CB(GETINFOSXMLGROUP,getInfosXmlGroup) + CB(PROCESSDATA,processData) + CB(GETPOSITION,getPosition) + CB(GETLATENCY,getLatency) + CB(GETCORECALLBACK,getCoreCallback) + CB(SORTPLACEMENT,sortPlacement) + CB(ISSELECTABLEOUTPUT,isSelectableOutput) + CB(CANSUPPORTCONTENTTYPE,canSupportContentType) + VCB(SETCORETOKEN,setCoreToken) + CB(ONCOREUSERMSG,onCoreUserMsg) +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_mediaconverter.h b/Src/Wasabi/api/service/svcs/svc_mediaconverter.h new file mode 100644 index 00000000..c08c2932 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_mediaconverter.h @@ -0,0 +1,161 @@ +#ifndef _SVC_MEDIACONVERTER_H +#define _SVC_MEDIACONVERTER_H + +#include <bfc/dispatch.h> + +#include <api/core/chunklist.h> +#include <api/core/mediainfo.h> +#include <api/syscb/callbacks/corecbi.h> + +#include <api/service/services.h> + +// do NOT derive from these ones +class NOVTABLE svc_mediaConverter : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::MEDIACONVERTER; } + + // test if the converter can handle that stream, filename or chunktype: + // if your converter can accept streams depending on the data stream you should + // test the file thru the reader interface (like to test if the file header is ok) + // if your converter can accept files thru a test on the filename string, you should + // test the name string (like tone://... or *.wav) + // if your converter can accept depending on the chunktype, you should test the chunktype + // (like MP3, PCM, etc...) + // returns 1 if ok + int canConvertFrom(svc_fileReader *reader, const char *name, const char *chunktype) { return _call(CANCONVERTFROM,0,reader,name,chunktype); } + + // returns the chunk type that the converter will convert to + // (PCM, MP3, etc...) + const char *getConverterTo() { return _call(GETCONVERTERTO,""); } + + // override this one if your converter can decode depending on a "Content-Type:" HTTP header + int canSupportContentType(const char *contenttype) { return _call(CANSUPPORTCONTENTTYPE,0,contenttype); } + + // fills up the infos class + int getInfos(MediaInfo *infos) { return _call(GETINFOS,0,infos); } + + // writes back the infos on the file. + // note: the reader you get in the infos class has the filename opened in read/write mode + // return 1 if update succeeded, 0 if error + int setInfos(MediaInfo *infos) { return _call(SETINFOS,0,infos); } + + // returns the id of the xml group the media info editor will use for displaying/editing infos + const char *getInfosXmlGroup() { return _call(GETINFOSXMLGROUP,(const char *)NULL); } + + // process current file data + // returns 1 if ok, 0 when file/stream has ended + int processData(MediaInfo *infos, ChunkList *chunk_list, bool *killswitch) { return _call(PROCESSDATA,0,infos,chunk_list,killswitch); } + + // returns the current position in ms + // usually the position is automatically calculated with the amount of PCM data converters send back to the core + // so you don't have to override this function. however, if you want to force the position, return a value other than -1 + int getPosition(void) { return _call(GETPOSITION,-1); } + + // returns the latency of the converter in ms + int getLatency(void) { return _call(GETLATENCY,0); } + + // sort function to be able to specify where you want your converter placed in the converter list + // (like if you want to be before or after the crossfader for example, override this function) + // return -1 to be placed before "otherconverter", 1 to be placed after "otherconverter", otherwise 0 + int sortPlacement(const char *otherconverter) { return _call(SORTPLACEMENT,0,otherconverter); } + + // return 1 if you want this converter to be selectable as output in prefs->audio + int isSelectableOutput(void) { return _call(ISSELECTABLEOUTPUT,0); } + + // message received by sendConvertersMsg() in the core + int onCoreUserMsg(const char *msg, const char *value) { return _call(ONCOREUSERMSG,0,msg,value); } + + + // internally used by wasabi + CoreCallback *getCoreCallback(void) { return _call(GETCORECALLBACK,(CoreCallback *)0); } + void setCoreToken(CoreToken t) { _voidcall(SETCORETOKEN,t); } + + enum { + CANCONVERTFROM=10, + GETCONVERTERTO=20, + GETINFOS=30, + PROCESSDATA=40, + GETPOSITION=50, + GETLATENCY=60, + GETCORECALLBACK=70, + SORTPLACEMENT=80, + CANSUPPORTCONTENTTYPE=90, + SETCORETOKEN=100, + SETINFOS=110, + GETINFOSXMLGROUP=120, + ISSELECTABLEOUTPUT=130, + ONCOREUSERMSG=140, + }; +}; + +class NOVTABLE svc_mediaConverterNI : public svc_mediaConverter { +public: + virtual int canConvertFrom(svc_fileReader *reader, const char *name, const char *chunktype)=0; + virtual const char *getConverterTo()=0; + virtual int canSupportContentType(const char *contenttype) { return 0; } + + virtual int getInfos(MediaInfo *infos)=0; + + virtual int setInfos(MediaInfo *infos)=0; + + virtual const char *getInfosXmlGroup()=0; + + virtual int processData(MediaInfo *infos, ChunkList *chunk_list, bool *killswitch)=0; + + virtual int getPosition(void) { return -1; } + + virtual int getLatency(void) { return 0; } + + virtual int sortPlacement(const char *otherconverter) { return 0; } + + virtual int isSelectableOutput(void) { return 0; } + + virtual int onCoreUserMsg(const char *msg, const char *value) { return 0; } + + virtual CoreCallback *getCoreCallback(void)=0; + + virtual void setCoreToken(CoreToken t)=0; +protected: + RECVS_DISPATCH; +}; + +// derive from this one +class NOVTABLE svc_mediaConverterI : public svc_mediaConverterNI, public CoreCallbackI { +public: + svc_mediaConverterI() : m_coretoken(0) { } + + virtual int canConvertFrom(svc_fileReader *reader, const char *name, const char *chunktype)=0; + virtual const char *getConverterTo()=0; + virtual int canSupportContentType(const char *contenttype) { return 0; } + + virtual int getInfos(MediaInfo *infos)=0; + + virtual int setInfos(MediaInfo *infos) { return 0; } + + virtual const char *getInfosXmlGroup() { return (const char *)NULL; } + + virtual int processData(MediaInfo *infos, ChunkList *chunk_list, bool *killswitch)=0; + + virtual int getPosition(void) { return -1; } + + virtual int getLatency(void) { return 0; } + + virtual int sortPlacement(const char *otherconverter) { return 0; } + + virtual int isSelectableOutput(void) { return 0; } + + virtual int onCoreUserMsg(const char *msg, const char *value) { return 0; } + + virtual CoreCallback *getCoreCallback(void) { return this; } + + virtual void setCoreToken(CoreToken t) { m_coretoken=t; } + +protected: + CoreToken m_coretoken; +}; + +#include <api/service/servicei.h> +template <class T> +class MediaConverterCreator : public waServiceFactoryT<svc_mediaConverter, T> { }; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_mediacore.cpp b/Src/Wasabi/api/service/svcs/svc_mediacore.cpp new file mode 100644 index 00000000..154b7a00 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_mediacore.cpp @@ -0,0 +1,45 @@ +#include <precomp.h> + +#include "svc_mediacore.h" + +#define CBCLASS svc_mediaCoreI +START_DISPATCH; + VCB(SETCALLBACK,setCallback); + VCB(SETNEXTFILE,setNextFile); + VCB(START,start); + VCB(PAUSE,pause); + VCB(SETPOSITION,setPosition); + VCB(SETVOLUME,setVolume); + VCB(SETPAN,setPan); + VCB(ABORTCURRENTSONG,abortCurrentSong); + VCB(STOP,stop); + CB(GETPLAYING,getPlaying); + CB(GETPOSITION,getPosition); + CB(GETWRITEPOSITION,getWritePosition); + CB(GETTITLE,getTitle); + VCB(GETINFO,getInfo); + CB(GETLENGTH,getLength); + CB(GETVOLUME,getVolume); + CB(GETPAN,getPan); + VCB(SETEQSTATUS,setEQStatus); + CB(GETEQSTATUS,getEQStatus); + VCB(SETEQPREAMP,setEQPreamp); + CB(GETEQPREAMP,getEQPreamp); + VCB(SETEQBAND,setEQBand); + CB(GETEQBAND,getEQBand); + VCB(SETEQBANDS,setEQBands); + VCB(GETEQBANDS,getEQBands); + VCB(SETEQ,setEQ); + VCB(GETEQ,getEQ); + CB(GETMETADATA,getMetaData); + CB(GETVISDATA,getVisData); + VCB(MUTE,mute); + CB(ISMUTED,isMuted); + VCB(SETCORETOKEN,setCoreToken); + VCB(SETPRIORITY,setPriority); + CB(GETPRIORITY,getPriority); + VCB(REBUILDCONVERTERSCHAIN, rebuildConvertersChain) + CB(SENDCONVERTERSMSG, sendConvertersMsg) +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_mediacore.h b/Src/Wasabi/api/service/svcs/svc_mediacore.h new file mode 100644 index 00000000..2ddbdceb --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_mediacore.h @@ -0,0 +1,172 @@ +#ifndef _SVC_MEDIACORE_H +#define _SVC_MEDIACORE_H + +#include <api/service/services.h> +#include <bfc/dispatch.h> +#include <api/syscb/callbacks/corecbi.h> + +class NOVTABLE svc_mediaCore : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::MEDIACORE; } + + void setCallback(CoreCallback *callback) { _voidcall(SETCALLBACK,callback); } + void setCoreToken(CoreToken t) { _voidcall(SETCORETOKEN,t); } + + void setNextFile(const char *file, const char *to=NULL, int uniqueid=0) { _voidcall(SETNEXTFILE,file,to,uniqueid); } + + void start(void) { _voidcall(START); } + void pause(int pause) { _voidcall(PAUSE,pause); } + void setPosition(int ms) { _voidcall(SETPOSITION,ms); } + + void setVolume(int volume) { _voidcall(SETVOLUME,volume); } + void setPan(int pan) { _voidcall(SETPAN,pan); } + + void abortCurrentSong() { _voidcall(ABORTCURRENTSONG); } + void stop(int suppress_callback=FALSE) { _voidcall(STOP,suppress_callback); } + + int getPlaying(void) { return _call(GETPLAYING,0); } + int getPosition(void) { return _call(GETPOSITION,0); } + int getWritePosition(void) { return _call(GETWRITEPOSITION,0); } + + int getTitle(char *title, int maxlen) { return _call(GETTITLE,0,title,maxlen); } + void getInfo(char *info, int maxlen) { _voidcall(GETINFO,info,maxlen); } + int getLength(void) { return _call(GETLENGTH,0); } + + int getVolume(void) { return _call(GETVOLUME,0); } + int getPan(void) { return _call(GETPAN,0); } + + void mute(int mute) { _voidcall(MUTE,mute); } + int isMuted() { return _call(ISMUTED,0); } + + void setEQStatus(int enable) { _voidcall(SETEQSTATUS,enable); } + int getEQStatus() { return _call(GETEQSTATUS,0); } + void setEQPreamp(char pre) { _voidcall(SETEQPREAMP,pre); } + char getEQPreamp() { return _call(GETEQPREAMP,0); } + void setEQBand(int band, char val) { _voidcall(SETEQBAND,band,val); } + char getEQBand(int band) { return _call(GETEQBAND,0,band); } + void setEQBands(char tab[10]) { _voidcall(SETEQBANDS,tab); } + void getEQBands(char *tab) { _voidcall(GETEQBANDS,tab); } + + void setEQ(int enable, char pre, char tab[10]) { _voidcall(SETEQ,enable,pre,tab); } + void getEQ(int *enable, char *pre, char *tab) { _voidcall(GETEQ,enable,pre,tab); } + + int getMetaData(const char *name, char *data, int data_len) { return _call(GETMETADATA,0,name,data,data_len); } + + int getVisData(void *dataptr, int sizedataptr) { return _call(GETVISDATA,0,dataptr,sizedataptr); } + + void setPriority(int priority) { _voidcall(SETPRIORITY,priority); } + int getPriority() { return _call(GETPRIORITY,0); } + + void rebuildConvertersChain() { _voidcall(REBUILDCONVERTERSCHAIN); } + + int sendConvertersMsg(const char *msg, const char *value) { return _call(SENDCONVERTERSMSG,0,msg,value); } + + enum { + SETCALLBACK=10, + SETNEXTFILE=20, + START=30, + PAUSE=40, + SETPOSITION=50, + SETVOLUME=60, + SETPAN=70, + ABORTCURRENTSONG=80, + STOP=90, + GETPLAYING=100, + GETPOSITION=110, + GETWRITEPOSITION=120, + GETTITLE=130, + GETINFO=140, + GETLENGTH=150, + GETVOLUME=160, + GETPAN=170, + SETEQSTATUS=180, + GETEQSTATUS=190, + SETEQPREAMP=200, + GETEQPREAMP=210, + SETEQBAND=220, + GETEQBAND=230, + SETEQBANDS=240, + GETEQBANDS=250, + SETEQ=260, + GETEQ=270, + GETMETADATA=280, + GETVISDATA=290, + MUTE=300, + ISMUTED=310, + SETCORETOKEN=320, + SETPRIORITY=330, + GETPRIORITY=340, + REBUILDCONVERTERSCHAIN=350, + SENDCONVERTERSMSG=360, + }; +}; + +// derive from this one +class NOVTABLE svc_mediaCoreI : public svc_mediaCore { +public: + svc_mediaCoreI() : m_coretoken(0) { } + + virtual void setCallback(CoreCallback *callback)=0; + virtual void setCoreToken(CoreToken t) { m_coretoken=t; } + + virtual void setNextFile(const char *file, const char *to=NULL, int uniqueid=0)=0; + /* call to specify next file from WCM_NEEDNEXTFILE, or before calling start() */ + + virtual void start(void)=0; /* start playback */ + virtual void pause(int pause)=0; /* set/unset paused state (nonzero is paused, zero is unpaused) */ + virtual void setPosition(int ms)=0; /* set position of current stream in ms */ + + virtual void setVolume(int volume)=0; /* volume is 0 to 255 */ + virtual void setPan(int pan)=0; /* pan is -127 to 127 */ + virtual void abortCurrentSong()=0; /* abort decoding of current song and start playing the next one */ + virtual void stop(int suppress_callback=FALSE)=0; + + virtual int getPlaying(void)=0; /* 0 is not playing, 1 is playing, -1 is paused */ + virtual int getPosition(void)=0; /* get position of current stream in ms */ + virtual int getWritePosition(void)=0; /* get written position of current stream in ms */ + + virtual int getTitle(char *title, int maxlen)=0; // returns uniqueid + virtual void getInfo(char *info, int maxlen)=0; + virtual int getLength(void)=0; /* get length of track in ms. -1 indicates infinite/unknown */ + + virtual int getVolume(void)=0; /* get volume (0-255) */ + virtual int getPan(void)=0; /* get panning (-127 to 127) */ + + virtual void mute(int mute)=0; + virtual int isMuted()=0; + + virtual void setEQStatus(int enable)=0; /* 0 if off, 1 if on */ + virtual int getEQStatus()=0; /* 0 if off, 1 if on */ + virtual void setEQPreamp(char pre)=0; /* -127 to 127 (-20db to +20db) */ + virtual char getEQPreamp()=0; /* -127 to 127 (-20db to +20db) */ + virtual void setEQBand(int band, char val)=0; /* band=0-9 */ + virtual char getEQBand(int band)=0; /* band=0-9 */ + virtual void setEQBands(char tab[10])=0; /* eq values are -127 to 127 (-20db to +20db) */ + virtual void getEQBands(char *tab)=0; /* eq values are -127 to 127 (-20db to +20db) */ + + virtual void setEQ(int enable, char pre, char tab[10])=0; + virtual void getEQ(int *enable, char *pre, char *tab)=0; + + virtual int getMetaData(const char *name, char *data, int data_len)=0; // returns size of data + + virtual int getVisData(void *dataptr, int sizedataptr)=0; // returns size of data it wanted to copy, if any. + + virtual void setPriority(int priority)=0; + virtual int getPriority()=0; + + virtual void rebuildConvertersChain()=0; + + virtual int sendConvertersMsg(const char *msg, const char *value)=0; + +protected: + RECVS_DISPATCH; + + CoreToken m_coretoken; +}; + +#include <api/service/servicei.h> + +template <class T> +class MediaCoreCreator : public waServiceFactoryT<svc_mediaCore, T> { }; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_metadata.cpp b/Src/Wasabi/api/service/svcs/svc_metadata.cpp new file mode 100644 index 00000000..dfacc342 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_metadata.cpp @@ -0,0 +1,14 @@ +#include <precomp.h> + +#include "svc_metadata.h" + +#define CBCLASS svc_metaDataI +START_DISPATCH; + CB(ENUMMETADATA, enumMetaData); + CB(HASMETADATA, hasMetaData); + CB(ALLOWOPERATION, allowOperation); + CB(GETGUID, getGUID); + CB(GETMETANAME, getMetaTableName); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_metadata.h b/Src/Wasabi/api/service/svcs/svc_metadata.h new file mode 100644 index 00000000..f237849d --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_metadata.h @@ -0,0 +1,97 @@ +#ifndef _SVC_METADATA_H +#define _SVC_METADATA_H + +// see helper class in common/metadatasvc.h to implement this + +#include <api/service/services.h> +#include <bfc/dispatch.h> +#include <bfc/string/string.h> +#include <api/db/metatags.h> + +class NOVTABLE svc_metaData : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::METADATA; } + + int enumMetaData(int n, char *mdName, int mdNameMaxLength, int *mdType, BOOL *mdIndexed, BOOL *mdMaintainUniques); + int hasMetaData(const char *name, int type); + int allowOperation(GUID whom, const char *playstring, int op, char *field, void *data, int data_len); + GUID getGUID(); + const char *getMetaTableName(); + + enum { + HASMETADATA=10, + ENUMMETADATA=20, + ALLOWOPERATION=30, + GETGUID=40, + GETMETANAME=50, + }; + +}; + +inline int svc_metaData::hasMetaData(const char *name, int type) { + return _call(HASMETADATA, 0, name, type); +} + +inline int svc_metaData::enumMetaData(int n, char *mdName, int mdNameMaxLength, int *mdType, BOOL *mdIndexed, BOOL *mdMaintainUniques) { + return _call(ENUMMETADATA, 0, n, mdName, mdNameMaxLength, mdType, mdIndexed, mdMaintainUniques); +} + +inline int svc_metaData::allowOperation(GUID whom, const char *playstring, int op, char *field, void *data, int data_len) { + return _call(ALLOWOPERATION, 0, whom, playstring, op, field, data, data_len); +} + +inline GUID svc_metaData::getGUID() { + return _call(GETGUID, INVALID_GUID); +} + +inline const char *svc_metaData::getMetaTableName() { + return _call(GETMETANAME, (const char *)NULL); +} + +// see helper class in common/metadatasvc.h to implement this +class NOVTABLE svc_metaDataI : public svc_metaData { +public: + virtual int enumMetaData(int n, char *mdName, int mdNameMaxLength, int *mdType, BOOL *mdIndexed, BOOL *mdMaintainUniques)=0; + virtual int hasMetaData(const char *name, int type)=0; + virtual int allowOperation(GUID whom, const char *playstring, int op, char *field, void *data, int data_len)=0; + virtual GUID getGUID()=0; + virtual const char *getMetaTableName()=0; + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/servicei.h> + +// if you want to use class MetaDataSvc (instead of deriving from +// svc_metaDataI yourself) use class MetaDataSvcFactory in common/metadatasvc.h +template <class T> +class MetaDataSvcCreator : public waServiceFactoryTSingle<svc_metaData, T> {}; + +#include <api/service/svc_enum.h> + +class MetaDataSvcEnum : public SvcEnumT<svc_metaData> { +public: + MetaDataSvcEnum(const char *metadata=NULL, int mdtype=MDT_NONE) : md(metadata), type(mdtype) {} +protected: + virtual int testService(svc_metaData *svc) { + if (md.isempty() || type == MDT_NONE) return TRUE; + return svc->hasMetaData(md, type); + } +private: + String md; + int type; +}; + +class MetaDataSvcEnumGuid : public SvcEnumT<svc_metaData> { +public: + MetaDataSvcEnumGuid(GUID g) : guid(g) {} +protected: + virtual int testService(svc_metaData *svc) { + return (svc->getGUID() == guid); + } +private: + GUID guid; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_minibrowser.cpp b/Src/Wasabi/api/service/svcs/svc_minibrowser.cpp new file mode 100644 index 00000000..65c3c0dd --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_minibrowser.cpp @@ -0,0 +1,12 @@ +#include <precomp.h> +#include "svc_minibrowser.h" + +#define CBCLASS svc_miniBrowserI +START_DISPATCH; + CB(TESTGUID, testGuid); + CB(CREATEMINIBROWSER, createMiniBrowser); + VCB(DESTROYMINIBROWSER, destroyMiniBrowser); +END_DISPATCH; +#undef CBCLASS + + diff --git a/Src/Wasabi/api/service/svcs/svc_minibrowser.h b/Src/Wasabi/api/service/svcs/svc_minibrowser.h new file mode 100644 index 00000000..9772131b --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_minibrowser.h @@ -0,0 +1,69 @@ +#ifndef _SVC_MINIBROWSER_H +#define _SVC_MINIBROWSER_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class MiniBrowser; + +#include <bfc/nsguid.h> + +// {2E41D2E8-19A5-4029-9339-8FDF7481000A} +static const GUID GUID_MINIBROWSER_ANY = +{ 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; + +// {C0A3D1AC-2430-45a7-B51B-AB04B74DD9EA} +static const GUID GUID_MINIBROWSER_IEACTIVEX = +{ 0xc0a3d1ac, 0x2430, 0x45a7, { 0xb5, 0x1b, 0xab, 0x4, 0xb7, 0x4d, 0xd9, 0xea } }; + +class NOVTABLE svc_miniBrowser : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::MINIBROWSER; } + + int testGuid(GUID g); + MiniBrowser *createMiniBrowser(); + void destroyMiniBrowser(MiniBrowser *b); + + enum { + TESTGUID =10, + CREATEMINIBROWSER =20, + DESTROYMINIBROWSER =30, + }; +}; + +inline int svc_miniBrowser::testGuid(GUID g) { + return _call(TESTGUID, 0, g); +} + +inline MiniBrowser *svc_miniBrowser::createMiniBrowser() { + return _call(CREATEMINIBROWSER, (MiniBrowser *)0); +} + +inline void svc_miniBrowser::destroyMiniBrowser(MiniBrowser *b) { + _voidcall(DESTROYMINIBROWSER, b); +} + +class NOVTABLE svc_miniBrowserI : public svc_miniBrowser { +public: + virtual int testGuid(GUID g)=0; + virtual MiniBrowser *createMiniBrowser()=0; + virtual void destroyMiniBrowser(MiniBrowser *b)=0; + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/svc_enum.h> + +class MiniBrowserSvcEnum : public SvcEnumT<svc_miniBrowser> { +public: + MiniBrowserSvcEnum(GUID g) : guid(g) {} +protected: + virtual int testService(svc_miniBrowser *svc) { + return (svc->testGuid(guid)); + } +private: + GUID guid; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_objectdir.cpp b/Src/Wasabi/api/service/svcs/svc_objectdir.cpp new file mode 100644 index 00000000..e79e5a48 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_objectdir.cpp @@ -0,0 +1,32 @@ +#include <precomp.h> + +#include "svc_objectdir.h" +#include <api/api.h> + +#define CBCLASS svc_objectDirI +START_DISPATCH; + CB(GETDEPENDENCYPTR, getDependencyPtr); + CB(GETDIRTYPE, getDirType); + CB(GETNUMOBJECTS, getNumObjects); + CB(ENUMOBJECT, enumObject); + CB(GETOBJECT, getObject); + CB(GETOBJECTLABEL, getObjectLabel); + CB(SETOBJECTLABEL, setObjectLabel); + CB(INSERTOBJECT, insertObject); + CB(REMOVEOBJECT, removeObject); + VCB(CLEARALL, clearAll); + CB(ONACTION, onAction); + VCB(ONPRERENDER, onPrerender); + VCB(ONPOSTRENDER, onPostrender); + CB(GETOBJECTPATH, getObjectPath); + CB(GETOBJECTDISPLAYGROUP, getObjectDisplayGroup); + CB(GETOBJECTICON, getObjectIcon); + CB(GETOBJECTSELECTABLE, getObjectSelectable); + CB(GETOBJECTSORTORDER, getObjectSortOrder); + CB(TAGOBJECT, tagObject); + CB(UNTAGOBJECT, untagObject); + CB(ENUMOBJECTBYTAG, enumObjectByTag); + CB(ISTAGGED, isTagged); + CB(CONTEXTMENU, contextMenu); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_objectdir.h b/Src/Wasabi/api/service/svcs/svc_objectdir.h new file mode 100644 index 00000000..fdf5cd2f --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_objectdir.h @@ -0,0 +1,294 @@ +#ifndef _SVC_OBJECTDIR_H +#define _SVC_OBJECTDIR_H + +#include <bfc/dispatch.h> +#include <bfc/string/StringW.h> +#include <api/service/services.h> +#include <api/syscb/callbacks/runlevelcb.h> + +// there is class ObjectDir in bfc/wnds, you should derive from it +// also class ContextCmdObjDir + +typedef size_t ObjectHandle; +#define INVALID_OBJECT_HANDLE ((ObjectHandle)0) + +#define DD_OBJECTDIR L"service:svc_objectDir" + +class ifc_window; +class ifc_dependent; +class BaseCanvas; + +class svc_objectDir : public Dispatchable +{ +public: + static int getServiceType() { return WaSvc::OBJECTDIR; } + static const wchar_t *dragitem_getDatatype() { return DD_OBJECTDIR; } + static const GUID *depend_getClassGuid() { + // {2364D110-0F12-40d4-BBAE-D2DA174751B5} + static const GUID ret = + { 0x2364d110, 0xf12, 0x40d4, { 0xbb, 0xae, 0xd2, 0xda, 0x17, 0x47, 0x51, 0xb5 } }; + return &ret; + } + + api_dependent *getDependencyPtr(); + + const wchar_t *getDirType(); + + int getNumObjects(); + ObjectHandle enumObject(int n); + + void *getObject(ObjectHandle handle); + + const wchar_t *getObjectLabel(ObjectHandle handle); + int setObjectLabel(ObjectHandle handle, const wchar_t *newlabel); + + ObjectHandle insertObject(const wchar_t *parameter=NULL, const wchar_t *label=NULL, const wchar_t *path=NULL); + int removeObject(ObjectHandle handle); + + void clearAll(); + + const wchar_t *getObjectPath(ObjectHandle handle); + const wchar_t *getObjectDisplayGroup(ObjectHandle handle); + const wchar_t *getObjectIcon(ObjectHandle handle); + int getObjectSelectable(ObjectHandle handle); + int getObjectSortOrder(ObjectHandle handle); // -32767..32767 + + // tagging + int tagObject(const wchar_t *tag, ObjectHandle handle, int exclusive=FALSE); + int untagObject(const wchar_t *tag, ObjectHandle handle); + ObjectHandle enumObjectByTag(const wchar_t *tag, int n); + int isTagged(const wchar_t *tag, ObjectHandle handle); + + int onAction(int action, ifc_window *from, const wchar_t *target, ObjectHandle handle); + enum { + ODACTION_SELECTED=100, + ODACTION_DESELECTED=200, + ODACTION_CONTEXTMENU=300, + }; + + int contextMenu(ifc_window *from, int x, int y, ObjectHandle handle); + + void onPrerender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style); + void onPostrender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style); + // render styles + enum { + RENDERSTYLE_TREEWND=10, + }; + + // dependency events, param is handle of object in question + enum { + Event_OBJECT_ADDED=100, + Event_OBJECT_REMOVED=110, + Event_OBJECT_LABELCHANGE=200, + Event_OBJECT_ICONCHANGE=300, + Event_OBJECT_PATHCHANGE=400, + Event_OBJECT_SELECTABLECHANGE=500, + Event_OBJECT_SORTORDERCHANGE=600, + Event_OBJECT_TAGCHANGE=700, + }; + + // dispatchable codes + enum { + GETDEPENDENCYPTR=100, + GETNUMOBJECTS=200, + ENUMOBJECT=300, + GETOBJECT=400, + GETOBJECTLABEL=500, + SETOBJECTLABEL=510, + INSERTOBJECT=600, + REMOVEOBJECT=610, + CLEARALL=700, + GETDIRTYPE=800, + ONACTION=900, + ONPRERENDER=1000, + ONPOSTRENDER=1010, + GETOBJECTPATH=1100, + GETOBJECTDISPLAYGROUP=1200, + GETOBJECTICON=1300, + GETOBJECTSELECTABLE=1400, + GETOBJECTSORTORDER=1500, + TAGOBJECT=1600, + UNTAGOBJECT=1700, + ENUMOBJECTBYTAG=1800, + ISTAGGED=1900, + CONTEXTMENU=3000, + }; +}; + +inline +api_dependent *svc_objectDir::getDependencyPtr() { + return _call(GETDEPENDENCYPTR, (api_dependent*)NULL); +} + +inline +const wchar_t *svc_objectDir::getDirType() { + return _call(GETDIRTYPE, (const wchar_t *)NULL); +} + +inline +int svc_objectDir::getNumObjects() { + return _call(GETNUMOBJECTS, 0); +} + +inline +ObjectHandle svc_objectDir::enumObject(int n) { + return _call(ENUMOBJECT, INVALID_OBJECT_HANDLE, n); +} + +inline +void *svc_objectDir::getObject(ObjectHandle handle) { + return _call(GETOBJECT, (void*)NULL, handle); +} + +inline +const wchar_t *svc_objectDir::getObjectLabel(ObjectHandle handle) { + return _call(GETOBJECTLABEL, (const wchar_t *)NULL, handle); +} + +inline +int svc_objectDir::setObjectLabel(ObjectHandle handle, const wchar_t *newlabel) { + return _call(SETOBJECTLABEL, 0, handle, newlabel); +} + +inline +ObjectHandle svc_objectDir::insertObject(const wchar_t *parameter, const wchar_t *label, const wchar_t *path) { + return _call(INSERTOBJECT, INVALID_OBJECT_HANDLE, parameter, label, path); +} + +inline +int svc_objectDir::removeObject(ObjectHandle handle) { + return _call(REMOVEOBJECT, 0, handle); +} + +inline +void svc_objectDir::clearAll() { + _voidcall(CLEARALL); +} + +inline +const wchar_t *svc_objectDir::getObjectPath(ObjectHandle handle) { + return _call(GETOBJECTPATH, (const wchar_t *)NULL, handle); +} + +inline +const wchar_t *svc_objectDir::getObjectDisplayGroup(ObjectHandle handle) { + return _call(GETOBJECTDISPLAYGROUP, L"", handle); +} + +inline +const wchar_t *svc_objectDir::getObjectIcon(ObjectHandle handle) { + return _call(GETOBJECTICON, (const wchar_t *)NULL, handle); +} + +inline +int svc_objectDir::getObjectSelectable(ObjectHandle handle) { + return _call(GETOBJECTSELECTABLE, TRUE, handle); +} + +inline +int svc_objectDir::getObjectSortOrder(ObjectHandle handle) { + return _call(GETOBJECTSORTORDER, 0, handle); +} + +inline +int svc_objectDir::tagObject(const wchar_t *tag, ObjectHandle handle, int exclusive) { + return _call(TAGOBJECT, 0, tag, handle, exclusive); +} +inline +int svc_objectDir::untagObject(const wchar_t *tag, ObjectHandle handle) { + return _call(UNTAGOBJECT, 0, tag, handle); +} +inline +ObjectHandle svc_objectDir::enumObjectByTag(const wchar_t *tag, int n) { + return _call(ENUMOBJECTBYTAG, INVALID_OBJECT_HANDLE, tag, n); +} +inline +int svc_objectDir::isTagged(const wchar_t *tag, ObjectHandle handle) { + return _call(ISTAGGED, 0, tag, handle); +} + +inline +int svc_objectDir::onAction(int action, ifc_window *from, const wchar_t *target, ObjectHandle handle) { + return _call(ONACTION, 0, action, from, target, handle); +} + +inline +int svc_objectDir::contextMenu(ifc_window *from, int x, int y, ObjectHandle handle) { + return _call(CONTEXTMENU, 0, from, x, y, handle); +} + +inline +void svc_objectDir::onPrerender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) { + _voidcall(ONPRERENDER, handle, r, c, style); +} +inline +void svc_objectDir::onPostrender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) { + _voidcall(ONPOSTRENDER, handle, r, c, style); +} + + +/** + Service implementation. Usually you'll derive from ObjectDir, not this. + You can still derive from this if you want to fully implement the interface yourself for some reason though. + @see ObjectDir +*/ +class svc_objectDirI : public svc_objectDir { +public: + virtual api_dependent *getDependencyPtr()=0; + + virtual const wchar_t *getDirType()=0; + + virtual int getNumObjects()=0; + virtual ObjectHandle enumObject(int n)=0; + + virtual void *getObject(ObjectHandle handle)=0; + + virtual const wchar_t *getObjectLabel(ObjectHandle handle)=0; + virtual int setObjectLabel(ObjectHandle handle, const wchar_t *newlabel)=0; + + virtual ObjectHandle insertObject(const wchar_t *parameter=NULL, const wchar_t *label=NULL, const wchar_t *path=NULL)=0; + virtual int removeObject(ObjectHandle handle)=0; + + virtual void clearAll()=0; + + virtual const wchar_t *getObjectPath(ObjectHandle handle)=0; + virtual const wchar_t *getObjectDisplayGroup(ObjectHandle handle)=0; + virtual const wchar_t *getObjectIcon(ObjectHandle handle)=0; + virtual int getObjectSelectable(ObjectHandle handle)=0; + virtual int getObjectSortOrder(ObjectHandle handle)=0; + + virtual int tagObject(const wchar_t *tag, ObjectHandle handle, int exclusive=FALSE)=0; + virtual int untagObject(const wchar_t *tag, ObjectHandle handle)=0; + virtual ObjectHandle enumObjectByTag(const wchar_t *tag, int n)=0; + virtual int isTagged(const wchar_t *tag, ObjectHandle handle)=0; + + virtual int onAction(int action, ifc_window *from, const wchar_t *target, ObjectHandle handle)=0; + + // return -1 to request renaming the item, 0 normally + virtual int contextMenu(ifc_window *from, int x, int y, ObjectHandle handle)=0; + + virtual void onPrerender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) { } + virtual void onPostrender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) { } + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/servicei.h> + +template <class T> +class ObjectDirCreator : public waServiceFactoryTSingle<svc_objectDir, T> { }; + +#include <api/service/svc_enum.h> + +class ObjectDirEnum : public SvcEnumT<svc_objectDir> { +public: + ObjectDirEnum(const wchar_t *_name) : name(_name) {} + virtual int testService(svc_objectDir *svc) { + return !WCSICMP(svc->getDirType(), name); + } +private: + StringW name; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_player.h b/Src/Wasabi/api/service/svcs/svc_player.h new file mode 100644 index 00000000..cf6f136e --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_player.h @@ -0,0 +1,35 @@ +#ifndef _SVC_PLAYER_H +#define _SVC_PLAYER_H + +#include <bfc/dispatch.h> + +#include <api/service/services.h> + +class api_window; + +class svc_player { +public: + static const char *getServiceName() { return "Standard player service"; } + static int getServiceType() { return WaSvc::UNIQUE; } + static GUID getServiceGuid() { + // {9DE79C4A-B9E6-46f4-9AE2-40E0F09CCA51} + const GUID guid = + { 0x9de79c4a, 0xb9e6, 0x46f4, { 0x9a, 0xe2, 0x40, 0xe0, 0xf0, 0x9c, 0xca, 0x51 } }; + return guid; + } + virtual void openFile(const char *filename, FOURCC droptarg=MK3CC('d','e','f'))=0; + virtual void openFiles(api_window *parent=NULL, const char *type=NULL, FOURCC droptarg=MK3CC('d','e','f'))=0; +}; + +class svc_playerI : public svc_player { +}; + +#include <api/service/servicei.h> + +template <class T> +class PlayerCreator : public waServiceFactoryTSingle<svc_player, T> { +public: + PlayerCreator() : waServiceFactoryTSingle<svc_player, T>(svc_player::getServiceGuid()) {} +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_playlist.cpp b/Src/Wasabi/api/service/svcs/svc_playlist.cpp new file mode 100644 index 00000000..88b81c53 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_playlist.cpp @@ -0,0 +1,28 @@ +#include <precomp.h> + +#include "svc_playlist.h" + +#define CBCLASS svc_playlistReaderI +START_DISPATCH; + CB(GETEXTENSION, getExtension); + CB(TESTFILENAME, testFilename); + CB(GETDESCRIPTION, getDescription); + CB(READPLAYLIST, readPlaylist); + CB(GETLABEL, getLabel); + CB(GETNUMENTRIES, getNumEntries); + CB(ENUMENTRY, enumEntry); + VCB(ENABLEDATABASEADD, enableDatabaseAdd); +END_DISPATCH; +#undef CBCLASS + +#define CBCLASS svc_playlistWriterI +START_DISPATCH; + CB(GETEXTENSION, getExtension); + CB(GETDESCRIPTION, getDescription); + CB(WRITEPLAYLIST, writePlaylist); + CB(BEGINWRITE, beginWrite); + VCB(WRITEENTRY, writeEntry); + VCB(ENDWRITE, endWrite); + VCB(ENABLEMETADATA, enableMetadata); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_playlist.h b/Src/Wasabi/api/service/svcs/svc_playlist.h new file mode 100644 index 00000000..928da339 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_playlist.h @@ -0,0 +1,216 @@ +#ifndef _SVC_PLAYLIST_H +#define _SVC_PLAYLIST_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class Playlist; + +class NOVTABLE svc_playlistReader : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::PLAYLISTREADER; } + + const char *getExtension(); + int testFilename(const char *filename); + const char *getDescription(); + + void setAllowedMetadataColumns(const char *columnslist); // "a;b;c" ""=all + void setBannedMetadataColumns(const char *columnslist); // "a;b;c" ""==all + + void enableDatabaseAdd(int enabled); // defaults to TRUE +// void enableMetadata(int enabled); // defaults to TRUE + + int readPlaylist(const char *filename); + + const char *getLabel(); + int getNumEntries(); + const char *enumEntry(int n); + +protected: + enum { + GETEXTENSION=0, READPLAYLIST=1, GETLABEL=2, GETNUMENTRIES=3, ENUMENTRY=4, + TESTFILENAME=100, + GETDESCRIPTION=110, + ENABLEDATABASEADD=200, + }; +}; + +inline +const char *svc_playlistReader::getExtension() { + return _call(GETEXTENSION, ""); +} + +inline +int svc_playlistReader::testFilename(const char *filename) { + return _call(TESTFILENAME, -1, filename); +} + +inline +const char *svc_playlistReader::getDescription() { + return _call(GETDESCRIPTION, (const char *)NULL); +} + +inline +void svc_playlistReader::enableDatabaseAdd(int enabled) { + _voidcall(ENABLEDATABASEADD, enabled); +} + +inline +int svc_playlistReader::readPlaylist(const char *filename) { + return _call(READPLAYLIST, 0, filename); +} + +inline +const char *svc_playlistReader::getLabel() { + return _call(GETLABEL, (const char *)0); +} + +inline +int svc_playlistReader::getNumEntries() { + return _call(GETNUMENTRIES, 0); +} + +inline +const char *svc_playlistReader::enumEntry(int n) { + return _call(ENUMENTRY, (const char *)NULL, n); +} + +class NOVTABLE svc_playlistReaderI : public svc_playlistReader { +public: + virtual const char *getExtension()=0; + virtual int testFilename(const char *filename) { return -1; } + virtual const char *getDescription() { return NULL; } + + virtual void enableDatabaseAdd(int enabled)=0; + + virtual int readPlaylist(const char *filename)=0; + + virtual const char *getLabel()=0; + virtual int getNumEntries()=0; + virtual const char *enumEntry(int n)=0; + +private: + RECVS_DISPATCH; +}; + +class NOVTABLE svc_playlistWriter : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::PLAYLISTWRITER; } + + const char *getExtension(); + const char *getDescription(); + + void enableMetadata(int enabled); + + int writePlaylist(const char *filename, Playlist *pl, int full_data, int first, int last); + +// old-style, DEPRECATED + int beginWrite(const char *filename, int n, const char *label); + void writeEntry(const char *playstring); + void endWrite(); + +protected: + enum { + GETEXTENSION=0, + GETDESCRIPTION=1, + BEGINWRITE=2, + WRITEENTRY=3, + ENDWRITE=4, + WRITEPLAYLIST=100, + ENABLEMETADATA=200, + }; +}; + +inline +const char *svc_playlistWriter::getExtension() { + return _call(GETEXTENSION, (const char *)0); +} + +inline +const char *svc_playlistWriter::getDescription() { + return _call(GETDESCRIPTION, (const char *)0); +} + +inline +void svc_playlistWriter::enableMetadata(int enabled) { + _voidcall(ENABLEMETADATA, enabled); +} + +inline +int svc_playlistWriter::writePlaylist(const char *filename, Playlist *pl, int full_data, int first, int last) { + return _call(WRITEPLAYLIST, -1, filename, pl, full_data, first, last); +} + +inline +int svc_playlistWriter::beginWrite(const char *filename, int n, const char *label) { + return _call(BEGINWRITE, 0, filename, n, label); +} + +inline +void svc_playlistWriter::writeEntry(const char *playstring) { + _voidcall(WRITEENTRY, playstring); +} + +inline +void svc_playlistWriter::endWrite() { + _voidcall(ENDWRITE); +} + +class NOVTABLE svc_playlistWriterI : public svc_playlistWriter { +public: + virtual const char *getExtension()=0; + virtual const char *getDescription() { return NULL; } + + virtual void enableMetadata(int enabled) { } + + virtual int writePlaylist(const char *filename, Playlist *pl, int full_data, int first, int last) { return -1; } + +// old-style, DEPRECATED + virtual int beginWrite(const char *filename, int n, const char *label) { return 0; } + virtual void writeEntry(const char *playstring) { } + virtual void endWrite() { } + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/servicei.h> + +template <class T> +class PlaylistReaderCreator : public waServiceFactoryT<svc_playlistReader, T> {}; + +template <class T> +class PlaylistWriterCreator : public waServiceFactoryT<svc_playlistWriter, T> {}; + +#include <api/service/svc_enum.h> +#include <bfc/string/string.h> + +class PlaylistReaderEnum : public SvcEnumT<svc_playlistReader> { +public: + PlaylistReaderEnum(const char *filename) : fn(filename) {} + +protected: + virtual int testService(svc_playlistReader *svc) { + int r = svc->testFilename(fn); + if (r == -1) return STRCASEEQL(svc->getExtension(), Std::extension(fn)); + return r; + } + +private: + String fn; +}; + +class PlaylistWriterEnum : public SvcEnumT<svc_playlistWriter> { +public: + PlaylistWriterEnum(const char *filename) : + ext(Std::extension(filename)) {} +protected: + virtual int testService(svc_playlistWriter *svc) { + return STRCASEEQL(svc->getExtension(), ext); + } + +private: + String ext; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_redir.cpp b/Src/Wasabi/api/service/svcs/svc_redir.cpp new file mode 100644 index 00000000..ab7d42f6 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_redir.cpp @@ -0,0 +1,10 @@ +#include <precomp.h> + +#include "svc_redir.h" + +#define CBCLASS svc_redirectI +START_DISPATCH; + CB(ISMINE, isMine); + CB(REDIRECT, redirect); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_redir.h b/Src/Wasabi/api/service/svcs/svc_redir.h new file mode 100644 index 00000000..9ab82b8a --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_redir.h @@ -0,0 +1,63 @@ +#ifndef _SVC_REDIR_H +#define _SVC_REDIR_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +/* Domains: + "Filename" + "Url" +*/ + +// if you want to redirect a string easily, look at RedirString in +// bfc/util/redirstr.h + +class svc_redirect : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::REDIRECT; } + + int isMine(const wchar_t *str, const wchar_t *domain); + int redirect(const wchar_t *orig_str, const wchar_t *domain, wchar_t *buf, int buflen); + +protected: + enum { + ISMINE=100, + REDIRECT=200, + }; +}; + +inline int svc_redirect::isMine(const wchar_t *str, const wchar_t *domain) { + return _call(ISMINE, 0, str, domain); +} + +inline int svc_redirect::redirect(const wchar_t *orig_str, const wchar_t *domain, wchar_t *buf, int buflen) { + return _call(REDIRECT, 0, orig_str, domain, buf, buflen); +} + +class svc_redirectI : public svc_redirect { +public: + virtual int isMine(const wchar_t *str, const wchar_t *domain)=0; + virtual int redirect(const wchar_t *orig_str, const wchar_t *domain, wchar_t *buf, int buflen)=0; + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/svc_enum.h> + +class RedirectEnum : public SvcEnumT<svc_redirect> { +public: + RedirectEnum(const wchar_t *filename, const wchar_t *domain=L"Filename") : + fn(filename), dom(domain) { + } + + virtual int testService(svc_redirect *svc) { + if (svc->isMine(fn, dom)) return 1; + return 0; + } + +private: + const wchar_t *fn, *dom; +}; +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_scriptobj.cpp b/Src/Wasabi/api/service/svcs/svc_scriptobj.cpp new file mode 100644 index 00000000..4d154c85 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_scriptobj.cpp @@ -0,0 +1,10 @@ +#include <precomp.h> + +#include "svc_scriptobji.h" + +#define CBCLASS svc_scriptObjectI +START_DISPATCH; + CB(GETCONTROLLER, getController); + VCB(ONREGISTER, onRegisterClasses); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_scriptobj.h b/Src/Wasabi/api/service/svcs/svc_scriptobj.h new file mode 100644 index 00000000..8cdae362 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_scriptobj.h @@ -0,0 +1,29 @@ +#ifndef _SVC_SCRIPTOBJECT_H +#define _SVC_SCRIPTOBJECT_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class ScriptObjectController; + +class svc_scriptObject : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::SCRIPTOBJECT; } + ScriptObjectController *getController(int n); + void onRegisterClasses(ScriptObjectController *rootController); + + enum { + GETCONTROLLER=10, + ONREGISTER=20, + }; +}; + +inline ScriptObjectController *svc_scriptObject::getController(int n) { + return _call(GETCONTROLLER, (ScriptObjectController *)0, n); +} + +inline void svc_scriptObject::onRegisterClasses(ScriptObjectController *rootController) { + _voidcall(ONREGISTER, rootController); +} + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_scriptobji.h b/Src/Wasabi/api/service/svcs/svc_scriptobji.h new file mode 100644 index 00000000..59014cf0 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_scriptobji.h @@ -0,0 +1,51 @@ +#pragma once +#include "svc_scriptobji.h" +// derive from this one +class svc_scriptObjectI : public svc_scriptObject { +public: + virtual ScriptObjectController *getController(int n)=0; + virtual void onRegisterClasses(ScriptObjectController *rootController) {}; + +protected: + RECVS_DISPATCH; +}; + +template <class T> +class ScriptObjectControllerCreator : public svc_scriptObjectI { +public: + static const char *getServiceName() { return "ScriptObjectControllerCreator"; } + + ScriptObjectControllerCreator() + { + } + + virtual ~ScriptObjectControllerCreator() + { + } + + virtual ScriptObjectController *getController(int n) + { + if (n == 0) return &single_controller; + return NULL; + } + +private: + T single_controller; +}; + +#include <api/service/servicei.h> +template <class T> +class ScriptObjectCreator : public waServiceFactoryTSingle<svc_scriptObject, T> {}; + +#include <api/service/svc_enum.h> + +class ExternalScriptObjectEnum : public SvcEnumT<svc_scriptObject> { +public: + ExternalScriptObjectEnum() { } + +protected: + virtual int testService(svc_scriptObject*svc) { + return (svc->getController(0) != NULL); + } +}; + diff --git a/Src/Wasabi/api/service/svcs/svc_skinfilter.cpp b/Src/Wasabi/api/service/svcs/svc_skinfilter.cpp new file mode 100644 index 00000000..34d2adf4 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_skinfilter.cpp @@ -0,0 +1,10 @@ +#include <precomp.h> + +#include "svc_skinfilter.h" + +#define CBCLASS svc_skinFilterI +START_DISPATCH; + CB(FILTERBITMAP, filterBitmap); + CB(FILTERCOLOR, filterColor); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_skinfilter.h b/Src/Wasabi/api/service/svcs/svc_skinfilter.h new file mode 100644 index 00000000..ef3fae71 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_skinfilter.h @@ -0,0 +1,56 @@ +#ifndef _SVC_SKINFILTER_H +#define _SVC_SKINFILTER_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +// TODO: make some sort of ifc_bitmap so we can do OS-level manipulations if necessary + +class NOVTABLE svc_skinFilter : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::SKINFILTER; } + int filterBitmap(uint8_t *bits, int w, int h, int bpp, const wchar_t *element_id, const wchar_t *forcegroup=NULL); + ARGB32 filterColor(ARGB32 color, const wchar_t *element_id, const wchar_t *forcegroup=NULL); + + enum { + FILTERBITMAP=100, + FILTERCOLOR=200, + }; +}; + +inline int svc_skinFilter::filterBitmap(uint8_t *bits, int w, int h, int bpp, const wchar_t *element_id, const wchar_t *forcegroup) { + return _call(FILTERBITMAP, 0, bits, w, h, bpp, element_id, forcegroup); +} + +inline ARGB32 svc_skinFilter::filterColor(ARGB32 color, const wchar_t *element_id, const wchar_t *forcegroup) { + return _call(FILTERCOLOR, (ARGB32)0, color, element_id, forcegroup); +} + +// derive from this one +class NOVTABLE svc_skinFilterI : public svc_skinFilter +{ +public: + virtual int filterBitmap(uint8_t *bits, int w, int h, int bpp, const wchar_t *element_id, const wchar_t *forcegroup=NULL)=0; + virtual ARGB32 filterColor(ARGB32 color, const wchar_t *element_id, const wchar_t *forcegroup=NULL) + { + // easy cheesy helper + filterBitmap((uint8_t *)&color, 1, 1, 32, element_id, forcegroup); + return color; + } + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/svc_enum.h> + +class SkinFilterEnum : public SvcEnumT<svc_skinFilter> { +public: + SkinFilterEnum() {} +protected: + virtual int testService(svc_skinFilter* svc) { + return TRUE; + } +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_storagevolenum.cpp b/Src/Wasabi/api/service/svcs/svc_storagevolenum.cpp new file mode 100644 index 00000000..8e26b793 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_storagevolenum.cpp @@ -0,0 +1,30 @@ +#include <precomp.h> +#include "svc_storagevolenum.h" + +//----------------------------------------------------------------- + +#define CBCLASS StorageVolumeI +START_DISPATCH; + CB(GETVOLUMENAME, getVolumeName); + CB(GETMOUNTPATH, getMountPath); + CB(GETLABEL, getLabel); + CB(GETTYPE, getType); + CB(ISREMOVABLE, isRemovable); + CB(ISWRITABLE, isWritable); + CB(GETFREESPACE, getFreeSpace); + CB(GETSIZE, getSize); +END_DISPATCH; +#undef CBCLASS + +//----------------------------------------------------------------- + +#define CBCLASS svc_storageVolumeEnumI +START_DISPATCH; + CB(GETNUMVOLUMES, getNumVolumes); + CB(ENUMVOLUME, enumVolume); +END_DISPATCH; +#undef CBCLASS + +//----------------------------------------------------------------- + + diff --git a/Src/Wasabi/api/service/svcs/svc_storagevolenum.h b/Src/Wasabi/api/service/svcs/svc_storagevolenum.h new file mode 100644 index 00000000..15d60ed7 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_storagevolenum.h @@ -0,0 +1,96 @@ +#ifndef __SVC_STORAGEVOLENUM_H +#define __SVC_STORAGEVOLENUM_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +enum StorageVolumeTypes { + NOT_VALID = 0, //Not a valid Volume. + UNKNOWN = 1, //Unknown Drive Type. + LOCAL = 1<<1, //Local (Fixed) Hard Drive. + REMOVABLE = 1<<2, //Removable Drive (Floppy, LS-120, Zip, USB FlashCard Reader, etc.) + NETWORK = 1<<3, //Network Drive (SMB, NFS, etc.) + CDROM = 1<<4, //CD / DVD ROM, WRITER, Re-WRITER, etc. + RAMDISK = 1<<5, //RAM Drive. +}; + +//----------------------------------------------------------------- + +class NOVTABLE StorageVolume : public Dispatchable { +public: + const char *getVolumeName() { return _call(GETVOLUMENAME, (const char *) NULL); } + const char *getMountPath() { return _call(GETMOUNTPATH, (const char *) NULL); } + const char *getLabel() { return _call(GETLABEL, (const char *) NULL); } + + int getType() { return _call(GETTYPE, 0); } + + int isRemovable() { return _call(ISREMOVABLE, -1); } + int isWritable() { return _call(ISWRITABLE, -1); } + + __int64 getFreeSpace() { return _call(GETFREESPACE, -1); } + __int64 getSize() { return _call(GETSIZE, -1); } + + enum { + GETVOLUMENAME = 10, + GETMOUNTPATH = 20, + GETLABEL = 30, + GETTYPE = 40, + ISREMOVABLE = 50, + ISWRITABLE = 60, + GETFREESPACE = 70, + GETSIZE = 80 + }; +}; + +//----------------------------------------------------------------- + +class StorageVolumeI : public StorageVolume { +public: + virtual const char *getVolumeName()=0; + virtual const char *getMountPath()=0; + virtual const char *getLabel()=0; + + virtual int getType()=0; + + virtual int isRemovable()=0; + virtual int isWritable()=0; + + virtual __int64 getFreeSpace()=0; + virtual __int64 getSize()=0; + +protected: + RECVS_DISPATCH; + +}; + +//----------------------------------------------------------------- + +class NOVTABLE svc_storageVolumeEnum : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::STORAGEVOLENUM; } + + int getNumVolumes() { return _call(GETNUMVOLUMES, (int) 0); } + StorageVolume *enumVolume(int which) { return _call(ENUMVOLUME, (StorageVolume *)NULL); } + + enum { + GETNUMVOLUMES = 10, + ENUMVOLUME = 20, + }; + +}; + +//----------------------------------------------------------------- + +class svc_storageVolumeEnumI : public svc_storageVolumeEnum { +public: + virtual int getNumVolumes()=0; //Get the number of Storage Volumes. + //Enum a Storage Volume. + virtual StorageVolume *enumVolume(int which)=0; + +protected: + RECVS_DISPATCH; + +}; + +#endif //__SVC_STORAGEVOLENUM_H
\ No newline at end of file diff --git a/Src/Wasabi/api/service/svcs/svc_stringconverter.cpp b/Src/Wasabi/api/service/svcs/svc_stringconverter.cpp new file mode 100644 index 00000000..cf1c1222 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_stringconverter.cpp @@ -0,0 +1,12 @@ +#include <precomp.h> +#include "svc_stringconverter.h" + +#define CBCLASS svc_stringConverterI +START_DISPATCH + CB(CANCONVERT, canConvert); + CB(CONVERTTOUTF8, convertToUTF8); + CB(PREFLIGHTTOUTF8, preflightToUTF8); + CB(CONVERTFROMUTF8, convertFromUTF8); + CB(PREFLIGHTFROMUTF8, preflightFromUTF8); +END_DISPATCH +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_stringconverter.h b/Src/Wasabi/api/service/svcs/svc_stringconverter.h new file mode 100644 index 00000000..c03baac0 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_stringconverter.h @@ -0,0 +1,94 @@ +#ifndef _SVC_STRINGCONVERTER_H +#define _SVC_STRINGCONVERTER_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> +#include <api/service/svcs/svc_stringtypes.h> + +// Porting Rule: A new service to respond to at least OSNATIVE and UTF16 shall be +// provided for every new platform. This service should provide transcoding +// to and from the platform's native internationalized string encoding format +// (ie: MBCS under Win9x, WorldScript on the Mac, etc etc etc).and to and from +// UTF16. If the OSNATIVE string _IS_ UTF16, just respond that you can convert +// both. + +class NOVTABLE svc_stringConverter : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::STRINGCONVERTER; } + + // test the type. + int canConvert(FOURCC encoding_type); + + // The return code is the number of bytes written to the output buffer, or the error. + // A return code of 0 is not an error, other than you passing NULL or a size 0 buffer won't do much interesting. + int convertToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes, char *out_buffer, int size_out_bytes); + int preflightToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes); + int convertFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes, void *out_buffer, int size_out_bytes); + int preflightFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes); + +protected: + enum { + CANCONVERT, + CONVERTTOUTF8, + PREFLIGHTTOUTF8, + CONVERTFROMUTF8, + PREFLIGHTFROMUTF8 + }; +}; + + +inline +int svc_stringConverter::canConvert(FOURCC encoding_type) { + return _call(CANCONVERT, (int)0, encoding_type); +} + +inline +int svc_stringConverter::convertToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes, char *out_buffer, int size_out_bytes) { + return _call(CONVERTTOUTF8, (int)0, encoding_type, in_buffer, size_in_bytes, out_buffer, size_out_bytes); +} + +inline +int svc_stringConverter::preflightToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes) { + return _call(PREFLIGHTTOUTF8, (int)0, encoding_type, in_buffer, size_in_bytes); +} + +inline +int svc_stringConverter::convertFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes, void *out_buffer, int size_out_bytes) { + return _call(CONVERTFROMUTF8, (int)0, encoding_type, in_buffer, size_in_bytes, out_buffer, size_out_bytes); +} + +inline +int svc_stringConverter::preflightFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes) { + return _call(PREFLIGHTFROMUTF8, (int)0, encoding_type, in_buffer, size_in_bytes); +} + +// implementor derives from this one +class NOVTABLE svc_stringConverterI : public svc_stringConverter { +public: + + // test the type + virtual int canConvert(FOURCC encoding_type) = 0; + + virtual int convertToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes, char *out_buffer, int size_out_bytes) = 0; + virtual int preflightToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes) = 0; + virtual int convertFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes, void *out_buffer, int size_out_bytes) = 0; + virtual int preflightFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes) = 0; + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/svc_enum.h> + +class StringConverterEnum : public SvcEnumT<svc_stringConverter> { +public: + StringConverterEnum(FOURCC enc_type) : encoding_type(enc_type) {} +protected: + virtual int testService(svc_stringConverter *svc) { + return (svc->canConvert(encoding_type)); + } +private: + FOURCC encoding_type; +}; + +#endif // _SVC_STRINGCONVERTER_H diff --git a/Src/Wasabi/api/service/svcs/svc_stringtypes.h b/Src/Wasabi/api/service/svcs/svc_stringtypes.h new file mode 100644 index 00000000..bff5cf9f --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_stringtypes.h @@ -0,0 +1,35 @@ +#ifndef _SVC_STRINGTYPES_H +#define _SVC_STRINGTYPES_H + +// Here, you look like you're in need of some error codes. +namespace SvcStrCnv { + typedef enum { + // The conversion failed for some generic 'fatal' reason, not covered by the + // other reasons below. (Possibly a bug in the service implementation). + ERROR_FATAL = -1, + + // The conversion failed because your output buffer was too small. + ERROR_BUFFER_OVERRUN = -2, + + // The conversion failed because your input string had unrecoverable errors in it + ERROR_INPUT = -3, + + // The service instance does not support that type of encoding for conversion + ERROR_INVALID = -4, + + // The service instance isn't available (ONLY generated by EncodedStr.cpp, obviously) + ERROR_UNAVAILABLE = -5, + + } ConvertErrors; + + // These types MUST be supported by the platform port for this service. + typedef enum { + OSNATIVE=MK4CC('n','a','t','v'), + UTF16=MK4CC('u','-','1','6'), + } EncodingTypes; + // Other service instances may implement other encoding types. + // They all should provide their own FOURCC #define or enum in their headers. +} + + +#endif // _SVC_STRINGTYPES_H diff --git a/Src/Wasabi/api/service/svcs/svc_textfeed.cpp b/Src/Wasabi/api/service/svcs/svc_textfeed.cpp new file mode 100644 index 00000000..7ede4ce4 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_textfeed.cpp @@ -0,0 +1,18 @@ +#include <precomp.h> + +#include "svc_textfeed.h" +#include <bfc/depend.h> + +#define CBCLASS svc_textFeedI +START_DISPATCH; + CB(SVCTEXTFEED_HASFEED, hasFeed); + CB(SVCTEXTFEED_GETFEEDTEXT, getFeedText); + CB(SVCTEXTFEED_GETFEEDDESC, getFeedDescription); + CB(SVCTEXTFEED_GETDEPENDENCYPTR, getDependencyPtr); +END_DISPATCH; +#undef CBCLASS + +void *svc_textFeedI::dependent_getInterface(const GUID *classguid) { + HANDLEGETINTERFACE(svc_textFeed); + return NULL; +} diff --git a/Src/Wasabi/api/service/svcs/svc_textfeed.h b/Src/Wasabi/api/service/svcs/svc_textfeed.h new file mode 100644 index 00000000..c37754f7 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_textfeed.h @@ -0,0 +1,21 @@ +#ifndef _SVC_TEXTFEED_H +#define _SVC_TEXTFEED_H + +//#include <api/service/services.h> +#include <api/skin/feeds/api_textfeed.h> + +class NOVTABLE svc_textFeedI : public svc_textFeed +{ +public: + virtual int hasFeed(const wchar_t *name) = 0; + virtual const wchar_t *getFeedText(const wchar_t *name) = 0; + virtual const wchar_t *getFeedDescription(const wchar_t *name) = 0; + virtual api_dependent *getDependencyPtr() = 0; + virtual void *dependent_getInterface(const GUID *classguid); //implemented for you + +protected: + RECVS_DISPATCH; +}; + + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_tooltips.cpp b/Src/Wasabi/api/service/svcs/svc_tooltips.cpp new file mode 100644 index 00000000..f42f7fed --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_tooltips.cpp @@ -0,0 +1,10 @@ +#include <precomp.h> +#include "svc_tooltips.h" + +#define CBCLASS svc_toolTipsRendererI +START_DISPATCH; + CB(SPAWNTOOLTIP, spawnTooltip); +END_DISPATCH; +#undef CBCLASS + + diff --git a/Src/Wasabi/api/service/svcs/svc_tooltips.h b/Src/Wasabi/api/service/svcs/svc_tooltips.h new file mode 100644 index 00000000..c3591146 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_tooltips.h @@ -0,0 +1,30 @@ +#ifndef _SVC_TOOLTIPS_H +#define _SVC_TOOLTIPS_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class NOVTABLE svc_toolTipsRenderer : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::TOOLTIPSRENDERER; } + + int spawnTooltip(const wchar_t *text); + + enum { + SPAWNTOOLTIP =10, + }; +}; + +inline int svc_toolTipsRenderer::spawnTooltip(const wchar_t *text) { + return _call(SPAWNTOOLTIP, 0, text); +} + +class NOVTABLE svc_toolTipsRendererI : public svc_toolTipsRenderer { +public: + virtual int spawnTooltip(const wchar_t *text)=0; + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_wndcreate.cpp b/Src/Wasabi/api/service/svcs/svc_wndcreate.cpp new file mode 100644 index 00000000..168e7a2f --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_wndcreate.cpp @@ -0,0 +1,16 @@ +#include <precomp.h> + +#include "svc_wndcreate.h" + +#define CBCLASS svc_windowCreateI +START_DISPATCH; + CB(TESTGUID, testGuid); + CB(CREATEWINDOWBYGUID, createWindowByGuid); + CB(TESTTYPE, testType); + CB(CREATEWINDOWOFTYPE, createWindowOfType); + CB(DESTROYWINDOW, destroyWindow); + CB(REFCOUNT, refcount); +END_DISPATCH; +#undef CBCLASS + + diff --git a/Src/Wasabi/api/service/svcs/svc_wndcreate.h b/Src/Wasabi/api/service/svcs/svc_wndcreate.h new file mode 100644 index 00000000..95e46f89 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_wndcreate.h @@ -0,0 +1,120 @@ +#ifndef _SVC_WNDCREATE_H +#define _SVC_WNDCREATE_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +#define BUCKETITEM L"buck" +#define PLAYLISTSIDECAR L"plsc" + +class ifc_window; + +class NOVTABLE svc_windowCreate : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::WINDOWCREATE; } + + int testGuid(GUID g); + ifc_window *createWindowByGuid(GUID g, ifc_window *parent); + int testType(const wchar_t *windowtype); + ifc_window *createWindowOfType(const wchar_t *windowtype, ifc_window *parent, int n = 0); + int destroyWindow(ifc_window *w); + + int refcount(); // how many windows created + + enum { + TESTGUID = 100, + CREATEWINDOWBYGUID = 200, + TESTTYPE = 301, + CREATEWINDOWOFTYPE = 402, + DESTROYWINDOW = 500, + REFCOUNT = 600, + }; +}; + +inline int svc_windowCreate::testGuid(GUID g) +{ + return _call(TESTGUID, 0, g); +} + +inline ifc_window *svc_windowCreate::createWindowByGuid(GUID g, ifc_window *parent) +{ + return _call(CREATEWINDOWBYGUID, (ifc_window*)0, g, parent); +} + +inline int svc_windowCreate::destroyWindow(ifc_window *w) +{ + return _call(DESTROYWINDOW, 0, w); +} + +inline int svc_windowCreate::testType(const wchar_t *windowtype) +{ + return _call(TESTTYPE, 0, windowtype); +} + +inline ifc_window *svc_windowCreate::createWindowOfType(const wchar_t * windowtype, ifc_window *parent, int n) +{ + return _call(CREATEWINDOWOFTYPE, (ifc_window*)0, windowtype, parent, n); +} + +inline int svc_windowCreate::refcount() +{ + return _call(REFCOUNT, -1); +} + +class NOVTABLE svc_windowCreateI : public svc_windowCreate +{ +public: + virtual ~svc_windowCreateI() { } + virtual int testGuid(GUID g) { return 0; } + virtual ifc_window *createWindowByGuid(GUID g, ifc_window *parent) { return NULL; } + virtual int testType(const wchar_t *windowtype) { return 0; } + virtual ifc_window *createWindowOfType(const wchar_t *windowtype, ifc_window *parent, int n) { return NULL; } + virtual int destroyWindow(ifc_window *w) = 0; + + virtual int refcount() { return -1; } // FUCKO: make pure abstract + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/servicei.h> +template <class T> +class WndCreateCreator : public waServiceFactoryT<svc_windowCreate, T> {}; + +template <class T> +class WndCreateCreatorSingle : public waServiceFactoryTSingle<svc_windowCreate, T> {}; + +#include <api/service/svc_enum.h> +#include <bfc/string/StringW.h> + +class WindowCreateByGuidEnum : public SvcEnumT<svc_windowCreate> +{ +public: + WindowCreateByGuidEnum(GUID _g) : targetguid(_g) { } + +protected: + virtual int testService(svc_windowCreate *svc) + { + return svc->testGuid(targetguid); + } + +private: + GUID targetguid; +}; + +class WindowCreateByTypeEnum : public SvcEnumT<svc_windowCreate> +{ +public: + WindowCreateByTypeEnum(const wchar_t *_wtype) : wtype(_wtype) { } + +protected: + virtual int testService(svc_windowCreate *svc) + { + return svc->testType(wtype); + } + +private: + StringW wtype; +}; +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_xmlprov.cpp b/Src/Wasabi/api/service/svcs/svc_xmlprov.cpp new file mode 100644 index 00000000..b84826eb --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_xmlprov.cpp @@ -0,0 +1,10 @@ +#include <precomp.h> + +#include "svc_xmlprov.h" + +#define CBCLASS svc_xmlProviderI +START_DISPATCH; + CB(TESTDESC, testDesc); + CB(GETXMLDATA, getXmlData); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_xmlprov.h b/Src/Wasabi/api/service/svcs/svc_xmlprov.h new file mode 100644 index 00000000..d6c27f01 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_xmlprov.h @@ -0,0 +1,56 @@ +#ifndef _SVC_XMLPROVIDER_H +#define _SVC_XMLPROVIDER_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> + +class skin_xmlreaderparams; + +class NOVTABLE svc_xmlProvider : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::XMLPROVIDER; } + + int testDesc(const wchar_t *desc); + const wchar_t *getXmlData(const wchar_t *desc, const wchar_t *incpath, skin_xmlreaderparams *params=NULL); + + enum { + TESTDESC=10, + GETXMLDATA=20, + }; +}; + +inline int svc_xmlProvider::testDesc(const wchar_t *desc) { + return _call(TESTDESC, 0, desc); +} + +inline const wchar_t *svc_xmlProvider::getXmlData(const wchar_t *desc, const wchar_t *incpath, skin_xmlreaderparams *params) { + return _call(GETXMLDATA, (const wchar_t *)0, desc, incpath, params); +} + +// derive from this one +class NOVTABLE svc_xmlProviderI : public svc_xmlProvider { +public: + virtual int testDesc(const wchar_t *desc)=0; + virtual const wchar_t *getXmlData(const wchar_t *desc, const wchar_t *incpath, skin_xmlreaderparams *params=NULL)=0; + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/svc_enum.h> +#include <bfc/string/StringW.h> + +class XmlProviderEnum : public SvcEnumT<svc_xmlProvider> { +public: + XmlProviderEnum(const wchar_t *_desc) : desc(_desc) { } + +protected: + virtual int testService(svc_xmlProvider *svc) { + return svc->testDesc(desc); + } + +private: + StringW desc; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_xuiobject.cpp b/Src/Wasabi/api/service/svcs/svc_xuiobject.cpp new file mode 100644 index 00000000..52973975 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_xuiobject.cpp @@ -0,0 +1,12 @@ +#include <precomp.h> + +#include "svc_xuiobject.h" + +#define CBCLASS svc_xuiObjectI +START_DISPATCH; + CB(XUI_TESTTAG, testTag); +// CB(XUI_INSTANTIATE, instantiate); + CB(XUI_INSTANTIATEWITHPARAMS, instantiate); + VCB(XUI_DESTROY, destroy); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_xuiobject.h b/Src/Wasabi/api/service/svcs/svc_xuiobject.h new file mode 100644 index 00000000..de825b5b --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_xuiobject.h @@ -0,0 +1,76 @@ +#ifndef _SVC_XUIOBJECT_H +#define _SVC_XUIOBJECT_H + +#include <bfc/dispatch.h> +#include <api/service/services.h> +#include <bfc/platform/platform.h> +#include <bfc/string/StringW.h> +class GuiObject; +class skin_xmlreaderparams; + +class NOVTABLE svc_xuiObject : public Dispatchable +{ +public: + static FOURCC getServiceType() + { + return WaSvc::XUIOBJECT; + } + int testTag( const wchar_t *xmltag ); + GuiObject *instantiate( const wchar_t *xmltag, ifc_xmlreaderparams *params = NULL ); + void destroy( GuiObject *g ); + + enum + { + XUI_TESTTAG = 10, + //XUI_INSTANTIATE=20, // RETIRED + XUI_INSTANTIATEWITHPARAMS = 25, + XUI_DESTROY = 30, + }; +}; + +inline int svc_xuiObject::testTag(const wchar_t *xmltag) { + return _call(XUI_TESTTAG, 0, xmltag); +} + +inline GuiObject *svc_xuiObject::instantiate(const wchar_t *xmltag, ifc_xmlreaderparams *params) { + return _call(XUI_INSTANTIATEWITHPARAMS, (GuiObject *)NULL, xmltag, params); +} + +inline void svc_xuiObject::destroy(GuiObject *o) { + _voidcall(XUI_DESTROY, o); +} + +// derive from this one +class svc_xuiObjectI : public svc_xuiObject +{ +public: + virtual int testTag(const wchar_t *xmltag)=0; + virtual GuiObject *instantiate(const wchar_t *xmltag, ifc_xmlreaderparams *params=NULL)=0; + virtual void destroy(GuiObject *o)=0; + +protected: + RECVS_DISPATCH; +}; + +#include <api/service/servicei.h> +template <class T> +class XuiObjectCreator : public waServiceFactoryTSingle<svc_xuiObject, T> { +public: + virtual const wchar_t *svc_getTestString() { return T::xuisvc_getXmlTag(); } +}; + +#include <api/service/svc_enum.h> +#include <bfc/string/StringW.h> + +class XuiObjectSvcEnum : public SvcEnumT<svc_xuiObject> { +public: + XuiObjectSvcEnum(const wchar_t *xmltag) : tag(xmltag) {} +protected: + virtual int testService(svc_xuiObject *svc) { + return (svc->testTag(tag)); + } +private: + StringW tag; +}; + +#endif diff --git a/Src/Wasabi/api/service/waservicefactory.cpp b/Src/Wasabi/api/service/waservicefactory.cpp new file mode 100644 index 00000000..7ed88b65 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactory.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:57:16 2003] +// +// File : waservicefactory.cpp +// Class : waServiceFactory +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include <precomp.h> +#include "waservicefactory.h" + + diff --git a/Src/Wasabi/api/service/waservicefactory.h b/Src/Wasabi/api/service/waservicefactory.h new file mode 100644 index 00000000..88a72104 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactory.h @@ -0,0 +1,109 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:57:16 2003] +// +// File : waservicefactory.h +// Class : waServiceFactory +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __WASERVICEFACTORY_H +#define __WASERVICEFACTORY_H + +#include <bfc/dispatch.h> +#include <bfc/nsguid.h> +#include "api_service.h" +// ---------------------------------------------------------------------------- + +class NOVTABLE waServiceFactory : public Dispatchable +{ +protected: + waServiceFactory() throw( ) {} + ~waServiceFactory() {} + +public: + FOURCC getServiceType(); + const char *getServiceName(); + GUID getGuid(); + const wchar_t *getTestString(); + + void *getInterface( int global_lock = TRUE ); + int releaseInterface( void *ifc ); + + int supportNonLockingGetInterface(); + int serviceNotify( int msg, intptr_t param1 = 0, intptr_t param2 = 0 ); + +protected: + enum + { + WASERVICEFACTORY_GETSERVICETYPE = 100, + WASERVICEFACTORY_GETSERVICENAME = 200, + WASERVICEFACTORY_GETGUID = 210, + WASERVICEFACTORY_GETINTERFACE = 300, + WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE = 301, + WASERVICEFACTORY_RELEASEINTERFACE = 310, + WASERVICEFACTORY_GETTESTSTRING = 500, + WASERVICEFACTORY_SERVICENOTIFY = 600, + }; +}; + +// ---------------------------------------------------------------------------- + +inline FOURCC waServiceFactory::getServiceType() +{ + FOURCC __retval = _call( WASERVICEFACTORY_GETSERVICETYPE, (FOURCC)NULL ); + return __retval; +} + +inline const char *waServiceFactory::getServiceName() +{ + const char *__retval = _call( WASERVICEFACTORY_GETSERVICENAME, (const char *)0 ); + return __retval; +} + +inline GUID waServiceFactory::getGuid() +{ + GUID __retval = _call( WASERVICEFACTORY_GETGUID, INVALID_GUID ); + return __retval; +} + +inline const wchar_t *waServiceFactory::getTestString() +{ + return _call( WASERVICEFACTORY_GETTESTSTRING, (const wchar_t *)0 ); +} + + +inline void *waServiceFactory::getInterface( int global_lock ) +{ + void *__retval = _call( WASERVICEFACTORY_GETINTERFACE, (void *)NULL, global_lock ); + +#if 0 // unused in Winamp 5 + // -- generated code - edit in waservicefactoryi.h + // support old code that always locks even when global_lock==FALSE + if ( !global_lock && __retval != NULL && !supportNonLockingGetInterface() ) + WASABI_API_SVC->service_unlock( __retval ); +#endif + return __retval; +} + +inline int waServiceFactory::releaseInterface( void *ifc ) +{ + int __retval = _call( WASERVICEFACTORY_RELEASEINTERFACE, (int)0, ifc ); + return __retval; +} + + +inline int waServiceFactory::supportNonLockingGetInterface() +{ + int __retval = _call( WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, (int)0 ); + return __retval; +} + +inline int waServiceFactory::serviceNotify( int msg, intptr_t param1, intptr_t param2 ) +{ + int __retval = _call( WASERVICEFACTORY_SERVICENOTIFY, (int)0, msg, param1, param2 ); + return __retval; +} + +// ---------------------------------------------------------------------------- + +#endif // __WASERVICEFACTORY_H diff --git a/Src/Wasabi/api/service/waservicefactorybase.cpp b/Src/Wasabi/api/service/waservicefactorybase.cpp new file mode 100644 index 00000000..793842b3 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactorybase.cpp @@ -0,0 +1,5 @@ +#include <precomp.h> +//<?#include "<class data="implementationheader"/>" +#include "waservicefactorybase.h" +//?> + diff --git a/Src/Wasabi/api/service/waservicefactorybase.h b/Src/Wasabi/api/service/waservicefactorybase.h new file mode 100644 index 00000000..19c9c56d --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactorybase.h @@ -0,0 +1,76 @@ +#ifndef __WASERVICEFACTORYBASE_IMPL_H +#define __WASERVICEFACTORYBASE_IMPL_H + +/*<?<autoheader/>*/ +class CfgItem; +/*?>*/ + +#include "waservicefactoryi.h" + +template <class SERVICETYPE, class SERVICE> +class NOVTABLE waServiceFactoryBaseX : public waServiceFactoryI { +public: + waServiceFactoryBaseX(GUID myGuid = INVALID_GUID) : guid(myGuid) {} + virtual FOURCC svc_serviceType()=0; + virtual const char *svc_getServiceName() { return SERVICE::getServiceName(); } + virtual GUID svc_getGuid() { return guid; } + virtual void *svc_getInterfaceAndLock() {// this is only for back compat + return getInterface(TRUE); + } + + virtual void *svc_getInterface(int global_lock)=0; + virtual int svc_releaseInterface(void *ptr)=0; + + virtual CfgItem *svc_getCfgInterface() { return NULL; } + virtual const wchar_t *svc_getTestString() { return NULL; } + + virtual int svc_notify(int msg, int param1 = 0, int param2 = 0) { return 0; } + +private: + GUID guid; +}; + +// if you derive from this, all you have to do is override the newService() +// and delService() methods... if all you need to do is instantiate a class +// and destroy it use the helper below (waServiceFactoryT) +template <class SERVICETYPE, class SERVICE> +class NOVTABLE waServiceFactoryBase : public waServiceFactoryBaseX<SERVICETYPE, SERVICE> { +public: + waServiceFactoryBase(GUID myGuid = INVALID_GUID) : waServiceFactoryBaseX<SERVICETYPE, SERVICE>(myGuid) {} + virtual FOURCC svc_serviceType() { return SERVICETYPE::getServiceType(); } + virtual void *svc_getInterface(int global_lock) { // new style, client optionally does the locking + SERVICETYPE *ret = newService(); + if (global_lock) WASABI_API_SVC->service_lock(this, ret); + return ret; + } + virtual int svc_releaseInterface(void *ptr) { + return delService(static_cast<SERVICE*>(static_cast<SERVICETYPE*>(ptr))); + } +protected: + virtual SERVICETYPE *newService()=0; + virtual int delService(SERVICETYPE *service)=0; +}; + +// and this one just exposes a service pointer, without factory. note that +// SERVICETYPE and SERVICE do not have to be related (unlike waServiceFactoryBase +// who needs a relationship between the classes in releaseInterface) +template <class SERVICETYPE, class SERVICE> +class NOVTABLE waServiceBase : public waServiceFactoryBaseX<SERVICETYPE, SERVICE> { +public: + waServiceBase(GUID myGuid = INVALID_GUID) : waServiceFactoryBaseX<SERVICETYPE, SERVICE>(myGuid) {} + virtual FOURCC svc_serviceType() { return SERVICE::getServiceType(); } + virtual void *svc_getInterface(int global_lock) { // new style, client optionally does the locking + SERVICETYPE *ret = getService(); + if (global_lock) WASABI_API_SVC->service_lock(this, ret); + return ret; + } + virtual int svc_releaseInterface(void *ptr) { + return TRUE; + } +protected: + virtual SERVICETYPE *getService()=0; +}; + + + +#endif // __WASERVICEFACTORYBASE_IMPL_H diff --git a/Src/Wasabi/api/service/waservicefactoryi.cpp b/Src/Wasabi/api/service/waservicefactoryi.cpp new file mode 100644 index 00000000..18ad97dd --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryi.cpp @@ -0,0 +1,2 @@ +#include <precomp.h> +#include <api/service/servicei.h> diff --git a/Src/Wasabi/api/service/waservicefactoryi.h b/Src/Wasabi/api/service/waservicefactoryi.h new file mode 100644 index 00000000..28d0b846 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryi.h @@ -0,0 +1,73 @@ +#ifndef __WASERVICEFACTORY_IMPL_H +#define __WASERVICEFACTORY_IMPL_H + +/*<?<autoheader/>*/ +#include "waservicefactory.h" +#include "waservicefactoryx.h" + +class CfgItem; +/*?>*/ +/*[interface.header.h] +#include "common/nsguid.h" +#include "studio/api.h" +*/ + +// this is a wasabi service factory. it's a static object you can query to +// fetch the * to your real service interface +class NOVTABLE waServiceFactoryI : public waServiceFactoryX { +public: + virtual ~waServiceFactoryI() {} +protected: +/*[interface.x_getServiceType.h] + public: +*/ + DISPATCH(100) virtual FOURCC x_getServiceType() { return svc_serviceType(); } // see services.h + DISPATCH(200) virtual const char *x_getServiceName() { return svc_getServiceName(); } + DISPATCH(210) virtual GUID getGuid() { return svc_getGuid(); } // GUID per service factory, can be INVALID_GUID +/** + Fetches a pointer to an instance of the service. Optionally locks it into the + global table, so that it can be safely released via service_release() + @see ComponentAPI::service_release() + @param global_lock If TRUE, calls service_lock() with the service * + @see releaseInterface() +*/ +/*[dispatchable.getInterface.postcall] + // -- generated code - edit in waservicefactoryi.h + // support old code that always locks even when global_lock==FALSE + if (!global_lock && __retval != NULL && !supportNonLockingGetInterface()) + WASABI_API_SVC->service_unlock(__retval); +*/ + DISPATCH(300) virtual void *getInterface(int global_lock = TRUE) { return svc_getInterface(global_lock); } + DISPATCH(300) virtual void *_RETIRED_getInterface() { return getInterface(); } // for back compat + DISPATCH(301) virtual int supportNonLockingGetInterface() { return svc_supportNonLockingGetInterface(); } + +/** + Releases a pointer to an instance of the service. Call this when you're done + with a service interface. Do NOT just call delete on it! Only the original + service factory can safely delete it. Also, do not pass in any pointers + that were not allocated from this factory. + @see getInterface() + @ret TRUE if no error, FALSE if error. +*/ + DISPATCH(310) virtual int releaseInterface(void *ifc) { return svc_releaseInterface(ifc); } // when they're done w/ it + +/** + Fetches a string for optional quick lookup of a service factory. This string + is defined on a service family type basis. e.g. the xuitag for xuicreators. +*/ + DISPATCH(500) virtual const wchar_t *getTestString() { return svc_getTestString(); } + DISPATCH(600) virtual int serviceNotify(int msg, int param1 = 0, int param2 = 0) { return svc_notify(msg, param1, param2); } +public: + + NODISPATCH virtual FOURCC svc_serviceType()=0; // see services.h + NODISPATCH virtual const char *svc_getServiceName()=0; + NODISPATCH virtual GUID svc_getGuid()=0; // GUID per service factory, can be INVALID_GUID + NODISPATCH virtual void *svc_getInterface(int global_lock = TRUE)=0; + NODISPATCH virtual int svc_supportNonLockingGetInterface() { return TRUE; } + NODISPATCH virtual int svc_releaseInterface(void *ifc)=0; // when they're done w/ it + NODISPATCH virtual CfgItem *svc_getCfgInterface()=0; + NODISPATCH virtual const wchar_t *svc_getTestString()=0; + NODISPATCH virtual int svc_notify(int msg, int param1 = 0, int param2 = 0)=0; +}; + +#endif // __WASERVICEFACTORY_IMPL_H diff --git a/Src/Wasabi/api/service/waservicefactoryt.cpp b/Src/Wasabi/api/service/waservicefactoryt.cpp new file mode 100644 index 00000000..fdab05e0 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryt.cpp @@ -0,0 +1,5 @@ +#include <precomp.h> +//<?#include "<class data="implementationheader"/>" +#include "waservicefactoryt.h" +//?> + diff --git a/Src/Wasabi/api/service/waservicefactoryt.h b/Src/Wasabi/api/service/waservicefactoryt.h new file mode 100644 index 00000000..f2cc6e67 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryt.h @@ -0,0 +1,28 @@ +#ifndef __WASERVICEFACTORYT_IMPL_H +#define __WASERVICEFACTORYT_IMPL_H + +/*<?<autoheader/>*/ +/*?>*/ + +#include "waservicefactorybase.h" + +// this is a service factory template that will manufacture any number +// of a given class SERVICE, which is derived from service class SERVICETYPE +template <class SERVICETYPE, class SERVICE> +class waServiceFactoryT : public waServiceFactoryBase<SERVICETYPE, SERVICE> { +public: + waServiceFactoryT(GUID myGuid = INVALID_GUID) : + waServiceFactoryBase<SERVICETYPE, SERVICE>(myGuid) {} + virtual SERVICETYPE *newService() { + SERVICE *ret = new SERVICE; + ASSERT(ret != NULL); + return ret; + } + virtual int delService(SERVICETYPE *service) { + ASSERT(service != NULL); + delete static_cast<SERVICE*>(service); + return 1; + } +}; + +#endif // __WASERVICEFACTORYT_IMPL_H diff --git a/Src/Wasabi/api/service/waservicefactorytsingle.cpp b/Src/Wasabi/api/service/waservicefactorytsingle.cpp new file mode 100644 index 00000000..358de389 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactorytsingle.cpp @@ -0,0 +1,5 @@ +#include <precomp.h> +//<?#include "<class data="implementationheader"/>" +#include "waservicefactorytsingle.h" +//?> + diff --git a/Src/Wasabi/api/service/waservicefactorytsingle.h b/Src/Wasabi/api/service/waservicefactorytsingle.h new file mode 100644 index 00000000..3a3a8d2f --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactorytsingle.h @@ -0,0 +1,47 @@ +#ifndef __WASERVICEFACTORYTSINGLE_IMPL_H +#define __WASERVICEFACTORYTSINGLE_IMPL_H + +/*<?<autoheader/>*/ +/*?>*/ + +#include "waservicefactorybase.h" + +#include <bfc/bfc_assert.h> + +// this is a service factory template that holds one copy of a class +// and reissues the pointer as needed, with reference counting +template <class SERVICETYPE, class SERVICE> +class waServiceFactoryTSingle : public waServiceFactoryBase<SERVICETYPE, SERVICE> { +public: + waServiceFactoryTSingle(GUID myGuid = INVALID_GUID) : + refcount(0), waServiceFactoryBase<SERVICETYPE, SERVICE>(myGuid) { + singleService = new SERVICE; + } + waServiceFactoryTSingle(SERVICE *svc, GUID myGuid = INVALID_GUID) : + singleService(svc), refcount(0), + waServiceFactoryBase<SERVICETYPE, SERVICE>(myGuid) { } + ~waServiceFactoryTSingle() { + delete singleService; + } + virtual SERVICETYPE *newService() { + ASSERT(singleService != NULL); + refcount++; + return singleService; + } + virtual int delService(SERVICETYPE *service) { + ASSERT(static_cast<SERVICE*>(service) == singleService); + refcount--; + ASSERT(refcount >= 0); + return 1; + } + + SERVICE *getSingleService() { return singleService; } + +private: + SERVICE * singleService; + int refcount; +}; + + + +#endif // __WASERVICEFACTORYTSINGLE_IMPL_H diff --git a/Src/Wasabi/api/service/waservicefactoryx.cpp b/Src/Wasabi/api/service/waservicefactoryx.cpp new file mode 100644 index 00000000..5853b833 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryx.cpp @@ -0,0 +1,32 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:57:16 2003] +// +// File : waservicefactoryx.cpp +// Class : waServiceFactory +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include <precomp.h> + +#include "waservicefactoryx.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS waServiceFactoryX +START_DISPATCH; + CB(WASERVICEFACTORY_GETSERVICETYPE, x_getServiceType); + CB(WASERVICEFACTORY_GETSERVICENAME, x_getServiceName); + CB(WASERVICEFACTORY_GETGUID, getGuid); + case WASERVICEFACTORY_GETINTERFACE: + switch (nparam) { + default: cb<CBCLASS>(&CBCLASS::getInterface, retval, params); break; + case 0: cb<CBCLASS>(&CBCLASS::_RETIRED_getInterface, retval, params); break; + } + break; + CB(WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, supportNonLockingGetInterface); + CB(WASERVICEFACTORY_RELEASEINTERFACE, releaseInterface); + CB(WASERVICEFACTORY_GETTESTSTRING, getTestString); + CB(WASERVICEFACTORY_SERVICENOTIFY, serviceNotify); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/waservicefactoryx.h b/Src/Wasabi/api/service/waservicefactoryx.h new file mode 100644 index 00000000..dd00a241 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryx.h @@ -0,0 +1,37 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:57:16 2003] +// +// File : waservicefactoryx.h +// Class : waServiceFactory +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __WASERVICEFACTORYX_H +#define __WASERVICEFACTORYX_H + +#include "waservicefactory.h" + +// ---------------------------------------------------------------------------- + +class NOVTABLE waServiceFactoryX : public waServiceFactory { + protected: + waServiceFactoryX() {} + protected: + + public: + + virtual FOURCC x_getServiceType()=0; + virtual const char *x_getServiceName()=0; + virtual GUID getGuid()=0; + virtual void *getInterface(int global_lock = TRUE)=0; + virtual void *_RETIRED_getInterface()=0; + virtual int supportNonLockingGetInterface()=0; + virtual int releaseInterface(void *ifc)=0; + virtual const wchar_t *getTestString()=0; + virtual int serviceNotify(int msg, int param1 = 0, int param2 = 0)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __WASERVICEFACTORYX_H |