<commit_before>/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Authors :
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 * USA
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <glib.h>
#include <glib/gprintf.h>
#include <libsoup/soup-misc.h>
#include "e-ews-item.h"
#include "e-ews-connection.h"
#include "e-ews-message.h"

G_DEFINE_TYPE (EEwsItem, e_ews_item, G_TYPE_OBJECT)

struct _EEwsItemPrivate {
	EEwsItemType item_type;

	/* MAPI properties */
	/* The Exchange server is so fundamentally misdesigned that it doesn't expose
	   certain information in a coherent way; the \Answered, and \Deleted message
	   flags don't even seem to work properly. It looks like the only way to work
	   it out is from the PidTagIconIndex field. Quite what the hell an *icon*
	   selector is doing in the database, I have absolutely no fucking idea; a
	   database is supposed to represent the *data*, not do bizarre things that
	   live in the client. But that's typical Exchange brain damage for you... */
	guint32 mapi_icon_index;		/* http://msdn.microsoft.com/en-us/library/cc815472.aspx */
	guint32 mapi_last_verb_executed;	/* http://msdn.microsoft.com/en-us/library/cc841968.aspx */
	guint32 mapi_message_status;		/* http://msdn.microsoft.com/en-us/library/cc839915.aspx */
	guint32 mapi_message_flags;		/* http://msdn.microsoft.com/en-us/library/cc839733.aspx */

	/* properties */
	EwsId *item_id;
	gchar *subject;
	gchar *mime_content;

	time_t date_received;
	time_t date_sent;
	time_t date_created;

	gsize size;
	gchar *msg_id;
	gchar *in_replyto;
	gchar *references;
	gboolean has_attachments;
	gboolean is_read;
	EwsImportance importance;

	GSList *to_recipients;
	GSList *cc_recipients;
	GSList *bcc_recipients;

	EwsMailbox *from;
	EwsMailbox *sender;

	GSList *modified_occurrences;
	GSList *attachments_list;
};

static GObjectClass *parent_class = NULL;
static void	ews_item_free_mailbox (EwsMailbox *mb);

static void
e_ews_item_dispose (GObject *object)
{
	EEwsItem *item = (EEwsItem *) object;
	EEwsItemPrivate *priv;

	g_return_if_fail (E_IS_EWS_ITEM (item));

	priv = item->priv;

	if (priv->item_id) {
		g_free (priv->item_id);
		priv->item_id = NULL;
	}

	g_free (priv->subject);
	priv->subject = NULL;

	g_free (priv->msg_id);
	priv->msg_id = NULL;

	g_free (priv->in_replyto);
	priv->in_replyto = NULL;

	g_free (priv->references);
	priv->references = NULL;

	if (priv->to_recipients) {
		g_slist_foreach (priv->to_recipients, (GFunc) ews_item_free_mailbox, NULL);<commit_msg>Fix leak of ->item_id->id and ->item_id->changekey in EEwsItem<commit_after>/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Authors :
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 * USA
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <glib.h>
#include <glib/gprintf.h>
#include <libsoup/soup-misc.h>
#include "e-ews-item.h"
#include "e-ews-connection.h"
#include "e-ews-message.h"

G_DEFINE_TYPE (EEwsItem, e_ews_item, G_TYPE_OBJECT)

struct _EEwsItemPrivate {
	EEwsItemType item_type;

	/* MAPI properties */
	/* The Exchange server is so fundamentally misdesigned that it doesn't expose
	   certain information in a coherent way; the \Answered, and \Deleted message
	   flags don't even seem to work properly. It looks like the only way to work
	   it out is from the PidTagIconIndex field. Quite what the hell an *icon*
	   selector is doing in the database, I have absolutely no fucking idea; a
	   database is supposed to represent the *data*, not do bizarre things that
	   live in the client. But that's typical Exchange brain damage for you... */
	guint32 mapi_icon_index;		/* http://msdn.microsoft.com/en-us/library/cc815472.aspx */
	guint32 mapi_last_verb_executed;	/* http://msdn.microsoft.com/en-us/library/cc841968.aspx */
	guint32 mapi_message_status;		/* http://msdn.microsoft.com/en-us/library/cc839915.aspx */
	guint32 mapi_message_flags;		/* http://msdn.microsoft.com/en-us/library/cc839733.aspx */

	/* properties */
	EwsId *item_id;
	gchar *subject;
	gchar *mime_content;

	time_t date_received;
	time_t date_sent;
	time_t date_created;

	gsize size;
	gchar *msg_id;
	gchar *in_replyto;
	gchar *references;
	gboolean has_attachments;
	gboolean is_read;
	EwsImportance importance;

	GSList *to_recipients;
	GSList *cc_recipients;
	GSList *bcc_recipients;

	EwsMailbox *from;
	EwsMailbox *sender;

	GSList *modified_occurrences;
	GSList *attachments_list;
};

static GObjectClass *parent_class = NULL;
static void	ews_item_free_mailbox (EwsMailbox *mb);

static void
e_ews_item_dispose (GObject *object)
{
	EEwsItem *item = (EEwsItem *) object;
	EEwsItemPrivate *priv;

	g_return_if_fail (E_IS_EWS_ITEM (item));

	priv = item->priv;

	if (priv->item_id) {
		g_free (priv->item_id->id);
		g_free (priv->item_id->change_key);
		g_free (priv->item_id);
		priv->item_id = NULL;
	}

	g_free (priv->subject);
	priv->subject = NULL;

	g_free (priv->msg_id);
	priv->msg_id = NULL;

	g_free (priv->in_replyto);
	priv->in_replyto = NULL;

	g_free (priv->references);
	priv->references = NULL;

	if (priv->to_recipients) {
		g_slist_foreach (priv->to_recipients, (GFunc) ews_item_free_mailbox, NULL);
{'fraction_non_alphanumeric': 0.10899424014178112, 'fraction_numerical': 0.01595037660611431, 'mean_word_length': 4.23338485316847, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7285079', 'n_tokens_mistral': 2524, 'n_tokens_neox': 2346, 'n_words': 716}