cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=cf27288b505b5745493c01caa85b0103749c96d7

commit cf27288b505b5745493c01caa85b0103749c96d7
Author: Srivardhan Hebbar <[email protected]>
Date:   Wed Mar 25 19:26:41 2015 +0100

    ecore_con: add example for ftp upload.
    
    Summary:
    Added example for ftp upload. In the .gitignore only 2 files added which 
were missing. The differences it is showing is cos of reordering. I did ls and 
redirected the file to gitignore. So the files got reordered.
    
    Signed-off-by: Srivardhan Hebbar <[email protected]>
    
    Reviewers: cedric
    
    Reviewed By: cedric
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D2223
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 src/examples/ecore/.gitignore                  | 20 ++++---
 src/examples/ecore/ecore_con_url_ftp_example.c | 83 ++++++++++++++++++++++++++
 2 files changed, 94 insertions(+), 9 deletions(-)

diff --git a/src/examples/ecore/.gitignore b/src/examples/ecore/.gitignore
index 497f0f3..700be32 100644
--- a/src/examples/ecore/.gitignore
+++ b/src/examples/ecore/.gitignore
@@ -3,39 +3,41 @@
 /ecore_audio_playback
 /ecore_audio_to_ogg
 /ecore_client_bench
+/ecore_compose_get_example
+/ecore_con_client_example
 /ecore_con_client_simple_example
 /ecore_con_lookup_example
+/ecore_con_server_example
 /ecore_con_server_http_example
 /ecore_con_server_simple_example
 /ecore_con_url_cookies_example
 /ecore_con_url_download_example
+/ecore_con_url_ftp_example
 /ecore_con_url_headers_example
 /ecore_evas_basics_example
 /ecore_evas_buffer_example_01
 /ecore_evas_buffer_example_02
 /ecore_evas_callbacks
 /ecore_evas_ews_example
-/ecore_evas_object_example
-/ecore_evas_window_sizes_example
 /ecore_evas_extn_plug_example
 /ecore_evas_extn_socket_example
+/ecore_evas_object_example
+/ecore_evas_window_sizes_example
 /ecore_event_example_01
 /ecore_event_example_02
 /ecore_exe_example
 /ecore_exe_example_child
 /ecore_fd_handler_example
+/ecore_fd_handler_gnutls_example
+/ecore_file_download_example
+/ecore_getopt_example
 /ecore_idler_example
+/ecore_imf_example
 /ecore_job_example
+/ecore_pipe_gstreamer_example
 /ecore_pipe_simple_example
 /ecore_poller_example
 /ecore_server_bench
 /ecore_thread_example
 /ecore_time_functions_example
 /ecore_timer_example
-/ecore_con_client_example
-/ecore_con_server_example
-/ecore_file_download_example
-/ecore_imf_example
-/ecore_pipe_gstreamer_example
-/ecore_getopt_example
-/ecore_compose_get_example
diff --git a/src/examples/ecore/ecore_con_url_ftp_example.c 
b/src/examples/ecore/ecore_con_url_ftp_example.c
new file mode 100644
index 0000000..d3a1488
--- /dev/null
+++ b/src/examples/ecore/ecore_con_url_ftp_example.c
@@ -0,0 +1,83 @@
+//Compile with:
+// gcc -o ecore_con_url_ftp_example ecore_con_url_ftp_example.c `pkg-config 
--libs --cflags ecore ecore-con eina`
+
+#include <stdio.h>
+#include <Eina.h>
+#include <Ecore.h>
+#include <Ecore_Con.h>
+
+static Eina_Bool
+_url_data_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info)
+{
+   Ecore_Con_Event_Url_Data *url_data = event_info;
+   int i;
+
+   for (i = 0; i < url_data->size; i++)
+     printf("%c", url_data->data[i]);
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
+_url_complete_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void 
*event_info)
+{
+   Ecore_Con_Event_Url_Complete *url_complete = event_info;
+
+   printf("\n");
+   printf("upload completed with status code: %d\n", url_complete->status);
+
+   ecore_main_loop_quit();
+
+   return EINA_TRUE;
+}
+
+int
+main(int argc, const char *argv[])
+{
+   Ecore_Con_Url *ec_url = NULL;
+   const char *file, *user, *passwd, *dir;
+
+   if (argc < 5)
+     {
+        printf("./ecore_con_url_ftp <ftp_server_address> <username> <password> 
<file> <directory(optional)>\n");
+        return -1;
+     }
+
+   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;
+     }
+
+   user = argv[2];
+   passwd = argv[3];
+   file = argv[4];
+   dir = argv[5];
+
+   ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _url_data_cb, NULL);
+   ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _url_complete_cb, 
NULL);
+
+   ecore_con_url_verbose_set(ec_url, EINA_TRUE);
+   ecore_con_url_ftp_use_epsv_set(ec_url, EINA_TRUE);
+
+   if( !ecore_con_url_ftp_upload(ec_url, file, user, passwd, dir))
+     {
+        printf("could not realize request.\n");
+        goto free_ec_url;
+     }
+
+   ecore_main_loop_begin();
+
+free_ec_url:
+   ecore_con_url_free(ec_url);
+end:
+   ecore_con_url_shutdown();
+   ecore_con_shutdown();
+
+   return 0;
+}
+

-- 


Reply via email to