static void * document_create(Eon_Document *d, const char *options)
{
	Ecore_Ipc_Server *srv;

	printf("[REMOTE] Initializing engine\n");

	ecore_init();
	ecore_ipc_init();
	srv = ecore_ipc_server_connect(ECORE_IPC_LOCAL_SYSTEM, "eon-remote", 0, NULL);
	if (!srv)
	{
		/* FIXME add a good way to tell the system that the creation
		 * failed
		 */
		exit(1);
	}
	rdoc = calloc(1, sizeof(Engine_Remote_Document));
	ekeko_event_listener_add(d, EON_DOCUMENT_OBJECT_NEW, _object_new_cb, EINA_FALSE, NULL);

	ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD,
		handler_server_add, NULL);
	ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL,
		handler_server_del, NULL);
	ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA,
		handler_server_data, NULL);

	rdoc->srv = srv;
	return rdoc;
}
/* externally accessible functions */
int
main(int    argc,
     char **argv)
{
   int i;

   for (i = 1; i < argc; i++)
     {
        if ((!strcmp(argv[i], "-h")) ||
            (!strcmp(argv[i], "-help")) ||
            (!strcmp(argv[i], "--help")))
          {
             printf(
               "This is an internal tool for Enlightenment.\n"
               "do not use it.\n"
               );
             exit(0);
          }
        else if (!strncmp(argv[i], "--nice=", 7))
          {
             const char *val;
             int ret = 0;

             val = argv[i] + 7;
             if (*val)
               ret = nice(atoi(val));
          }
     }

   ecore_init();
   ecore_app_args_set(argc, (const char **)argv);
   eet_init();
   evas_init();
   ecore_evas_init();
   edje_init();
   ecore_file_init();
   ecore_ipc_init();

   e_user_dir_concat_static(_thumbdir, "fileman/thumbnails");
   ecore_file_mkpath(_thumbdir);

   if (_e_ipc_init()) ecore_main_loop_begin();

   if (_e_ipc_server)
     {
        ecore_ipc_server_del(_e_ipc_server);
        _e_ipc_server = NULL;
     }

   ecore_ipc_shutdown();
   ecore_file_shutdown();
   ecore_evas_shutdown();
   edje_shutdown();
   evas_shutdown();
   eet_shutdown();
   ecore_shutdown();

   return 0;
}
示例#3
0
/* externally accessible functions */
int
main(int argc, char **argv)
{
   if (argc > 1)
     {
        printf(
        "This is an internal tool for Enlightenment.\n"
        "do not use it.\n"
        );
        exit(0);
     }

   eina_init();
   eet_init();
   ecore_init();
   ecore_app_args_set(argc, (const char **)argv);

   ecore_file_init();
   ecore_ipc_init();
   _e_storage_volume_edd_init();
   if (!_e_fm_ipc_init()) return -1;
   efm_log_dom = eina_log_domain_register("efm", EINA_COLOR_GREEN);
   _e_fm_init();

   ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _e_fm_ipc_slave_data_cb, NULL);
   ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _e_fm_ipc_slave_error_cb, NULL);
   ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _e_fm_ipc_slave_del_cb, NULL);

   ecore_main_loop_begin();

   if (_e_fm_ipc_server)
     {
        ecore_ipc_server_del(_e_fm_ipc_server);
        _e_fm_ipc_server = NULL;
     }

   _e_fm_shutdown();
   _e_storage_volume_edd_shutdown();
   ecore_ipc_shutdown();
   ecore_file_shutdown();
   ecore_shutdown();
   eina_shutdown();
   return 0;
}
示例#4
0
/**
 * @param argc: Number of command line arguments supplied.
 * @param argv: Char* array containing the command line arguments supplied.
 * @return: To the system, normally 0.
 * @brief: The first function once enotes is called.
 */
