diff options
author | Hiroyuki Ikezoe <poincare@ikezoe.net> | 2009-01-27 23:23:52 +0000 |
---|---|---|
committer | Hiroyuki Ikezoe <hiikezoe@src.gnome.org> | 2009-01-27 23:23:52 +0000 |
commit | 9e93356f5b6d5551330315299f7f838b0a8a9123 (patch) | |
tree | 7fd80577def177bc7b4bddbf654d72d54c05affc | |
parent | 2a48d5f7ff3d40773cbce1c647fe8b87773bdf0d (diff) | |
download | evolution-data-server-9e93356f5b6d5551330315299f7f838b0a8a9123.tar.gz |
Move frompos_sort from camel-mbox-summary.c, and rename to
2009-01-28 Hiroyuki Ikezoe <poincare@ikezoe.net>
* camel-local-provider.[ch]: Move frompos_sort from
camel-mbox-summary.c, and rename to camel_local_frompos_sort.
And just return substraction a2 from a1.
* camel-mbox-summary.c, camel-spool-summary.c: Use
camel_local_frompos_sort for camel_db_set_collate.
svn path=/branches/gnome-2-24/; revision=9977
-rw-r--r-- | camel/providers/local/ChangeLog | 9 | ||||
-rw-r--r-- | camel/providers/local/Makefile.am | 1 | ||||
-rw-r--r-- | camel/providers/local/camel-local-private.c | 53 | ||||
-rw-r--r-- | camel/providers/local/camel-local-private.h | 2 | ||||
-rw-r--r-- | camel/providers/local/camel-mbox-summary.c | 26 | ||||
-rw-r--r-- | camel/providers/local/camel-spool-summary.c | 27 |
6 files changed, 69 insertions, 49 deletions
diff --git a/camel/providers/local/ChangeLog b/camel/providers/local/ChangeLog index ce93eb650..439196b81 100644 --- a/camel/providers/local/ChangeLog +++ b/camel/providers/local/ChangeLog @@ -1,3 +1,12 @@ +2009-01-28 Hiroyuki Ikezoe <poincare@ikezoe.net> + + * camel-local-provider.[ch]: Move frompos_sort from + camel-mbox-summary.c, and rename to camel_local_frompos_sort. + And just return substraction a2 from a1. + + * camel-mbox-summary.c, camel-spool-summary.c: Use + camel_local_frompos_sort for camel_db_set_collate. + 2009-01-12 Srinivasa Ragavan <sragavan@novell.com> * camel-mbox-folder.c: (mbox_get_message): Revert previous fix diff --git a/camel/providers/local/Makefile.am b/camel/providers/local/Makefile.am index 78fd4afb2..f52ce4644 100644 --- a/camel/providers/local/Makefile.am +++ b/camel/providers/local/Makefile.am @@ -29,6 +29,7 @@ libcamellocal_la_SOURCES = \ camel-local-folder.c \ camel-local-store.c \ camel-local-summary.c \ + camel-local-private.c \ camel-local-provider.c \ camel-mbox-folder.c \ camel-mbox-store.c \ diff --git a/camel/providers/local/camel-local-private.c b/camel/providers/local/camel-local-private.c new file mode 100644 index 000000000..38fedceff --- /dev/null +++ b/camel/providers/local/camel-local-private.c @@ -0,0 +1,53 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- + * + * Copyright (C) 2008 Novell, Inc. (www.novell.com) + * + * Authors: Srinivsa Ragavan <sragavan@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 + * 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 <glib.h> +#include <string.h> +#include <stdlib.h> +#include "camel-local-private.h" + +int +camel_local_frompos_sort (void *enc, int len1, void * data1, int len2, void *data2) +{ + static char *sa1=NULL, *sa2=NULL; + static int l1=0, l2=0; + int a1, a2; + + if (l1 < len1+1) { + sa1 = g_realloc (sa1, len1+1); + l1 = len1+1; + } + if (l2 < len2+1) { + sa2 = g_realloc (sa2, len2+1); + l2 = len2+1; + } + strncpy (sa1, data1, len1);sa1[len1] = 0; + strncpy (sa2, data2, len2);sa2[len2] = 0; + + a1 = strtoul (sa1, NULL, 10); + a2 = strtoul (sa2, NULL, 10); + + return a1 - a2; +} diff --git a/camel/providers/local/camel-local-private.h b/camel/providers/local/camel-local-private.h index 22b527763..950e3d820 100644 --- a/camel/providers/local/camel-local-private.h +++ b/camel/providers/local/camel-local-private.h @@ -42,6 +42,8 @@ struct _CamelLocalFolderPrivate { #define CAMEL_LOCAL_FOLDER_LOCK(f, l) (g_mutex_lock(((CamelLocalFolder *)f)->priv->l)) #define CAMEL_LOCAL_FOLDER_UNLOCK(f, l) (g_mutex_unlock(((CamelLocalFolder *)f)->priv->l)) +int camel_local_frompos_sort (void *enc, int len1, void * data1, int len2, void *data2); + G_END_DECLS #endif /* CAMEL_LOCAL_PRIVATE_H */ diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c index ea489d6fa..e34fbc5c8 100644 --- a/camel/providers/local/camel-mbox-summary.c +++ b/camel/providers/local/camel-mbox-summary.c @@ -46,6 +46,7 @@ #include "camel-string-utils.h" #include "camel-store.h" #include "camel-folder.h" +#include "camel-local-private.h" #define io(x) #define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/ @@ -211,29 +212,6 @@ camel_mbox_summary_finalise(CamelObject *obj) { /*CamelMboxSummary *mbs = CAMEL_MBOX_SUMMARY(obj);*/ } -static int -frompos_sort (void *enc, int len1, void * data1, int len2, void *data2) -{ - static char *sa1=NULL, *sa2=NULL; - static int l1=0, l2=0; - int a1, a2; - - if (l1 < len1+1) { - sa1 = g_realloc (sa1, len1+1); - l1 = len1+1; - } - if (l2 < len2+1) { - sa2 = g_realloc (sa2, len2+1); - l2 = len2+1; - } - strncpy (sa1, data1, len1);sa1[len1] = 0; - strncpy (sa2, data2, len2);sa2[len2] = 0; - - a1 = strtoul (sa1, NULL, 10); - a2 = strtoul (sa2, NULL, 10); - - return (a1 < a1) ? -1 : (a1 > a2) ? 1 : 0; -} /** * camel_mbox_summary_new: @@ -252,7 +230,7 @@ camel_mbox_summary_new(struct _CamelFolder *folder, const char *filename, const CamelFolderSummary *summary = (CamelFolderSummary *)new; /* Set the functions for db sorting */ - camel_db_set_collate (folder->parent_store->cdb_r, "bdata", "mbox_frompos_sort", (CamelDBCollate)frompos_sort); + camel_db_set_collate (folder->parent_store->cdb_r, "bdata", "mbox_frompos_sort", (CamelDBCollate)camel_local_frompos_sort); summary->sort_by = "bdata"; summary->collate = "mbox_frompos_sort"; diff --git a/camel/providers/local/camel-spool-summary.c b/camel/providers/local/camel-spool-summary.c index 644de220a..ba1c7b834 100644 --- a/camel/providers/local/camel-spool-summary.c +++ b/camel/providers/local/camel-spool-summary.c @@ -41,6 +41,7 @@ #include "camel-store.h" #include "camel-spool-summary.h" +#include "camel-local-private.h" #define io(x) #define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/ @@ -107,30 +108,6 @@ camel_spool_summary_finalise(CamelObject *obj) /*CamelSpoolSummary *mbs = CAMEL_SPOOL_SUMMARY(obj);*/ } -static int -frompos_sort (void *enc, int len1, void * data1, int len2, void *data2) -{ - static char *sa1=NULL, *sa2=NULL; - static int l1=0, l2=0; - int a1, a2; - - if (l1 < len1+1) { - sa1 = g_realloc (sa1, len1+1); - l1 = len1+1; - } - if (l2 < len2+1) { - sa2 = g_realloc (sa2, len2+1); - l2 = len2+1; - } - strncpy (sa1, data1, len1);sa1[len1] = 0; - strncpy (sa2, data2, len2);sa2[len2] = 0; - - a1 = strtoul (sa1, NULL, 10); - a2 = strtoul (sa2, NULL, 10); - - return (a1 < a1) ? -1 : (a1 > a2) ? 1 : 0; -} - CamelSpoolSummary * camel_spool_summary_new(struct _CamelFolder *folder, const char *mbox_name) { @@ -138,7 +115,7 @@ camel_spool_summary_new(struct _CamelFolder *folder, const char *mbox_name) ((CamelFolderSummary *)new)->folder = folder; if (folder) { - camel_db_set_collate (folder->parent_store->cdb_r, "bdata", "spool_frompos_sort", (CamelDBCollate)frompos_sort); + camel_db_set_collate (folder->parent_store->cdb_r, "bdata", "spool_frompos_sort", (CamelDBCollate)camel_local_frompos_sort); ((CamelFolderSummary *)new)->sort_by = "bdata"; ((CamelFolderSummary *)new)->collate = "spool_frompos_sort"; } |