• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 Collabora Ltd.
3  * Copyright (C) 2009 Gustavo Noronha Silva <gns@gnome.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef WEBKIT_DOWNLOAD_H
22 #define WEBKIT_DOWNLOAD_H
23 
24 #include <webkit/webkitdefines.h>
25 
26 #include <glib-object.h>
27 
28 G_BEGIN_DECLS
29 
30 #define WEBKIT_TYPE_DOWNLOAD            (webkit_download_get_type())
31 #define WEBKIT_DOWNLOAD(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOWNLOAD, WebKitDownload))
32 #define WEBKIT_DOWNLOAD_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_DOWNLOAD, WebKitDownloadClass))
33 #define WEBKIT_IS_DOWNLOAD(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOWNLOAD))
34 #define WEBKIT_IS_DOWNLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_DOWNLOAD))
35 #define WEBKIT_DOWNLOAD_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_DOWNLOAD, WebKitDownloadClass))
36 
37 typedef enum {
38     WEBKIT_DOWNLOAD_STATUS_ERROR = -1,
39     WEBKIT_DOWNLOAD_STATUS_CREATED = 0,
40     WEBKIT_DOWNLOAD_STATUS_STARTED,
41     WEBKIT_DOWNLOAD_STATUS_CANCELLED,
42     WEBKIT_DOWNLOAD_STATUS_FINISHED
43 } WebKitDownloadStatus;
44 
45 typedef enum {
46     WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER,
47     WEBKIT_DOWNLOAD_ERROR_DESTINATION,
48     WEBKIT_DOWNLOAD_ERROR_NETWORK
49 } WebKitDownloadError;
50 
51 typedef struct _WebKitDownloadPrivate WebKitDownloadPrivate;
52 
53 struct _WebKitDownload {
54     GObject parent_instance;
55 
56     WebKitDownloadPrivate *priv;
57 };
58 
59 struct _WebKitDownloadClass {
60     GObjectClass parent_class;
61 
62     /* Padding for future expansion */
63     void (*_webkit_reserved0) (void);
64     void (*_webkit_reserved1) (void);
65     void (*_webkit_reserved2) (void);
66     void (*_webkit_reserved3) (void);
67 };
68 
69 WEBKIT_API GType
70 webkit_download_get_type                    (void);
71 
72 WEBKIT_API WebKitDownload*
73 webkit_download_new                         (WebKitNetworkRequest *request);
74 
75 WEBKIT_API void
76 webkit_download_start                       (WebKitDownload       *download);
77 
78 WEBKIT_API void
79 webkit_download_cancel                      (WebKitDownload       *download);
80 
81 WEBKIT_API const gchar*
82 webkit_download_get_uri                     (WebKitDownload       *download);
83 
84 WEBKIT_API WebKitNetworkRequest*
85 webkit_download_get_network_request         (WebKitDownload       *download);
86 
87 WEBKIT_API const gchar*
88 webkit_download_get_suggested_filename      (WebKitDownload       *download);
89 
90 WEBKIT_API const gchar*
91 webkit_download_get_destination_uri         (WebKitDownload       *download);
92 
93 WEBKIT_API void
94 webkit_download_set_destination_uri         (WebKitDownload       *download,
95                                              const gchar          *destination_uri);
96 
97 WEBKIT_API gdouble
98 webkit_download_get_progress                (WebKitDownload       *download);
99 
100 WEBKIT_API gdouble
101 webkit_download_get_elapsed_time            (WebKitDownload       *download);
102 
103 WEBKIT_API guint64
104 webkit_download_get_total_size              (WebKitDownload       *download);
105 
106 WEBKIT_API guint64
107 webkit_download_get_current_size            (WebKitDownload       *download);
108 
109 WEBKIT_API WebKitDownloadStatus
110 webkit_download_get_status                  (WebKitDownload       *download);
111 
112 G_END_DECLS
113 
114 #endif
115