evolution-data-server r9977 - branches/gnome-2-24/camel/providers/local



Author: hiikezoe
Date: Tue Jan 27 23:23:52 2009
New Revision: 9977
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9977&view=rev

Log:
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.



Added:
   branches/gnome-2-24/camel/providers/local/camel-local-private.c
Modified:
   branches/gnome-2-24/camel/providers/local/ChangeLog
   branches/gnome-2-24/camel/providers/local/Makefile.am
   branches/gnome-2-24/camel/providers/local/camel-local-private.h
   branches/gnome-2-24/camel/providers/local/camel-mbox-summary.c
   branches/gnome-2-24/camel/providers/local/camel-spool-summary.c

Modified: branches/gnome-2-24/camel/providers/local/Makefile.am
==============================================================================
--- branches/gnome-2-24/camel/providers/local/Makefile.am	(original)
+++ branches/gnome-2-24/camel/providers/local/Makefile.am	Tue Jan 27 23:23:52 2009
@@ -29,6 +29,7 @@
 	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			\

Added: branches/gnome-2-24/camel/providers/local/camel-local-private.c
==============================================================================
--- (empty file)
+++ branches/gnome-2-24/camel/providers/local/camel-local-private.c	Tue Jan 27 23:23:52 2009
@@ -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;
+}

Modified: branches/gnome-2-24/camel/providers/local/camel-local-private.h
==============================================================================
--- branches/gnome-2-24/camel/providers/local/camel-local-private.h	(original)
+++ branches/gnome-2-24/camel/providers/local/camel-local-private.h	Tue Jan 27 23:23:52 2009
@@ -42,6 +42,8 @@
 #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 */

Modified: branches/gnome-2-24/camel/providers/local/camel-mbox-summary.c
==============================================================================
--- branches/gnome-2-24/camel/providers/local/camel-mbox-summary.c	(original)
+++ branches/gnome-2-24/camel/providers/local/camel-mbox-summary.c	Tue Jan 27 23:23:52 2009
@@ -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 @@
 {
 	/*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 @@
 		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";
 

Modified: branches/gnome-2-24/camel/providers/local/camel-spool-summary.c
==============================================================================
--- branches/gnome-2-24/camel/providers/local/camel-spool-summary.c	(original)
+++ branches/gnome-2-24/camel/providers/local/camel-spool-summary.c	Tue Jan 27 23:23:52 2009
@@ -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 @@
 	/*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 @@
 
 	((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";
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]