# HG changeset patch # User Paul Boddie # Date 1411861932 -7200 # Node ID 13a18bb26c90a92af1f8e8933d7fd9fe70941a08 # Parent dc2dbe0697209edc72f1e7f9973bec05646463a3 Added URL extraction, resource retrieval and parsing. diff -r dc2dbe069720 -r 13a18bb26c90 modules/fburl.js --- a/modules/fburl.js Sun Sep 28 00:12:15 2014 +0200 +++ b/modules/fburl.js Sun Sep 28 01:52:12 2014 +0200 @@ -22,6 +22,9 @@ this._result = null; this._searched = false; this._error = null; + this._listener = null; + this._url = null; + this._fb = null; }; fburl.fbUrlProvider.prototype = { @@ -90,6 +93,7 @@ if (this._context) { this._query.stopQuery(this._context); this._context = null; + this._listener = null; } }, @@ -100,10 +104,22 @@ onSearchFoundCard: function (aCard) { - // NOTE: Will eventually use this to retrieve the free/busy document, - // NOTE: extract the intervals, and then notify the listener. + this._result = aCard; + + // Obtain the URL from the card. + + this._url = aCard.getProperty("FBURL", ""); + + // Retrieve the resource and parse it. - this._result = aCard; + var parser = Cc["@mozilla.org/calendar/ics-service;1"].getService(Ci.calIICSService); + //var parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser); + var service = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); + var stream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream); + var channel = service.newChannelFromURI(service.newURI(this._url, null, null)); + + stream.init(channel.open()); + this._fb = parser.parseICS(stream.read(-1), null).getFirstSubcomponent("VFREEBUSY"); }, QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsIAbDirSearchListener])