]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2004-01-11 18:26:02 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 11 Jan 2004 18:26:02 +0000 (18:26 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 11 Jan 2004 18:26:02 +0000 (18:26 +0000)
further widget and layout processing

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@306 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

Makefile.am
Makefile.in
cfg.c
drv_MatrixOrbital.c
layout.c
plugin.c
plugin_string.c
widget.c
widget.h
widget_text.c

index 25f11649a8afb3765a16ea4edb69feb8ed0249d2..d143f1cde5749a95a028e2dc72cb9f134832a062 100644 (file)
@@ -22,6 +22,7 @@ evaluator.c evaluator.h \
 plugin.c plugin.h \
 plugin_math.c \
 plugin_string.c \
+plugin_cfg.c \
 plugin_xmms.c \
 plugin_i2c_sensors.c \
 widget.c widget.h \
index 77ce17d9fbcbc17a0189ef995a5ba0517303f2bb..83c17afc61295af79371c06ecac3cebc0a7dbb4d 100644 (file)
@@ -101,7 +101,7 @@ AM_CFLAGS = $(X_CFLAGS) -D_GNU_SOURCE -Wall
 lcd4linux_LDFLAGS = $(X_LIBS)
 lcd4linux_LDADD = liblcd4linux.la @DRVLIBS@ 
 
-lcd4linux_SOURCES =  lcd4linux.c pid.c pid.h parser.c parser.h processor.c processor.h layout.c layout.h evaluator.c evaluator.h plugin.c plugin.h plugin_math.c plugin_string.c plugin_xmms.c plugin_i2c_sensors.c widget.c widget.h widget_text.c widget_text.h system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h exec.c exec.h expr.c expr.h mail2.c socket.c socket.h imon.c imon.h
+lcd4linux_SOURCES =  lcd4linux.c pid.c pid.h parser.c parser.h processor.c processor.h layout.c layout.h evaluator.c evaluator.h plugin.c plugin.h plugin_math.c plugin_string.c plugin_cfg.c plugin_xmms.c plugin_i2c_sensors.c widget.c widget.h widget_text.c widget_text.h system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h exec.c exec.h expr.c expr.h mail2.c socket.c socket.h imon.c imon.h
 
 
 liblcd4linux_la_DEPENDENCIES = @DRIVERS@
@@ -139,11 +139,11 @@ PROGRAMS =  $(bin_PROGRAMS)
 lcd4linux_OBJECTS =  lcd4linux.$(OBJEXT) pid.$(OBJEXT) parser.$(OBJEXT) \
 processor.$(OBJEXT) layout.$(OBJEXT) evaluator.$(OBJEXT) \
 plugin.$(OBJEXT) plugin_math.$(OBJEXT) plugin_string.$(OBJEXT) \
-plugin_xmms.$(OBJEXT) plugin_i2c_sensors.$(OBJEXT) widget.$(OBJEXT) \
-widget_text.$(OBJEXT) system.$(OBJEXT) isdn.$(OBJEXT) wifi.$(OBJEXT) \
-mail.$(OBJEXT) seti.$(OBJEXT) battery.$(OBJEXT) dvb.$(OBJEXT) \
-filter.$(OBJEXT) exec.$(OBJEXT) expr.$(OBJEXT) mail2.$(OBJEXT) \
-socket.$(OBJEXT) imon.$(OBJEXT)
+plugin_cfg.$(OBJEXT) plugin_xmms.$(OBJEXT) plugin_i2c_sensors.$(OBJEXT) \
+widget.$(OBJEXT) widget_text.$(OBJEXT) system.$(OBJEXT) isdn.$(OBJEXT) \
+wifi.$(OBJEXT) mail.$(OBJEXT) seti.$(OBJEXT) battery.$(OBJEXT) \
+dvb.$(OBJEXT) filter.$(OBJEXT) exec.$(OBJEXT) expr.$(OBJEXT) \
+mail2.$(OBJEXT) socket.$(OBJEXT) imon.$(OBJEXT)
 lcd4linux_DEPENDENCIES =  liblcd4linux.la
 CFLAGS = @CFLAGS@
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -169,10 +169,10 @@ DEP_FILES =  .deps/BeckmannEgle.P .deps/Crystalfontz.P .deps/Cwlinux.P \
 .deps/expr.P .deps/filter.P .deps/fontmap.P .deps/icon.P .deps/imon.P \
 .deps/isdn.P .deps/layout.P .deps/lcd4linux.P .deps/lock.P .deps/mail.P \
 .deps/mail2.P .deps/parport.P .deps/parser.P .deps/pid.P .deps/pixmap.P \
-.deps/plugin.P .deps/plugin_i2c_sensors.P .deps/plugin_math.P \
-.deps/plugin_string.P .deps/plugin_xmms.P .deps/processor.P \
-.deps/seti.P .deps/socket.P .deps/system.P .deps/udelay.P \
-.deps/widget.P .deps/widget_text.P .deps/wifi.P
+.deps/plugin.P .deps/plugin_cfg.P .deps/plugin_i2c_sensors.P \
+.deps/plugin_math.P .deps/plugin_string.P .deps/plugin_xmms.P \
+.deps/processor.P .deps/seti.P .deps/socket.P .deps/system.P \
+.deps/udelay.P .deps/widget.P .deps/widget_text.P .deps/wifi.P
 SOURCES = $(liblcd4linux_la_SOURCES) $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES)
 OBJECTS = $(liblcd4linux_la_OBJECTS) $(lcd4linux_OBJECTS)
 
