Enlightenment CVS committal
Author : raster
Project : e17
Module : apps/e
Dir : e17/apps/e/src/bin
Modified Files:
Makefile.am e_apps.c e_main.c e_remote_main.c
Added Files:
e_eapp_main.c
Log Message:
new eapp file format.. now to do the file layout arrangement we discussed...
btw - u'll need to update eet for this...
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- Makefile.am 26 Nov 2004 11:11:05 -0000 1.3
+++ Makefile.am 2 Dec 2004 04:24:54 -0000 1.4
@@ -6,7 +6,7 @@
@e_cflags@ \
@EDJE_DEF@
-bin_PROGRAMS = enlightenment enlightenment_remote
+bin_PROGRAMS = enlightenment enlightenment_remote enlightenment_eapp
enlightenment_SOURCES = \
e.h \
@@ -67,3 +67,9 @@
e_remote_main.c
enlightenment_remote_LDFLAGS = @e_libs@ @dlopen_libs@
+
+enlightenment_eapp_SOURCES = \
+e.h \
+e_eapp_main.c
+
+enlightenment_eapp_LDFLAGS = @e_libs@ @dlopen_libs@
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_apps.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_apps.c 25 Nov 2004 03:37:44 -0000 1.1
+++ e_apps.c 2 Dec 2004 04:24:54 -0000 1.2
@@ -2,7 +2,7 @@
/* TODO List:
*
- * * if a application .eet file is added in a different location in a
monitored app tree but has the same filename as an existing one somewhere else,
the existing one gets a changed callback, not an dded callback for the new one
+ * * if a application .eapp file is added in a different location in a
monitored app tree but has the same filename as an existing one somewhere else,
the existing one gets a changed callback, not an dded callback for the new one
* * track app execution state, visibility state etc. and call callbacks
* * calls to execute an app or query its runing/starting state etc.
*/
@@ -80,7 +80,7 @@
char buf[4096];
a->path = strdup(path);
- snprintf(buf, sizeof(buf), "%s/.directory.eet", path);
+ snprintf(buf, sizeof(buf), "%s/.directory.eapp", path);
a->directory_mod_time = e_file_mod_time(buf);
if (e_file_exists(buf))
_e_app_fields_fill(a, buf);
@@ -92,7 +92,7 @@
{
char *p;
- /* check if file ends in .eet */
+ /* check if file ends in .eapp */
p = strrchr(path, '.');
if (!p)
{
@@ -100,7 +100,7 @@
return NULL;
}
p++;
- if (strcasecmp(p, "eet"))
+ if (strcasecmp(p, "eapp"))
{
free(a);
return NULL;
@@ -283,45 +283,119 @@
static void
_e_app_fields_fill(E_App *a, char *path)
{
+ Eet_File *ef;
char buf[4096];
- char *str;
+ char *str, *v;
char *lang;
+ int size;
/* get our current language */
lang = getenv("LANG");
/* if its "C" its the default - so drop it */
if ((lang) && (!strcmp(lang, "C")))
lang = NULL;
- /* get fields (language local preferred) */
- if (lang)
+ ef = eet_open(a->path, EET_FILE_MODE_READ);
+ if (!ef) return;
+ if (lang) snprintf(buf, sizeof(buf), "app/info/name[%s]", lang);
+ v = eet_read(ef, buf, &size);
+ if (v)
+ {
+ str = malloc(size + 1);
+ memcpy(str, v, size);
+ str[size] = 0;
+ a->name = str;
+ free(v);
+ }
+ else
{
- snprintf(buf, sizeof(buf), "app/name[%s]", lang);
- a->name = edje_file_data_get(path, buf);
+ v = eet_read(ef, "app/info/name", &size);
+ if (v)
+ {
+ str = malloc(size + 1);
+ memcpy(str, v, size);
+ str[size] = 0;
+ a->name = str;
+ free(v);
+ }
+ }
+ if (lang) snprintf(buf, sizeof(buf), "app/info/generic[%s]", lang);
+ v = eet_read(ef, buf, &size);
+ if (v)
+ {
+ str = malloc(size + 1);
+ memcpy(str, v, size);
+ str[size] = 0;
+ a->generic = str;
+ free(v);
}
- if (!a->name) a->name = edje_file_data_get(path, "app/name");
- if (lang)
+ else
{
- snprintf(buf, sizeof(buf), "app/generic[%s]", lang);
- a->generic = edje_file_data_get(path, buf);
+ v = eet_read(ef, "app/info/generic", &size);
+ if (v)
+ {
+ str = malloc(size + 1);
+ memcpy(str, v, size);
+ str[size] = 0;
+ a->generic = str;
+ free(v);
+ }
+ }
+ if (lang) snprintf(buf, sizeof(buf), "app/info/comment[%s]", lang);
+ v = eet_read(ef, buf, &size);
+ if (v)
+ {
+ str = malloc(size + 1);
+ memcpy(str, v, size);
+ str[size] = 0;
+ a->comment = str;
+ free(v);
}
- if (!a->generic) a->generic = edje_file_data_get(path, "app/generic");
- if (lang)
+ else
{
- snprintf(buf, sizeof(buf), "app/comment[%s]", lang);
- a->comment = edje_file_data_get(path, buf);
+ v = eet_read(ef, "app/info/comment", &size);
+ if (v)
+ {
+ str = malloc(size + 1);
+ memcpy(str, v, size);
+ str[size] = 0;
+ a->comment = str;
+ free(v);
+ }
+ }
+ v = eet_read(ef, "app/info/exe", &size);
+ if (v)
+ {
+ str = malloc(size + 1);
+ memcpy(str, v, size);
+ str[size] = 0;
+ a->exe = str;
+ free(v);
+ }
+ v = eet_read(ef, "app/window/name", &size);
+ if (v)
+ {
+ str = malloc(size + 1);
+ memcpy(str, v, size);
+ str[size] = 0;
+ a->win_name = str;
+ free(v);
+ }
+ v = eet_read(ef, "app/window/class", &size);
+ if (v)
+ {
+ str = malloc(size + 1);
+ memcpy(str, v, size);
+ str[size] = 0;
+ a->win_class = str;
+ free(v);
}
- if (!a->comment) a->comment = edje_file_data_get(path, "app/comment");
-
- a->exe = edje_file_data_get(path, "app/exe");
- a->win_name = edje_file_data_get(path, "app/window/name");
- a->win_class = edje_file_data_get(path, "app/window/class");
-
- str = edje_file_data_get(path, "app/startup_notify");
- if (str)
+ v = eet_read(ef, "app/info/startup_notify", &size);
+ if (v)
{
- a->startup_notify = atoi(str);
- free(str);
+ a->startup_notify = *v;
+ free(v);
}
+ eet_close(ef);
}
static void
@@ -567,7 +641,7 @@
mod_time = e_file_mod_time(a->path);
snprintf(buf, sizeof(buf), "%s/.order", a->path);
order_mod_time = e_file_mod_time(buf);
- snprintf(buf, sizeof(buf), "%s/.directory.eet", a->path);
+ snprintf(buf, sizeof(buf), "%s/.directory.eapp", a->path);
directory_mod_time = e_file_mod_time(buf);
if ((mod_time != a->mod_time) ||
(order_mod_time != a->order_mod_time) ||
@@ -594,7 +668,7 @@
}
if (directory_mod_time != a->directory_mod_time)
{
- snprintf(buf, sizeof(buf), "%s/.directory.eet", a->path);
+ snprintf(buf, sizeof(buf), "%s/.directory.eapp",
a->path);
_e_app_fields_empty(a);
_e_app_fields_fill(a, buf);
ch = calloc(1, sizeof(E_App_Change_Info));
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_main.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- e_main.c 26 Nov 2004 11:11:05 -0000 1.3
+++ e_main.c 2 Dec 2004 04:24:54 -0000 1.4
@@ -63,8 +63,11 @@
{
if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
{
+ char buf[1024];
i++;
- display_name = argv[i];
+
+ snprintf(buf, sizeof(buf), "DISPLAY=%s", argv[i]);
+ putenv(buf);
}
}
@@ -94,7 +97,7 @@
_e_main_idle_enterer_before =
ecore_idle_enterer_add(_e_main_cb_idler_before, NULL);
/* init x */
- if (!ecore_x_init(display_name))
+ if (!ecore_x_init(NULL))
{
e_error_message_show("Enlightenment cannot initialize its X
connection.\n"
"Have you set your DISPLAY variable?");
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_remote_main.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- e_remote_main.c 1 Dec 2004 07:01:31 -0000 1.3
+++ e_remote_main.c 2 Dec 2004 04:24:54 -0000 1.4
@@ -1,5 +1,18 @@
#include "e.h"
+typedef struct _E_IPC_Opt_Handler E_IPC_Opt_Handler;
+
+struct _E_IPC_Opt_Handler
+{
+ char *option;
+ char *desc;
+ int num_params;
+ int replies;
+ int type;
+ int simple_request_id;
+ void (*func) (char **params);
+};
+
/* local subsystem functions */
static int _e_cb_signal_exit(void *data, int ev_type, void *ev);
static int _e_ipc_init(void);
@@ -9,12 +22,32 @@
static int _e_ipc_cb_server_del(void *data, int type, void *event);
static int _e_ipc_cb_server_data(void *data, int type, void *event);
+static void _e_help(void);
+
/* local subsystem globals */
static Ecore_Ipc_Server *_e_ipc_server = NULL;
static const char *display_name = NULL;
static int reply_count = 0;
static int reply_expect = 0;
+#define SIMPLE_REQ 0
+#define SIMPLE_STR_REQ 1
+#define FULL_FUNC 2
+
+#define REQ(opt, desc, ipc, rep) {opt, desc, 0, rep, SIMPLE_REQ, ipc, NULL}
+#define STR(opt, desc, ipc, rep) {opt, desc, 1, rep, SIMPLE_STR_REQ, ipc, NULL}
+#define FNC(opt, desc, param, fn, rep) {opt, desc, param, rep, SIMPLE_FUNC, 0,
fn}
+
+E_IPC_Opt_Handler handlers[] =
+{
+ STR("-module-load", "Load module OPT1 into memory", E_IPC_OP_MODULE_LOAD,
0),
+ STR("-module-unload", "Unload (and disable) module OPT1 from memory",
E_IPC_OP_MODULE_UNLOAD, 0),
+ STR("-module-enable", "Enable module OPT1 if not enabled",
E_IPC_OP_MODULE_ENABLE, 0),
+ STR("-module-disable", "Disable module OPT1 if not disabled",
E_IPC_OP_MODULE_DISABLE, 0),
+ REQ("-module-list", "List all loaded modules and their states",
E_IPC_OP_MODULE_LIST, 1),
+ STR("-bg-set", "Set the background edje file to be OPT1", E_IPC_OP_BG_SET,
0)
+};
+
/* externally accessible functions */
int
main(int argc, char **argv)
@@ -30,6 +63,14 @@
i++;
display_name = argv[i];
}
+ else if ((!strcmp(argv[i], "-h")) ||
+ (!strcmp(argv[i], "-help")) ||
+ (!strcmp(argv[i], "--h")) ||
+ (!strcmp(argv[i], "--help")))
+ {
+ _e_help();
+ exit(0);
+ }
}
/* basic ecore init */
@@ -121,73 +162,63 @@
int argc;
char **argv;
int i;
+ int process_count = 0;
e = event;
ecore_app_args_get(&argc, &argv);
for (i = 1; i < argc; i++)
{
char *v;
-
- if ((!strcmp(argv[i], "-load-module")) && (i < (argc - 1)))
+ int j;
+
+ for (j = 0; j < (sizeof(handlers) / sizeof(E_IPC_Opt_Handler)); j++)
{
- i++;
- v = argv[i];
- ecore_ipc_server_send(_e_ipc_server,
- E_IPC_DOMAIN_REQUEST,
- E_IPC_OP_MODULE_LOAD,
- 0/*ref*/, 0/*ref_to*/, 0/*response*/,
- v, strlen(v));
- }
- else if ((!strcmp(argv[i], "-unload-module")) && (i < (argc - 1)))
- {
- i++;
- v = argv[i];
- ecore_ipc_server_send(_e_ipc_server,
- E_IPC_DOMAIN_REQUEST,
- E_IPC_OP_MODULE_UNLOAD,
- 0/*ref*/, 0/*ref_to*/, 0/*response*/,
- v, strlen(v));
- }
- else if ((!strcmp(argv[i], "-enable-module")) && (i < (argc - 1)))
- {
- i++;
- v = argv[i];
- ecore_ipc_server_send(_e_ipc_server,
- E_IPC_DOMAIN_REQUEST,
- E_IPC_OP_MODULE_ENABLE,
- 0/*ref*/, 0/*ref_to*/, 0/*response*/,
- v, strlen(v));
+ E_IPC_Opt_Handler *handler;
+
+ handler = &handlers[j];
+ if (!strcmp(handler->option, argv[i]))
+ {
+ if (i >= (argc - handler->num_params))
+ {
+ printf("ERROR: option %s expects %i parameters\n",
+ handler->option, handler->num_params);
+ exit(-1);
+ }
+ else
+ {
+ switch (handler->type)
+ {
+ case SIMPLE_REQ:
+ ecore_ipc_server_send(_e_ipc_server,
+ E_IPC_DOMAIN_REQUEST,
+ handler->simple_request_id,
+ 0/*ref*/, 0/*ref_to*/,
0/*response*/,
+ NULL, 0);
+ break;
+ case SIMPLE_STR_REQ:
+ v = argv[i + 1];
+ ecore_ipc_server_send(_e_ipc_server,
+ E_IPC_DOMAIN_REQUEST,
+ handler->simple_request_id,
+ 0/*ref*/, 0/*ref_to*/,
0/*response*/,
+ v, strlen(v));
+ break;
+ case FULL_FUNC:
+ handler->func(argv + i + 1);
+ break;
+ default:
+ break;
+ }
+ process_count++;
+ reply_expect += handler->replies;
+ i += handler->num_params;
+ break;
+ }
+ }
}
- else if ((!strcmp(argv[i], "-disable-module")) && (i < (argc - 1)))
- {
- i++;
- v = argv[i];
- ecore_ipc_server_send(_e_ipc_server,
- E_IPC_DOMAIN_REQUEST,
- E_IPC_OP_MODULE_DISABLE,
- 0/*ref*/, 0/*ref_to*/, 0/*response*/,
- v, strlen(v));
- }
- else if ((!strcmp(argv[i], "-list-modules")))
- {
- reply_expect++;
- ecore_ipc_server_send(_e_ipc_server,
- E_IPC_DOMAIN_REQUEST,
- E_IPC_OP_MODULE_LIST,
- 0/*ref*/, 0/*ref_to*/, 0/*response*/,
- NULL, 0);
- }
- else if ((!strcmp(argv[i], "-bg-set")) && (i < (argc - 1)))
- {
- i++;
- v = argv[i];
- ecore_ipc_server_send(_e_ipc_server,
- E_IPC_DOMAIN_REQUEST,
- E_IPC_OP_BG_SET,
- 0/*ref*/, 0/*ref_to*/, 0/*response*/,
- v, strlen(v));
- }
}
+ if (process_count <= 0)
+ _e_help();
if (reply_count >= reply_expect) ecore_main_loop_quit();
return 1;
}
@@ -207,6 +238,8 @@
Ecore_Ipc_Event_Server_Data *e;
e = event;
+ /* FIXME: should make this function/callback based in a table like the */
+ /* option handlers... */
printf("REPLY: BEGIN\n");
switch (e->minor)
{
@@ -247,3 +280,46 @@
if (reply_count >= reply_expect) ecore_main_loop_quit();
return 1;
}
+
+static void
+_e_help(void)
+{
+ int j, k, l;
+ E_IPC_Opt_Handler *handler;
+ char buf[128];
+ int parsize = 0, opsize = 0;
+
+ printf("OPTIONS:\n");
+ for (j = 0; j < (sizeof(handlers) / sizeof(E_IPC_Opt_Handler)); j++)
+ {
+ handler = &handlers[j];
+ if (strlen(handler->option) > parsize) parsize =
strlen(handler->option);
+ l = 0;
+ for (k = 0; k < handler->num_params; k++)
+ {
+ snprintf(buf, sizeof(buf), " OPT%i", k + 1);
+ l += strlen(buf);
+ }
+ if (l > opsize) opsize = l;
+ }
+ for (j = 0; j < (sizeof(handlers) / sizeof(E_IPC_Opt_Handler)); j++)
+ {
+ handler = &handlers[j];
+ printf(" %s", handler->option);
+ l = parsize - strlen(handler->option);
+ for (k = 0; k < l; k++) printf(" ");
+ l = 0;
+ for (k = 0; k < handler->num_params; k++)
+ {
+ snprintf(buf, sizeof(buf), " OPT%i", k + 1);
+ printf("%s", buf);
+ l += strlen(buf);
+ }
+ while (l < opsize)
+ {
+ printf(" ");
+ l++;
+ }
+ printf(" - %s\n", handler->desc);
+ }
+}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs