static void
settings_jh_headers_changed (GSettings *settings,
                             const gchar *key,
                             EMailSession *session)
{
	GSList *node;
	GPtrArray *name, *value;
	gchar **strv;
	gint i;

	strv = g_settings_get_strv (settings, "junk-custom-header");
	if (key) {
		for (i = 0, node = config->jh_header; strv[i] && node; i++, node = g_slist_next (node)) {
			if (g_strcmp0 (node->data, strv[i]) != 0)
				break;
		}

		/* both lists are read to the end, thus they are the same */
		if (!node && !strv[i]) {
			g_strfreev (strv);
			return;
		}
	}

	g_slist_foreach (config->jh_header, (GFunc) g_free, NULL);
	g_slist_free (config->jh_header);
	config->jh_header = NULL;

	for (i = 0; strv[i] != NULL; i++)
		config->jh_header = g_slist_append (config->jh_header, g_strdup (strv[i]));
	g_strfreev (strv);

	node = config->jh_header;
	name = g_ptr_array_new ();
	value = g_ptr_array_new ();
	while (node && node->data) {
		gchar **tok = g_strsplit (node->data, "=", 2);
		g_ptr_array_add (name, g_strdup (tok[0]));
		g_ptr_array_add (value, g_strdup (tok[1]));
		node = node->next;
		g_strfreev (tok);
	}
	camel_session_set_junk_headers (
		CAMEL_SESSION (session),
		(const gchar **) name->pdata,
		(const gchar **) value->pdata, name->len);

	g_ptr_array_foreach (name, (GFunc) g_free, NULL);
	g_ptr_array_foreach (value, (GFunc) g_free, NULL);
	g_ptr_array_free (name, TRUE);
	g_ptr_array_free (value, TRUE);
}
Beispiel #2
0
static void
settings_jh_check_changed (GSettings *settings,
                           const gchar *key,
                           EMailSession *session)
{
	config->jh_check = g_settings_get_boolean (settings, "junk-check-custom-header");
	if (!config->jh_check) {
		camel_session_set_junk_headers (
			CAMEL_SESSION (session), NULL, NULL, 0);
	} else {
		settings_jh_headers_changed (settings, NULL, session);
	}
}
Beispiel #3
0
static void
gconf_jh_check_changed (GConfClient *client,
                        guint cnxn_id,
                        GConfEntry *entry,
                        EMailSession *session)
{
	config->jh_check = gconf_client_get_bool (
		client, "/apps/evolution/mail/junk/check_custom_header", NULL);
	if (!config->jh_check) {
		camel_session_set_junk_headers (
			CAMEL_SESSION (session), NULL, NULL, 0);
	} else {
		gconf_jh_headers_changed (client, 0, NULL, session);
	}
}
Beispiel #4
0
static void
settings_jh_headers_changed (GSettings *settings,
                             const gchar *key,
                             EMailSession *session)
{
	GSList *node;
	GPtrArray *name, *value;
	gchar **strv;
	gint i;

	g_slist_foreach (config->jh_header, (GFunc) g_free, NULL);
	g_slist_free (config->jh_header);
	config->jh_header = NULL;

	strv = g_settings_get_strv (settings, "junk-custom-header");
	for (i = 0; strv[i] != NULL; i++)
		config->jh_header = g_slist_append (config->jh_header, g_strdup (strv[i]));
	g_strfreev (strv);

	node = config->jh_header;
	name = g_ptr_array_new ();
	value = g_ptr_array_new ();
	while (node && node->data) {
		gchar **tok = g_strsplit (node->data, "=", 2);
		g_ptr_array_add (name, g_strdup (tok[0]));
		g_ptr_array_add (value, g_strdup (tok[1]));
		node = node->next;
		g_strfreev (tok);
	}
	camel_session_set_junk_headers (
		CAMEL_SESSION (session),
		(const gchar **) name->pdata,
		(const gchar **) value->pdata, name->len);

	g_ptr_array_foreach (name, (GFunc) g_free, NULL);
	g_ptr_array_foreach (value, (GFunc) g_free, NULL);
	g_ptr_array_free (name, TRUE);
	g_ptr_array_free (value, TRUE);
}
Beispiel #5
0
static void
gconf_jh_headers_changed (GConfClient *client,
                          guint cnxn_id,
                          GConfEntry *entry,
                          EMailSession *session)
{
	GSList *node;
	GPtrArray *name, *value;

	g_slist_foreach (config->jh_header, (GFunc) g_free, NULL);
	g_slist_free (config->jh_header);

	config->jh_header = gconf_client_get_list (
		client, "/apps/evolution/mail/junk/custom_header",
		GCONF_VALUE_STRING, NULL);

	node = config->jh_header;
	name = g_ptr_array_new ();
	value = g_ptr_array_new ();
	while (node && node->data) {
		gchar **tok = g_strsplit (node->data, "=", 2);
		g_ptr_array_add (name, g_strdup (tok[0]));
		g_ptr_array_add (value, g_strdup (tok[1]));
		node = node->next;
		g_strfreev (tok);
	}
	camel_session_set_junk_headers (
		CAMEL_SESSION (session),
		(const gchar **) name->pdata,
		(const gchar **) value->pdata, name->len);

	g_ptr_array_foreach (name, (GFunc) g_free, NULL);
	g_ptr_array_foreach (value, (GFunc) g_free, NULL);
	g_ptr_array_free (name, TRUE);
	g_ptr_array_free (value, TRUE);
}