1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  *  Copyright © 2002 Jorn Baayen
4  *  Copyright © 2003, 2004 Marco Pesenti Gritti
5  *  Copyright © 2004, 2005, 2006 Christian Persch
6  *
7  *  This file is part of Epiphany.
8  *
9  *  Epiphany is free software: you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation, either version 3 of the License, or
12  *  (at your option) any later version.
13  *
14  *  Epiphany is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with Epiphany.  If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #pragma once
24 
25 #include <glib.h>
26 #include <gio/gio.h>
27 #include <gtk/gtk.h>
28 
29 extern GQuark ephy_file_helpers_error_quark;
30 #define EPHY_FILE_HELPERS_ERROR_QUARK        (ephy_file_helpers_error_quark)
31 
32 G_BEGIN_DECLS
33 
34 typedef enum
35 {
36   EPHY_FILE_HELPERS_NONE             = 0,
37   EPHY_FILE_HELPERS_KEEP_DIR         = 1 << 1,
38   EPHY_FILE_HELPERS_PRIVATE_PROFILE  = 1 << 2,
39   EPHY_FILE_HELPERS_ENSURE_EXISTS    = 1 << 3,
40   EPHY_FILE_HELPERS_STEAL_DATA       = 1 << 4,
41   EPHY_FILE_HELPERS_TESTING_MODE     = 1 << 5
42 } EphyFileHelpersFlags;
43 
44 typedef enum
45 {
46   EPHY_FILE_HELPERS_I_UNDERSTAND_I_MUST_NOT_USE_THIS_FUNCTION_UNDER_FLATPAK
47 } EphyFileHelpersNotFlatpakTag;
48 
49 gboolean           ephy_file_helpers_init                   (const char            *profile_dir,
50                                                              EphyFileHelpersFlags   flags,
51                                                              GError               **error);
52 const char *       ephy_profile_dir                         (void);
53 gboolean           ephy_profile_dir_is_default              (void);
54 gboolean           ephy_profile_dir_is_web_application      (void);
55 const char *       ephy_cache_dir                           (void);
56 const char *       ephy_config_dir                          (void);
57 char       *       ephy_default_profile_dir                 (void);
58 char       *       ephy_default_cache_dir                   (void);
59 char       *       ephy_default_config_dir                  (void);
60 void               ephy_file_helpers_shutdown               (void);
61 char       *       ephy_file_get_downloads_dir              (void);
62 char       *       ephy_file_desktop_dir                    (void);
63 const char *       ephy_file_tmp_dir                        (void);
64 char       *       ephy_file_tmp_filename                   (const char            *base,
65                                                              const char            *extension);
66 gboolean           ephy_ensure_dir_exists                   (const char            *dir,
67                                                              GError               **error);
68 gboolean           ephy_file_launch_handler                 (GFile                 *file,
69                                                              guint32                user_time);
70 gboolean           ephy_file_delete_dir_recursively         (const char            *directory,
71                                                              GError               **error);
72 char       *       ephy_sanitize_filename                   (char                  *filename);
73 void               ephy_open_default_instance_window        (void);
74 void               ephy_open_incognito_window               (const char            *uri);
75 
76 /* These functions attempt to launch a particular application chosen by
77  * Epiphany, which is not possible to do when running inside flatpak. Be
78  * careful!
79  */
80 gboolean           ephy_file_launch_desktop_file            (const char                   *filename,
81                                                              guint32                       user_time,
82                                                              EphyFileHelpersNotFlatpakTag  tag);
83 gboolean           ephy_file_open_uri_in_default_browser    (const char                   *uri,
84                                                              guint32                       user_time,
85                                                              GdkScreen                    *screen,
86                                                              EphyFileHelpersNotFlatpakTag  tag);
87 gboolean           ephy_file_browse_to                      (GFile                        *file,
88                                                              guint32                       user_time);
89 
90 void               ephy_copy_directory                      (const char                   *source,
91                                                              const char                   *target);
92 
93 G_END_DECLS
94