END_TEST START_TEST(ecore_con_test_ecore_con_url_init) { int ret; ret = ecore_con_url_init(); fail_if(ret != 1); ret = ecore_con_url_shutdown(); fail_if(ret != 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; }
FileDownloader::FileDownloader(string _url, string _dest, bool auto_del): url_con(NULL), dl_file(NULL), auto_destroy(auto_del), idler(NULL), url(_url), dest(_dest), user_data(NULL) { ecore_con_url_init(); complete_handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _complete_cb, this); progress_handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _progress_cb, this); }
END_TEST #endif START_TEST(ecore_con_test_ecore_con_url_download) { Ecore_Con_Url *url; url_test *info; int ret; #ifdef ECORE_CON_HTTP_TEST_URL const char link[] = ECORE_CON_HTTP_TEST_URL; #else const char link[] = DEFAULT_LINK; #endif char url_data[] = "test"; ret = eina_init(); fail_if(ret != 1); ret = ecore_con_url_init(); fail_if(ret != 1); url = ecore_con_url_new(link); fail_if(!url); ecore_con_url_verbose_set(url, EINA_TRUE); fail_if (strcmp(ecore_con_url_url_get(url), link)); ecore_con_url_data_set(url, url_data); fail_if (strcmp(ecore_con_url_data_get(url), url_data)); info = (url_test *) malloc(sizeof(url_test)); info->_tmpfd = 0; if (!ecore_con_url_get(url)) { close(info->_tmpfd); free(info); ecore_con_url_free(url); fail(); } else { ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _url_compl_cb, info); } ret = ecore_con_url_shutdown(); fail_if(ret != 0); ret = eina_shutdown(); }
Elm_Url * _elm_url_download(const char *url, Elm_Url_Done done_cb, Elm_Url_Cancel cancel_cb, Elm_Url_Progress progress_cb, const void *data) { Ecore_Con_Url *target; Elm_Url *r; ecore_con_url_init(); target = ecore_con_url_new(url); if (!target) goto on_error; #if defined(HAVE_GETUID) && defined(HAVE_GETEUID) if (getuid() == geteuid()) #endif { if (getenv("http_proxy")) ecore_con_url_proxy_set(target, getenv("http_proxy")); if (getenv("https_proxy")) ecore_con_url_proxy_set(target, getenv("https_proxy")); if (getenv("ftp_proxy")) ecore_con_url_proxy_set(target, getenv("ftp_proxy")); } r = malloc(sizeof (Elm_Url)); if (!r) goto on_error; r->url = eina_stringshare_add(url); r->cb.done = done_cb; r->cb.cancel = cancel_cb; r->cb.progress = progress_cb; r->data = data; r->download = eina_binbuf_new(); r->target = target; r->handler.progress = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _elm_url_progress, r); r->handler.done = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _elm_url_done, r); r->handler.data = ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _elm_url_data, r); if (!ecore_con_url_get(r->target)) { _elm_url_free(r); cancel_cb((void*) data, NULL, -1); return NULL; } return r; on_error: ecore_con_url_shutdown(); cancel_cb((void*) data, NULL, -1); return NULL; }
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; }
int ecore_file_download_init(void) { #ifdef BUILD_ECORE_CON if (!ecore_con_url_init()) return 0; # ifdef HAVE_CURL _url_complete_handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _ecore_file_download_url_complete_cb, NULL); _url_progress_download = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _ecore_file_download_url_progress_cb, NULL); # endif #endif /* BUILD_ECORE_CON */ return 1; }
END_TEST #endif #ifdef ECORE_CON_HTTP_TEST_URL START_TEST(ecore_con_test_ecore_con_url_post) { Ecore_Con_Url *ec_url; url_test *info; int ret; char link[] = ECORE_CON_HTTP_TEST_URL; char url_data[] = "test"; char *username = NULL, *password = NULL; char url[4096]; ret = eina_init(); fail_if(ret != 1); ret = ecore_con_url_init(); fail_if(ret != 1); fail_unless(_parse_url(link, url, &username, &password, NULL, NULL)); fprintf (stderr, "HTTP: \n url = %s \n username = %s \n password = %s \n", url, username, password); ecore_con_url_pipeline_set(EINA_TRUE); fail_unless (ecore_con_url_pipeline_get()); ec_url = ecore_con_url_custom_new(url, "POST"); fail_unless (ec_url); ecore_con_url_additional_header_add(ec_url, "User-Agent", "blablabla"); ecore_con_url_verbose_set(ec_url, EINA_TRUE); ecore_con_url_httpauth_set(ec_url, username, password, EINA_FALSE); ecore_con_url_time(ec_url, ECORE_CON_URL_TIME_IFMODSINCE, 0); fail_unless(ecore_con_url_post(ec_url, url_data, 4, NULL)); ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _url_compl_cb, info); ret = ecore_con_url_shutdown(); fail_if(ret != 0); ret = eina_shutdown(); }
END_TEST START_TEST(ecore_con_test_ecore_con_url_create) { Ecore_Con_Url *url; int ret; ret = eina_init(); fail_if(ret != 1); ret = ecore_con_url_init(); fail_if(ret != 1); url = ecore_con_url_new("http://google.com"); fail_if(!url); ecore_con_url_free(url); ret = ecore_con_url_shutdown(); fail_if(ret != 0); ret = eina_shutdown(); }
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; }
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; } }