static gboolean is_ntp_active(void) { gchar *unit_path; GVariant *result; GVariant *state; gboolean ret; if (!ntp_units->len) return FALSE; result = call_systemd("LoadUnit", g_variant_new("(s)", get_ntp_unit(0)->name)); if (!result) return FALSE; g_variant_get(result, "(&o)", &unit_path); state = get_object_property(SYSTEMD_NAME, unit_path, SYSTEMD_UNIT_INTERFACE, "ActiveState"); g_variant_unref(result); if (!state) return FALSE; ret = g_strcmp0(g_variant_get_string(state, NULL), "active") == 0 || g_strcmp0(g_variant_get_string(state, NULL), "activating") == 0; g_variant_unref(state); return ret; }
bool idproxyGetProperty(NPObject *obj, NPIdentifier name, NPVariant *result) { int prop; struct IDProxyObject *obj_ = (void *) obj; _assertZero(get_object_property(food, obj_->id, (void *) CFDataGetBytePtr(name), CFDataGetLength(name), &prop)); if(prop) { *((struct NPFuckedUpVariant *) result) = variant_for_object_name(prop); return true; } else { return false; } }
static int perform_action(struct userdata *u, union pa_policy_context_action *action, char *var_value) { struct pa_policy_set_property *setprop; struct pa_policy_del_property *delprop; struct pa_policy_set_default *setdef; struct pa_policy_object *object; const char *old_value; const char *prop_value; const char *objname; const char *objtype; int success; switch (action->any.type) { case pa_policy_set_property: setprop = &action->setprop; object = &setprop->object; if (!object_assert(u, object)) success = false; else { switch (setprop->value.type) { case pa_policy_value_constant: prop_value = setprop->value.constant.string; break; case pa_policy_value_copy: prop_value = var_value; break; default: prop_value = NULL; break; } if (prop_value == NULL) success = false; else { success = true; old_value = get_object_property(object, setprop->property); objname = object_name(object); objtype = object_type_str(object->type); if (!strcmp(prop_value, old_value)) { pa_log_debug("%s '%s' property '%s' value is already '%s'", objtype, objname, setprop->property, prop_value); } else { pa_log_debug("setting %s '%s' property '%s' to '%s'", objtype, objname, setprop->property, prop_value); set_object_property(object, setprop->property, prop_value); } /* Forward shared strings */ pa_shared_data_sets(u->shared, setprop->property, prop_value); } } break; case pa_policy_delete_property: delprop = &action->delprop; object = &delprop->object; if (!object_assert(u, object)) success = false; else { success = true; objname = object_name(object); objtype = object_type_str(object->type); pa_log_debug("deleting %s '%s' property '%s'", objtype, objname, delprop->property); delete_object_property(object, delprop->property); } break; case pa_policy_set_default: setdef = &action->setdef; setdef->var->default_state = setdef->default_state; pa_log_debug("setting activity group %s default state to %d", setdef->var->device, setdef->default_state); apply_activity(u, setdef->var); success = true; break; default: success = false; break; } return success; }