Exemplo n.º 1
0
/* free with g_slist_free_full (flags, g_free);
   the lists' members are values for the String xml element. */
GSList *
ews_utils_gather_server_user_flags (ESoapMessage *msg,
				    CamelMessageInfo *mi)
{
	GSList *out_user_flags = NULL;
	const CamelNamedFlags *user_flags;
	guint ii, len;

	camel_message_info_property_lock (mi);

	user_flags = camel_message_info_get_user_flags (mi);
	len = camel_named_flags_get_length (user_flags);

	/* transfer camel flags to become the categories as an XML
	 * array of strings */
	for (ii = 0; ii < len; ii++) {
		const gchar *n = ews_utils_rename_label (camel_named_flags_get (user_flags, ii), FALSE);
		if (*n == '\0')
			continue;

		/* Skip evolution-defined flags which are not supposed to
		   be categories on an Exchange server */
		if (ews_utils_is_system_user_flag (n))
			continue;

		out_user_flags = g_slist_prepend (out_user_flags, g_strdup (n));
	}

	camel_message_info_property_unlock (mi);

	return g_slist_reverse (out_user_flags);
}
Exemplo n.º 2
0
static void
ews_utils_merge_server_user_flags (EEwsItem *item,
                                   CamelMessageInfo *mi)
{
	GSList *list = NULL;
	const GSList *p;
	const CamelNamedFlags *user_flags;
	guint ii, len;

	camel_message_info_property_lock (mi);
	camel_message_info_freeze_notifications (mi);

	user_flags = camel_message_info_get_user_flags (mi);
	len = camel_named_flags_get_length (user_flags);

	/* transfer camel flags to a list */
	for (ii = 0; ii < len; ii++) {
		const gchar *name = camel_named_flags_get (user_flags, ii);

		if (!ews_utils_is_system_user_flag (name))
			list = g_slist_prepend (list, (gchar *) name);
	}

	for (p = list; p; p = p->next) {
		/* remove custom user flags */
		camel_message_info_set_user_flag (mi, p->data, FALSE);
	}

	g_slist_free (list);

	/* now transfer over all the categories */
	for (p = e_ews_item_get_categories (item); p; p = p->next) {
		camel_message_info_set_user_flag (mi, ews_utils_rename_label (p->data, TRUE), TRUE);
	}

	camel_message_info_thaw_notifications (mi);
	camel_message_info_property_unlock (mi);
}
/**
 * camel_named_flags_equal:
 * @named_flags_a: (nullable): the first #CamelNamedFlags
 * @named_flags_b: (nullable): the second #CamelNamedFlags
 *
 * Compares content of the two #CamelNamedFlags and returns whether
 * they equal. Note this is an expensive operation for large sets.
 *
 * Returns: Whether the two #CamelNamedFlags have the same content.
 *
 * Since: 3.24
 **/
gboolean
camel_named_flags_equal (const CamelNamedFlags *named_flags_a,
			 const CamelNamedFlags *named_flags_b)
{
	guint ii, len;

	if (named_flags_a == named_flags_b)
		return TRUE;

	if (!named_flags_a || !named_flags_b)
		return camel_named_flags_get_length (named_flags_a) == camel_named_flags_get_length (named_flags_b);

	len = camel_named_flags_get_length (named_flags_a);
	if (len != camel_named_flags_get_length (named_flags_b))
		return FALSE;

	for (ii = 0; ii < len; ii++) {
		if (!camel_named_flags_contains (named_flags_a, camel_named_flags_get (named_flags_b, ii)))
			return FALSE;
	}

	return TRUE;
}