int
main(int argc, char *argv[])
{
	int             note_count;

	/* IPC Check */
	ecore_ipc_init();
	dml("IPC Initiated Successfully", 1);

	/* loading will increment this if there are notes if not we may need to
	 * create a blank one */
	note_count = 0;

	if ((ecore_config_init("enotes")) == ECORE_CONFIG_ERR_FAIL) {
		ecore_ipc_shutdown();
		return (-1);
	}
	ecore_app_args_set(argc, (const char **) argv);

	ecore_config_app_describe("E-Notes - Sticky Notes for Enlightenment\n\
Copyright (c) Thomas Fletcher\n\
Usage: enotes [options]");

	/* Read the Usage and Configurations */
	main_config = mainconfig_new();
	if (read_configuration(main_config) != ECORE_CONFIG_PARSE_CONTINUE) {
		ecore_config_shutdown();
		ecore_ipc_shutdown();
		ecore_shutdown();
		mainconfig_free(main_config);
		return (-1);
	}

	dml("Successfully Read Configurations and Usage", 1);

	process_note_storage_locations();

	if (find_server() != 0) {
		if (remotecmd != NULL)
			send_to_server(remotecmd);
		else
			send_to_server("DEFNOTE");
	} else {
		dml("Server wasn't found.. Creating one", 1);
		/* Setup Server */
		setup_server();

		/* Initialise the E-Libs */
		ecore_init();
		ecore_x_init(NULL);
		ecore_app_args_set(argc, (const char **) argv);
		if (!ecore_evas_init()) {
			mainconfig_free(main_config);
			return -1;
		}
		ewl_init(&argc, argv);
		edje_init();

		dml("Efl Successfully Initiated", 1);

		autoload();
		/* create autosave timer */
		update_autosave();

		if (remotecmd != NULL)
			handle_ipc_message(remotecmd);

		/* Begin the Control Centre */
		if (main_config->controlcentre == 1) {
			setup_cc();
			dml("Control Centre Setup", 1);
		} else {
			dml("No Control Centre - Displaying Notice", 1);
			if (get_note_count() == 0)
				new_note();
		}

		if (main_config->welcome == 1) {
			open_welcome();
		}

		/* Begin the main loop */
		dml("Starting Main Loop", 1);
		ecore_main_loop_begin();

		dml("Main Loop Ended", 1);

		/* Save Controlcentre Settings */
		set_cc_pos();

		autosave();
		if (autosave_timer)
			ecore_timer_del(autosave_timer);

		/* Save and Free the Configuration */
		ecore_config_save();
		dml("Configuration Saved", 1);
		mainconfig_free(main_config);
		dml("Configuration Structure Free'd", 1);

		/* Shutdown the E-Libs */
		edje_shutdown();
		ecore_evas_shutdown();
		ecore_x_shutdown();
		ecore_shutdown();
		dml("Efl Shutdown", 1);
	}

	/* End IPC */
	ecore_ipc_shutdown();
	dml("IPC Shutdown", 1);

	dml("Leaving.", 1);
	return (0);
}
示例#5
0
int
ecore_config_ipc_init(Ecore_Config_Ipc_Server_List ** srv_list, char *pipe_name,
                      connstate * cs)
{
  int global     , port, connected;
  struct stat     st;
  char           *p;
  char            str[PATH_MAX], buf[PATH_MAX];
  DIR            *dir;
  struct dirent  *socket;
  Ecore_Ipc_Server *tmp_sock;
  Ecore_Config_Ipc_Server_List *tmp;

  global = 0;

  port = 0;

  if (ecore_ipc_init() < 1)
    return ECORE_CONFIG_ERR_FAIL;
  if (!srv_list)
    return ECORE_CONFIG_ERR_FAIL;
  if (*srv_list)
    return ECORE_CONFIG_ERR_IGNORED;

  if ((p = getenv("HOME"))) {   /* debug-only ### FIXME */
    snprintf(str, PATH_MAX -1, "%s/.ecore/%s/.global", p, pipe_name);
    if (stat(str, &st))
      global = 0;

    else
      global = 1;

    snprintf(str, PATH_MAX -1, "%s/.ecore/%s/", p, pipe_name);
    snprintf(buf, PATH_MAX -1, str);

    if ((dir = opendir(buf))) {
      connected = 0;
      while ((socket = readdir(dir))) {
        if (!strcmp(socket->d_name, ".") || !strcmp(socket->d_name, "..") ||
            !strcmp(socket->d_name, ".global"))
          continue;
        if (!is_dir(socket->d_name)) {
          port = atoi(socket->d_name);

          E(2, "Trying %s on port %d ", pipe_name, port);
          //if (!connected) {
          if ((tmp_sock =
               ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, pipe_name, port,
                                        NULL))) {
            E(2, "- connected!\n");
            if (!(tmp = malloc(sizeof(Ecore_Config_Ipc_Server_List))))
              return ECORE_CONFIG_ERR_OOM;
            memset(tmp, 0, sizeof(Ecore_Config_Ipc_Server_List));
            tmp->srv = tmp_sock;

            if (!*srv_list)
              *srv_list = tmp;
            else {
              tmp->next = *srv_list;
              *srv_list = tmp;
            }


            connected = 1;
            if (!global)
              break;
          } else {
            /* not connected */
            E(2, "- failed :(\n");
          }

          //} else {
          //  E(3, "Should also try connecting to %d!!!\n", port);
          //}

        }                       /* is not dir */
      }                         /* while dir */

      closedir(dir);

      if (connected) {

        ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD,
                                ecore_config_ipc_server_con, cs);
        ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL,
                                ecore_config_ipc_server_dis, cs);
        ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA,
                                ecore_config_ipc_server_sent, NULL);

        return ECORE_CONFIG_ERR_SUCC;
      }
    }                           /* opendir */
  } else {                      /* if we cannot access the home variable */
    if ((tmp_sock =
         ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, pipe_name, 0, NULL))) {
      E(2, "Connected to %s on default port (0)!\n", pipe_name);
      ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD,
                              ecore_config_ipc_server_con, cs);
      ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL,
                              ecore_config_ipc_server_dis, cs);
      ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA,
                              ecore_config_ipc_server_sent, NULL);
      if (!(tmp = malloc(sizeof(Ecore_Config_Ipc_Server_List))))
        return ECORE_CONFIG_ERR_OOM;
      memset(tmp, 0, sizeof(Ecore_Config_Ipc_Server_List));
      tmp->srv = tmp_sock;

      if (!*srv_list)
        *srv_list = tmp;

      return ECORE_CONFIG_ERR_SUCC;
    }
  }

  *srv_list = NULL;
  return ECORE_CONFIG_ERR_NOTFOUND;
}
示例#6
0
evfs_connection *
evfs_connect(void (*callback_func) (EvfsEvent *, void *), void *obj)
{
   ecore_init();
   ecore_ipc_init();
   int connect_attempts = 0;

   evfs_connection *connection = NEW(evfs_connection);

   connection->id = MAX_CLIENT;
   connection->prog_event = NULL;
   connection->callback_func = callback_func;
   connection->obj = obj;

   evfs_io_initialise();
   evfs_vfolder_initialise();

   if (!_libevfs_init)
     {
        _libevfs_init = 1;
	_libevfs_next_command_id = 1;
	evfs_session_servers = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);

	/*Register the callback*/
        ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, evfs_server_data,
                                NULL);
        client_list = ecore_list_new();

        ecore_list_append(client_list, connection);
     }
   else
     {
        ecore_list_prepend(client_list, connection);
     }

 retry:

   if (connect_attempts > MAX_ATTEMPTS)
     {
        fprintf(stderr, "Could not start server after max attempts\n");
        exit(1);                /*We shouldn't really kill the libraries parent! */
        return NULL;
     }

   if (!
       (connection->server =
        ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, EVFS_IPC_TITLE,0,
                                 connection)))	   
     {	     
        fprintf(stderr,
                "Cannot connect to evfs server with '%s', making new server and trying again..\n",
                EVFS_IPC_TITLE);

        if (!connect_attempts)
          {
             if (evfs_server_spawn())
               {
                  printf("Failure to start evfs server!\n");
               }
          }

        connect_attempts++;
        usleep(100000 * connect_attempts);
        goto retry;

     } else {
	     ecore_hash_set(evfs_session_servers, connection->server, (int*)1);

	     while (connection->id == MAX_CLIENT) {
		        /*printf("Waiting for connection id..\n");*/
			ecore_main_loop_iterate();
	     }
	     /*printf("Got connection ID: %d\n", connection->id);*/
	     
     }

   return connection;
}