Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / servers / exchange / storage / e-storage.h
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* e-storage.h
3  *
4  * Copyright (C) 2000  Ximian, Inc.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU Lesser General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program 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  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  * Author: Ettore Perazzoli
21  */
22
23 #ifndef _E_STORAGE_H_
24 #define _E_STORAGE_H_
25
26 #include <glib-object.h>
27 #include "e-folder.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #pragma }
32 #endif /* __cplusplus */
33
34 #define E_TYPE_STORAGE                  (e_storage_get_type ())
35 #define E_STORAGE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_STORAGE, EStorage))
36 #define E_STORAGE_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_STORAGE, EStorageClass))
37 #define E_IS_STORAGE(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_STORAGE))
38 #define E_IS_STORAGE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_STORAGE))
39 #define E_STORAGE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_STORAGE, EStorageClass))
40
41 typedef struct EStorage        EStorage;
42 typedef struct EStoragePrivate EStoragePrivate;
43 typedef struct EStorageClass   EStorageClass;
44
45 typedef enum {
46         E_STORAGE_OK,
47         E_STORAGE_GENERICERROR,
48         E_STORAGE_EXISTS,
49         E_STORAGE_INVALIDTYPE,
50         E_STORAGE_IOERROR,
51         E_STORAGE_NOSPACE,
52         E_STORAGE_NOTEMPTY,
53         E_STORAGE_NOTFOUND,
54         E_STORAGE_NOTIMPLEMENTED,
55         E_STORAGE_PERMISSIONDENIED,
56         E_STORAGE_UNSUPPORTEDOPERATION,
57         E_STORAGE_UNSUPPORTEDTYPE,
58         E_STORAGE_CANTCHANGESTOCKFOLDER,
59         E_STORAGE_CANTMOVETODESCENDANT,
60         E_STORAGE_NOTONLINE,
61         E_STORAGE_INVALIDNAME
62 } EStorageResult;
63
64 typedef void (* EStorageResultCallback) (EStorage *storage, EStorageResult result, void *data);
65 typedef void (* EStorageDiscoveryCallback) (EStorage *storage, EStorageResult result, const char *path, void *data);
66
67 struct EStorage {
68         GObject parent;
69
70         EStoragePrivate *priv;
71 };
72
73 struct EStorageClass {
74         GObjectClass parent_class;
75
76         /* Signals.  */
77
78         void (* new_folder)     (EStorage *storage, const char *path);
79         void (* updated_folder) (EStorage *storage, const char *path);
80         void (* removed_folder) (EStorage *storage, const char *path);
81
82         /* Virtual methods.  */
83
84         GList      * (* get_subfolder_paths)     (EStorage *storage,
85                                                   const char *path);
86         EFolder    * (* get_folder)              (EStorage *storage,
87                                                   const char *path);
88         const char * (* get_name)                (EStorage *storage);
89
90         void         (* async_create_folder)  (EStorage *storage,
91                                                const char *path,
92                                                const char *type,
93                                                EStorageResultCallback callback,
94                                                void *data);
95
96         void         (* async_remove_folder)  (EStorage *storage,
97                                                const char *path,
98                                                EStorageResultCallback callback,
99                                                void *data);
100
101         void         (* async_xfer_folder)    (EStorage *storage,
102                                                const char *source_path,
103                                                const char *destination_path,
104                                                const gboolean remove_source,
105                                                EStorageResultCallback callback,
106                                                void *data);
107
108         void         (* async_open_folder)    (EStorage *storage,
109                                                const char *path,
110                                                EStorageDiscoveryCallback callback,
111                                                void *data);
112
113         gboolean     (* will_accept_folder)   (EStorage *storage,
114                                                EFolder *new_parent,
115                                                EFolder *source);
116
117         void         (* async_discover_shared_folder)  (EStorage *storage,
118                                                         const char *owner,
119                                                         const char *folder_name,
120                                                         EStorageDiscoveryCallback callback,
121                                                         void *data);
122         void         (* cancel_discover_shared_folder) (EStorage *storage,
123                                                         const char *owner,
124                                                         const char *folder_name);
125         void         (* async_remove_shared_folder)    (EStorage *storage,
126                                                         const char *path,
127                                                         EStorageResultCallback callback,
128                                                         void *data);
129 };
130
131 GType       e_storage_get_type                (void);
132 void        e_storage_construct               (EStorage   *storage,
133                                                const char *name,
134                                                EFolder    *root_folder);
135 EStorage   *e_storage_new                     (const char *name,
136                                                EFolder    *root_folder);
137
138 gboolean    e_storage_path_is_relative        (const char *path);
139 gboolean    e_storage_path_is_absolute        (const char *path);
140
141 GList      *e_storage_get_subfolder_paths     (EStorage   *storage,
142                                                const char *path);
143 EFolder    *e_storage_get_folder              (EStorage   *storage,
144                                                const char *path);
145
146 const char *e_storage_get_name                (EStorage *storage);
147
148 /* Folder operations.  */
149
150 void  e_storage_async_create_folder  (EStorage               *storage,
151                                       const char             *path,
152                                       const char             *type,
153                                       EStorageResultCallback  callback,
154                                       void                   *data);
155 void  e_storage_async_remove_folder  (EStorage               *storage,
156                                       const char             *path,
157                                       EStorageResultCallback  callback,
158                                       void                   *data);
159 void  e_storage_async_xfer_folder    (EStorage               *storage,
160                                       const char             *source_path,
161                                       const char             *destination_path,
162                                       const gboolean          remove_source,
163                                       EStorageResultCallback  callback,
164                                       void                   *data);
165 void  e_storage_async_open_folder    (EStorage                  *storage,
166                                       const char                *path,
167                                       EStorageDiscoveryCallback  callback,
168                                       void                      *data);
169
170 const char *e_storage_result_to_string   (EStorageResult  result);
171
172 gboolean    e_storage_will_accept_folder (EStorage       *storage,
173                                           EFolder        *new_parent,
174                                           EFolder        *source);
175
176 /* Shared folders.  */
177 void        e_storage_async_discover_shared_folder  (EStorage                 *storage,
178                                                      const char               *owner,
179                                                      const char               *folder_name,
180                                                      EStorageDiscoveryCallback callback,
181                                                      void                     *data);
182 void        e_storage_cancel_discover_shared_folder (EStorage                 *storage,
183                                                      const char               *owner,
184                                                      const char               *folder_name);
185 void        e_storage_async_remove_shared_folder    (EStorage                 *storage,
186                                                      const char               *path,
187                                                      EStorageResultCallback    callback,
188                                                      void                     *data);
189
190 /* Utility functions.  */
191
192 char *e_storage_get_path_for_physical_uri  (EStorage   *storage,
193                                             const char *physical_uri);
194
195 /* FIXME: Need to rename these.  */
196
197 gboolean e_storage_new_folder             (EStorage   *storage,
198                                            const char *path,
199                                            EFolder    *folder);
200 gboolean e_storage_removed_folder         (EStorage   *storage,
201                                            const char *path);
202
203 gboolean e_storage_declare_has_subfolders (EStorage   *storage,
204                                            const char *path,
205                                            const char *message);
206 gboolean e_storage_get_has_subfolders     (EStorage   *storage,
207                                            const char *path);
208
209 #ifdef __cplusplus
210 }
211 #endif /* __cplusplus */
212
213 #endif /* _E_STORAGE_H_ */