Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.NWFilter.xml | 5 +++++ src/nwfilter.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/data/org.libvirt.NWFilter.xml b/data/org.libvirt.NWFilter.xml index c025d30..9a1b44f 100644 --- a/data/org.libvirt.NWFilter.xml +++ b/data/org.libvirt.NWFilter.xml @@ -3,5 +3,10 @@ <node name="/org/libvirt/nwfilter"> <interface name="org.libvirt.NWFilter"> + <property name="Name" type="s" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterGetName"/> + <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/> + </property> </interface> </node> diff --git a/src/nwfilter.c b/src/nwfilter.c index 4d20162..c72317e 100644 --- a/src/nwfilter.c +++ b/src/nwfilter.c @@ -3,7 +3,50 @@ #include <libvirt/libvirt.h> +static virNWFilterPtr +virtDBusNWFilterGetVirNWFilter(virtDBusConnect *connect, + const gchar *objectPath, + GError **error) +{ + virNWFilterPtr nwfilter; + + if (virtDBusConnectOpen(connect, error) < 0) + return NULL; + + nwfilter = virtDBusUtilVirNWFilterFromBusPath(connect->connection, + objectPath, + connect->nwfilterPath); + if (!nwfilter) { + virtDBusUtilSetLastVirtError(error); + return NULL; + } + + return nwfilter; +} + +static void +virtDBusNWFilterGetName(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virNWFilter) nwfilter = NULL; + const gchar *name; + + nwfilter = virtDBusNWFilterGetVirNWFilter(connect, objectPath, error); + if (!nwfilter) + return; + + name = virNWFilterGetName(nwfilter); + if (!name) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("s", name); +} + static virtDBusGDBusPropertyTable virtDBusNWFilterPropertyTable[] = { + { "Name", virtDBusNWFilterGetName, NULL }, { 0 } }; -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list