aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJames Lal <james@lightsofapollo.com>2012-07-06 16:48:14 -0700
committerJames Lal <james@lightsofapollo.com>2012-07-06 16:48:14 -0700
commit1edfd60cccfdda4a21acbdef834f7b9db260af88 (patch)
treef0b9a1bd3516bf49be257ed77ffad7ab6c92a1f1 /scripts
parent8997061718d9990960dfea0ba58e88138f3b5a88 (diff)
downloadjsCalDAV-1edfd60cccfdda4a21acbdef834f7b9db260af88.tar.gz
Adding lightly tested calendar home resolver
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/connect76
1 files changed, 34 insertions, 42 deletions
diff --git a/scripts/connect b/scripts/connect
index 149d54a..84f25a7 100755
--- a/scripts/connect
+++ b/scripts/connect
@@ -34,6 +34,34 @@ var con = new CalDav.Connection({
});
var Propfind = CalDav.Request.Propfind;
+var CalendarHome = CalDav.Request.CalendarHome;
+
+function getCalendarDetails(caluri) {
+
+ var calFind = findProp(caluri);
+ calFind.prop(['ical', 'calendar-color']);
+ calFind.prop('owner');
+ calFind.prop('displayname');
+ calFind.prop('resourcetype');
+ calFind.prop(['calserver', 'getctag']);
+ calFind.depth = 1;
+
+
+ // found calendar home find calendars.
+ calFind.send(function(err, data) {
+ var url, name;
+
+ for (url in data) {
+ if (data[url].resourcetype.value.indexOf('calendar') !== -1) {
+ name = data[url].displayname.value.value;
+ console.log('CAL RESOURCE:', name, '-', url);
+ }
+ }
+ console.log('DATA:');
+ console.log(JSON.stringify(data));
+ });
+
+}
function findProp(uri) {
return new Propfind(con, {
@@ -41,12 +69,6 @@ function findProp(uri) {
});
}
-// Have some url determine where the principal is
-var findCal = findProp();
-findCal.prop('current-user-principal');
-findCal.prop('resourcetype');
-findCal.prop('principal-URL');
-
function getProp(propName, obj, single) {
var key, url, level, results = {};
@@ -65,41 +87,11 @@ function getProp(propName, obj, single) {
return results;
}
-findCal.send(function(err, data) {
-
- // found principal find calendar home
- var principaluri = getProp('current-user-principal', data, true);
- console.log('PRINCIPAL:', principaluri);
- var principalFind = findProp(principaluri);
-
- principalFind.prop('resourcetype');
- principalFind.prop(['caldav', 'calendar-home-set']);
-
- principalFind.send(function(err, data) {
- var caluri = getProp('calendar-home-set', data, true);
- var calFind = findProp(caluri);
- console.log('CALENDAR_HOME:', caluri);
- calFind.prop(['ical', 'calendar-color']);
- calFind.prop('owner');
- calFind.prop('displayname');
- calFind.prop('resourcetype');
- calFind.prop(['calserver', 'getctag']);
- calFind.depth = 1;
-
-
- // found calendar home find calendars.
- calFind.send(function(err, data) {
- var url, name;
-
- for (url in data) {
- if (data[url].resourcetype.value.indexOf('calendar') !== -1) {
- name = data[url].displayname.value.value;
- console.log('CAL RESOURCE:', name, '-', url);
- }
- }
- console.log('DATA:');
- console.log(JSON.stringify(data));
- });
- });
+var home = new CalendarHome(con, {
+ url: config.uri
+});
+home.send(function(err, data) {
+ console.log('CALENDAR_HOME:', data);
+ getCalendarDetails(data);
});