mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
demo/miracle-wfdctl: rollback method definitions in dbus interfaces from async to sync
This commit is contained in:
parent
ac9ea16e61
commit
ad407d7505
4 changed files with 34 additions and 28 deletions
|
@ -14,7 +14,7 @@ namespace Org {
|
||||||
public interface Sink : GLib.Object {
|
public interface Sink : GLib.Object {
|
||||||
|
|
||||||
[DBus (name = "StartSession")]
|
[DBus (name = "StartSession")]
|
||||||
public abstract async GLib.ObjectPath start_session(string param0, string param1, uint param2, uint param3, uint param4, uint param5, string param6) throws DBusError, IOError;
|
public abstract GLib.ObjectPath start_session(string param0, string param1, uint param2, uint param3, uint param4, uint param5, string param6) throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "Session")]
|
[DBus (name = "Session")]
|
||||||
public abstract GLib.ObjectPath session { owned get; }
|
public abstract GLib.ObjectPath session { owned get; }
|
||||||
|
@ -27,13 +27,13 @@ namespace Org {
|
||||||
public interface Session : GLib.Object {
|
public interface Session : GLib.Object {
|
||||||
|
|
||||||
[DBus (name = "Resume")]
|
[DBus (name = "Resume")]
|
||||||
public abstract async void resume() throws DBusError, IOError;
|
public abstract void resume() throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "Pause")]
|
[DBus (name = "Pause")]
|
||||||
public abstract async void pause() throws DBusError, IOError;
|
public abstract void pause() throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "Teardown")]
|
[DBus (name = "Teardown")]
|
||||||
public abstract async void teardown() throws DBusError, IOError;
|
public abstract void teardown() throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "Sink")]
|
[DBus (name = "Sink")]
|
||||||
public abstract GLib.ObjectPath sink { owned get; }
|
public abstract GLib.ObjectPath sink { owned get; }
|
||||||
|
|
|
@ -14,10 +14,10 @@ namespace Org {
|
||||||
public interface Peer : GLib.Object {
|
public interface Peer : GLib.Object {
|
||||||
|
|
||||||
[DBus (name = "Connect")]
|
[DBus (name = "Connect")]
|
||||||
public abstract async void connect(string param0, string param1) throws DBusError, IOError;
|
public abstract void connect(string param0, string param1) throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "Disconnect")]
|
[DBus (name = "Disconnect")]
|
||||||
public abstract async void disconnect() throws DBusError, IOError;
|
public abstract void disconnect() throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "Link")]
|
[DBus (name = "Link")]
|
||||||
public abstract GLib.ObjectPath link { owned get; }
|
public abstract GLib.ObjectPath link { owned get; }
|
||||||
|
@ -57,10 +57,10 @@ namespace Org {
|
||||||
public interface Link : GLib.Object {
|
public interface Link : GLib.Object {
|
||||||
|
|
||||||
[DBus (name = "Manage")]
|
[DBus (name = "Manage")]
|
||||||
public abstract async void manage() throws DBusError, IOError;
|
public abstract void manage() throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "Unmanage")]
|
[DBus (name = "Unmanage")]
|
||||||
public abstract async void unmanage() throws DBusError, IOError;
|
public abstract void unmanage() throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "InterfaceIndex")]
|
[DBus (name = "InterfaceIndex")]
|
||||||
public abstract uint interface_index { get; }
|
public abstract uint interface_index { get; }
|
||||||
|
|
|
@ -12,16 +12,16 @@ namespace Org {
|
||||||
public interface Device : GLib.Object {
|
public interface Device : GLib.Object {
|
||||||
|
|
||||||
[DBus (name = "Reapply")]
|
[DBus (name = "Reapply")]
|
||||||
public abstract async void reapply(GLib.HashTable<string, GLib.HashTable<string, GLib.Variant>> connection, uint64 version_id, uint flags) throws DBusError, IOError;
|
public abstract void reapply(GLib.HashTable<string, GLib.HashTable<string, GLib.Variant>> connection, uint64 version_id, uint flags) throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "GetAppliedConnection")]
|
[DBus (name = "GetAppliedConnection")]
|
||||||
public abstract async void get_applied_connection(uint flags, out GLib.HashTable<string, GLib.HashTable<string, GLib.Variant>> connection, out uint64 version_id) throws DBusError, IOError;
|
public abstract void get_applied_connection(uint flags, out GLib.HashTable<string, GLib.HashTable<string, GLib.Variant>> connection, out uint64 version_id) throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "Disconnect")]
|
[DBus (name = "Disconnect")]
|
||||||
public abstract async void disconnect() throws DBusError, IOError;
|
public abstract void disconnect() throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "Delete")]
|
[DBus (name = "Delete")]
|
||||||
public abstract async void delete() throws DBusError, IOError;
|
public abstract void delete() throws DBusError, IOError;
|
||||||
|
|
||||||
[DBus (name = "StateChanged")]
|
[DBus (name = "StateChanged")]
|
||||||
public signal void state_changed(uint new_state, uint old_state, uint reason);
|
public signal void state_changed(uint new_state, uint old_state, uint reason);
|
||||||
|
|
|
@ -312,7 +312,7 @@ private class WfdCtl : GLib.Application
|
||||||
info("NetworkManager is releasing ownership of %s...", opt_iface);
|
info("NetworkManager is releasing ownership of %s...", opt_iface);
|
||||||
|
|
||||||
d.managed = false;
|
d.managed = false;
|
||||||
yield wait_prop_changed(d as DBusProxy, "Managed");
|
yield wait_prop_changed(d, "Managed");
|
||||||
}
|
}
|
||||||
|
|
||||||
Link l = find_link_by_name(opt_iface);
|
Link l = find_link_by_name(opt_iface);
|
||||||
|
@ -324,8 +324,8 @@ private class WfdCtl : GLib.Application
|
||||||
if(!l.managed) {
|
if(!l.managed) {
|
||||||
info("wifid is acquiring ownership of %s...", opt_iface);
|
info("wifid is acquiring ownership of %s...", opt_iface);
|
||||||
|
|
||||||
yield l.manage();
|
l.manage();
|
||||||
yield wait_prop_changed(l as DBusProxy, "Managed");
|
yield wait_prop_changed(l, "Managed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ private class WfdCtl : GLib.Application
|
||||||
info("update wfd_subelems to broadcast what kind of device we are");
|
info("update wfd_subelems to broadcast what kind of device we are");
|
||||||
|
|
||||||
l.wfd_subelements = opt_wfd_subelems;
|
l.wfd_subelements = opt_wfd_subelems;
|
||||||
yield wait_prop_changed(l as DBusProxy, "WfdSubelements");
|
yield wait_prop_changed(l, "WfdSubelements");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(-1 == l.p2p_state) {
|
if(-1 == l.p2p_state) {
|
||||||
|
@ -344,13 +344,13 @@ private class WfdCtl : GLib.Application
|
||||||
}
|
}
|
||||||
else if(0 == l.p2p_state) {
|
else if(0 == l.p2p_state) {
|
||||||
info("wait for P2P supporting status...");
|
info("wait for P2P supporting status...");
|
||||||
yield wait_prop_changed(l as DBusProxy, "P2PState", 3);
|
yield wait_prop_changed(l, "P2PState", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!l.p2p_scanning) {
|
if(!l.p2p_scanning) {
|
||||||
info("start P2P scanning...");
|
info("start P2P scanning...");
|
||||||
l.p2p_scanning = true;
|
l.p2p_scanning = true;
|
||||||
yield wait_prop_changed(l as DBusProxy, "P2PScanning");
|
yield wait_prop_changed(l, "P2PScanning");
|
||||||
}
|
}
|
||||||
|
|
||||||
print("wait for peer '%s'...", opt_peer_mac);
|
print("wait for peer '%s'...", opt_peer_mac);
|
||||||
|
@ -392,8 +392,8 @@ private class WfdCtl : GLib.Application
|
||||||
ulong id = p.formation_failure.connect((r) => {
|
ulong id = p.formation_failure.connect((r) => {
|
||||||
info("failed to form P2P group: %s", r);
|
info("failed to form P2P group: %s", r);
|
||||||
});
|
});
|
||||||
yield p.connect("auto", "");
|
p.connect("auto", "");
|
||||||
yield wait_prop_changed(p as DBusProxy, "Connected", 20);
|
yield wait_prop_changed(p, "Connected", 20);
|
||||||
|
|
||||||
(p as Object).disconnect(id);
|
(p as Object).disconnect(id);
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ private class WfdCtl : GLib.Application
|
||||||
info("establishing display session...");
|
info("establishing display session...");
|
||||||
|
|
||||||
Sink sink = find_sink_by_mac(opt_peer_mac);
|
Sink sink = find_sink_by_mac(opt_peer_mac);
|
||||||
string path = yield sink.start_session(opt_authority,
|
string path = sink.start_session(opt_authority,
|
||||||
@"x://$(opt_display)",
|
@"x://$(opt_display)",
|
||||||
g.x,
|
g.x,
|
||||||
g.y,
|
g.y,
|
||||||
|
@ -532,15 +532,15 @@ private class WfdCtl : GLib.Application
|
||||||
|
|
||||||
if(l.managed) {
|
if(l.managed) {
|
||||||
info("wifid is releasing ownership of %s...", opt_iface);
|
info("wifid is releasing ownership of %s...", opt_iface);
|
||||||
yield l.unmanage();
|
l.unmanage();
|
||||||
yield wait_prop_changed(l as DBusProxy, "Managed");
|
yield wait_prop_changed(l, "Managed");
|
||||||
}
|
}
|
||||||
|
|
||||||
Device d = find_device_by_name(opt_iface);
|
Device d = find_device_by_name(opt_iface);
|
||||||
if(null != d && !d.managed) {
|
if(null != d && !d.managed) {
|
||||||
info("NetworkManager is acquiring ownership of %s...", opt_iface);
|
info("NetworkManager is acquiring ownership of %s...", opt_iface);
|
||||||
d.managed = true;
|
d.managed = true;
|
||||||
yield wait_prop_changed(d as DBusProxy, "Managed");
|
yield wait_prop_changed(d, "Managed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,7 +564,13 @@ private class WfdCtl : GLib.Application
|
||||||
info("tearing down wireless display...");
|
info("tearing down wireless display...");
|
||||||
|
|
||||||
if(null != curr_session) {
|
if(null != curr_session) {
|
||||||
curr_session.teardown.begin(quit);
|
try {
|
||||||
|
curr_session.teardown();
|
||||||
|
}
|
||||||
|
catch(Error e) {
|
||||||
|
warning("failed to tearing down normally: %s", e.message);
|
||||||
|
quit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
release_wnic_ownership.begin(quit);
|
release_wnic_ownership.begin(quit);
|
||||||
|
@ -693,11 +699,11 @@ private class WfdCtl : GLib.Application
|
||||||
return find_link_by_name(nic_name) != null;
|
return find_link_by_name(nic_name) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void wait_prop_changed(DBusProxy o,
|
private async void wait_prop_changed<T>(T o,
|
||||||
string name,
|
string name,
|
||||||
uint timeout = 1) throws WfdCtlError
|
uint timeout = 1) throws WfdCtlError
|
||||||
{
|
{
|
||||||
ulong prop_changed_id = o.g_properties_changed.connect((props) => {
|
ulong prop_changed_id = (o as DBusProxy).g_properties_changed.connect((props) => {
|
||||||
string k;
|
string k;
|
||||||
Variant v;
|
Variant v;
|
||||||
foreach(var prop in props) {
|
foreach(var prop in props) {
|
||||||
|
@ -725,7 +731,7 @@ private class WfdCtl : GLib.Application
|
||||||
if(0 < timeout) {
|
if(0 < timeout) {
|
||||||
Source.remove(timeout_id);
|
Source.remove(timeout_id);
|
||||||
}
|
}
|
||||||
o.disconnect(prop_changed_id);
|
(o as DBusProxy).disconnect(prop_changed_id);
|
||||||
|
|
||||||
if(timed_out) {
|
if(timed_out) {
|
||||||
throw new WfdCtlError.TIMEOUT("timeout to wait for property %s change",
|
throw new WfdCtlError.TIMEOUT("timeout to wait for property %s change",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue