1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 #ifndef SHARE_MGR_H
4 #define SHARE_MGR_H
5 
6 #include <glib.h>
7 
8 struct _SeafileSession;
9 
10 typedef struct _SeafShareManager SeafShareManager;
11 typedef struct _SeafShareManagerPriv SeafShareManagerPriv;
12 typedef struct _ShareRepoInfo ShareRepoInfo;
13 
14 struct _SeafShareManager {
15     struct _SeafileSession *seaf;
16 
17 };
18 
19 SeafShareManager*
20 seaf_share_manager_new (struct _SeafileSession *seaf);
21 
22 int
23 seaf_share_manager_start (SeafShareManager *mgr);
24 
25 int
26 seaf_share_manager_add_share (SeafShareManager *mgr, const char *repo_id,
27                               const char *from_email, const char *to_email,
28                               const char *permission);
29 
30 int
31 seaf_share_manager_set_subdir_perm_by_path (SeafShareManager *mgr, const char *repo_id,
32                                             const char *from_email, const char *to_email,
33                                             const char *permission, const char *path);
34 
35 int
36 seaf_share_manager_set_permission (SeafShareManager *mgr, const char *repo_id,
37                                    const char *from_email, const char *to_email,
38                                    const char *permission);
39 
40 GList*
41 seaf_share_manager_list_share_repos (SeafShareManager *mgr, const char *email,
42                                      const char *type, int start, int limit,
43                                      gboolean *db_err);
44 
45 GList *
46 seaf_share_manager_list_shared_to (SeafShareManager *mgr,
47                                    const char *owner,
48                                    const char *repo_id);
49 
50 GList *
51 seaf_share_manager_list_repo_shared_to (SeafShareManager *mgr,
52                                         const char *owner,
53                                         const char *repo_id,
54                                         GError **error);
55 
56 GList *
57 seaf_share_manager_list_repo_shared_group (SeafShareManager *mgr,
58                                            const char *from_email,
59                                            const char *repo_id,
60                                            GError **error);
61 
62 GHashTable *
63 seaf_share_manager_get_shared_dirs_to_user (SeafShareManager *mgr,
64                                             const char *orig_repo_id,
65                                             const char *to_email);
66 
67 GHashTable *
68 seaf_share_manager_get_shared_dirs_to_group (SeafShareManager *mgr,
69                                              const char *orig_repo_id,
70                                              GList *groups);
71 
72 int
73 seaf_share_manager_remove_share (SeafShareManager *mgr, const char *repo_id,
74                                  const char *from_email, const char *to_email);
75 
76 int
77 seaf_share_manager_unshare_subdir (SeafShareManager* mgr,
78                                    const char *orig_repo_id,
79                                    const char *path,
80                                    const char *from_email,
81                                    const char *to_email);
82 
83 
84 /* Remove all share info of a repo. */
85 int
86 seaf_share_manager_remove_repo (SeafShareManager *mgr, const char *repo_id);
87 
88 char *
89 seaf_share_manager_check_permission (SeafShareManager *mgr,
90                                      const char *repo_id,
91                                      const char *email);
92 
93 GHashTable *
94 seaf_share_manager_get_shared_sub_dirs (SeafShareManager *mgr,
95                                         const char *repo_id,
96                                         const char *path);
97 
98 int
99 seaf_share_manager_is_repo_shared (SeafShareManager *mgr,
100                                    const char *repo_id);
101 
102 GObject *
103 seaf_get_shared_repo_by_path (SeafRepoManager *mgr,
104                               const char *repo_id,
105                               const char *path,
106                               const char *shared_to,
107                               int is_org,
108                               GError **error);
109 int
110 seaf_share_manager_unshare_group_subdir (SeafShareManager* mgr,
111                                          const char *repo_id,
112                                          const char *path,
113                                          const char *owner,
114                                          int group_id);
115 
116 gboolean
117 seaf_share_manager_repo_has_been_shared (SeafShareManager* mgr,
118                                          const char *repo_id,
119                                          gboolean including_groups);
120 
121 GList *
122 seaf_share_manager_org_get_shared_users_by_repo (SeafShareManager* mgr,
123                                                  int org_id,
124                                                  const char *repo_id);
125 
126 GList *
127 seaf_share_manager_get_shared_users_by_repo (SeafShareManager* mgr,
128                                              const char *repo_id);
129 #endif /* SHARE_MGR_H */
130 
131