1
0

api_application.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include "../replicant/foundation/dispatch.h"
  3. #include "../replicant/foundation/error.h"
  4. #include "../replicant/service/types.h"
  5. #include "../replicant/nx/nxuri.h"
  6. // {23B96771-09D7-46d3-9AE2-20DCEA6C86EA}
  7. static const GUID applicationApiServiceGuid =
  8. {
  9. 0x23b96771, 0x9d7, 0x46d3, { 0x9a, 0xe2, 0x20, 0xdc, 0xea, 0x6c, 0x86, 0xea }
  10. };
  11. // ----------------------------------------------------------------------------
  12. class api_application: public Wasabi2::Dispatchable
  13. {
  14. protected:
  15. api_application() : Dispatchable(DISPATCHABLE_VERSION) {}
  16. ~api_application() {}
  17. public:
  18. static GUID GetServiceType() { return SVC_TYPE_UNIQUE; }
  19. static GUID GetServiceGUID() { return applicationApiServiceGuid; }
  20. const char *GetUserAgent() { return Application_GetUserAgent(); }
  21. /* returns a path where you can store data files, if you need to */
  22. int GetDataPath(nx_uri_t *path) { return Application_GetDataPath(path); }
  23. /* checks whether or not a particular feature has permissions to operate.
  24. returns NErr_True or NErr_False. see features.h for known GUIDs */
  25. int GetPermission(GUID feature) { return Application_GetPermission(feature); }
  26. /* checks whether or not a particular feature is available.
  27. This only includes some features that might be absent based on OS version, hardware support, or third party dependencies
  28. It's meant for code that is otherwise unable to easily check directly or via other methods (e.g. WASABI2_API_SVC->GetService)
  29. returns NErr_True or NErr_False. see features.h for known GUIDs */
  30. int GetFeature(GUID feature) { return Application_GetFeature(feature); }
  31. /* used by a component to set features that are available. See notes above for GetFeature
  32. for thread-safety, you should only call this during your RegisterServices() function
  33. (or during application init if you are hosting Wasabi) */
  34. void SetFeature(GUID feature) { Application_SetFeature(feature); }
  35. unsigned int GetBuildNumber() { return Application_GetBuildNumber(); }
  36. int GetVersionString(nx_string_t *version) { return Application_GetVersionString(version); }
  37. int GetProductShortName(nx_string_t *name) { return Application_GetProductShortName(name); }
  38. int GetDeviceID(nx_string_t *value) { return Application_GetDeviceID(value); }
  39. enum
  40. {
  41. DISPATCHABLE_VERSION,
  42. };
  43. protected:
  44. virtual const char * Application_GetUserAgent()=0;
  45. virtual int Application_GetDataPath(nx_uri_t *path)=0;
  46. virtual int Application_GetPermission(GUID feature)=0;
  47. virtual int Application_GetFeature(GUID feature)=0;
  48. virtual void Application_SetFeature(GUID feature)=0;
  49. virtual unsigned int Application_GetBuildNumber() { return 0; }
  50. virtual int Application_GetVersionString(nx_string_t *version)=0;
  51. virtual int Application_GetProductShortName(nx_string_t *name)=0;
  52. virtual int Application_GetDeviceID(nx_string_t *value)=0;
  53. };