1 /*
2   Copyright (C) 2004-2005 SKYRIX Software AG
3   Copyright (C) 2006-2015 Inverse inc.
4 
5   This file is part of SOGo.
6 
7   SOGo is free software; you can redistribute it and/or modify it under
8   the terms of the GNU Lesser General Public License as published by the
9   Free Software Foundation; either version 2, or (at your option) any
10   later version.
11 
12   SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
13   WARRANTY; without even the implied warranty of MERCHANTABILITY or
14   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15   License for more details.
16 
17   You should have received a copy of the GNU Lesser General Public
18   License along with OGo; see the file COPYING.  If not, write to the
19   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20   02111-1307, USA.
21 */
22 
23 #ifndef __SOGo_SOGoGCSFolder_H__
24 #define __SOGo_SOGoGCSFolder_H__
25 
26 #import "SOGoFolder.h"
27 
28 @class NSArray;
29 @class NSDictionary;
30 @class NSMutableDictionary;
31 @class NSString;
32 
33 @class GCSFolder;
34 @class WOContext;
35 @class WOResponse;
36 
37 @class SOGoUser;
38 
39 @protocol DOMElement;
40 
41 /*
42   SOGoGCSFolder
43 
44   A common superclass for folders stored in GCS. Already deals with all GCS
45   folder specific things.
46 
47   Important: folders should NOT retain the context! Otherwise you might get
48              cyclic references.
49 */
50 
51 @interface SOGoGCSFolder : SOGoFolder
52 {
53   NSString *ocsPath;
54   GCSFolder *ocsFolder;
55   NSMutableDictionary *childRecords;
56   BOOL userCanAccessAllObjects; /* i.e. user obtains 'Access Object' on
57                                    subobjects */
58 }
59 
60 + (id) folderWithSubscriptionReference: (NSString *) reference
61 			   inContainer: (id) aContainer;
62 
63 /* accessors */
64 
65 - (void) setOCSPath: (NSString *)_Path;
66 - (NSString *) ocsPath;
67 
68 - (GCSFolder *) ocsFolderForPath: (NSString *)_path;
69 - (GCSFolder *) ocsFolder;
70 
71 - (NSString *) folderReference;
72 - (NSArray *) pathArrayToFolder;
73 
74 - (void) setFolderPropertyValue: (id) theValue
75                      inCategory: (NSString *) theKey;
76 - (id) folderPropertyValueInCategory: (NSString *) theKey;
77 - (id) folderPropertyValueInCategory: (NSString *) theKey
78 			     forUser: (SOGoUser *) theUser;
79 
80 - (BOOL) synchronize;
81 - (void) setSynchronize: (BOOL) new;
82 
83 /* lower level fetches */
84 - (void) deleteEntriesWithIds: (NSArray *) ids;
85 
86 - (Class) objectClassForComponentName: (NSString *) componentName;
87 - (Class) objectClassForContent: (NSString *) content;
88 
89 - (void) removeChildRecordWithName: (NSString *) childName;
90 
91 - (id) createChildComponentWithRecord: (NSDictionary *) record;
92 - (id) createChildComponentWithName: (NSString *) newName
93                          andContent: (NSString *) newContent;
94 
95 /* folder type */
96 
97 - (BOOL) folderIsMandatory;
98 
99 - (BOOL) create;
100 - (NSException *) delete;
101 - (void) renameTo: (NSString *) newName;
102 
103 - (void) removeFolderSettings: (NSMutableDictionary *) moduleSettings
104                 withReference: (NSString *) reference;
105 
106 - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier
107 		     reallyDo: (BOOL) reallyDo
108                      response: (WOResponse *) theResponse;
109 - (BOOL) userIsSubscriber: (NSString *) subscribingUser;
110 
111 - (void) initializeQuickTablesAclsInContext: (WOContext *) localContext;
112 
113 /* acls as a container */
114 - (NSArray *) aclUsersForObjectAtPath: (NSArray *) objectPathArray;
115 - (NSArray *) aclsForUser: (NSString *) uid
116           forObjectAtPath: (NSArray *) objectPathArray;
117 - (void) setRoles: (NSArray *) roles
118           forUser: (NSString *) uid
119   forObjectAtPath: (NSArray *) objectPathArray;
120 - (void) removeAclsForUsers: (NSArray *) users
121             forObjectAtPath: (NSArray *) objectPathArray;
122 
123 /* DAV */
124 - (NSURL *) publicDavURL;
125 - (NSURL *) realDavURL;
126 
127 - (NSDictionary *) davSQLFieldsTable;
128 - (NSDictionary *) parseDAVRequestedProperties: (id <DOMElement>) propElement;
129 
130 - (NSString *) davCollectionTag;
131 
132 - (NSArray *) syncTokenFieldsWithProperties: (NSDictionary *) properties
133                           matchingSyncToken: (NSString *) syncToken
134                                    fromDate: (NSCalendarDate *) theStartDate
135                                 initialLoad: (BOOL) initialLoadInProgress;
136 
137 /* multiget helper */
138 - (WOResponse *) performMultigetInContext: (WOContext *) queryContext
139                               inNamespace: (NSString *) namespace;
140 
141 @end
142 
143 #endif /* __SOGo_SOGoGCSFolder_H__ */
144