Пример #1
0
int
main()
{
   Ecore_Con_Server *svr;
   eina_init();
   ecore_init();
   ecore_con_init();

/* comment if not using gnutls */
   gnutls_global_set_log_level(9);
   gnutls_global_set_log_function(tls_log_func);

/* to use a PEM certificate with TLS and SSL3, uncomment the lines below */
   if (!(svr = ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_TLS | ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT, "127.0.0.1", 8080, NULL)))
/* to use simple tcp with ssl/tls, use this line */
//   if (!ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_SSL3, "127.0.0.1", 8080, NULL))
     exit(1);

   ecore_con_ssl_server_cert_add(svr, "server.pem");
   ecore_con_ssl_server_privkey_add(svr, "server.pem");
/* set event handler for client connect */
   ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb)_add, NULL);
/* set event handler for client disconnect */
   ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb)_del, NULL);
/* set event handler for receiving client data */
   ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb)_data, NULL);

/* start server */
   ecore_main_loop_begin();
}
Пример #2
0
int
main(void)
{
   double done;
   eina_init();
   ecore_init();
   ecore_con_init();

   eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_ERR);
   eina_log_domain_level_set("eina", EINA_LOG_LEVEL_ERR);
   counter = eina_counter_new("client");
   eina_counter_start(counter);
   done = ecore_time_get();

   ecore_job_add(_spawn, NULL);

/* set event handler for server connect */
   ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb)_add, NULL);
   ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb)_del, NULL);

/* start client */
   ecore_main_loop_begin();
   eina_counter_stop(counter, 1);
   printf("\nTime elapsed for %i connections: %f seconds\n%s", NUM_CLIENTS, ecore_time_get() - done, eina_counter_dump(counter));
   return 0;
}
Пример #3
0
void
ipc_init(void)
{
   char *file = NULL;
   Ecore_Fd_Handler *fdh;
   
   file = getenv("EXQUISITE_IPC");
   if (!file || !file[0]) file = "/tmp/exquisite";

   if (!method) method = getenv("EXQUISITE_IPC_METHOD");

   if (!method || !method[0] || !strcmp(method, "fifo"))
     {
        unlink(file);
        mkfifo(file, S_IRUSR | S_IWUSR |  S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
        fd = open(file, O_RDWR);
        fcntl(fd, F_SETFL, O_NONBLOCK);
        if (fd < 0)
          {
             printf("EXQUISITE ERROR: Cannot create fifo: %s\n", file);
             exit(-1);
          }
        fdh = ecore_main_fd_handler_add(fd, ECORE_FD_READ, 
                                        fifo_input, NULL, 
                                        NULL, NULL);
     }
   else if (strstr(method, "socket"))
     {
        ecore_con_init();

        if (!strcmp(method, "socket"))
          {
             sock = ecore_con_server_add(ECORE_CON_LOCAL_SYSTEM, 
                                         file,
                                         0, NULL);
          }
        else
          {
             sock = ecore_con_server_add(ECORE_CON_LOCAL_ABSTRACT, 
                                         file,
                                         0, NULL);
          }

        if (!sock)
          {
            printf("EXQUISITE ERROR: Cannot create socket %s.\n", file);
            exit(-1);
          }

        ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
                                socket_input, NULL);
        ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
                                socket_del, NULL);
     }
   else
     {
        printf("Invalid ipc method: %s\n", method);
        exit(0);
     }
}
Пример #4
0
int main()
{
	eina_init();
	ecore_con_init();

	/*no new function because there's no free function*/
	static zrpc_con zcon;
	/*set up host/port*/
//	zcon.host = "www.domain.com";
//	zcon.port = 4444;
	zcon.host = "10.10.10.6";
	zcon.port = 65534;

//	char *username = "******";
//	char *password = "******";
	char *username = "******";
	char *password = "******";

	/*all zrpc functions take a minimum of 3 arguments:
	 * 1) a zcon handle
	 * 2) a zrpc_network_cb function
	 * 3) a (void*) to pass to the callback
	 */
	zrpc_User_login(username, password, &zcon, (void*)post, &zcon);

	/*start the ecore job server*/
	ecore_main_loop_begin();
	return 0;
}
Пример #5
0
static void _init(EWeather *eweather)
{
   Instance *inst = calloc(1, sizeof(Instance));
   eweather->plugin.data = inst;
   inst->weather = eweather;
   inst->host = eina_stringshare_add("www.google.com");

   printf("INIT %d\n",ecore_con_init());

   inst->add_handler =
      ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
	    _server_add, inst);
   inst->del_handler =
      ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
	    _server_del, inst);
   inst->err_handler =
      ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ERROR,
	    _server_error, inst);
   inst->data_handler =
      ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
	    _server_data, inst);

   inst->check_timer =
      ecore_timer_add(0, _weather_cb_check, inst);
}
Пример #6
0
/**
 * @brief Initialize the store library and all it's required submodules.
 * @return 1 or greater on success, 0 otherwise.
 */
