ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / modules / vfolder / vfolder-util.h
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* 
3  * vfolder-util.h - Utility functions for wrapping monitors and 
4  *                  filename/uri parsing.
5  *
6  * Copyright (C) 2002 Ximian, Inc.
7  *
8  * The Gnome Library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * The Gnome Library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with the Gnome Library; see the file COPYING.LIB.  If not,
20  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  * Author: Alex Graveley <alex@ximian.com>
24  *         Based on original code by George Lebl <jirka@5z.com>.
25  */
26
27 #ifndef VFOLDER_UTIL_H
28 #define VFOLDER_UTIL_H
29
30 #include <time.h>
31
32 #include <glib.h>
33 #include <libgnomevfs/gnome-vfs-uri.h>
34 #include <libgnomevfs/gnome-vfs-utils.h>
35 #include <libgnomevfs/gnome-vfs-monitor.h>
36
37 G_BEGIN_DECLS
38
39 typedef struct {
40         const gchar *scheme;
41         gboolean     is_all_scheme;
42         gboolean     ends_in_slash;
43         gchar       *path;
44         gchar       *file;
45         GnomeVFSURI *uri;
46 } VFolderURI;
47
48 /* assumes vuri->path already set */
49 gboolean vfolder_uri_parse_internal (GnomeVFSURI *uri, VFolderURI *vuri);
50
51 #define VFOLDER_URI_PARSE(_uri, _vuri) {                                    \
52         gchar *path;                                                        \
53         path = gnome_vfs_unescape_string ((_uri)->text, G_DIR_SEPARATOR_S); \
54         if (path != NULL) {                                                 \
55                 (_vuri)->path = g_alloca (strlen (path) + 1);               \
56                 strcpy ((_vuri)->path, path);                               \
57                 g_free (path);                                              \
58         } else {                                                            \
59                 (_vuri)->path = NULL;                                       \
60         }                                                                   \
61         vfolder_uri_parse_internal ((_uri), (_vuri));                       \
62         D (g_print ( "%s(): %s\n", G_GNUC_FUNCTION, (_vuri)->path));        \
63 }
64
65
66 typedef struct {
67         GnomeVFSMonitorType     type;
68
69         GnomeVFSMonitorHandle  *vfs_handle;
70
71         time_t                  ctime;
72         gchar                  *uri;
73
74         gboolean                frozen;
75
76         GnomeVFSMonitorCallback callback;
77         gpointer                user_data;
78 } VFolderMonitor;
79
80
81 VFolderMonitor *vfolder_monitor_dir_new  (const gchar             *uri,
82                                           GnomeVFSMonitorCallback  callback,
83                                           gpointer                 user_data);
84 VFolderMonitor *vfolder_monitor_file_new (const gchar             *uri,
85                                           GnomeVFSMonitorCallback  callback,
86                                           gpointer                 user_data);
87 void            vfolder_monitor_emit     (const gchar             *uri,
88                                           GnomeVFSMonitorEventType event_type);
89 void            vfolder_monitor_freeze   (VFolderMonitor          *monitor);
90 void            vfolder_monitor_thaw     (VFolderMonitor          *monitor);
91 void            vfolder_monitor_cancel   (VFolderMonitor          *monitor);
92
93
94 GnomeVFSResult vfolder_make_directory_and_parents (const gchar *uri, 
95                                                    gboolean     skip_filename,
96                                                    guint        permissions);
97
98
99 gchar   *vfolder_timestamp_file_name   (const gchar *file);
100 gchar   *vfolder_untimestamp_file_name (const gchar *file);
101 gboolean vfolder_check_extension       (const char  *name, 
102                                         const char  *ext_check);
103 gchar   *vfolder_escape_home           (const gchar *file);
104
105 gchar   *vfolder_build_uri             (const char *first_element,
106                                         ...);
107
108
109 G_END_DECLS
110
111 #endif /* VFOLDER_UTIL_H */