1 /* NSObject+DAV.h - this file is part of SOGo
2  *
3  * Copyright (C) 2008-2013 Inverse inc.
4  *
5  * This file is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This file 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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; see the file COPYING.  If not, write to
17  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef NSOBJECT_DAV_H
22 #define NSOBJECT_DAV_H
23 
24 #import <Foundation/NSObject.h>
25 #import <Foundation/NSDictionary.h>
26 
27 @class NSMutableDictionary;
28 @class NSString;
29 
30 @class SoSelectorInvocation;
31 
32 @class SOGoWebDAVValue;
33 
34 typedef enum _HTTPStatusCode {
35   HTTPStatus200 = 0,
36   HTTPStatus201,
37   HTTPStatus404,
38 } HTTPStatusCode;
39 
40 #define davElement(t,n) \
41   [NSDictionary dictionaryWithObjectsAndKeys: t, @"method", n, @"ns", nil]
42 
43 #define davElementWithContent(t,n,c) \
44   [NSDictionary dictionaryWithObjectsAndKeys: t, @"method", \
45 		n, @"ns",				    \
46 		c, @"content", nil]
47 
48 #define davElementWithAttributesAndContent(t,a,n,c)                      \
49   [NSDictionary dictionaryWithObjectsAndKeys: t, @"method", \
50 		a, @"attributes",			    \
51 		n, @"ns",				    \
52 		c, @"content", nil]
53 
54 SEL SOGoSelectorForPropertyGetter (NSString *property);
55 SEL SOGoSelectorForPropertySetter (NSString *property);
56 
57 @interface NSObject (SOGoWebDAVExtensions)
58 
59 - (NSString *)
60  asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces;
61 - (SOGoWebDAVValue *) asWebDAVValue;
62 
63 - (SOGoWebDAVValue *) davSupportedReportSet;
64 
65 - (SEL) davPropertySelectorForKey: (NSString *) key;
66 - (NSString *) davReportSelectorForKey: (NSString *) key;
67 - (SoSelectorInvocation *) davReportInvocationForKey: (NSString *) key;
68 
69 /* response helpers */
70 - (NSDictionary *) responseForURL: (NSString *) url
71                 withProperties200: (NSArray *) properties200
72                  andProperties404: (NSArray *) properties404;
73 
74 @end
75 
76 #endif /* NSOBJECT_DAV_H */
77