int
store_init(void)
{
   if (++_store_init_count != 1)
     return _store_init_count;

   if (!eina_init())
     {
        fprintf(stderr, "Store can not initialize Eina\n");
        return --_store_init_count;
     }

   _store_log_dom_global = eina_log_domain_register("store", EINA_COLOR_RED);
   if (_store_log_dom_global < 0)
     {
        EINA_LOG_ERR("Store can not create a general log domain");
        goto shutdown_eina;
     }

   if (!ecore_init())
     {
        ERR("Can not initialize Ecore");
        goto unregister_log_domain;
     }

   if (!ecore_con_init())
     {
        ERR("Can not initialize Ecore_Con");
        goto shutdown_ecore;
     }

   if (!ecore_con_url_init())
     {
        ERR("Can not initialize Ecore_Con_Url");
        goto shutdown_ecore_con;
     }

   if (!ecore_con_url_pipeline_get())
     ecore_con_url_pipeline_set(EINA_TRUE);

   return _store_init_count;

shutdown_ecore_con:
   ecore_con_shutdown();
shutdown_ecore:
   ecore_shutdown();
unregister_log_domain:
   eina_log_domain_unregister(_store_log_dom_global);
   _store_log_dom_global = -1;
shutdown_eina:
   eina_shutdown();
   return --_store_init_count;
}
Пример #7
0
/**
 * @brief Initialize Azy
 *
 * This function initializes error handlers, events, and
 * logging functions for Azy and must be called prior to making any
 * calls.
 * @return The number of times the function has been called, or -1 on failure
 */
