1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

Make miracle-wifid conexists with other network tools

The new option --lazy-managed will let miracle-wifid don't managed the
links automatically. Instead, the link will be managed only when the new
DBus property Managed was set to true. So this will be possible that
miracle-wifid could be conexists with other network tools like
networkmanager.

For example, unmange the device in networkmanager with setting the DBus
property org.freedesktop.NetworkManager.Device.Managed to false and
manage it in miracle-wifid with setting
org.freedesktop.miracle.wifi.Link.Managed to true, then both them could
works and don't need to kill each other.

Besides, there is new command named make-managed in miracle-wifictl and
miracle-sinkctla.
This commit is contained in:
Xu Fasheng 2016-10-21 00:43:03 +08:00 committed by Derek Dai
parent d239c528ff
commit 7d7df75bc9
No known key found for this signature in database
GPG key ID: E109CC97553EF009
9 changed files with 260 additions and 26 deletions

View file

@ -100,6 +100,8 @@ int link_new(struct manager *m,
if (out)
*out = l;
l->public = true;
link_dbus_added(l);
return 0;
error:
@ -116,6 +118,9 @@ void link_free(struct link *l)
link_set_managed(l, false);
link_dbus_removed(l);
l->public = false;
if (shl_htable_remove_uint(&l->m->links, l->ifindex, NULL)) {
log_info("remove link: %s", l->ifname);
--l->m->link_cnt;
@ -142,14 +147,19 @@ bool link_is_using_dev(struct link *l)
return l->use_dev;
}
void link_set_managed(struct link *l, bool set)
bool link_get_managed(struct link *l)
{
return l->managed;
}
int link_set_managed(struct link *l, bool set)
{
int r;
if (!l)
return log_vEINVAL();
return log_EINVAL();
if (l->managed == set)
return;
return 0;
if (set) {
log_info("manage link %s", l->ifname);
@ -157,7 +167,7 @@ void link_set_managed(struct link *l, bool set)
r = supplicant_start(l->s);
if (r < 0) {
log_error("cannot start supplicant on %s", l->ifname);
return;
return -EFAULT;
}
} else {
log_info("link %s no longer managed", l->ifname);
@ -165,6 +175,7 @@ void link_set_managed(struct link *l, bool set)
}
l->managed = set;
return 0;
}
int link_renamed(struct link *l, const char *ifname)
@ -199,6 +210,9 @@ int link_set_friendly_name(struct link *l, const char *name)
if (!l || !name || !*name)
return log_EINVAL();
if (!l->managed)
return log_EUNMANAGED();
t = strdup(name);
if (!t)
return log_ENOMEM();
@ -234,6 +248,9 @@ int link_set_wfd_subelements(struct link *l, const char *val)
if (!l || !val)
return log_EINVAL();
if (!l->managed)
return log_EUNMANAGED();
t = strdup(val);
if (!t)
return log_ENOMEM();
@ -266,6 +283,9 @@ int link_set_p2p_scanning(struct link *l, bool set)
if (!l)
return log_EINVAL();
if (!l->managed)
return log_EUNMANAGED();
if (set) {
return supplicant_p2p_start_scan(l->s);
} else {
@ -276,7 +296,16 @@ int link_set_p2p_scanning(struct link *l, bool set)
bool link_get_p2p_scanning(struct link *l)
{
return l && supplicant_p2p_scanning(l->s);
if (!l) {
log_vEINVAL();
return false;
}
if (!l->managed) {
return false;
}
return supplicant_p2p_scanning(l->s);
}
void link_supplicant_started(struct link *l)
@ -284,9 +313,8 @@ void link_supplicant_started(struct link *l)
if (!l || l->public)
return;
log_debug("link %s started", l->ifname);
l->public = true;
link_dbus_added(l);
link_set_friendly_name(l, l->m->friendly_name);
log_info("link %s managed", l->ifname);
}
void link_supplicant_stopped(struct link *l)
@ -294,9 +322,7 @@ void link_supplicant_stopped(struct link *l)
if (!l || !l->public)
return;
log_debug("link %s stopped", l->ifname);
link_dbus_removed(l);
l->public = false;
log_info("link %s unmanaged", l->ifname);
}
void link_supplicant_p2p_scan_changed(struct link *l, bool new_value)