Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright 2010 John-Mark Bell <jmb@netsurf-browser.org>
  3.  *
  4.  * This file is part of NetSurf, http://www.netsurf-browser.org/
  5.  *
  6.  * NetSurf is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; version 2 of the License.
  9.  *
  10.  * NetSurf is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. /**
  20.  * \file desktop/download.h
  21.  * \brief Core download context (interface)
  22.  */
  23.  
  24. #ifndef NETSURF_DESKTOP_DOWNLOAD_H_
  25. #define NETSURF_DESKTOP_DOWNLOAD_H_
  26.  
  27. #include "utils/errors.h"
  28.  
  29. struct gui_window;
  30. struct llcache_handle;
  31.  
  32. /** Type of a download context */
  33. typedef struct download_context download_context;
  34.  
  35. /**
  36.  * Create a download context
  37.  *
  38.  * \param llcache  Low-level cache handle for download
  39.  * \param parent   Parent window, for UI
  40.  * \return NSERROR_OK on success, appropriate error otherwise
  41.  *
  42.  * This must only be called by the core browser window fetch infrastructure.
  43.  * Ownership of the download context object created is passed to the frontend.
  44.  */
  45. nserror download_context_create(struct llcache_handle *llcache,
  46.                 struct gui_window *parent);
  47.  
  48. /**
  49.  * Destroy a download context
  50.  *
  51.  * \param ctx  Context to destroy
  52.  *
  53.  * Called by the frontend when it has finished with a download context
  54.  */
  55. void download_context_destroy(download_context *ctx);
  56.  
  57. /**
  58.  * Abort a download fetch
  59.  *
  60.  * \param ctx  Context to abort
  61.  *
  62.  * Called by the frontend to abort a download.
  63.  * The context must be destroyed independently.
  64.  */
  65. void download_context_abort(download_context *ctx);
  66.  
  67. /**
  68.  * Retrieve the URL for a download
  69.  *
  70.  * \param ctx  Context to retrieve URL from
  71.  * \return URL string
  72.  */
  73. const char *download_context_get_url(const download_context *ctx);
  74.  
  75. /**
  76.  * Retrieve the MIME type for a download
  77.  *
  78.  * \param ctx  Context to retrieve MIME type from
  79.  * \return MIME type string
  80.  */
  81. const char *download_context_get_mime_type(const download_context *ctx);
  82.  
  83. /**
  84.  * Retrieve total byte length of download
  85.  *
  86.  * \param ctx  Context to retrieve byte length from
  87.  * \return Total length, in bytes, or 0 if unknown
  88.  */
  89. unsigned long download_context_get_total_length(const download_context *ctx);
  90.  
  91. /**
  92.  * Retrieve the filename for a download
  93.  *
  94.  * \param ctx  Context to retrieve filename from
  95.  * \return Filename string
  96.  */
  97. const char *download_context_get_filename(const download_context *ctx);
  98.  
  99. #endif
  100.