Enlightenment CVS committal

Author  : mekius
Project : e17
Module  : apps/exquisite

Dir     : e17/apps/exquisite/src/bin


Modified Files:
        ipc.c ipc.h main.c main.h theme.c write.c 


Log Message:
Added all the necessary commands to deal with verbose boots like Usplash.  This 
includes TEXT, TEXT-URGENT, STATUS, SUCCESS, FAILURE and CLEAR.  Also added the 
TIMEOUT command.  The theme was updated to use all this new functionality.

===================================================================
RCS file: /cvs/e/e17/apps/exquisite/src/bin/ipc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ipc.c       2 Nov 2007 06:21:09 -0000       1.1
+++ ipc.c       29 Nov 2007 07:00:31 -0000      1.2
@@ -3,10 +3,14 @@
 static int _ipc_cb_client_add(void *data, int type, void *event);
 static int _ipc_cb_client_del(void *data, int type, void *event);
 static int _ipc_cb_client_data(void *data, int type, void *event);
+static int _ipc_cb_timeout(void *data);
 static void _ipc_cb_theme_exit_done(void *data);
 
 static Ecore_Ipc_Server *_ipc_server = NULL;
 static Ecore_Ipc_Client *_ipc_exit_client = NULL;
+static Ecore_Timer *timeout = NULL;
+static int timeout_seconds = 0;
+int quitting;
 
 void
 ipc_init(void)
@@ -57,8 +61,18 @@
 {
    Ecore_Ipc_Event_Client_Data *e;
    
+   if(quitting) return 1;
+
    e = event;
    if (ecore_ipc_client_server_get(e->client) != _ipc_server) return 1;
+   
+   if(timeout) 
+    {
+       ecore_timer_del(timeout);
+       timeout = NULL;
+       timeout = ecore_timer_add(timeout_seconds, _ipc_cb_timeout, NULL);
+    }
+   
    switch (e->major)
      {
       case EXIT_NOW:
@@ -88,17 +102,59 @@
       case PULSATE:
        theme_pulsate();
        break;
+      case TEXT:
+        if (!quiet && (e->data) && ((char *)e->data)[e->size -1] == 0)
+          theme_text_add(e->data);
+        break;
+      case TEXT_URGENT:
+        if ((e->data) && ((char *)e->data)[e->size -1] == 0)
+          theme_text_add(e->data);
+        break;
+      case STATUS:
+        if ((e->data) && ((char *)e->data)[e->size -1] == 0)
+          theme_status_set(e->data, -1);
+        break;
+      case SUCCESS:
+        if ((e->data) && ((char *)e->data)[e->size -1] == 0)
+          theme_status_set(e->data, 1);
+        break;
+      case FAILURE:
+        if ((e->data) && ((char *)e->data)[e->size -1] == 0)
+          theme_status_set(e->data, 0);
+        break;
+      case CLEAR:
+        theme_text_clear();
+        break;
+      case TIMEOUT:
+        timeout_seconds = e->ref;
+        if(timeout) 
+          {
+             ecore_timer_del(timeout);
+             timeout = NULL;
+          }
+          timeout = ecore_timer_add(timeout_seconds, _ipc_cb_timeout, NULL);
+        break;
       default:
        break;
      }
    return 1;
 }
 
+static int
+_ipc_cb_timeout(void *data)
+{
+   theme_exit(_ipc_cb_theme_exit_done, data);
+   return 0;
+}
+
 static void
 _ipc_cb_theme_exit_done(void *data)
 {
-   ecore_ipc_client_send(data, 0, 0, 0, 0, 0, NULL, 0);
-   ecore_ipc_client_flush(data);
+   if(data)
+     {
+        ecore_ipc_client_send(data, 0, 0, 0, 0, 0, NULL, 0);
+        ecore_ipc_client_flush(data);
+     }
    ecore_main_loop_quit();
    _ipc_exit_client = NULL;
 }
