MateConfSources* mateconf_sources_new_from_addresses(GSList * addresses, GError** err) { MateConfSources *sources; GList *sources_list; g_return_val_if_fail( (err == NULL) || (*err == NULL), NULL); sources_list = NULL; if (addresses != NULL) { GError *last_error = NULL; while (addresses != NULL) { MateConfSource* source; if (last_error) { g_error_free (last_error); last_error = NULL; } source = mateconf_resolve_address ((const gchar*)addresses->data, &last_error); if (source != NULL) { sources_list = g_list_prepend(sources_list, source); g_return_val_if_fail(last_error == NULL, NULL); } else { g_assert(last_error != NULL); mateconf_log(GCL_WARNING, _("Failed to load source \"%s\": %s"), (const gchar*)addresses->data, last_error->message); } addresses = g_slist_next(addresses); } if (sources_list == NULL) { g_assert (last_error != NULL); g_propagate_error (err, last_error); return NULL; } if (last_error) { g_error_free(last_error); last_error = NULL; } } sources = g_new0 (MateConfSources, 1); sources->sources = g_list_reverse (sources_list); { GList *tmp; int i; gboolean some_writable; some_writable = FALSE; i = 0; tmp = sources->sources; while (tmp != NULL) { MateConfSource *source = tmp->data; if (source->flags & MATECONF_SOURCE_ALL_WRITEABLE) { some_writable = TRUE; mateconf_log (GCL_DEBUG, _("Resolved address \"%s\" to a writable configuration source at position %d"), source->address, i); } else if (source->flags & MATECONF_SOURCE_NEVER_WRITEABLE) { mateconf_log (GCL_DEBUG, _("Resolved address \"%s\" to a read-only configuration source at position %d"), source->address, i); } else { some_writable = TRUE; mateconf_log (GCL_DEBUG, _("Resolved address \"%s\" to a partially writable configuration source at position %d"), source->address, i); } ++i; tmp = tmp->next; } if (!some_writable) mateconf_log (GCL_WARNING, _("None of the resolved addresses are writable; saving configuration settings will not be possible")); } return sources; }
static gboolean check_mateconf (gboolean display_errors) { GSList* addresses; GSList* tmp; gchar* conffile; GError* error; gboolean retval; retval = FALSE; conffile = NULL; /* If mateconfd is already running, it's expected that we won't be able * to get locks etc., and everything is already fine. * Plus we can skip the slow sanity checks like resolve_address. */ if (mateconf_ping_daemon ()) { retval = TRUE; goto out; } conffile = g_build_filename (MATECONF_CONFDIR, "path", NULL); error = NULL; addresses = mateconf_load_source_path (conffile, &error); if (addresses == NULL) { if (display_errors) show_fatal_error_dialog (_("Please contact your system administrator to resolve the following problem:\n" "No configuration sources in the configuration file \"%s\"; this means that preferences and other settings can't be saved. %s%s"), conffile, error ? _("Error reading the file: ") : "", error ? error->message : ""); if (error) g_error_free (error); goto out; } tmp = addresses; while (tmp != NULL) { MateConfSource *source; const char *address; address = tmp->data; error = NULL; source = mateconf_resolve_address (address, &error); if (error) { if (display_errors) show_fatal_error_dialog (_("Please contact your system administrator to resolve the following problem:\n" "Could not resolve the address \"%s\" in the configuration file \"%s\": %s"), address, conffile, error->message); g_error_free (error); goto out; } mateconf_source_free (source); g_free (tmp->data); tmp = tmp->next; } g_slist_free (addresses); retval = TRUE; out: g_free (conffile); return retval; }