1 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
2 /*
3  * libbalsa vfs glue layer library
4  * Copyright (C) 2008 Albrecht Dre� <albrecht.dress@arcor.de>
5  *
6  * This program 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; either version 2, or (at your option)
9  * any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19  * 02111-1307, USA.
20  */
21 
22 #ifndef __LIBBALSA_VFS_H__
23 #define __LIBBALSA_VFS_H__
24 
25 
26 #include <glib.h>
27 #include <glib-object.h>
28 #include <gmime/gmime.h>
29 #include <gtk/gtk.h>
30 #include "libbalsa.h"
31 #include "misc.h"
32 
33 
34 G_BEGIN_DECLS
35 
36 
37 /* a vfs file description as GObject */
38 #define LIBBALSA_TYPE_VFS            (libbalsa_vfs_get_type())
39 #define LIBBALSA_VFS(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), LIBBALSA_TYPE_VFS, LibbalsaVfs))
40 #define LIBBALSA_VFS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), LIBBALSA_TYPE_VFS, LibbalsaVfsClass))
41 #define LIBBALSA_IS_VFS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), LIBBALSA_TYPE_VFS))
42 #define LIBBALSA_IS_VFS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), LIBBALSA_TYPE_VFS))
43 #define LIBBALSA_VFS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), LIBBALSA_TYPE_VFS, LibbalsaVfsClass))
44 
45 typedef struct _LibbalsaVfsClass LibbalsaVfsClass;
46 
47 
48 struct _LibbalsaVfs {
49     GObject parent;
50 
51     struct _LibbalsaVfsPriv * priv;
52 };
53 
54 struct _LibbalsaVfsClass {
55     GObjectClass parent;
56 };
57 
58 gboolean libbalsa_vfs_local_only(void);
59 
60 GType libbalsa_vfs_get_type(void);
61 LibbalsaVfs * libbalsa_vfs_new(void);
62 LibbalsaVfs * libbalsa_vfs_new_from_uri(const gchar * uri);
63 LibbalsaVfs * libbalsa_vfs_append(const LibbalsaVfs * file,
64                                   const gchar * text);
65 LibbalsaVfs * libbalsa_vfs_dir_append(const LibbalsaVfs * dir,
66                                       const gchar * filename);
67 const gchar * libbalsa_vfs_get_folder(const LibbalsaVfs * file);
68 const gchar * libbalsa_vfs_get_uri(const LibbalsaVfs * file);
69 const gchar * libbalsa_vfs_get_uri_utf8(const LibbalsaVfs * file);
70 const gchar * libbalsa_vfs_get_basename_utf8(const LibbalsaVfs * file);
71 const gchar * libbalsa_vfs_get_mime_type(const LibbalsaVfs * file);
72 const gchar * libbalsa_vfs_get_charset(const LibbalsaVfs * file);
73 LibBalsaTextAttribute libbalsa_vfs_get_text_attr(const LibbalsaVfs * file);
74 guint64 libbalsa_vfs_get_size(const LibbalsaVfs * file);
75 GMimeStream * libbalsa_vfs_create_stream(const LibbalsaVfs * file,
76                                          mode_t mode,
77                                          gboolean rdwr,
78                                          GError ** err);
79 gboolean libbalsa_vfs_file_exists(const LibbalsaVfs * file);
80 gboolean libbalsa_vfs_is_regular_file(const LibbalsaVfs * file,
81                                       GError **err);
82 gint libbalsa_vfs_file_unlink(const LibbalsaVfs * file,
83                               GError **err);
84 
85 /* application launch helpers */
86 gboolean libbalsa_vfs_launch_app(const LibbalsaVfs * file,
87                                  GObject * object,
88                                  GError **err);
89 gboolean libbalsa_vfs_launch_app_for_body(LibBalsaMessageBody * mime_body,
90                                           GObject * object,
91                                           GError **err);
92 void libbalsa_vfs_fill_menu_by_content_type(GtkMenu * menu,
93                                             const gchar * content_type,
94                                             GCallback callback,
95                                             gpointer data);
96 GtkWidget * libbalsa_vfs_mime_button(LibBalsaMessageBody * mime_body,
97                                      const gchar * content_type,
98                                      GCallback callback,
99                                      gpointer data);
100 
101 /* content type helpers */
102 gchar * libbalsa_vfs_content_description(const gchar * mime_type);
103 gchar * libbalsa_vfs_content_type_of_buffer(const guchar * buffer,
104                                             gsize length);
105 
106 G_END_DECLS
107 
108 
109 #endif				/* __LIBBALSA_VFS_H__ */
110