===================================================================
RCS file: /cvs/e/e17/apps/exquisite/src/bin/ipc.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ipc.h       2 Nov 2007 06:21:09 -0000       1.1
+++ ipc.h       29 Nov 2007 07:00:31 -0000      1.2
@@ -6,5 +6,12 @@
      MESSAGE,
      PROGRESS,
      TICK,
-     PULSATE
+     PULSATE,
+     TEXT,
+     TEXT_URGENT,
+     STATUS,
+     SUCCESS,
+     FAILURE,
+     CLEAR,
+     TIMEOUT
 } Ipc_Major;
===================================================================
RCS file: /cvs/e/e17/apps/exquisite/src/bin/main.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- main.c      2 Nov 2007 06:21:09 -0000       1.1
+++ main.c      29 Nov 2007 07:00:31 -0000      1.2
@@ -11,6 +11,7 @@
 int         fn_cache = 512 * 1024;
 int         engine = SOFT_X;
 int         scr_w, scr_h;
+int         quiet;
 
 static char *theme = NULL;
 
@@ -67,7 +68,8 @@
    int h = 480;
    double fps = 60.0;
    int fullscreen = 0;
-   
+   quiet = 0;
+
    ecore_app_args_get(&argc, &argv);
    for (i = 1; i < argc; i++)
      {
@@ -121,6 +123,10 @@
                  exit(-1);
               }
          }
+        else if ((!strcmp(argv[i], "-quiet")))
+          {
+             quiet = 1;
+          }
        else if ((!strcmp(argv[i], "-h")))
          {
             printf("%s [OPTIONS]\n"
@@ -137,6 +143,7 @@
                    "-ic Kb     Set image cache in Kb\n"
                    "-fc Kb     Set font cache in Kb\n"
                    "-fps fps   Set attempted framerate in frames per second\n"
+                    "-quiet     Run Exquisite in quiet mode, text is 
suppressed\n"
                    "-h         Display this help\n",
                    argv[0]);
             exit(0);
===================================================================
RCS file: /cvs/e/e17/apps/exquisite/src/bin/main.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- main.h      2 Nov 2007 06:21:09 -0000       1.1
+++ main.h      29 Nov 2007 07:00:31 -0000      1.2
@@ -23,6 +23,8 @@
 extern Evas       *evas;
 extern Evas_Coord  scr_w;
 extern Evas_Coord  scr_h;
+extern int         quiet;
+extern int         quitting;
 
 void theme_init(const char *theme);
 void theme_shutdown(void);
@@ -32,6 +34,10 @@
 void theme_message_set(const char *txt);
 void theme_progress_set(double val);
 void theme_tick(void);
+void theme_pulsate(void);
+void theme_text_add(const char *txt);
+void theme_status_set(const char *txt, int type);
+void theme_text_clear();
 
 void ipc_init(void);
 void ipc_shutdown(void);
===================================================================
RCS file: /cvs/e/e17/apps/exquisite/src/bin/theme.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- theme.c     2 Nov 2007 06:21:09 -0000       1.1
+++ theme.c     29 Nov 2007 07:00:31 -0000      1.2
@@ -2,7 +2,69 @@
 
 static void _theme_cb_exit_done(void *data, Evas_Object *obj, const char 
*emission, const char *source);
 
+typedef struct _Exquisite_Text_Line Exquisite_Text_Line;
+struct _Exquisite_Text_Line {
+  const char* message;
+  const char* status_text;
+  int status;
+};
+
 static Evas_Object *o_bg = NULL;
+static Evas_List *messages = NULL;
+static char *txt = NULL;
+
+static void
+theme_update_text(int signal)
+{
+   char buf[8192];
+   char buf2[8192];
+   char *p = buf, *s = buf2;
+   Evas_List *l = NULL;
+   int i;
+   const char *msg, *status;
+   Exquisite_Text_Line *t;
+
+   edje_object_signal_emit(o_bg, "exquisite", "text_enable");
+
+   if(!messages)
+     {
+        buf[0] = 0;
+        buf2[0] = 0;
+     }
+
+   for(l = messages, i = 0; l != NULL && i < 8192; l = l->next)
+     {
+       t = (Exquisite_Text_Line*)l->data;
+       snprintf(p, strlen(t->message)+8, "<p>%s</p>", t->message);
+       p = buf+strlen(buf);
+       
+       if(!t->status_text)
+         snprintf(s, 5, "<br>");
+       else
+         {
+           if(t->status != -1)
+             snprintf(s, strlen(t->status_text)+8, "<%i>%s</%i>", t->status, 
t->status_text, t->status);
+           else
+             snprintf(s, strlen(t->status_text)+5, "%s<br>", t->status_text);
+         }
+       
+       s = buf2+strlen(buf2);
+     }
+
+   if (edje_object_part_exists(o_bg, "textarea") &&
+       edje_object_part_exists(o_bg, "statusarea"))
+     {          
+        if(signal == 1)
+          edje_object_signal_emit(o_bg, "exquisite", "text_set");  
+        else if(signal == 2)
+          edje_object_signal_emit(o_bg, "exquisite", "status_set");
+        else if(signal == 3)             
+          edje_object_signal_emit(o_bg, "exquisite", "text_clear");
+        
+        edje_object_part_text_set(o_bg, "textarea", buf);
+        edje_object_part_text_set(o_bg, "statusarea", buf2);
+     }
+}
 
 void
 theme_init(const char *theme)
@@ -40,6 +102,7 @@
 void
 theme_exit(void (*func) (void *data), void *data)
 {
+   quitting = 1;
    edje_object_signal_emit(o_bg, "exquisite", "exit");
    _theme_exit_func = func;
    theme_exit_data = data;
@@ -65,7 +128,7 @@
    else
      {
        Edje_Message_String m;
-       m.str = txt;
+       m.str = (char *)txt;
        edje_object_message_send(o_bg, EDJE_MESSAGE_STRING, 0, &m);
      }
 }
@@ -82,7 +145,7 @@
    else
      {
        Edje_Message_String m;
-       m.str = txt;
+       m.str = (char *)txt;
        edje_object_message_send(o_bg, EDJE_MESSAGE_STRING, 1, &m);
      }
 }
