mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-10 05:59:45 -05:00
Merge from dev-FireflyShell branch
This commit is contained in:
@@ -11,6 +11,9 @@ void plugin_handler(int, int, void *, int);
|
||||
|
||||
#define PIPE_BUFFER_SIZE 4096
|
||||
|
||||
#define USE_UDP 0
|
||||
#define USE_MAILSLOT 1
|
||||
|
||||
/* Globals */
|
||||
PLUGIN_EVENT_FN _pefn = { plugin_handler };
|
||||
PLUGIN_INPUT_FN *_ppi;
|
||||
@@ -40,6 +43,7 @@ PLUGIN_INFO *plugin_info(PLUGIN_INPUT_FN *ppi) {
|
||||
return &_pi;
|
||||
}
|
||||
|
||||
#if USE_UDP
|
||||
/** NO LOG IN HERE! We'll go into an endless loop. :) */
|
||||
void plugin_handler(int event_id, int intval, void *vp, int len) {
|
||||
int total_len = 3 * sizeof(int) + len + 1;
|
||||
@@ -76,3 +80,44 @@ void plugin_handler(int event_id, int intval, void *vp, int len) {
|
||||
free(pmsg);
|
||||
return;
|
||||
}
|
||||
#endif /* USE_UDP */
|
||||
|
||||
#if USE_MAILSLOT
|
||||
#define MAILSLOT_NAME "\\\\.\\mailslot\\FireflyMediaServer--67A72768-4154-417e-BFA0-FA9B50C342DE"
|
||||
/** NO LOG IN HERE! We'll go into an endless loop. :) */
|
||||
void plugin_handler(int event_id, int intval, void *vp, int len) {
|
||||
HANDLE h = CreateFile(MAILSLOT_NAME, GENERIC_WRITE,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (h != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD bytes_written;
|
||||
const int packet_size = 12 + len;
|
||||
unsigned char *buffer = (unsigned char *)malloc(packet_size);
|
||||
if(!buffer)
|
||||
return;
|
||||
memset(buffer, 0, packet_size);
|
||||
|
||||
buffer[0] = packet_size & 0xff;
|
||||
buffer[1] = (packet_size >> 8) & 0xff;
|
||||
buffer[2] = (packet_size >> 16) & 0xff;
|
||||
buffer[3] = (packet_size >> 24) & 0xff;
|
||||
|
||||
buffer[4] = event_id & 0xff;
|
||||
buffer[5] = (event_id >> 8) & 0xff;
|
||||
buffer[6] = (event_id >> 16) & 0xff;
|
||||
buffer[7] = (event_id >> 24) & 0xff;
|
||||
|
||||
buffer[8] = intval & 0xff;
|
||||
buffer[9] = (intval >> 8) & 0xff;
|
||||
buffer[10] = (intval >> 16) & 0xff;
|
||||
buffer[11] = (intval >> 24) & 0xff;
|
||||
|
||||
memcpy(buffer + 12, vp, len);
|
||||
|
||||
/* If this fails then there's nothing we can do about it anyway. */
|
||||
WriteFile(h, buffer, packet_size, &bytes_written, NULL);
|
||||
CloseHandle(h);
|
||||
}
|
||||
}
|
||||
#endif /* USE_MAILSLOT */
|
||||
|
||||
Reference in New Issue
Block a user