int
azy_init(void)
{
   if (++azy_init_count_ != 1)
     return azy_init_count_;
   if (!eina_init()) return 0;
   azy_log_dom = eina_log_domain_register("azy", EINA_COLOR_BLUE);
   if (azy_log_dom < 0)
     {
        ERR("Could not register 'azy' log domain!");
        goto eina_fail;
     }
   if (!ecore_init()) goto fail;
   if (!ecore_con_init()) goto ecore_fail;

   azy_lib_register_errors_();

   AZY_CLIENT_DISCONNECTED = ecore_event_type_new();
   AZY_CLIENT_UPGRADE = ecore_event_type_new();
   AZY_CLIENT_CONNECTED = ecore_event_type_new();
   AZY_CLIENT_RETURN = ecore_event_type_new();
   AZY_CLIENT_RESULT = ecore_event_type_new();
   AZY_CLIENT_ERROR = ecore_event_type_new();

   AZY_SERVER_CLIENT_ADD = ecore_event_type_new();
   AZY_SERVER_CLIENT_UPGRADE = ecore_event_type_new();
   AZY_SERVER_CLIENT_DEL = ecore_event_type_new();

   AZY_EVENT_DOWNLOAD_STATUS = ecore_event_type_new();

   eina_magic_string_set(AZY_MAGIC_SERVER, "Azy_Server");
   eina_magic_string_set(AZY_MAGIC_SERVER_CLIENT, "Azy_Server_Client");
   eina_magic_string_set(AZY_MAGIC_SERVER_MODULE, "Azy_Server_Module");
   eina_magic_string_set(AZY_MAGIC_SERVER_MODULE_DEF, "Azy_Server_Module_Def");
   eina_magic_string_set(AZY_MAGIC_SERVER_MODULE_METHOD, "Azy_Server_Module_Method");
   eina_magic_string_set(AZY_MAGIC_CLIENT, "Azy_Client");
   eina_magic_string_set(AZY_MAGIC_CLIENT_DATA_HANDLER, "Azy_Client_Handler_Data");
   eina_magic_string_set(AZY_MAGIC_NET, "Azy_Net");
   eina_magic_string_set(AZY_MAGIC_VALUE, "Azy_Value");
   eina_magic_string_set(AZY_MAGIC_CONTENT, "Azy_Content");
   return azy_init_count_;

ecore_fail:
   ecore_shutdown();
fail:
   eina_log_domain_unregister(azy_log_dom);
   azy_log_dom = -1;
eina_fail:
   eina_shutdown();
   return 0;
}
Пример #8
0
EAPI_MAIN int elm_main(int argc, char **argv)
{
    Evas_Object *win = NULL;

    ecore_init();
    ecore_con_init();
    ecore_con_url_init();

    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

    /* Create an win, associate it with a canvas and */
    /* turn it visible on WM (Window Manager).       */
    win = elm_win_util_standard_add("Greetings", "Hello, World!");
    elm_win_autodel_set(win, EINA_TRUE);

    CalaosCameraView *cam = new CalaosCameraView(evas_object_evas_get(win));
    Evas_Object *o = cam->getSmartObject();

    //cam->setCameraUrl("http://*****:*****@10.7.0.102/image.jpg");
    //cam->setCameraUrl("http://192.168.0.47/axis-cgi/jpg/image.cgi");
    //cam->setCameraUrl("http://192.168.0.47/axis-cgi/mjpg/video.cgi");
    cam->setCameraUrl("http://192.168.0.37:8080/video");
    //cam->setCameraUrl("http://192.168.0.47");
    //cam->setCameraUrl("http://192.168.0.13/video.mjpg");
    //cam->setCameraUrl("http://192.168.0.13/image.jpg");

    CalaosCameraView *cam2 = new CalaosCameraView(evas_object_evas_get(win));
    Evas_Object *o2 = cam2->getSmartObject();
    cam2->setCameraUrl("http://192.168.0.47/axis-cgi/mjpg/video.cgi");

    cam->play();
    cam2->play();

    evas_object_resize(o, 640, 480);
    evas_object_move(o, 0, 0);
    evas_object_show(o);

    evas_object_resize(o2, 640, 480);
    evas_object_move(o2, 640, 0);
    evas_object_show(o2);

    evas_object_resize(win, 640*2, 480);
    evas_object_show(win);

    elm_run();
    elm_shutdown();

    return 0;
}
Пример #9
0
Файл: irc.c Проект: Limsik/e17
EMAPI int
protocol_init(Emote_Protocol *p)
{
   unsigned int i;
   m = p;

   ecore_con_init();

   _irc_servers = eina_hash_string_superfast_new(NULL);

   for (i = 0; i < (sizeof(_em_events)/sizeof(Emote_Event_Type)); ++i)
      emote_event_handler_add(_em_events[i], _irc_event_handler, NULL);

   return 1;
}
Пример #10
0
int
enfeeble_init(void)
{
   eina_init();
   ecore_init();
   ecore_con_init();

   /* real men don't accept failure as a possibility */
   enfeeble_log_dom = eina_log_domain_register("enfeeble", EINA_COLOR_RED);

   ENFEEBLE_EVENT_CONNECT = ecore_event_type_new();
   ENFEEBLE_EVENT_DISCONNECT = ecore_event_type_new();
   ENFEEBLE_EVENT_MESSAGE = ecore_event_type_new();

   return 1;
}
Пример #11
0
int main (int argc, char *argv[]) {
  ecore_con_init();

  printf("Server is running: waiting for connections\n");
  svr = ecore_con_server_add(ECORE_CON_LOCAL_USER, "con_example", 0, NULL);
  ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
			  (Handler_Func)client_connect, NULL);
  ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
			  (Handler_Func)client_disconnect, NULL);
  ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
			  (Handler_Func)client_data, NULL);
  ecore_main_loop_begin();

  ecore_con_shutdown();
  return 0;
}
Пример #12
0
int main (int argc, char *argv[]) {
  const char msg[] = "Hello Server\n";

  if (argc != 3)
    {
      fprintf(stderr, "Usage: con_tcp_client_example host port\n");
      return 1;
    }

  ecore_con_init();

  ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, 
                          event_hup, NULL);

  svr = ecore_con_server_connect(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_SSL3, argv[1], atoi(argv[2]), NULL);
  if( !svr )
    {
      printf("Unable to connect\n");
      return 1;
    }
  else
    {
      printf("Trying to connect\n");
    }

  printf("Server handle: 0x%08x\n", svr);

  ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
			  (Handler_Func)server_add, NULL);
  ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
			  (Handler_Func)server_del, NULL);
  ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
			  (Handler_Func)client_add, NULL);
  ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
			  (Handler_Func)client_del, NULL);
  ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
			  (Handler_Func)server_data, NULL);
  ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
			  (Handler_Func)client_data, NULL);

  ecore_con_server_send(svr, msg, sizeof(msg));

  ecore_main_loop_begin();

  ecore_con_shutdown();
  return 0;
}
Пример #13
0
int
shotgun_init(void)
{
   eina_init();
   ecore_init();
   ecore_con_init();

   /* real men don't accept failure as a possibility */
   shotgun_log_dom = eina_log_domain_register("shotgun", EINA_COLOR_RED);

   SHOTGUN_EVENT_CONNECT = ecore_event_type_new();
   SHOTGUN_EVENT_CONNECTION_STATE = ecore_event_type_new();
   SHOTGUN_EVENT_DISCONNECT = ecore_event_type_new();
   SHOTGUN_EVENT_MESSAGE = ecore_event_type_new();
   SHOTGUN_EVENT_PRESENCE = ecore_event_type_new();
   SHOTGUN_EVENT_IQ = ecore_event_type_new();

   return 1;
}
Пример #14
0
void sourcedrop_init(void)
{
    ecore_init();
    ecore_con_init();
    handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, (Ecore_Event_Handler_Cb)__upload_completed_cb, NULL);
}
Пример #15
0
int
main(int argc, const char *argv[])
{
   Ecore_Con_Url *ec_url = NULL;
   struct _request *req;
   int fd;
   const char *filename = "downloadedfile.dat";

   if (argc < 2)
     {
        printf("need one parameter: <url>\n");
        return -1;
     }

   fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644);

   if (fd == -1)
     {
        printf("error: could not open file for writing: \"%s\"\n",
               filename);
        return -1;
     }

   ecore_init();
   ecore_con_init();
   ecore_con_url_init();

   ec_url = ecore_con_url_new(argv[1]);
   if (!ec_url)
     {
        printf("error when creating ecore con url object.\n");
        goto end;
     }

   req = malloc(sizeof(*req));
   req->size = 0;
   ecore_con_url_data_set(ec_url, req);

   ecore_con_url_fd_set(ec_url, fd);

   ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _url_progress_cb, NULL);
   ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _url_complete_cb, NULL);

   if (!ecore_con_url_get(ec_url))
     {
        printf("could not realize request.\n");
        goto free_ec_url;
     }

   ecore_main_loop_begin();

