static gboolean gvir_sandbox_config_service_load_config(GVirSandboxConfig *config, GKeyFile *file, GError **error) { GVirSandboxConfigServicePrivate *priv = GVIR_SANDBOX_CONFIG_SERVICE(config)->priv; gboolean ret = FALSE; gchar *str; if (!GVIR_SANDBOX_CONFIG_CLASS(gvir_sandbox_config_service_parent_class) ->load_config(config, file, error)) goto cleanup; if ((str = g_key_file_get_string(file, "service", "executable", NULL)) != NULL) { g_free(priv->executable); priv->executable = str; } if ((str = g_key_file_get_string(file, "service", "unit", NULL)) != NULL) { g_free(priv->unit); priv->unit = str; } ret = TRUE; cleanup: return ret; }
static void gvir_sandbox_config_service_systemd_save_config(GVirSandboxConfig *config, GKeyFile *file) { GVirSandboxConfigServiceSystemdPrivate *priv = GVIR_SANDBOX_CONFIG_SERVICE_SYSTEMD(config)->priv; GVIR_SANDBOX_CONFIG_CLASS(gvir_sandbox_config_service_systemd_parent_class) ->save_config(config, file); g_key_file_set_string(file, "service", "bootTarget", priv->bootTarget); }
static void gvir_sandbox_config_service_save_config(GVirSandboxConfig *config, GKeyFile *file) { GVirSandboxConfigServicePrivate *priv = GVIR_SANDBOX_CONFIG_SERVICE(config)->priv; GVIR_SANDBOX_CONFIG_CLASS(gvir_sandbox_config_service_parent_class) ->save_config(config, file); if (priv->executable) g_key_file_set_string(file, "service", "executable", priv->executable); if (priv->unit) g_key_file_set_string(file, "service", "unit", priv->unit); }
static void gvir_sandbox_config_service_systemd_class_init(GVirSandboxConfigServiceSystemdClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); GVirSandboxConfigClass *config_class = GVIR_SANDBOX_CONFIG_CLASS(klass); object_class->finalize = gvir_sandbox_config_service_systemd_finalize; object_class->get_property = gvir_sandbox_config_service_systemd_get_property; object_class->set_property = gvir_sandbox_config_service_systemd_set_property; config_class->load_config = gvir_sandbox_config_service_systemd_load_config; config_class->save_config = gvir_sandbox_config_service_systemd_save_config; config_class->get_command = gvir_sandbox_config_service_systemd_get_command; g_type_class_add_private(klass, sizeof(GVirSandboxConfigServiceSystemdPrivate)); }
static gboolean gvir_sandbox_config_service_systemd_load_config(GVirSandboxConfig *config, GKeyFile *file, GError **error) { GVirSandboxConfigServiceSystemdPrivate *priv = GVIR_SANDBOX_CONFIG_SERVICE_SYSTEMD(config)->priv; gboolean ret = FALSE; if (!GVIR_SANDBOX_CONFIG_CLASS(gvir_sandbox_config_service_systemd_parent_class) ->load_config(config, file, error)) goto cleanup; if ((priv->bootTarget = g_key_file_get_string(file, "service", "bootTarget", error)) == NULL) goto cleanup; ret = TRUE; cleanup: return ret; }
static void gvir_sandbox_config_service_class_init(GVirSandboxConfigServiceClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); GVirSandboxConfigClass *config_class = GVIR_SANDBOX_CONFIG_CLASS(klass); object_class->finalize = gvir_sandbox_config_service_finalize; object_class->get_property = gvir_sandbox_config_service_get_property; object_class->set_property = gvir_sandbox_config_service_set_property; config_class->load_config = gvir_sandbox_config_service_load_config; config_class->save_config = gvir_sandbox_config_service_save_config; g_object_class_install_property(object_class, PROP_UNIT, g_param_spec_string("unit", "Unit", "The systemd unit name", NULL, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); g_object_class_install_property(object_class, PROP_EXECUTABLE, g_param_spec_string("executable", "Executable", "The executable name path", NULL, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); g_type_class_add_private(klass, sizeof(GVirSandboxConfigServicePrivate)); }