[861] in BarnOwl Developers

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

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

daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:10:30 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Sat, 12 Jan 2008 03:52:33 -0500 (EST)

Author: nelhage
Date: 2008-01-12 03:52:33 -0500 (Sat, 12 Jan 2008)
New Revision: 851

Modified:
   branches/barnowl_sqlite/owl/message.c
   branches/barnowl_sqlite/owl/perlwrap.pm
Log:
Fix the attribute list in `i'

Modified: branches/barnowl_sqlite/owl/message.c
===================================================================
--- branches/barnowl_sqlite/owl/message.c	2008-01-12 08:43:25 UTC (rev 850)
+++ branches/barnowl_sqlite/owl/message.c	2008-01-12 08:52:33 UTC (rev 851)
@@ -96,32 +96,6 @@
   return SvIV(attr);
 }
 
-/* We cheat and indent it for now, since we really want this for
- * the 'info' function.  Later there should just be a generic
- * function to indent fmtext.
- */
-void owl_message_attributes_tofmtext(owl_message *m, owl_fmtext *fm) {
-  int i, j;
-  owl_pair *p;
-  char *buff;
-
-  owl_fmtext_init_null(fm);
-
-  // XXX TODO FIXME
-  /*  j=owl_list_get_size(&(m->attributes));
-  for (i=0; i<j; i++) {
-    p=owl_list_get_element(&(m->attributes), i);
-    buff=owl_sprintf("  %-15.15s: %-35.35s\n", owl_pair_get_key(p), owl_pair_get_value(p));
-    if(buff == NULL) {
-      buff=owl_sprintf("  %-15.15s: %-35.35s\n", owl_pair_get_key(p), "<error>");
-      if(buff == NULL)
-        buff=owl_strdup("   <error>\n");
-    }
-    owl_fmtext_append_normal(fm, buff);
-    owl_free(buff);
-    }*/
-}
-
 int owl_message_get_id(owl_message *m) {
   return owl_message_get_attribute_int(m, "id");
 }
@@ -1093,3 +1067,17 @@
   owl_fmtext_free(&b);
 }
 
+void owl_message_attributes_tofmtext(owl_message *m, owl_fmtext *fm) {
+  int i, j;
+  owl_pair *p;
+  char *buff;
+
+  owl_fmtext_init_null(fm);
+
+  char *text = owl_perlconfig_message_call_method(m, "__format_attributes", 0, NULL);
+
+  owl_fmtext_append_normal(fm, text);
+
+  owl_free(text);
+}
+

Modified: branches/barnowl_sqlite/owl/perlwrap.pm
===================================================================
--- branches/barnowl_sqlite/owl/perlwrap.pm	2008-01-12 08:43:25 UTC (rev 850)
+++ branches/barnowl_sqlite/owl/perlwrap.pm	2008-01-12 08:52:33 UTC (rev 851)
@@ -323,6 +323,20 @@
     $self->{$attr} = $val;
 }
 
+sub __format_attributes {
+    my $self = shift;
+    my %skip = map {$_ => 1} qw(_time fields id deleted __fmtext type);
+    my $text = "";
+    my @keys = sort keys %$self;
+    for my $k (@keys) {
+        my $v = $self->{$k};
+        unless($skip{$k}) {
+            $text .= sprintf("  %-15.15s: %-35.35s\n", $k, $v);
+        }
+    }
+    return $text;
+}
+
 sub type        { return shift->{"type"}; }
 sub direction   { return shift->{"direction"}; }
 sub time        { return shift->{"time"}; }


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