static void
e_ews_convert_sexp_to_restriction (ESoapMessage *msg,
                                   const gchar *query,
                                   EEwsFolderType type)
{
	ESExp *sexp;
	ESExpResult *r;
	gint i;

	sexp = e_sexp_new ();

	if (type == E_EWS_FOLDER_TYPE_CONTACTS) {
		for (i = 0; i < G_N_ELEMENTS (contact_symbols); i++) {
			if (contact_symbols[i].immediate)
				e_sexp_add_ifunction (
					sexp, 0, contact_symbols[i].name,
					(ESExpIFunc *) contact_symbols[i].func, msg);
			else
				e_sexp_add_function (
					sexp, 0, contact_symbols[i].name,
					contact_symbols[i].func, msg);
		}

	} else if (type == E_EWS_FOLDER_TYPE_CALENDAR || type == E_EWS_FOLDER_TYPE_TASKS || type == E_EWS_FOLDER_TYPE_MEMOS) {
		for (i = 0; i < G_N_ELEMENTS (calendar_symbols); i++) {
			if (calendar_symbols[i].immediate)
				e_sexp_add_ifunction (
					sexp, 0, calendar_symbols[i].name,
					(ESExpIFunc *) calendar_symbols[i].func, msg);
			else
				e_sexp_add_function (
					sexp, 0, calendar_symbols[i].name,
					calendar_symbols[i].func, msg);
		}
	} else if (type == E_EWS_FOLDER_TYPE_MAILBOX) {
		for (i = 0; i < G_N_ELEMENTS (message_symbols); i++) {
			if (message_symbols[i].immediate)
				e_sexp_add_ifunction (
					sexp, 0, message_symbols[i].name,
					(ESExpIFunc *) message_symbols[i].func, msg);
			else
				e_sexp_add_function (
					sexp, 0, message_symbols[i].name,
					message_symbols[i].func, msg);
		}

	}

	e_sexp_input_text (sexp, query, strlen (query));
	e_sexp_parse (sexp);

	r = e_sexp_eval (sexp);
	if (!r)
		return;

	e_sexp_result_free (sexp, r);
	e_sexp_unref (sexp);
}
static void
e_cal_backend_sexp_finalize (GObject *object)
{
	ECalBackendSExpPrivate *priv;

	priv = E_CAL_BACKEND_SEXP_GET_PRIVATE (object);

	e_sexp_unref (priv->search_sexp);
	g_free (priv->text);
	g_free (priv->search_context);

	/* Chain up to parent's finalize() method. */
	G_OBJECT_CLASS (e_cal_backend_sexp_parent_class)->finalize (object);
}