return class->equal (settings_a, settings_b);
}
-/**
- * camel_settings_save_to_url:
- * @settings: a #CamelSettings
- * @url: a #CamelURL
- *
- * Writes the values of all properties of @settings to @url as parameter
- * strings. The parameter name in @url matches the corresponding property
- * in @settings.
- *
- * This function is highly Evolution-centric and is only temporary.
- * Expect this function to be removed as early as version 3.4.
- *
- * Since: 3.2
- **/
-void
-camel_settings_save_to_url (CamelSettings *settings,
- CamelURL *url)
-{
- CamelSettingsClass *class;
- GParamSpec **properties;
- GValue pvalue = G_VALUE_INIT;
- GValue svalue = G_VALUE_INIT;
- guint ii, n_properties;
-
- g_return_if_fail (CAMEL_IS_SETTINGS (settings));
- g_return_if_fail (url != NULL);
-
- g_value_init (&svalue, G_TYPE_STRING);
-
- class = CAMEL_SETTINGS_GET_CLASS (settings);
- properties = camel_settings_class_list_settings (class, &n_properties);
-
- for (ii = 0; ii < n_properties; ii++) {
- GParamSpec *pspec = properties[ii];
- gchar *string = NULL;
-
- g_value_init (&pvalue, pspec->value_type);
-
- g_object_get_property (
- G_OBJECT (settings),
- pspec->name, &pvalue);
-
- /* Some CamelNetworkSettings properties are put directly
- * in the CamelURL struct instead of in parameters. */
-
- if (g_strcmp0 (pspec->name, "auth-mechanism") == 0) {
- const gchar *auth = g_value_get_string (&pvalue);
- camel_url_set_authmech (url, auth);
- g_value_unset (&pvalue);
- continue;
- }
-
- if (g_strcmp0 (pspec->name, "host") == 0) {
- const gchar *host = g_value_get_string (&pvalue);
- camel_url_set_host (url, host);
- g_value_unset (&pvalue);
- continue;
- }
-
- if (g_strcmp0 (pspec->name, "port") == 0) {
- guint port = g_value_get_uint (&pvalue);
- camel_url_set_port (url, port);
- g_value_unset (&pvalue);
- continue;
- }
-
- if (g_strcmp0 (pspec->name, "user") == 0) {
- const gchar *user = g_value_get_string (&pvalue);
- camel_url_set_user (url, user);
- g_value_unset (&pvalue);
- continue;
- }
-
- /* Some CamelLocalSettings properties are put directly
- * in the CamelURL struct instead of in parameters. */
-
- if (g_strcmp0 (pspec->name, "path") == 0) {
- const gchar *path = g_value_get_string (&pvalue);
- camel_url_set_path (url, path);
- g_value_unset (&pvalue);
- continue;
- }
-
- /* If the property value matches the default value,
- * remove the corresponding URL parameter so we keep
- * the URL string to a minimum. */
- if (g_param_value_defaults (pspec, &pvalue)) {
- g_datalist_remove_data (&url->params, pspec->name);
- g_value_unset (&pvalue);
- continue;
- }
-
- /* For the most part we can just transform any supported
- * property type to a string, with a couple exceptions. */
-
- /* Transforming a boolean GValue to a string results
- * in "TRUE" or "FALSE" (all uppercase). Instead use
- * all lowercase since GKeyFile will require it. */
- if (G_VALUE_HOLDS_BOOLEAN (&pvalue)) {
- gboolean v_boolean = g_value_get_boolean (&pvalue);
- string = g_strdup (v_boolean ? "true" : "false");
-
- /* Transforming an enum GValue to a string results in
- * the GEnumValue name. We want the shorter nickname. */
- } else if (G_VALUE_HOLDS_ENUM (&pvalue)) {
- GParamSpecEnum *enum_pspec;
- GEnumClass *enum_class;
- GEnumValue *enum_value;
- gint value;
-
- enum_pspec = G_PARAM_SPEC_ENUM (pspec);
- enum_class = enum_pspec->enum_class;
-
- value = g_value_get_enum (&pvalue);
- enum_value = g_enum_get_value (enum_class, value);
-
- if (enum_value != NULL)
- string = g_strdup (enum_value->value_nick);
-
- } else if (G_VALUE_HOLDS (&pvalue, G_TYPE_STRV)) {
- gchar **strv = g_value_get_boxed (&pvalue);
-
- if (strv != NULL)
- string = g_strjoinv (",", strv);
-
- } else if (g_value_transform (&pvalue, &svalue)) {
- string = g_value_dup_string (&svalue);
-
- } else
- g_warning (
- "No handler to save property %s:%s (type %s)",
- G_OBJECT_TYPE_NAME (settings),
- pspec->name, g_type_name (pspec->value_type));
-
- /* CamelURL takes ownership of the string. */
- if (string != NULL)
- g_datalist_set_data_full (
- &url->params, pspec->name, string,
- (GDestroyNotify) g_free);
-
- g_value_unset (&pvalue);
- }
-
- g_free (properties);
-
- g_value_unset (&svalue);
-}