Confirmed the brightness command applies globally, not per-LED
(serverinfo showed exactly one adjustment object, "id": "default",
covering the whole string), so no LED-count configuration is needed
for this at all -- that question resolved itself once the mechanism
was actually inspected instead of assumed.
For "only react while Spotify is running": only one app can be in the
foreground on webOS at a time, so a "capture the current app" button
in this app's own UI can never work -- pressing it means this app is
foreground, not Spotify. The only workable UI is picking a target from
every *installed* app by name, regardless of what's currently running.
That needed a new native capability this service never had: calling
OUT to another Luna service, not just being called. Two additions:
foreground_app.c subscribes once, at startup, to
com.webos.applicationManager/getForegroundAppInfo
and keeps a thread-safe cache the audio thread can
read without a blocking Luna call
service.c new listApps method, bridging to
com.webos.applicationManager/listApps so the
frontend never has to call another service
directly -- same rule as everywhere else here
Until the subscription has delivered at least one reply, a restricted
sink treats the target app as inactive, not active -- reacting to
audio when the user explicitly restricted it to one app would be the
wrong failure mode. Verified end to end on the host: engine_smoke.c
opens the sink with a restriction set, confirms it reports itself
correctly inactive against the stub Luna bus (which always "fails" to
call out, exactly like a real host with no bus).
Needed real, linkable stub bodies for LSCall/LSCallOneReply/
LSCallCancel/LSMessageGetPayload/LSErrorInit/LSErrorFree
(test/stubs/luna-service2/lunaservice_stub.c) since foreground_app.c
is the first source file here that's actually linked into a host test
binary rather than only syntax-checked -- service.c/main.c's existing
stub declarations were never called, only compiled against. Confirmed
those really are the correct symbol names by cross-compiling clean
against the real webOS SDK's actual libluna-service2, not just the
stub.
Bumped to 1.0.5.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
77 lines
2.6 KiB
C
77 lines
2.6 KiB
C
// Minimal luna-service2 stand-in for host-side syntax checks. Mirrors the
|
|
// signatures this project calls, so a typo or a wrong argument count is caught
|
|
// without a webOS SDK. See ../glib.h.
|
|
#pragma once
|
|
|
|
#include <glib.h>
|
|
#include <stdbool.h>
|
|
|
|
typedef struct LSHandle LSHandle;
|
|
typedef struct LSMessage LSMessage;
|
|
|
|
typedef struct {
|
|
int error_code;
|
|
char* message;
|
|
const char* file;
|
|
int line;
|
|
const char* func;
|
|
void* padding;
|
|
unsigned long magic;
|
|
} LSError;
|
|
|
|
typedef bool (*LSMethodFunction)(LSHandle* sh, LSMessage* msg, void* category_context);
|
|
typedef bool (*LSFilterFunc)(LSHandle* sh, LSMessage* reply, void* ctx);
|
|
typedef unsigned long LSMessageToken;
|
|
|
|
typedef enum {
|
|
LUNA_METHOD_FLAGS_NONE = 0,
|
|
} LSMethodFlags;
|
|
|
|
typedef struct {
|
|
const char* name;
|
|
LSMethodFunction function;
|
|
LSMethodFlags flags;
|
|
} LSMethod;
|
|
|
|
typedef struct {
|
|
const char* name;
|
|
void* function;
|
|
unsigned int flags;
|
|
} LSSignal;
|
|
|
|
typedef struct {
|
|
const char* name;
|
|
void* function;
|
|
unsigned int flags;
|
|
} LSProperty;
|
|
|
|
void LSErrorInit(LSError* error);
|
|
void LSErrorFree(LSError* error);
|
|
|
|
bool LSRegister(const char* name, LSHandle** handle, LSError* error);
|
|
bool LSUnregister(LSHandle* handle, LSError* error);
|
|
|
|
bool LSRegisterCategory(LSHandle* handle, const char* category, LSMethod* methods,
|
|
LSSignal* signals, LSProperty* properties, LSError* error);
|
|
bool LSCategorySetData(LSHandle* handle, const char* category, void* user_data, LSError* error);
|
|
|
|
bool LSGmainAttach(LSHandle* handle, GMainLoop* loop, LSError* error);
|
|
|
|
const char* LSMessageGetPayload(LSMessage* message);
|
|
bool LSMessageIsSubscription(LSMessage* message);
|
|
bool LSMessageReply(LSHandle* sh, LSMessage* message, const char* reply, LSError* error);
|
|
void LSMessageRef(LSMessage* message);
|
|
void LSMessageUnref(LSMessage* message);
|
|
|
|
bool LSSubscriptionAdd(LSHandle* sh, const char* key, LSMessage* message, LSError* error);
|
|
bool LSSubscriptionReply(LSHandle* sh, const char* key, const char* payload, LSError* error);
|
|
|
|
// Client-call API: this service acting as a caller of another service, not
|
|
// just a callee. LSCall keeps calling `callback` for every reply (used for
|
|
// subscribe:true); LSCallOneReply auto-cancels after the first one.
|
|
bool LSCall(LSHandle* sh, const char* uri, const char* payload, LSFilterFunc callback,
|
|
void* ctx, LSMessageToken* ret_token, LSError* error);
|
|
bool LSCallOneReply(LSHandle* sh, const char* uri, const char* payload, LSFilterFunc callback,
|
|
void* ctx, LSMessageToken* ret_token, LSError* error);
|
|
bool LSCallCancel(LSHandle* sh, LSMessageToken token, LSError* error);
|