Commit db576b84 authored by Thomas Haller's avatar Thomas Haller

firewall: merge "started" signal and "available" property

The GObject property NM_FIREWALL_MANAGER_AVAILABLE is basically unused.
Drop it.
parent 753f39fa
......@@ -28,12 +28,8 @@
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE (NMFirewallManager,
PROP_AVAILABLE,
);
enum {
STARTED,
STATE_CHANGED,
LAST_SIGNAL
};
......@@ -141,6 +137,16 @@ _ops_type_to_string (CBInfoOpsType ops_type)
/*****************************************************************************/
gboolean
nm_firewall_manager_get_running (NMFirewallManager *self)
{
g_return_val_if_fail (NM_IS_FIREWALL_MANAGER (self), FALSE);
return NM_FIREWALL_MANAGER_GET_PRIVATE (self)->running;
}
/*****************************************************************************/
static gboolean
_cb_info_is_idle (CBInfo *info)
{
......@@ -406,32 +412,22 @@ nm_firewall_manager_cancel_call (NMFirewallManagerCallId call)
/*****************************************************************************/
static void
set_running (NMFirewallManager *self, gboolean now_running)
{
NMFirewallManagerPrivate *priv = NM_FIREWALL_MANAGER_GET_PRIVATE (self);
gboolean old_running = priv->running;
priv->running = now_running;
if (old_running != priv->running)
_notify (self, PROP_AVAILABLE);
}
static void
name_owner_changed (NMFirewallManager *self)
{
NMFirewallManagerPrivate *priv = NM_FIREWALL_MANAGER_GET_PRIVATE (self);
gs_free char *owner = NULL;
gboolean now_running;
owner = g_dbus_proxy_get_name_owner (priv->proxy);
if (owner) {
_LOGD (NULL, "firewall started");
set_running (self, TRUE);
g_signal_emit (self, signals[STARTED], 0);
} else {
_LOGD (NULL, "firewall stopped");
set_running (self, FALSE);
}
now_running = !!owner;
if (now_running == priv->running)
return;
priv->running = now_running;
_LOGD (NULL, "firewall %s", now_running ? "started" : "stopped");
g_signal_emit (self, signals[STATE_CHANGED], 0);
}
static void
......@@ -479,21 +475,6 @@ _proxy_new_cb (GObject *source_object,
/*****************************************************************************/
static void
get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
switch (prop_id) {
case PROP_AVAILABLE:
g_value_set_boolean (value, NM_FIREWALL_MANAGER_GET_PRIVATE ((NMFirewallManager *) object)->running);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/*****************************************************************************/
static void
nm_firewall_manager_init (NMFirewallManager * self)
{
......@@ -550,19 +531,10 @@ nm_firewall_manager_class_init (NMFirewallManagerClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = constructed;
object_class->get_property = get_property;
object_class->dispose = dispose;
obj_properties[PROP_AVAILABLE] =
g_param_spec_boolean (NM_FIREWALL_MANAGER_AVAILABLE, "", "",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
signals[STARTED] =
g_signal_new (NM_FIREWALL_MANAGER_STARTED,
signals[STATE_CHANGED] =
g_signal_new (NM_FIREWALL_MANAGER_STATE_CHANGED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
......
......@@ -33,9 +33,7 @@
#define NM_IS_FIREWALL_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_FIREWALL_MANAGER))
#define NM_FIREWALL_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_FIREWALL_MANAGER, NMFirewallManagerClass))
#define NM_FIREWALL_MANAGER_AVAILABLE "available"
#define NM_FIREWALL_MANAGER_STARTED "started"
#define NM_FIREWALL_MANAGER_STATE_CHANGED "state-changed"
typedef struct _NMFirewallManagerCallId *NMFirewallManagerCallId;
......@@ -46,6 +44,8 @@ GType nm_firewall_manager_get_type (void);
NMFirewallManager *nm_firewall_manager_get (void);
gboolean nm_firewall_manager_get_running (NMFirewallManager *self);
typedef void (*NMFirewallManagerAddRemoveCallback) (NMFirewallManager *self,
NMFirewallManagerCallId call_id,
GError *error,
......
......@@ -71,8 +71,6 @@ typedef struct {
GSList *pending_secondaries;
gulong fw_started_id;
NMSettings *settings;
NMDevice *default_device4, *activating_device4;
......@@ -2058,13 +2056,16 @@ connection_added (NMSettings *settings,
}
static void
firewall_started (NMFirewallManager *manager,
gpointer user_data)
firewall_state_changed (NMFirewallManager *manager,
gpointer user_data)
{
NMPolicy *self = (NMPolicy *) user_data;
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
const GSList *iter;
if (!nm_firewall_manager_get_running (manager))
return;
/* add interface of each device to correct zone */
for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter))
nm_device_update_firewall_zone (iter->data);
......@@ -2328,9 +2329,8 @@ constructed (GObject *object)
}
priv->firewall_manager = g_object_ref (nm_firewall_manager_get ());
priv->fw_started_id = g_signal_connect (priv->firewall_manager, NM_FIREWALL_MANAGER_STARTED,
G_CALLBACK (firewall_started), self);
g_signal_connect (priv->firewall_manager, NM_FIREWALL_MANAGER_STATE_CHANGED,
G_CALLBACK (firewall_state_changed), self);
priv->dns_manager = g_object_ref (nm_dns_manager_get ());
nm_dns_manager_set_initial_hostname (priv->dns_manager, priv->orig_hostname);
......@@ -2389,8 +2389,7 @@ dispose (GObject *object)
priv->pending_secondaries = NULL;
if (priv->firewall_manager) {
g_assert (priv->fw_started_id);
nm_clear_g_signal_handler (priv->firewall_manager, &priv->fw_started_id);
g_signal_handlers_disconnect_by_func (priv->firewall_manager, firewall_state_changed, self);
g_clear_object (&priv->firewall_manager);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment