[1006] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r992 - branches/barnowl_sqlite/owl

daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:12:04 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
X-Original-To: nelhage@nelhage.com
To: dirty-owl-hackers@MIT.EDU
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Wed, 26 Mar 2008 22:21:59 -0400 (EDT)

Author: nelhage
Date: 2008-03-26 22:21:59 -0400 (Wed, 26 Mar 2008)
New Revision: 992

Modified:
   branches/barnowl_sqlite/owl/functions.c
   branches/barnowl_sqlite/owl/owl.c
   branches/barnowl_sqlite/owl/owl.h
   branches/barnowl_sqlite/owl/view.c
Log:
Make views hold a filter name, rather than a filter object


Modified: branches/barnowl_sqlite/owl/functions.c
===================================================================
--- branches/barnowl_sqlite/owl/functions.c	2008-03-27 02:07:20 UTC (rev 991)
+++ branches/barnowl_sqlite/owl/functions.c	2008-03-27 02:21:59 UTC (rev 992)
@@ -2333,7 +2333,7 @@
     return;
   }
 
-  owl_view_new_filter(v, f);
+  owl_view_new_filter(v, filtname);
 
   /* Figure out what to set the current message to.
    * - If the view we're leaving has messages in it, go to the closest message
@@ -2341,7 +2341,7 @@
    * - If the view we're leaving is empty, try to restore the position
    *   from the last time we were in the new view.  */
   if(curid < 0) {
-    curid = owl_filter_get_cachedmsgid(v->filter);
+    curid = owl_filter_get_cachedmsgid(f);
   }
   owl_view_iterator_init_id(&it, v, curid);
 

Modified: branches/barnowl_sqlite/owl/owl.c
===================================================================
--- branches/barnowl_sqlite/owl/owl.c	2008-03-27 02:07:20 UTC (rev 991)
+++ branches/barnowl_sqlite/owl/owl.c	2008-03-27 02:21:59 UTC (rev 992)
@@ -330,7 +330,7 @@
 
   /* set the current view */
   owl_function_debugmsg("startup: setting the current view");
-  owl_view_create(owl_global_get_current_view(&g), "main", f);
+  owl_view_create(owl_global_get_current_view(&g), "main", "all");
   owl_global_set_current_style(&g, owl_global_get_style_by_name(&g, "default"));
   owl_function_firstmsg();
 

Modified: branches/barnowl_sqlite/owl/owl.h
===================================================================
--- branches/barnowl_sqlite/owl/owl.h	2008-03-27 02:07:20 UTC (rev 991)
+++ branches/barnowl_sqlite/owl/owl.h	2008-03-27 02:21:59 UTC (rev 992)
@@ -420,7 +420,7 @@
 
 typedef struct _owl_view {
   char *name;
-  owl_filter *filter;
+  char *filtname;
   owl_list messages;
 } owl_view;
 

Modified: branches/barnowl_sqlite/owl/view.c
===================================================================
--- branches/barnowl_sqlite/owl/view.c	2008-03-27 02:07:20 UTC (rev 991)
+++ branches/barnowl_sqlite/owl/view.c	2008-03-27 02:21:59 UTC (rev 992)
@@ -3,10 +3,10 @@
 
 static const char fileIdent[] = "$Id$";
 
-void owl_view_create(owl_view *v, char *name, owl_filter *f)
+void owl_view_create(owl_view *v, char *name, char *filtname)
 {
   v->name=owl_strdup(name);
-  v->filter=f;
+  v->filtname=owl_strdup(filtname);
   owl_list_create(&(v->messages));
   owl_view_recalculate(v);
 }
@@ -16,10 +16,15 @@
   return(v->name);
 }
 
+owl_filter * owl_view_get_filter(owl_view *v)
+{
+  return owl_global_get_filter(&g, v->filtname);
+}
+
 /* if the message matches the filter then add to view */
 void owl_view_consider_message(owl_view *v, owl_message *m)
 {
-  if (owl_filter_message_match(v->filter, m)) {
+  if (owl_filter_message_match(owl_view_get_filter(v), m)) {
     owl_list_append_element(&(v->messages),
                             (void*)owl_message_get_id(m));
   }
@@ -33,6 +38,7 @@
   owl_messagelist *gml;
   owl_list *ml;
   owl_message *m;
+  owl_filter *f;
 
   gml=owl_global_get_msglist(&g);
   ml=&(v->messages);
@@ -43,16 +49,18 @@
 
   /* find all the messages we want */
   owl_messagelist_start_iterate(gml);
+  f = owl_view_get_filter(v);
   while((m = owl_messagelist_iterate_next(gml)) != NULL) {
-    if (owl_filter_message_match(v->filter, m)) {
+    if (owl_filter_message_match(f, m)) {
       owl_list_append_element(ml, (void*)owl_message_get_id(m));
     }
   }
 }
 
-void owl_view_new_filter(owl_view *v, owl_filter *f)
+void owl_view_new_filter(owl_view *v, char *filtname)
 {
-  v->filter=f;
+  owl_free(v->filtname);
+  v->filtname = owl_strdup(filtname);
   owl_view_recalculate(v);
 }
 
@@ -109,7 +117,7 @@
  * be restored later if we switch back to this filter. */
 void owl_view_save_curmsgid(owl_view *v, int curid)
 {
-  owl_filter_set_cachedmsgid(v->filter, curid);
+  owl_filter_set_cachedmsgid(owl_view_get_filter(v), curid);
 }
 
 /* fmtext should already be initialized */
@@ -120,7 +128,7 @@
   owl_fmtext_append_normal(fm, "\n");
 
   owl_fmtext_append_normal(fm, "Filter: ");
-  owl_fmtext_append_normal(fm, owl_filter_get_name(v->filter));
+  owl_fmtext_append_normal(fm, owl_view_get_filtname(v));
   owl_fmtext_append_normal(fm, "\n");
 
   /* owl_fmtext_append_normal(fm, "Style: ");
@@ -130,13 +138,14 @@
 
 char *owl_view_get_filtname(owl_view *v)
 {
-  return(owl_filter_get_name(v->filter));
+  return v->filtname;
 }
 
 void owl_view_free(owl_view *v)
 {
   owl_list_free_simple(&(v->messages));
   if (v->name) owl_free(v->name);
+  if (v->filtname) owl_free(v->filtname);
 }
 
 /* View Iterators */


home help back first fref pref prev next nref lref last post