diff --git a/cfg.c b/cfg.c
index c5983d4b3d84d165cad5d16151a66fd4d4ad32f7..7e0becf54cc856e6d8d085e5fac53e4a694a3ca0 100644 (file)
--- a/cfg.c
+++ b/cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.25 2004/01/11 09:26:15 reinelt Exp $^
+/* $Id: cfg.c,v 1.26 2004/01/11 18:26:02 reinelt Exp $^
  *
  * config file stuff
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: cfg.c,v $
+ * Revision 1.26  2004/01/11 18:26:02  reinelt
+ * further widget and layout processing
+ *
  * Revision 1.25  2004/01/11 09:26:15  reinelt
  * layout starts to exist...
  *
 
 #include "debug.h"
 #include "cfg.h"
-#include "plugin.h"
 
 typedef struct {
   char *key;
@@ -396,12 +398,15 @@ char *l4l_cfg_get (char *section, char *key, char *defval)
 
 int l4l_cfg_number (char *section, char *key, int defval, int min, int max, int *value) 
 {
-  
   char *s, *e;
   
+  // start with default value
+  // in case of an (uncatched) error, you have the
+  // default value set, which may be handy...
+  *value=defval;
+
   s=cfg_get(section, key, NULL);
   if (s==NULL) {
-    *value=defval;
     return 0;
   }
   
@@ -529,12 +534,6 @@ static int cfg_read (char *file)
       val++;
     }
 
-    // provess 'value' in single-quotes
-    else if (*val=='\'' && *end=='\'') {
-      *end='\0';
-      val++;
-    }
-    
     // if key is '}', a section has been closed
     if (strcmp(key, "}")==0) {
       section_close=1;
@@ -613,39 +612,6 @@ static int cfg_read (char *file)
 }
 
 
-static void cfg_plugin (RESULT *result, int argc, RESULT *argv[])
-{
-  int i, len;
-  char *value;
-  char *buffer;
-  
-  // calculate key length
-  len=0;
-  for (i=0; i<argc; i++) {
-    len+=strlen(R2S(argv[i]))+1;
-  }
-  
-  // allocate key buffer
-  buffer=malloc(len+1);
-  
-  // prepare key buffer
-  *buffer='\0';
-  for (i=0; i<argc; i++) {
-    strcat (buffer, ".");
-    strcat (buffer, R2S(argv[i]));
-  }
-  
-  // buffer starts with '.', so cut off first char
-  value=cfg_get("", buffer+1, "");
-  
-  // free buffer again
-  free (buffer);
-  
-  // store result
-  SetResult(&result, R_STRING, value); 
-}
-
-
 int l4l_cfg_init (char *file)
 {
   if (cfg_check_source(file) == -1) {
@@ -658,9 +624,6 @@ int l4l_cfg_init (char *file)
   if (Config_File) free (Config_File);
   Config_File=strdup(file);
   
-  // register as a plugin
-  AddFunction ("cfg", -1, cfg_plugin);
-  
   return 0;
 }
 
index 03fc5b49b1f1e431f2d3c6c594ed0e0a80bd73f7..5ca694ac5810e9aae58ea8964ebe908ab75cd665 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.5 2004/01/11 09:26:15 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.6 2004/01/11 18:26:02 reinelt Exp $
  *
  * new style driver for Matrix Orbital serial display modules
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.6  2004/01/11 18:26:02  reinelt
+ * further widget and layout processing
+ *
  * Revision 1.5  2004/01/11 09:26:15  reinelt
  * layout starts to exist...
  *
@@ -678,7 +681,7 @@ int drv_MO_init (char *section)
   
   // register text widget
   wc=Widget_Text;
-  wc.render=NULL;
+  wc.draw=NULL; //Fixme
   widget_register(&wc);
   
   // register plugins
index 65b03731f9394a15a8f4585e974e14feea430b86..13d05f95cbd5b18d217ae61818327daa3110bbd4 100644 (file)
--- a/layout.c
+++ b/layout.c
@@ -1,4 +1,4 @@
-/* $Id: layout.c,v 1.2 2004/01/11 09:26:15 reinelt Exp $
+/* $Id: layout.c,v 1.3 2004/01/11 18:26:02 reinelt Exp $
  *
  * new layouter framework
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: layout.c,v $
+ * Revision 1.3  2004/01/11 18:26:02  reinelt
+ * further widget and layout processing
+ *
  * Revision 1.2  2004/01/11 09:26:15  reinelt
  * layout starts to exist...
  *
 #include "layout.h"
 
 
-void layout_addItem (char *name, int row, int col)
+int layout_addItem (char *name, int row, int col)
 {
-
-  debug ("layout_addItem(%s, %d, %d)", name, row, col);
+  // allocate widget
+  widget_add (name);
+  
 }
 
 
@@ -69,8 +73,6 @@ int layout_init (char *layout)
   char *widget;
   int row, col;
   
-  char buffer[32];
-  
   info ("initializing layout '%s'", layout);
   
   // prepare config section
index 405f15dcb7e4aaf0765f4a20737ac51ea5c574c6..ec60dbeb2a2b3de5e58a4843089d3401f79597ee 100644 (file)
--- a/plugin.c
+++ b/plugin.c
@@ -1,4 +1,4 @@
-/* $Id: plugin.c,v 1.8 2004/01/10 20:22:33 reinelt Exp $
+/* $Id: plugin.c,v 1.9 2004/01/11 18:26:02 reinelt Exp $
  *
  * plugin handler for the Evaluator
  *
@@ -22,6 +22,9 @@
  *
  *
  * $Log: plugin.c,v $
+ * Revision 1.9  2004/01/11 18:26:02  reinelt
+ * further widget and layout processing
+ *
  * Revision 1.8  2004/01/10 20:22:33  reinelt
  * added new function 'cfg_list()' (not finished yet)
  * added layout.c (will replace processor.c someday)
@@ -93,6 +96,7 @@
 // Prototypes
 int plugin_init_math (void);
 int plugin_init_string (void);
+int plugin_init_cfg (void);
 int plugin_init_xmms (void);
 int plugin_init_i2c_sensors (void);
 
@@ -101,6 +105,7 @@ int plugin_init (void)
 {
   plugin_init_math();
   plugin_init_string();
+  plugin_init_cfg();
   plugin_init_xmms();
   // MR: segfaults here
   // plugin_init_i2c_sensors();
index 63ca3a7237f56544150f8a9f11bb6c55363f686f..1b3050a7924aa2b7011722ca7275198640034762 100644 (file)
@@ -1,8 +1,9 @@
-/* $Id: plugin_string.c,v 1.1 2003/12/19 05:50:34 reinelt Exp $
+/* $Id: plugin_string.c,v 1.2 2004/01/11 18:26:02 reinelt Exp $
  *
  * string plugin
  *
- * Copyright 2003 Michael Reinelt <reinelt@eunet.at>
+ * Copyright 2003,2004 Michael Reinelt <reinelt@eunet.at>
+ * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
  *
  * This file is part of LCD4Linux.
  *
@@ -22,6 +23,9 @@
  *
  *
  * $Log: plugin_string.c,v $
+ * Revision 1.2  2004/01/11 18:26:02  reinelt
+ * further widget and layout processing
+ *
  * Revision 1.1  2003/12/19 05:50:34  reinelt
  * added plugin_math.c and plugin_string.c
  *
index 301914dc3becb17d1d6598e76e762cae15703c56..60414fe95c6f7e195e131a2b30563b38ebf37c39 100644 (file)
--- a/widget.c
+++ b/widget.c
@@ -1,4 +1,4 @@
-/* $Id: widget.c,v 1.5 2004/01/11 09:26:15 reinelt Exp $
+/* $Id: widget.c,v 1.6 2004/01/11 18:26:02 reinelt Exp $
  *
  * generic widget handling
  *
@@ -21,6 +21,9 @@
  *
  *
  * $Log: widget.c,v $
+ * Revision 1.6  2004/01/11 18:26:02  reinelt
+ * further widget and layout processing
+ *
  * Revision 1.5  2004/01/11 09:26:15  reinelt
  * layout starts to exist...
  *
@@ -86,12 +89,50 @@ int widget_register (WIDGET_CLASS *widget)
 }
 
 
-int widget_add (char *section, char *name)
+int widget_add (char *name)
 {
+  int i;
+  char *section;
+  char *class;
+  
+  WIDGET_CLASS *Class;
+  WIDGET       *Widget;
+  
+  // prepare config section
+  // strlen("Widget:")=7
+  section=malloc(strlen(name)+8);
+  strcpy(section, "Widget:");
+  strcat(section, name);
+  
+  // get widget class
+  class=cfg_get(section, "class", NULL);
+  if (class==NULL || *class=='\0') {
+    error ("error: widget '%s' has no class!", name);
+    return -1;
+  }
+  
+  // lookup widget class
+  for (i=0; i<nClasses; i++) {
+    if (strcasecmp(class, Classes[i].name)==0) {
+      Class=&(Classes[i]);
+      break;
+    }
+  }
+  if (i==nClasses) {
+    error ("widget '%s': class '%s' not supported");
+    return -1;
+  }
+  
   nWidgets++;
   Widgets=realloc(Widgets, nWidgets*sizeof(WIDGET));
-
-  Widgets[nWidgets-1].name = name;
+  Widget=&(Widgets[nWidgets-1]);
+  
+  Widget->name  = name;
+  Widget->class = Class;
   
+  if (Class->init!=0) {
+    Class->init(Widget);
+  }
+
   return 0;
 }
index 2ff0c8d4325cb530fd0782a407a0fd49c3b0936c..181e20bceb345dcdff79c765368201b7d79917b3 100644 (file)
--- a/widget.h
+++ b/widget.h
@@ -1,4 +1,4 @@
-/* $Id: widget.h,v 1.4 2004/01/10 20:22:33 reinelt Exp $
+/* $Id: widget.h,v 1.5 2004/01/11 18:26:02 reinelt Exp $
  *
  * generic widget handling
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: widget.h,v $
+ * Revision 1.5  2004/01/11 18:26:02  reinelt
+ * further widget and layout processing
+ *
  * Revision 1.4  2004/01/10 20:22:33  reinelt
  * added new function 'cfg_list()' (not finished yet)
  * added layout.c (will replace processor.c someday)
 
 struct WIDGET; // forward declaration
 
+
 typedef struct WIDGET_CLASS {
   char *name;
   int (*init)   (struct WIDGET *Self);
-  int (*update) (struct WIDGET *Self);
-  int (*render) (struct WIDGET *Self);
+  int (*update) (struct WIDGET *Self); // Fixme: do we really need this?
+  int (*draw)   (struct WIDGET *Self);
   int (*quit)   (struct WIDGET *Self);
 } WIDGET_CLASS;
 
+
 typedef struct WIDGET{
-  char *name;
+  char         *name;
   WIDGET_CLASS *class;
+  void         *data;
 } WIDGET;
 
 
+
 int widget_register (WIDGET_CLASS *widget);
 
 
index 59a122df8d9717c494974ae5f20dcaa717ed7ff5..c644ce654bb921341a0b5573f608fc5ed87aede7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: widget_text.c,v 1.1 2004/01/10 20:22:33 reinelt Exp $
+/* $Id: widget_text.c,v 1.2 2004/01/11 18:26:02 reinelt Exp $
  *
  * simple text widget handling
  *
@@ -21,6 +21,9 @@
  *
  *
  * $Log: widget_text.c,v $
+ * Revision 1.2  2004/01/11 18:26:02  reinelt
+ * further widget and layout processing
+ *
  * Revision 1.1  2004/01/10 20:22:33  reinelt
  * added new function 'cfg_list()' (not finished yet)
  * added layout.c (will replace processor.c someday)
 #include "widget.h"
 
 
+typedef struct WIDGET_TEXT {
+  char *value;
+  char *align;
+  int   width;
+  int   update;
+} WIDGET_TEXT;
+
+
+int widget_text_init (WIDGET *Self) {
+  
+  char *section;
+  WIDGET_TEXT *data;
+  
+  debug ("Michi: widget_text_init(%s)", Self->name);
+  
+  // prepare config section
+  // strlen("Widget:")=7
+  section=malloc(strlen(Self->name)+8);
+  strcpy(section, "Widget:");
+  strcat(section, Self->name);
+  
+  data=malloc(sizeof(WIDGET_TEXT));
+  
+  data->value = cfg_get (section, "value",  "''");
+  data->align = cfg_get (section, "align",  "L");
+  
+  cfg_number (section, "width",   5,  0, 99999, &(data->width));
+  cfg_number (section, "update", -1, -1, 99999, &(data->update));
+  
+  free (section);
+  Self->data=data;
+  
+  
+  return 0;
+}
+
+
+int widget_text_quit (WIDGET *Self) {
+
+  if (Self->data) {
+    free (Self->data);
+    Self->data=NULL;
+  }
+  
+  return 0;
+  
+}
+
+
+
 WIDGET_CLASS Widget_Text = {
   name:   "text",
-  init:   NULL,
+  init:   widget_text_init,
   update: NULL,
-  render: NULL,
-  quit:   NULL,
+  draw:   NULL,
+  quit:   widget_text_quit,
 };