/** * urf_device_get_property: **/ static void urf_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UrfDevice *device = URF_DEVICE (object); switch (prop_id) { case PROP_DEVICE_INDEX: g_value_set_int (value, urf_device_get_index (device)); break; case PROP_DEVICE_TYPE: g_value_set_int (value, urf_device_get_device_type (device)); break; case PROP_DEVICE_NAME: g_value_set_string (value, urf_device_get_name (device)); break; case PROP_URF_TYPE: g_value_set_string (value, urf_device_get_urf_type (device)); break; case PROP_DEVICE_PLATFORM: g_value_set_boolean (value, urf_device_is_platform (device)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/** * urf_killswitch_state_refresh: **/ static void urf_killswitch_state_refresh (UrfKillswitch *killswitch) { UrfKillswitchPrivate *priv = killswitch->priv; KillswitchState platform; KillswitchState new_state; gboolean platform_checked = FALSE; UrfDevice *device; GList *iter; GError *error = NULL; if (priv->devices == NULL) { priv->state = KILLSWITCH_STATE_NO_ADAPTER; priv->saved_state = KILLSWITCH_STATE_NO_ADAPTER; return; } platform = KILLSWITCH_STATE_NO_ADAPTER; new_state = KILLSWITCH_STATE_NO_ADAPTER; for (iter = priv->devices; iter; iter = iter->next) { KillswitchState state; device = (UrfDevice *)iter->data; state = urf_device_get_state (device); if (urf_device_is_platform (device) == TRUE) { /* Update the state of platform switch */ platform_checked = TRUE; if (state > platform) platform = state; } else { /* Update the state of non-platform switch */ if (state > new_state) new_state = state; } } if (platform_checked) new_state = aggregate_states (platform, new_state); g_message("killswitch state: %s new_state: %s", state_to_string(priv->state), state_to_string(new_state)); /* emit a signal for change */ if (priv->state != new_state) { priv->state = new_state; emit_properites_changed (killswitch); g_dbus_connection_emit_signal (priv->connection, NULL, priv->object_path, URF_KILLSWITCH_INTERFACE, "StateChanged", NULL, &error); if (error) { g_warning ("Failed to emit StateChanged: %s", error->message); g_error_free (error); } } }
/** * urf_killswitch_state_refresh: **/ static void urf_killswitch_state_refresh (UrfKillswitch *killswitch) { UrfKillswitchPrivate *priv = killswitch->priv; KillswitchState platform; KillswitchState new_state; gboolean platform_checked = FALSE; UrfDevice *device; GList *iter; if (priv->devices == NULL) { priv->state = KILLSWITCH_STATE_NO_ADAPTER; return; } platform = KILLSWITCH_STATE_NO_ADAPTER; new_state = KILLSWITCH_STATE_NO_ADAPTER; for (iter = priv->devices; iter; iter = iter->next) { KillswitchState state; device = (UrfDevice *)iter->data; state = urf_device_get_state (device); if (urf_device_is_platform (device) == TRUE) { /* Update the state of platform switch */ platform_checked = TRUE; if (state > platform) platform = state; } else { /* Update the state of non-platform switch */ if (state > new_state) new_state = state; } } if (platform_checked) new_state = aggregate_states (platform, new_state); /* emit a signal for change */ if (priv->state != new_state) { priv->state = new_state; g_signal_emit (G_OBJECT (killswitch), signals[SIGNAL_STATE_CHANGED], 0, priv->state); } }