From d7a1c7699b7bc87e9beea29aec82bf7f35d3f35f Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 17 May 2011 23:16:24 +0300 Subject: [PATCH] * mu-msg-data, mu-msg-data: removed --- src/mu-msg-data-cache.c | 93 ----------------------------------------- src/mu-msg-data-cache.h | 50 ---------------------- src/mu-msg-data.c | 72 ------------------------------- src/mu-msg-data.h | 77 ---------------------------------- 4 files changed, 292 deletions(-) delete mode 100644 src/mu-msg-data-cache.c delete mode 100644 src/mu-msg-data-cache.h delete mode 100644 src/mu-msg-data.c delete mode 100644 src/mu-msg-data.h diff --git a/src/mu-msg-data-cache.c b/src/mu-msg-data-cache.c deleted file mode 100644 index 04b74039..00000000 --- a/src/mu-msg-data-cache.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -** Copyright (C) 2011 Dirk-Jan C. Binnema -** -** This program is free software; you can redistribute it and/or modify it -** under the terms of the GNU General Public License as published by the -** Free Software Foundation; either version 3, or (at your option) any -** later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU 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. -** -*/ - -#include "mu-msg-data-cache.h" - -/* we cannot use GPtrArray, because we require the index to be stable... */ -struct _MuMsgDataCache { - MuMsgData **_data; - guint _index, _size; -}; - -MuMsgDataCache * -mu_msg_data_cache_new (guint32 max_size) -{ - MuMsgDataCache *cache; - MuMsgData **data; - - data = g_try_new0 (MuMsgData*, max_size); - if (!data) { - g_warning ("cannot allocate %u bytes", (unsigned)max_size); - return NULL; - } - - cache = g_new (MuMsgDataCache, 1); - cache->_data = (MuMsgData**)data; - cache->_index = 0; - cache->_size = max_size; - - return cache; -} - - -void -mu_msg_data_cache_destroy (MuMsgDataCache *self) -{ - if (!self) - return; - - mu_msg_data_cache_clear (self); - - g_free (self); -} - - -void -mu_msg_data_cache_clear (MuMsgDataCache *self) -{ - unsigned i; - - g_return_if_fail (self); - - for (i = 0; i != self->_index; ++i) { - mu_msg_data_destroy (self->_data[i]); - self->_data[i] = NULL; - } - - self->_index = 0; -} - -void -mu_msg_data_cache_append (MuMsgDataCache *self, MuMsgData *data, gboolean copy) -{ - g_return_if_fail (self); - g_return_if_fail (self->_index < G_MAXUINT32); - g_return_if_fail (data); - - self->_data[self->_index++] = copy ? mu_msg_data_copy (data) : data; -} - -const MuMsgData * -mu_msg_data_cache_get (MuMsgDataCache *self, guint index) -{ - g_return_val_if_fail (self, NULL); - g_return_val_if_fail (index < self->_size, NULL); - - return self->_data[index]; -} diff --git a/src/mu-msg-data-cache.h b/src/mu-msg-data-cache.h deleted file mode 100644 index 5ea98cf0..00000000 --- a/src/mu-msg-data-cache.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -** Copyright (C) 2011 Dirk-Jan C. Binnema -** -** This program is free software; you can redistribute it and/or modify it -** under the terms of the GNU General Public License as published by the -** Free Software Foundation; either version 3, or (at your option) any -** later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU 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. -** -*/ - -#ifndef __MU_MSG_DATA_CACHE_H__ -#define __MU_MSG_DATA_CACHE_H__ - -/* MuMsgDataCache stores MuMsgData objects which are basically - * serialized MuMsgIters; putting them in a datastructure allows us to - * work on them, e.g., for message threading */ - -#include - -G_BEGIN_DECLS - -struct _MuMsgDataCache; -typedef struct _MuMsgDataCache MuMsgDataCache; - -/** - * create a new MuMsgDataCache instance - * - * @param max_size maximum size of the cache - * - * @return - */ -MuMsgDataCache *mu_msg_data_cache_new (guint32 max_size) - G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; -void mu_msg_data_cache_destroy (MuMsgDataCache *self); -void mu_msg_data_cache_clear (MuMsgDataCache *self); -void mu_msg_data_cache_append (MuMsgDataCache *self, MuMsgData *data, gboolean own); -const MuMsgData *mu_msg_data_cache_get (MuMsgDataCache *self, guint index); - -G_END_DECLS - -#endif /*__MU_MSG_DATA_CACHE_H__*/ diff --git a/src/mu-msg-data.c b/src/mu-msg-data.c deleted file mode 100644 index 1975ccd0..00000000 --- a/src/mu-msg-data.c +++ /dev/null @@ -1,72 +0,0 @@ -/* -** Copyright (C) 2011 Dirk-Jan C. Binnema -** -** This program is free software; you can redistribute it and/or modify it -** under the terms of the GNU General Public License as published by the -** Free Software Foundation; either version 3, or (at your option) any -** later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU 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. -** -*/ - -#include /* for memcpy */ -#include "mu-msg-data.h" - - -MuMsgData* -mu_msg_data_new (void) -{ - return g_slice_new0 (MuMsgData); -} - -MuMsgData* -mu_msg_data_copy (MuMsgData *mdata) -{ - MuMsgData *copy; - - if (!mdata) - return NULL; - - copy = mu_msg_data_new (); - - /* shallow copy */ - memcpy (copy, mdata, sizeof(MuMsgData)); - - /* now, deep-copy ptr data */ - copy->cc = g_strdup (mdata->cc); - copy->from = g_strdup (mdata->from); - copy->maildir = g_strdup (mdata->maildir); - copy->msgid = g_strdup (mdata->msgid); - copy->path = g_strdup (mdata->path); - copy->refs = g_strdup (mdata->refs); - copy->subject = g_strdup (mdata->subject); - copy->to = g_strdup (mdata->to); - - return copy; -} - -void -mu_msg_data_destroy (MuMsgData *mdata) -{ - if (!mdata) - return; - - g_free (mdata->cc); - g_free (mdata->from); - g_free (mdata->maildir); - g_free (mdata->msgid); - g_free (mdata->path); - g_free (mdata->refs); - g_free (mdata->subject); - g_free (mdata->to); - - g_slice_free (MuMsgData, mdata); -} diff --git a/src/mu-msg-data.h b/src/mu-msg-data.h deleted file mode 100644 index e8432562..00000000 --- a/src/mu-msg-data.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -** Copyright (C) 2011 Dirk-Jan C. Binnema -** -** This program is free software; you can redistribute it and/or modify it -** under the terms of the GNU General Public License as published by the -** Free Software Foundation; either version 3, or (at your option) any -** later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU 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. -** -*/ - -#ifndef __MU_MSG_DATA_H__ -#define __MU_MSG_DATA_H__ - -#include -#include -#include -#include - -G_BEGIN_DECLS - -/* data structure for saving the data in a MuMsgIter */ -struct _MuMsgData { - char *cc; - char *from; - char *maildir; - char *msgid; - char *path; - char *refs; - char *subject; - char *to; - - size_t size; - time_t date; - MuMsgFlags flags; - MuMsgPrio prio; -}; -typedef struct _MuMsgData MuMsgData; - - -/** - * create an _unitialized_ MuMsgData structure, ie. you still need to - * initialize the struct members. Free with mu_msg_data_destroy - * - * - * @return a newly allocated MuMsgData struct - */ -MuMsgData* mu_msg_data_new (void) G_GNUC_WARN_UNUSED_RESULT; - -/** - * free the MuMsgData structure - * - * @param mdata a mu msg data structure, or NULL - */ -void mu_msg_data_destroy (MuMsgData *mdata); - - -/** - * (deep)copy a MuMsgData structure - * - * @param mdata a mu msg data structure or NULL - * - * @return a copy, or NULL (free with mu_msg_data_destroy) - */ -MuMsgData* mu_msg_data_copy (MuMsgData *mdata); - -G_END_DECLS - -#endif /*__MU_MSG_DATA_H__*/