@@ -118,6 +181,66 @@
    edje_object_signal_emit(o_bg, "exquisite", "pulsate");
 }
 
+void 
+theme_text_add(const char *txt)
+{
+   Exquisite_Text_Line *t = NULL;
+
+   t = malloc(sizeof(Exquisite_Text_Line));
+
+   if(!txt || (txt[0] == 0)) return;
+
+   t->message = evas_stringshare_add(txt);
+   t->status_text = NULL;
+   t->status = -1;
+
+   messages = evas_list_append(messages, t);
+   
+   /*A 1 means that a text update signal will be sent*/
+   theme_update_text(1);
+}
+
+void 
+theme_status_set(const char *txt, int type)
+{
+   Exquisite_Text_Line *t = NULL;
+
+   if(!txt || (txt[0] == 0) || !messages) return;
+
+   t = (Exquisite_Text_Line *)(evas_list_last(messages)->data);
+   
+   t->status = type;
+   if(t->status_text) evas_stringshare_del(t->status_text);
+   t->status_text = evas_stringshare_add(txt);
+   
+   /*A 2 means that a status update signal will be sent*/
+   theme_update_text(2);
+}
+
+void
+theme_text_clear()
+{
+  if (messages)
+    {
+      Evas_List *l = NULL;
+      Exquisite_Text_Line *t = NULL;
+   
+      for(l = messages; l != NULL; l = l->next)
+        {
+          t = l->data;
+          evas_stringshare_del(t->message);
+          if(t->status_text) evas_stringshare_del(t->status_text);
+          free(l->data);
+        }
+      
+      evas_list_free(messages);
+      messages = NULL;
+    }  
+  
+  /*A 3 means a text clear signal will be sent*/
+  theme_update_text(3);
+}
+
 static void
 _theme_cb_exit_done(void *data, Evas_Object *obj, const char *emission, const 
char *source)
 {
@@ -127,4 +250,6 @@
        _theme_exit_func = NULL;
        theme_exit_data = NULL;
      }