free_ec_url:
   free(req);
   ecore_con_url_free(ec_url);
end:

   close(fd);
   ecore_con_url_shutdown();
   ecore_con_shutdown();
   ecore_shutdown();

   return 0;
}
Пример #16
0
ApplicationMain::ApplicationMain(int argc, char **argv)
{
    cInfo() <<  "Calaos Home, starting...";

    if (system("killall -9 eskiss 2> /dev/null") == -1)
        cCritical() <<  "Error forking !";

    //init random generator
    srand(time(NULL));

    //Init SSL and CURL
    SSL_load_error_strings();
    SSL_library_init();
    curl_global_init(CURL_GLOBAL_ALL);

    char *themefile = argvOptionParam(argv, argv + argc, "--theme");
    if (themefile)
    {
        ApplicationMain::theme = themefile;
        cInfo() <<  "Using specified theme file: " << ApplicationMain::getTheme();
    }
    else
    {
        ApplicationMain::theme = Prefix::Instance().dataDirectoryGet() + "/default.edj";
        if (ecore_file_exists(ApplicationMain::theme.c_str()))
            cInfo() << "Using theme file " << theme;
        else
            cError() << theme << " Not found!";
    }

    //Init efl core
    if (!eina_init())
        throw (runtime_error("Unable to init Eina"));
    if (!ecore_init())
        throw (runtime_error("Unable to init Ecore"));
    if (!ecore_con_init())
        throw (runtime_error("Unable to init Ecore-Con"));
    if (!ecore_con_url_init())
        throw (runtime_error("Unable to init Ecore-Con-Url"));
    if (!evas_init())
        throw (runtime_error("Unable to init Evas"));
    if (!ecore_evas_init())
        throw (runtime_error("Unable to init Ecore-Evas"));
    if (!edje_init())
        throw (runtime_error("Unable to init Edje"));

    edje_frametime_set(1.0 / 60.0);
    edje_scale_set(1.0);

    if (!elm_init(argc, argv))
        throw (runtime_error("Unable to init Elementary"));

    //Load Calaos specific ELM extensions
    elm_theme_extension_add(NULL, ApplicationMain::getTheme());

    //Create the main window
    window = elm_win_add(NULL, "calaos-home", ELM_WIN_BASIC);
    elm_win_title_set(window, "Calaos Home");
    elm_win_borderless_set(window, true);

    bool bFullscreen = argvOptionCheck(argv, argv + argc, "--fullscreen");
    elm_win_fullscreen_set(window, bFullscreen);

    //Automatically quit main loop when the window is closed
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
    elm_win_autodel_set(window, true);

    if (argvOptionCheck(argv, argv + argc, "--set-elm-config"))
    {
        //force setting the correct elementary options for touchscreen
        elm_config_finger_size_set(10);
        elm_config_scroll_bounce_enabled_set(true);
        elm_config_scroll_thumbscroll_enabled_set(true);
        elm_config_scroll_thumbscroll_threshold_set(24);
        elm_config_scroll_thumbscroll_momentum_threshold_set(100.0);
        elm_config_scroll_bounce_friction_set(0.5);
        elm_config_scroll_page_scroll_friction_set(0.5);
        elm_config_scroll_bring_in_scroll_friction_set(0.5);
        elm_config_scroll_zoom_friction_set(0.5);
        elm_config_scroll_thumbscroll_friction_set(1.0);
        elm_config_scroll_thumbscroll_border_friction_set(0.5);
        elm_config_scroll_thumbscroll_sensitivity_friction_set(0.25);
    }

    evas_object_event_callback_add(window, EVAS_CALLBACK_RESIZE, _window_resize_cb, this);
    evas = evas_object_evas_get(window);

    Evas_Object *bg = elm_bg_add(window);
    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(window, bg);
    evas_object_show(bg);
    evas_object_size_hint_min_set(bg, 200, 200);
    elm_bg_color_set(bg, 0, 0, 0);

    layout = elm_layout_add(window);
    if (!elm_layout_file_set(layout, ApplicationMain::getTheme(), EDJE_GROUP_MAIN_LAYOUT))
    {
        string e = "Unable to find group \"";
        e += EDJE_GROUP_MAIN_LAYOUT;
        e += "\" in theme \"";
        e += ApplicationMain::getTheme();
        e += "\"";
        throw (runtime_error(e));
    }

    //create the screen suspend object and put it on the canvas
    ScreenSuspendView *screen_suspend = new ScreenSuspendView(evas, window);
    screen_suspend->Show();
    screen_suspend->setAutoDelete(true);

    evas_object_size_hint_weight_set(layout, 1.0, 1.0);
    evas_object_show(layout);

    evas_object_resize(window, 1024, 768);
    evas_object_show(window);
    ecore_evas_focus_set(ecore_evas_ecore_evas_get(evas_object_evas_get(window)), true);

    Resize();

    try
    {
        controller = new ApplicationController(evas, layout);
    }
    catch(exception const& e)
    {
        cCritical() <<  "Can't create ApplicationController";
        throw;
    }
}