Changeset 172437 in webkit


Ignore:
Timestamp:
Aug 12, 2014 1:22:05 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][WK2] Minibrowser: Enhance the application to use download directory selector.
https://bugs.webkit.org/show_bug.cgi?id=135791

Patch by Shivakumar JM <shiva.jm@samsung.com> on 2014-08-12
Reviewed by Gyuyoung Kim.

Currently Minibrowser stores the downloaded files to /tmp directory, add support so that destination folder can be selected by the
user.

  • MiniBrowser/efl/main.c:

(on_download_request):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r172430 r172437  
     12014-08-12  Shivakumar JM  <shiva.jm@samsung.com>
     2
     3        [EFL][WK2] Minibrowser: Enhance the application to use download directory selector.
     4        https://bugs.webkit.org/show_bug.cgi?id=135791
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        Currently Minibrowser stores the downloaded files to /tmp directory, add support so that destination folder can be selected by the
     9        user.
     10
     11        * MiniBrowser/efl/main.c:
     12        (on_download_request):
     13
    1142014-08-11  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
    215
  • trunk/Tools/MiniBrowser/efl/main.c

    r171906 r172437  
    655655{
    656656    Ewk_Download_Job *download = (Ewk_Download_Job *)event_info;
    657 
    658     // FIXME: The destination folder should be selected by the user but we set it to '/tmp' for now.
     657    Browser_Window *window = (Browser_Window *)user_data;
     658
    659659    Eina_Strbuf *destination_path = eina_strbuf_new();
     660
     661    const char *home_path = getenv("HOME");
     662    Eina_Stringshare *save_file_path = show_file_entry_dialog(window, "DOWNLOAD", home_path ? home_path : "/tmp");
     663
     664    if (save_file_path)
     665        eina_strbuf_append_printf(destination_path, "%s", save_file_path);
     666    else
     667        eina_strbuf_append(destination_path, "/tmp");
    660668
    661669    const char *suggested_name = ewk_download_job_suggested_filename_get(download);
    662670    if (suggested_name && *suggested_name)
    663         eina_strbuf_append_printf(destination_path, "/tmp/%s", suggested_name);
     671        eina_strbuf_append_printf(destination_path, "/%s", suggested_name);
    664672    else {
    665673        // Generate a unique file name since no name was suggested.
    666         char unique_path[] = "/tmp/downloaded-file.XXXXXX";
    667         if (mkstemp(unique_path) == -1) {
     674        eina_strbuf_append(destination_path, "/downloaded-file.XXXXXX");
     675        char *url = NULL;
     676        url = eina_strbuf_string_steal(destination_path);
     677        if (mkstemp(url) == -1) {
    668678            info("ERROR: Could not generate a unique file name.");
    669679            return;
    670680        }
    671         eina_strbuf_append(destination_path, unique_path);
     681        eina_strbuf_append(destination_path, url);
    672682    }
    673683
     
    675685    info("Downloading: %s", eina_strbuf_string_get(destination_path));
    676686    eina_strbuf_free(destination_path);
     687    eina_stringshare_del(save_file_path);
    677688}
    678689
Note: See TracChangeset for help on using the changeset viewer.