1 module carddav;
2 /+
3 struct AddressDataType
4 {
5     string contentType;
6     string version_;
7 }
8 
9 struct AddressBook struct
10 {
11     string path;
12     string name;
13     string description;
14     long maxResourceSize;
15     AddressDataType[] supportedAddressData;
16 }
17 
18 func (ab *AddressBook) SupportsAddressData(contentType, version string) bool {
19     if len(ab.SupportedAddressData) == 0 {
20         return contentType == "text/vcard" && version == "3.0"
21     }
22     for _, t := range ab.SupportedAddressData {
23         if t.ContentType == contentType && t.Version == version {
24             return true
25         }
26     }
27     return false
28 }
29 
30 struct AddressBookQuery
31 {
32     AddressDataRequest dataRequest;
33 
34     PropFilter[] propFilters;
35     FilterTst filterTest; // defaults to FilterAnyOf
36     int limit; // <= 0 means unlimited
37 }
38 
39 struct AddressDataRequest
40 {
41     string[] props;
42     bool allProp;
43 }
44 
45 type PropFilter struct {
46     Name string
47     Test FilterTest // defaults to FilterAnyOf
48 
49     // if IsNotDefined is set, TextMatches and Params need to be unset
50     IsNotDefined bool
51     TextMatches  []TextMatch
52     Params       []ParamFilter
53 }
54 
55 type ParamFilter struct {
56     Name string
57 
58     // if IsNotDefined is set, TextMatch needs to be unset
59     IsNotDefined bool
60     TextMatch    *TextMatch
61 }
62 
63 type TextMatch struct {
64     Text            string
65     NegateCondition bool
66     MatchType       MatchType // defaults to MatchContains
67 }
68 
69 type FilterTest string
70 
71 const (
72     FilterAnyOf FilterTest = "anyof"
73     FilterAllOf FilterTest = "allof"
74 )
75 
76 type MatchType string
77 
78 const (
79     MatchEquals     MatchType = "equals"
80     MatchContains   MatchType = "contains"
81     MatchStartsWith MatchType = "starts-with"
82     MatchEndsWith   MatchType = "ends-with"
83 )
84 
85 type AddressBookMultiGet struct {
86     Paths       []string
87     DataRequest AddressDataRequest
88 }
89 
90 type AddressObject struct {
91     Path    string
92     ModTime time.Time
93     ETag    string
94     Card    vcard.Card
95 }
96 
97 //SyncQuery is the query struct represents a sync-collection request
98 type SyncQuery struct {
99     DataRequest AddressDataRequest
100     SyncToken   string
101     Limit       int // <= 0 means unlimited
102 }
103 
104 //SyncResponse contains the returned sync-token for next time
105 type SyncResponse struct {
106     SyncToken string
107     Updated   []AddressObject
108     Deleted   []string
109 }
110 +/