diff options
author | James Lal <james@lightsofapollo.com> | 2012-07-07 09:00:49 -0700 |
---|---|---|
committer | James Lal <james@lightsofapollo.com> | 2012-07-07 09:00:49 -0700 |
commit | a3f59b6298d87c3a72c167142546a816b3f2e73d (patch) | |
tree | c7b1d138a2c766ca6fc50093a75e74743c16a2b8 | |
parent | 0541668eaa804770d51e85037c21887c045642c7 (diff) | |
download | jsCalDAV-a3f59b6298d87c3a72c167142546a816b3f2e73d.tar.gz |
More complete parsing of calendar data
-rw-r--r-- | lib/caldav/resources/calendar.js | 13 | ||||
-rw-r--r-- | lib/caldav/sax/dav_response.js | 45 | ||||
-rwxr-xr-x | scripts/connect | 5 | ||||
-rw-r--r-- | test/caldav/sax/dav_response_test.js | 1 |
4 files changed, 57 insertions, 7 deletions
diff --git a/lib/caldav/resources/calendar.js b/lib/caldav/resources/calendar.js index a5a47c7..fd921cb 100644 --- a/lib/caldav/resources/calendar.js +++ b/lib/caldav/resources/calendar.js @@ -6,10 +6,15 @@ /** * Represents a (Web/Cal)Dav resource type. * + * @param {Caldav.Connection} connection connection details. * @param {Object} options public options on prototype. */ - function Calendar(options) { + function Calendar(connection, options) { + if (typeof(options) === 'undefined') { + options = {}; + } + this.updateFromServer(options); } Calendar.prototype = { @@ -60,6 +65,12 @@ privilegeSet: null, /** + * Updates calendar details from server. + */ + updateFromServer: function() { + }, + + /** * Creates a query request for this calendar resource. * * @return {CalDav.Request.CalendarQuery} query object. diff --git a/lib/caldav/sax/dav_response.js b/lib/caldav/sax/dav_response.js index 0d9fb7c..dddd40b 100644 --- a/lib/caldav/sax/dav_response.js +++ b/lib/caldav/sax/dav_response.js @@ -43,11 +43,6 @@ var HrefHandler = Base.create({ name: 'href', - //don't add text only elements - //to the stack as objects - onopentag: null, - onclosetag: null, - onopentag: function() { if (this.currentTag.handler === this.handler) { this.stack.push(this.current); @@ -90,6 +85,38 @@ } }); + var PrivilegeSet = Base.create({ + name: 'PrivilegeSet', + + name: 'href', + + onopentag: function(data) { + if (this.currentTag.handler === this.handler) { + this.stack.push(this.current); + this.current = []; + } else { + if (data.tagSpec !== 'DAV:/privilege') { + this.current.push(data.local); + } + } + }, + + onclosetag: function(data) { + var current = this.currentTag; + var data; + + if (current.handler === this.handler) { + data = this.current; + + this.current = this.stack.pop(); + this.current[current.local] = data; + } + }, + + ontext: null + + }); + var ArrayHandler = Base.create({ name: 'array', @@ -124,14 +151,20 @@ handles: { 'DAV:/href': TextHandler, + 'http://calendarserver.org/ns//getctag': TextHandler, 'DAV:/status': HttpStatusHandler, 'DAV:/resourcetype': ArrayHandler, + 'DAV:/current-user-privilege-set': PrivilegeSet, 'DAV:/principal-URL': HrefHandler, 'DAV:/current-user-principal': HrefHandler, 'urn:ietf:params:xml:ns:caldav/calendar-data': CalendarDataHandler, 'DAV:/value': TextHandler, + 'DAV:/owner': HrefHandler, + 'DAV:/displayname': TextHandler, 'urn:ietf:params:xml:ns:caldav/calendar-home-set': HrefHandler, - 'urn:ietf:params:xml:ns:caldav/calendar-user-address-set': HrefHandler + 'urn:ietf:params:xml:ns:caldav/calendar-timezone': TextHandler, + 'http://apple.com/ns/ical//calendar-color': TextHandler, + 'urn:ietf:params:xml:ns:caldav/calendar-description': TextHandler }, onopentag: function(data, handler) { diff --git a/scripts/connect b/scripts/connect index 2807937..050df1b 100755 --- a/scripts/connect +++ b/scripts/connect @@ -41,6 +41,9 @@ function getCalendarDetails(caluri) { var calFind = findProp(caluri); calFind.prop(['ical', 'calendar-color']); calFind.prop('owner'); + calFind.prop('current-user-privilege-set'); + calFind.prop(['caldav', 'calendar-description']); + calFind.prop(['caldav', 'calendar-timezone']); calFind.prop('displayname'); calFind.prop('resourcetype'); calFind.prop(['calserver', 'getctag']); @@ -59,6 +62,8 @@ function getCalendarDetails(caluri) { } console.log('DATA:'); console.log(JSON.stringify(data)); + //console.log('RAW:'); + //console.log(calFind.xhr.xhr.responseText); }); } diff --git a/test/caldav/sax/dav_response_test.js b/test/caldav/sax/dav_response_test.js index f9243e8..45bc788 100644 --- a/test/caldav/sax/dav_response_test.js +++ b/test/caldav/sax/dav_response_test.js @@ -1,3 +1,4 @@ +testSupport.lib('responder'); testSupport.lib('sax'); testSupport.lib('sax/base'); testSupport.lib('sax/dav_response'); |