mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
miracled: implement Start/StopScan
Both dbus commands allow external programs to make our device discoverable for P2P devices and also start scanning for remote devices. The commands are *not* ref-counted right now, so parallel use is discouraged. However, these commands can interrupt normal operations on a wifi-device anyway, so if used in parallel, it is very like to break. Thus, keep the interface simple and require callers to do access-management (it's root-only, anyway..). Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
parent
8bcf3348e8
commit
e60e678d40
3 changed files with 42 additions and 2 deletions
|
@ -332,13 +332,24 @@ void peer_dbus_removed(struct peer *p)
|
|||
static int link_dbus_start_scan(sd_bus *bus, sd_bus_message *msg,
|
||||
void *data, sd_bus_error *err)
|
||||
{
|
||||
return -EINVAL;
|
||||
struct link *l = data;
|
||||
int r;
|
||||
|
||||
r = link_start_scan(l);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return sd_bus_reply_method_return(msg, NULL);
|
||||
}
|
||||
|
||||
static int link_dbus_stop_scan(sd_bus *bus, sd_bus_message *msg,
|
||||
void *data, sd_bus_error *err)
|
||||
{
|
||||
return -EINVAL;
|
||||
struct link *l = data;
|
||||
|
||||
link_stop_scan(l);
|
||||
|
||||
return sd_bus_reply_method_return(msg, NULL);
|
||||
}
|
||||
|
||||
static int link_dbus_get_type(sd_bus *bus,
|
||||
|
|
|
@ -307,3 +307,29 @@ int link_set_friendly_name(struct link *l, const char *name)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int link_start_scan(struct link *l)
|
||||
{
|
||||
if (!l)
|
||||
return -EINVAL;
|
||||
|
||||
switch (l->type) {
|
||||
case LINK_VIRTUAL:
|
||||
return -EOPNOTSUPP;
|
||||
case LINK_WIFI:
|
||||
return wifi_set_discoverable(l->w, true);
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
void link_stop_scan(struct link *l)
|
||||
{
|
||||
if (!l)
|
||||
return;
|
||||
|
||||
switch (l->type) {
|
||||
case LINK_WIFI:
|
||||
wifi_set_discoverable(l->w, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,9 @@ void link_free(struct link *l);
|
|||
|
||||
int link_set_friendly_name(struct link *l, const char *name);
|
||||
|
||||
int link_start_scan(struct link *l);
|
||||
void link_stop_scan(struct link *l);
|
||||
|
||||
/* manager */
|
||||
|
||||
struct manager {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue