mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 23:25:56 -05:00
[pairing/listener] Add function to retrieve name of remote and notify
about start and finish of remote pairing requests
This commit is contained in:
parent
ae446046f5
commit
4b49ce69e2
@ -20,6 +20,8 @@ enum listener_event_type
|
||||
LISTENER_STORED_PLAYLIST = (1 << 6),
|
||||
/* A library update has started or finished */
|
||||
LISTENER_UPDATE = (1 << 7),
|
||||
/* A pairing request has started or finished */
|
||||
LISTENER_PAIRING = (1 << 8),
|
||||
};
|
||||
|
||||
typedef void (*notify)(enum listener_event_type type);
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include "misc.h"
|
||||
#include "db.h"
|
||||
#include "remote_pairing.h"
|
||||
#include "listener.h"
|
||||
|
||||
|
||||
struct remote_info {
|
||||
@ -70,8 +71,6 @@ struct remote_info {
|
||||
char *v6_address;
|
||||
|
||||
struct evhttp_connection *evcon;
|
||||
|
||||
struct remote_info *next;
|
||||
};
|
||||
|
||||
|
||||
@ -613,6 +612,7 @@ pairing_cb(int fd, short event, void *arg)
|
||||
|
||||
CHECK_ERR(L_REMOTE, pthread_mutex_unlock(&remote_lck));
|
||||
|
||||
listener_notify(LISTENER_PAIRING);
|
||||
event_add(pairingev, NULL);
|
||||
}
|
||||
|
||||
@ -710,6 +710,8 @@ touch_remote_cb(const char *name, const char *type, const char *domain, const ch
|
||||
|
||||
CHECK_ERR(L_REMOTE, pthread_mutex_unlock(&remote_lck));
|
||||
}
|
||||
|
||||
listener_notify(LISTENER_PAIRING);
|
||||
}
|
||||
|
||||
/* Thread: filescanner, mpd */
|
||||
@ -736,6 +738,31 @@ remote_pairing_kickoff(char **arglist)
|
||||
CHECK_ERR(L_REMOTE, pthread_mutex_unlock(&remote_lck));
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the remote name of the current active pairing request as an allocated string (needs to be freed by the caller)
|
||||
* or NULL in case there is no active pairing request.
|
||||
*
|
||||
* Thread: httpd
|
||||
*/
|
||||
char *
|
||||
remote_pairing_get_name(void)
|
||||
{
|
||||
char *remote_name;
|
||||
|
||||
DPRINTF(E_DBG, L_REMOTE, "Get pairing remote name\n");
|
||||
|
||||
CHECK_ERR(L_REMOTE, pthread_mutex_lock(&remote_lck));
|
||||
|
||||
if (remote_info)
|
||||
remote_name = strdup(remote_info->pi.name);
|
||||
else
|
||||
remote_name = NULL;
|
||||
|
||||
CHECK_ERR(L_REMOTE, pthread_mutex_unlock(&remote_lck));
|
||||
|
||||
return remote_name;
|
||||
}
|
||||
|
||||
|
||||
/* Thread: main */
|
||||
int
|
||||
|
@ -5,6 +5,9 @@
|
||||
void
|
||||
remote_pairing_kickoff(char **arglist);
|
||||
|
||||
char *
|
||||
remote_pairing_get_name(void);
|
||||
|
||||
int
|
||||
remote_pairing_init(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user