+   
+   theme_text_clear();
 }
===================================================================
RCS file: /cvs/e/e17/apps/exquisite/src/bin/write.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- write.c     2 Nov 2007 06:21:09 -0000       1.1
+++ write.c     29 Nov 2007 07:00:31 -0000      1.2
@@ -65,14 +65,22 @@
 _help(void)
 {
    printf("Usage:\n"
-         "  -h         This help\n"
-         "  QUIT       Tell splash to exit immediately\n"
-         "  PROGRESS N Indicate boot progress is at N percent\n"
-         "  MSG X      Display string message X\n"
-         "  TITLE X    Diplsay title string X\n"
-         "  END        Shut down splash gracefully and exit when done\n"
-         "  TICK       Send hearbeat tick to splash\n"
-         "  PULSATE    Set exquisite into pulsate mode\n");
+         "  -h            This help\n"
+         "  QUIT          Tell splash to exit immediately\n"
+         "  PROGRESS N    Indicate boot progress is at N percent\n"
+         "  MSG X         Display string message X\n"
+         "  TITLE X       Diplsay title string X\n"
+         "  END           Shut down splash gracefully and exit when done\n"
+         "  TICK          Send hearbeat tick to splash\n"
+         "  PULSATE       Set exquisite into pulsate mode\n"
+          "  TEXT X        Add a line of text to the text box\n"
+          "  TEXT-URGENT X Add a line of text even in quiet mode\n"
+          "  STATUS  X     Set a general status for the last line of text\n"
+          "  SUCCESS X     Set a success status for the last line of text\n"
+          "  FAILURE X     Set a failure status for the last line of text\n"
+          "  CLEAR         Clear all text and hide text box\n"
+          "  TIMEOUT N     Exquisite will timeout in N seconds if no commands 
recv'd\n"
+   );
 }
 
 static int
@@ -145,6 +153,41 @@
    else if (!strcmp(buf, "PULSATE"))
      {
        ecore_ipc_server_send(e->server, PULSATE, 0, 0, 0, 0, NULL, 0);
+       ecore_main_loop_quit();
+     }
+   else if (!strcmp(buf, "TEXT"))
+     {
+       ecore_ipc_server_send(e->server, TEXT, 0, 0, 0, 0, q, strlen(q) + 1);
+       ecore_main_loop_quit();
+     }
+   else if (!strcmp(buf, "TEXT-URGENT"))
+     {
+       ecore_ipc_server_send(e->server, TEXT_URGENT, 0, 0, 0, 0, q, strlen(q) 
+ 1);
+       ecore_main_loop_quit();
+     }
+   else if (!strcmp(buf, "STATUS"))
+     {
+       ecore_ipc_server_send(e->server, STATUS, 0, 0, 0, 0, q, strlen(q) + 1);
+       ecore_main_loop_quit();
+     }
+   else if (!strcmp(buf, "SUCCESS"))
+     {
+       ecore_ipc_server_send(e->server, SUCCESS, 0, 0, 0, 0, q, strlen(q) + 1);
+       ecore_main_loop_quit();
+     }
+   else if (!strcmp(buf, "FAILURE"))
+     {
+       ecore_ipc_server_send(e->server, FAILURE, 0, 0, 0, 0, q, strlen(q) + 1);
+       ecore_main_loop_quit();
+     }   
+   else if (!strcmp(buf, "CLEAR"))
+     {
+       ecore_ipc_server_send(e->server, CLEAR, 0, 0, 0, 0, NULL, 0);
+       ecore_main_loop_quit();
+     }
+   else if (!strcmp(buf, "TIMEOUT"))
+     {
+       ecore_ipc_server_send(e->server, TIMEOUT, 0, atoi(q), 0, 0, NULL, 0);
        ecore_main_loop_quit();
      }
    else



-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to