aboutsummaryrefslogtreecommitdiff
path: root/Src/replicant/application
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/replicant/application
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/replicant/application')
-rw-r--r--Src/replicant/application/api_application.h62
-rw-r--r--Src/replicant/application/features.h92
2 files changed, 154 insertions, 0 deletions
diff --git a/Src/replicant/application/api_application.h b/Src/replicant/application/api_application.h
new file mode 100644
index 00000000..cf353610
--- /dev/null
+++ b/Src/replicant/application/api_application.h
@@ -0,0 +1,62 @@
+#pragma once
+#include "../replicant/foundation/dispatch.h"
+#include "../replicant/foundation/error.h"
+#include "../replicant/service/types.h"
+#include "../replicant/nx/nxuri.h"
+
+// {23B96771-09D7-46d3-9AE2-20DCEA6C86EA}
+static const GUID applicationApiServiceGuid =
+{
+ 0x23b96771, 0x9d7, 0x46d3, { 0x9a, 0xe2, 0x20, 0xdc, 0xea, 0x6c, 0x86, 0xea }
+};
+
+// ----------------------------------------------------------------------------
+class api_application: public Wasabi2::Dispatchable
+{
+protected:
+ api_application() : Dispatchable(DISPATCHABLE_VERSION) {}
+ ~api_application() {}
+public:
+ static GUID GetServiceType() { return SVC_TYPE_UNIQUE; }
+ static GUID GetServiceGUID() { return applicationApiServiceGuid; }
+ const char *GetUserAgent() { return Application_GetUserAgent(); }
+
+ /* returns a path where you can store data files, if you need to */
+ int GetDataPath(nx_uri_t *path) { return Application_GetDataPath(path); }
+
+ /* checks whether or not a particular feature has permissions to operate.
+ returns NErr_True or NErr_False. see features.h for known GUIDs */
+ int GetPermission(GUID feature) { return Application_GetPermission(feature); }
+
+ /* checks whether or not a particular feature is available.
+ This only includes some features that might be absent based on OS version, hardware support, or third party dependencies
+ It's meant for code that is otherwise unable to easily check directly or via other methods (e.g. WASABI2_API_SVC->GetService)
+ returns NErr_True or NErr_False. see features.h for known GUIDs */
+ int GetFeature(GUID feature) { return Application_GetFeature(feature); }
+
+ /* used by a component to set features that are available. See notes above for GetFeature
+ for thread-safety, you should only call this during your RegisterServices() function
+ (or during application init if you are hosting Wasabi) */
+ void SetFeature(GUID feature) { Application_SetFeature(feature); }
+
+ unsigned int GetBuildNumber() { return Application_GetBuildNumber(); }
+
+ int GetVersionString(nx_string_t *version) { return Application_GetVersionString(version); }
+ int GetProductShortName(nx_string_t *name) { return Application_GetProductShortName(name); }
+ int GetDeviceID(nx_string_t *value) { return Application_GetDeviceID(value); }
+ enum
+ {
+ DISPATCHABLE_VERSION,
+ };
+protected:
+ virtual const char * Application_GetUserAgent()=0;
+ virtual int Application_GetDataPath(nx_uri_t *path)=0;
+ virtual int Application_GetPermission(GUID feature)=0;
+ virtual int Application_GetFeature(GUID feature)=0;
+ virtual void Application_SetFeature(GUID feature)=0;
+ virtual unsigned int Application_GetBuildNumber() { return 0; }
+ virtual int Application_GetVersionString(nx_string_t *version)=0;
+ virtual int Application_GetProductShortName(nx_string_t *name)=0;
+ virtual int Application_GetDeviceID(nx_string_t *value)=0;
+};
+
diff --git a/Src/replicant/application/features.h b/Src/replicant/application/features.h
new file mode 100644
index 00000000..33473b97
--- /dev/null
+++ b/Src/replicant/application/features.h
@@ -0,0 +1,92 @@
+#pragma once
+#include "foundation/types.h"
+#include "foundation/mkncc.h"
+#ifdef __cplusplus
+#include "syscb/ifc_syscallback.h"
+#endif
+/*
+This is a listing of features that can be added to Application::SetPermission and api_application::SetFeature
+or queried with api_application::GetPermission or api_application::GetFeature
+
+if you are linking from a C file, prepend application_feature_ before each of these guids
+if you are linking from a C++ file, these are in the Features namespace
+*/
+#ifdef __cplusplus
+extern "C" {
+#define FEATURE(x) x
+#define PERMISSION(x) x
+ namespace Features {
+#else
+#define FEATURE(x) application_feature_ ## x
+#define PERMISSION(x) x application_feature_ ## x
+#endif
+
+/* these gets sent via api_sysb when permissions change */
+
+// {33C86C8A-281E-4CA7-88B0-9AF9A06C486D}
+static const GUID FEATURE(event_type) =
+{ 0x33c86c8a, 0x281e, 0x4ca7, { 0x88, 0xb0, 0x9a, 0xf9, 0xa0, 0x6c, 0x48, 0x6d } };
+
+static const int FEATURE(permissions_changed) = 0;
+static const int FEATURE(features_changed) = 1;
+
+#ifdef __cplusplus
+class SystemCallback : public ifc_sysCallback
+{
+protected:
+ GUID WASABICALL SysCallback_GetEventType() { return event_type; }
+ int WASABICALL SysCallback_Notify(int msg, intptr_t param1, intptr_t param2)
+ {
+ switch(msg)
+ {
+ case permissions_changed:
+ return FeaturesSystemCallback_OnPermissionsChanged();
+ case features_changed:
+ return FeaturesSystemCallback_OnFeaturesChanged();
+ default:
+ return NErr_Success;
+ }
+ }
+ virtual int WASABICALL FeaturesSystemCallback_OnPermissionsChanged() { return NErr_Success; }
+ virtual int WASABICALL FeaturesSystemCallback_OnFeaturesChanged() { return NErr_Success; }
+};
+#endif
+
+#if 0
+// {2E9CE2F8-E26D-4629-A3FF-5DF619136B2C}
+static const GUID PERMISSION(crossfade) =
+{ 0x2e9ce2f8, 0xe26d, 0x4629, { 0xa3, 0xff, 0x5d, 0xf6, 0x19, 0x13, 0x6b, 0x2c } };
+
+// {F7CCB4E1-CD8B-4D0A-973A-0C1F15FDDAE2}
+static const GUID PERMISSION(replaygain) =
+{ 0xf7ccb4e1, 0xcd8b, 0x4d0a, { 0x97, 0x3a, 0xc, 0x1f, 0x15, 0xfd, 0xda, 0xe2 } };
+
+// {9A52404E-764D-416D-9EC9-33AA84FBA13F}
+static const GUID PERMISSION(equalizer) =
+{ 0x9a52404e, 0x764d, 0x416d, { 0x9e, 0xc9, 0x33, 0xaa, 0x84, 0xfb, 0xa1, 0x3f } };
+#endif
+// {69663D62-5EC5-4B25-B91C-65E388C85E09}
+static const GUID FEATURE(aac_playback) =
+{ 0x69663d62, 0x5ec5, 0x4b25, { 0xb9, 0x1c, 0x65, 0xe3, 0x88, 0xc8, 0x5e, 0x9 } };
+
+// {281E7D5B-3A46-4F60-9026-D3FCBFCDD2BB}
+static const GUID PERMISSION(gapless) =
+{ 0x281e7d5b, 0x3a46, 0x4f60, { 0x90, 0x26, 0xd3, 0xfc, 0xbf, 0xcd, 0xd2, 0xbb } };
+
+// {4D6A0C67-D2FF-4F81-BA4F-369AF90BE680}
+static const GUID PERMISSION(flac_playback) =
+{ 0x4d6a0c67, 0xd2ff, 0x4f81, { 0xba, 0x4f, 0x36, 0x9a, 0xf9, 0xb, 0xe6, 0x80 } };
+
+// {5599E564-400B-40EC-8393-A58D4A6BEBD9}
+static const GUID PERMISSION(gracenote_autotag) =
+{ 0x5599e564, 0x400b, 0x40ec, { 0x83, 0x93, 0xa5, 0x8d, 0x4a, 0x6b, 0xeb, 0xd9 } };
+
+// {1A9106D7-C226-4B72-9A30-E4977A519234}
+static const GUID PERMISSION(alac_playback) =
+{ 0x1a9106d7, 0xc226, 0x4b72, { 0x9a, 0x30, 0xe4, 0x97, 0x7a, 0x51, 0x92, 0x34 } };
+
+
+#ifdef __cplusplus
+}
+}
+#endif