2001-02-09 00:13:16 -08:00
|
|
|
#include "e.h"
|
|
|
|
|
|
|
|
static EfsdConnection *ec = NULL;
|
|
|
|
static Evas_List fs_handlers = NULL;
|
|
|
|
|
|
|
|
static void _e_fs_fd_handle(int fd);
|
|
|
|
|
2001-02-12 16:18:42 -08:00
|
|
|
static void
|
2001-03-15 17:14:42 -08:00
|
|
|
_e_fs_fd_handle(int fd)
|
2001-02-12 16:18:42 -08:00
|
|
|
{
|
2001-03-15 17:14:42 -08:00
|
|
|
double start, current;
|
2001-02-15 15:10:30 -08:00
|
|
|
|
2001-03-25 13:37:09 -08:00
|
|
|
/* printf("############## fs event...\n"); */
|
2001-03-15 17:14:42 -08:00
|
|
|
start = e_get_time();
|
2001-02-15 15:10:30 -08:00
|
|
|
while ((ec) && efsd_events_pending(ec))
|
2001-03-15 17:14:42 -08:00
|
|
|
{
|
2001-03-23 19:18:17 -08:00
|
|
|
EfsdEvent ev;
|
2001-03-15 17:14:42 -08:00
|
|
|
|
2001-03-23 19:18:17 -08:00
|
|
|
if (efsd_next_event(ec, &ev) >= 0)
|
2001-02-15 15:10:30 -08:00
|
|
|
{
|
2001-03-23 19:18:17 -08:00
|
|
|
Evas_List l;
|
|
|
|
|
|
|
|
for (l = fs_handlers; l; l = l->next)
|
|
|
|
{
|
|
|
|
void (*func) (EfsdEvent *ev);
|
|
|
|
|
|
|
|
func = l->data;
|
|
|
|
func(&ev);
|
|
|
|
}
|
|
|
|
efsd_event_cleanup(&ev);
|
2001-02-15 15:10:30 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
efsd_close(ec);
|
|
|
|
e_del_event_fd(fd);
|
|
|
|
ec = NULL;
|
|
|
|
/* FIXME: need to queue a popup dialog here saying */
|
|
|
|
/* efsd went wonky */
|
|
|
|
printf("EEEEEEEEEEK efsd went wonky\n");
|
|
|
|
}
|
|
|
|
|
2001-03-15 17:14:42 -08:00
|
|
|
/* spent more thna 1/20th of a second here.. get out */
|
|
|
|
current = e_get_time();
|
|
|
|
if ((current - start) > 0.05)
|
|
|
|
{
|
|
|
|
printf("fs... too much time spent..\n");
|
|
|
|
break;
|
|
|
|
}
|
2001-02-12 16:18:42 -08:00
|
|
|
}
|
2001-03-25 13:37:09 -08:00
|
|
|
/* printf("############## fs done\n"); */
|
2001-02-09 00:13:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
e_fs_add_event_handler(void (*func) (EfsdEvent *ev))
|
|
|
|
{
|
|
|
|
if (!func) return;
|
|
|
|
fs_handlers = evas_list_append(fs_handlers, func);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
e_fs_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* already have an efsd around? */
|
|
|
|
ec = efsd_open();
|
|
|
|
/* no - efsd around */
|
|
|
|
if (!ec)
|
|
|
|
{
|
|
|
|
/* start efsd */
|
|
|
|
e_exec_run("efsd");
|
2001-02-12 17:31:05 -08:00
|
|
|
for (i = 0; (!ec) && (i < 4); i++)
|
2001-02-09 00:13:16 -08:00
|
|
|
{
|
2001-02-12 17:31:05 -08:00
|
|
|
sleep(1);
|
|
|
|
ec = efsd_open();
|
2001-02-09 00:13:16 -08:00
|
|
|
}
|
|
|
|
}
|
2001-02-12 10:58:51 -08:00
|
|
|
/* after several atempts to talk to efsd - lets give up */
|
2001-02-09 00:13:16 -08:00
|
|
|
if (!ec)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "efsd is not running - please run efsd.\n");
|
|
|
|
exit(-1);
|
|
|
|
}
|
2001-03-15 17:14:42 -08:00
|
|
|
e_add_event_fd(efsd_get_connection_fd(ec), _e_fs_fd_handle);
|
2001-02-12 10:58:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EfsdConnection *
|
|
|
|
e_fs_get_connection(void)
|
|
|
|
{
|
|
|
|
return ec;
|
2001-02-09 00:13:16 -08:00
|
|
|
}
|