/*
 * @author: ucla-cs
 * This is the ccnx protocol handler.
 * Protocol handling code derived from http://mike.kaply.com/2011/01/18/writing-a-firefox-protocol-handler/
 */

const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;

const nsIProtocolHandler = Ci.nsIProtocolHandler;

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("chrome://modules/content/ndn-js.jsm");
Components.utils.import("chrome://modules/content/ContentChannel.jsm");

function CcnxProtocol() {
}

CcnxProtocol.prototype = {
	scheme: "ccnx",
	protocolFlags: nsIProtocolHandler.URI_NORELATIVE |
                   nsIProtocolHandler.URI_NOAUTH |
                   nsIProtocolHandler.URI_LOADABLE_BY_ANYONE,

	newURI: function(aSpec, aOriginCharset, aBaseURI)
	{
		var uri = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI);
		uri.spec = aSpec;
		return uri;
	},

	newChannel: function(aURI)
	{
		try {
			var requestContent = function(contentListener) {
				var interest = aURI.spec.split(":")[1];
			    // 131.179.141.18 is lioncub.metwi.ucla.edu .
				var ndn = new NDN('131.179.141.18');
				
				var coListener = {
					onReceivedContentObject : function(contentObject) {
						// Set up defaults.
						var content = "";
						var contentType = "text/html";
						var contentCharset = "utf-8";

						// TODO: Need to check the signature, confirm that the name matches, etc.
						if (contentObject.content != null) {
							content = DataUtils.toString(contentObject.content);

							// TODO: Should look at the returned Name to get contentType. For now,
							//   just look for a file extension in the original interest.
							var interestLowerCase = interest.toLowerCase();
							if (interestLowerCase.indexOf(".gif") >= 0) {
								contentType = "image/gif";
								contentCharset = "ISO-8859-1";
							}
							else if (interestLowerCase.indexOf(".jpg") >= 0 ||
									 interestLowerCase.indexOf(".jpeg") >= 0) {
								contentType = "image/jpeg";
								contentCharset = "ISO-8859-1";
							}
							else if (interestLowerCase.indexOf(".png") >= 0) {
								contentType = "image/png";
								contentCharset = "ISO-8859-1";
							}
							else if (interestLowerCase.indexOf(".bmp") >= 0) {
								contentType = "image/bmp";
								contentCharset = "ISO-8859-1";
							}
							else if (interestLowerCase.indexOf(".css") >= 0)
								contentType = "text/css";
						}
						
						contentListener.onReceivedContent(content, contentType, contentCharset);
					}
				};
			
				ndn.getAsync(interest, coListener);
			};

			return new ContentChannel(aURI, requestContent);
		} catch (ex) {
			dump("CcnxProtocol.newChannel exception: " + ex + "\n");
		}
	},

	classDescription: "ccnx Protocol Handler",
	contractID: "@mozilla.org/network/protocol;1?name=" + "ccnx",
	classID: Components.ID('{8122e660-1012-11e2-892e-0800200c9a66}'),
	QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler])
}

if (XPCOMUtils.generateNSGetFactory)
	var NSGetFactory = XPCOMUtils.generateNSGetFactory([CcnxProtocol]);
else
	var NSGetModule = XPCOMUtils.generateNSGetModule([CcnxProtocol]);
 

