static void _grabber_tmdb_shutdown(void) { INF("Shutdown TMDb grabber"); eina_hash_free(_hash_req); free(_stats); ecore_con_url_shutdown(); ecore_con_shutdown(); }
FileDownloader::~FileDownloader() { cb_connection.disconnect(); cb_connection_user.disconnect(); ecore_event_handler_del(complete_handler); ecore_event_handler_del(progress_handler); Cancel(); ecore_con_url_shutdown(); }
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); }
ApplicationMain::~ApplicationMain() { DELETE_NULL(controller) elm_shutdown(); edje_shutdown(); ecore_evas_shutdown(); evas_shutdown(); ecore_con_url_shutdown(); ecore_con_shutdown(); ecore_shutdown(); eina_shutdown(); }
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; }
void ecore_file_download_shutdown(void) { #ifdef BUILD_ECORE_CON if (_url_complete_handler) ecore_event_handler_del(_url_complete_handler); if (_url_progress_download) ecore_event_handler_del(_url_progress_download); _url_complete_handler = NULL; _url_progress_download = NULL; ecore_file_download_abort_all(); ecore_con_url_shutdown(); #endif /* BUILD_ECORE_CON */ }
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(); }
/** * @brief Shutdown store and all it's submodules if possible. * @return 0 if store shuts down, greater than 0 otherwise. * This function shuts down all things set up in store_init() * and cleans up its memory. */ int store_shutdown(void) { if (_store_init_count <= 0) { fprintf(stderr, "Store init count not greater than 0 in shutdown."); return 0; } if (--_store_init_count != 0) return _store_init_count; ecore_con_url_shutdown(); ecore_con_shutdown(); ecore_shutdown(); eina_log_domain_unregister(_store_log_dom_global); _store_log_dom_global = -1; eina_shutdown(); return _store_init_count; }
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; }