networkd-manager-bus.c revision 4852e15970ec652b823bf568b398f730be1fe1a5
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen/***
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen This file is part of systemd.
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen Copyright 2015 Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen systemd is free software; you can redistribute it and/or modify it
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen under the terms of the GNU Lesser General Public License as published by
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen (at your option) any later version.
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen systemd is distributed in the hope that it will be useful, but
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen Lesser General Public License for more details.
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen You should have received a copy of the GNU Lesser General Public License
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen***/
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen#include "bus-util.h"
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen#include "networkd.h"
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersenstatic BUS_DEFINE_PROPERTY_GET_ENUM(property_get_operational_state, link_operstate, LinkOperationalState);
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersenconst sd_bus_vtable manager_vtable[] = {
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen SD_BUS_VTABLE_START(0),
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen SD_BUS_PROPERTY("OperationalState", "s", property_get_operational_state, offsetof(Manager, operational_state), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen SD_BUS_VTABLE_END
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen};
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersenint manager_send_changed(Manager *manager, const char *property, ...) {
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen char **l;
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen assert(manager);
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
4852e15970ec652b823bf568b398f730be1fe1a5Tom Gundersen if (!manager->bus)
4852e15970ec652b823bf568b398f730be1fe1a5Tom Gundersen return 0; /* replace by assert when we have kdbus */
4852e15970ec652b823bf568b398f730be1fe1a5Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen l = strv_from_stdarg_alloca(property);
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen return sd_bus_emit_properties_changed_strv(
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen manager->bus,
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen "/org/freedesktop/network1",
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen "org.freedesktop.network1.Manager",
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen l);
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen}