summaryrefslogtreecommitdiffabout
path: root/src/components/xriProtocolHandler.js
Side-by-side diff
Diffstat (limited to 'src/components/xriProtocolHandler.js') (more/less context) (ignore whitespace changes)
-rwxr-xr-xsrc/components/xriProtocolHandler.js10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/components/xriProtocolHandler.js b/src/components/xriProtocolHandler.js
index 7046cde..1105874 100755
--- a/src/components/xriProtocolHandler.js
+++ b/src/components/xriProtocolHandler.js
@@ -254,129 +254,129 @@ function renderService(srv, doc, qxri)
var uriParts = u.nodeValue.match('^(.*):(.*)$');
if (!uriParts)
continue;
if (uriParts[1] == 'data') {
uriParts = uriParts[2].match('^(.*/.*),(.*)');
if (uriParts && uriParts[1].match('^image/', 'i')) {
linkContent = "<img src=\"" + u.nodeValue + "\"/>";
}
else if (uriParts) {
linkContent = uriParts[1] + " data";
}
}
else if (uriParts[1] == 'skype') {
uriParts = uriParts[2].match('^(.*)\\?(.*)');
if (uriParts) {
if (uriParts[2] == "call") {
linkContent = "<img src=\"chrome://foxri/content/skype_call_large.png\" alt=\"Call " + uriParts[1] + "\"/>";
}
else if (uriParts[2] == "chat") {
linkContent = "<img src=\"chrome://foxri/content/skype_chat_large.png\" alt=\"Chat with " + uriParts[1] + "\"/>";
}
else if (uriParts[2] == "add") {
linkContent = "<img src=\"chrome://foxri/content/skype_add_large.png\" alt=\"Add " + uriParts[1] + " to Skype\"/>";
}
}
}
else if (uriParts[1] == 'aim') {
uriParts = uriParts[2].match('^(.*)\\?.*screenname=([^&]*)', 'i');
if (uriParts) {
linkContent = "<img src=\"chrome://foxri/content/aim_logo.gif\" alt=\"Chat with " + uriParts[2] + "\"/> Chat with " + uriParts[2];
}
}
html_uris += "<a href=\""+u.nodeValue+"\">"
+ linkContent + "</a>";
html_uris += "</div>";
}
var html = "<div class=\"service srv_" + getServiceClass(knownServiceType) + "\">\n";
html += html_types;
html += html_paths;
html += html_mediatypes;
if (html_uris) {
html += "<strong>URI(s):</strong><br/>\n";
html += html_uris;
}
html += "</div>";
return html;
}
function isKnownServiceType(type)
{
if (type.toLowerCase() in SERVICE_CLASSES) {
return true;
}
return false;
}
function getServiceClass(type)
{
- if (isKnownServiceType(type)) {
+ if (type && isKnownServiceType(type)) {
return SERVICE_CLASSES[type.toLowerCase()];
}
return type;
}
function guessServiceTypeByURI(uri)
{
if (uri == null || uri == "") {
return "unknown";
}
if (uri.match(/^https?:/i)) {
return "www";
}
else if (uri.match(/^skype:/i)) {
return "skype";
}
else if (uri.match(/^aim:/i)) {
return "aim";
}
else if (uri.match(/^xmpp:/i)) {
return "jabber";
}
else if (uri.match(/^tel:/i)) {
return "tel";
}
else if (uri.match(/^callto:/i)) {
return "callto";
}
else if (uri.match(/^telnet:/i)) {
return "telnet";
}
else if (uri.match(/^news:/i)) {
return "news";
}
else if (uri.match(/^nntp:/i)) {
return "nntp";
}
else if (uri.match(/^ftp:/i)) {
return "ftp";
}
else if (uri.match(/^mailto:/i)) {
return "email";
}
else if (uri.match(/^urn:/i)) {
return "urn";
}
else if (uri.match(/^data:/i)) {
return "data";
}
else if (uri.match(/^feed:/i)) {
return "feed";
}
return "unknown";
}
function guessServiceTypeByMime(mimeType)
{
if (mimeType.match(/^application\/(rss|atom)\+xml/i)) {
dump("feed detected!\n");
return "feed";
}
else if (mimeType.match(/^image\//i)) {
@@ -736,165 +736,163 @@ XRIChannel.prototype = {
/* public fields (nsIChannel implmentation) */
contentCharset: null,
contentLength: -1,
contentType: null,
notificationCallbacks: null,
originalURI: null,
owner: null,
securityInfo: null,
URI: null,
open: function()
{
dump("open not supporteD!!!!!!\n");
},
asyncOpen: function(listener, context)
{
dump("asyncOpen called!!!!!!\n");
this.asyncOpenListener = listener;
this.asyncOpenContext = context;
var hxri = PROXY_URI + this.qxri
+ "?_xrd_r=application/xrds%2Bxml;sep=false";
var ioService = Components.classesByID[kIOSERVICE_CID_STR].getService();
ioService = ioService.QueryInterface(nsIIOService);
var channel = ioService.newChannel(hxri, null, null);
if (this.scriptableInStream) {
dump("Hey! You can't possibly be reusing this handler?!\n");
return;
}
dump("making scriptableInStream\n");
this.scriptableInStream = Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance(Components.interfaces.nsIScriptableInputStream);
this.buf = '';
dump("notificationCallbacks = " + this.notificationCallbacks + "\n");
dump("loadFlags = " + this.loadFlags + "\n");
dump("loadGroup = " + this.loadGroup + "\n");
dump("owner = " + this.owner + "\n");
dump("securityInfo = " + this.securityInfo + "\n");
// these nsIRequest attributes must be copied to the stub
// channel that we created
channel.notificationCallbacks = this.notificationCallbacks;
channel.loadGroup = this.loadGroup;
channel.loadFlags = this.loadFlags;
this.mChannel = channel;
channel.asyncOpen(this, null);
},
-/* public fields (nsIChannel implmentation) */
+/* public fields (nsIChannel implementation) */
allowPipelining: false,
redirectionLimit: 5,
referrer: "",
requestMethod: "GET",
requestSucceeded: true,
responseStatus: 200,
responseStatusText: "OK",
getRequestHeader: function(header) {
dump("getRequestHeader(" + header + ")\n");
var httpChannel = this.mChannel.QueryInterface(nsIHttpChannel);
try {
var val = httpChannel.getRequestHeader(header);
dump("getRequestHeader(" + header + ") = " + val + "\n");
return val;
}
catch (e) {
+ dump("getRequestHeader - got exception: " + e + "\n");
throw e;
}
},
getResponseHeader: function(header) {
dump("getResponseHeader(" + header + ")\n");
var httpChannel = this.mChannel.QueryInterface(nsIHttpChannel);
try {
var val = httpChannel.getResponseHeader(header);
dump("getResponseHeader(" + header + ") = " + val + "\n");
return val;
}
catch (e) {
+ dump("getResponseHeader - got exception: " + e + "\n");
throw e;
}
-/* XXX
- if (header == "Content-Type")
- return "text/html";
-*/
return null;
},
isNoCacheResponse: function() {
dump("isNoCacheResponse()\n");
var httpChannel = this.mChannel.QueryInterface(nsIHttpChannel);
return httpChannel.isNoCacheResponse();
},
isNoStoreResponse: function() {
dump("isNoStoreResponse()\n");
var httpChannel = this.mChannel.QueryInterface(nsIHttpChannel);
return httpChannel.isNoStoreResponse();
return true;
},
setRequestHeader: function(header, value, merge) {
dump("setRequestHeader(" + header + ", " + value + ")\n");
var httpChannel = this.mChannel.QueryInterface(nsIHttpChannel);
return httpChannel.setRequestHeader(header, value, merge);
},
setResponseHeader: function(header, value, merge) {
dump("setResponseHeader(" + header + ", " + value + ")\n");
var httpChannel = this.mChannel.QueryInterface(nsIHttpChannel);
return httpChannel.setResponseHeader(header, value, merge);
},
visitRequestHeaders: function(visitor) {
dump("visitRequestHeaders()\n");
},
visitResponseHeaders: function(visitor) {
dump("visitResponseHeaders()\n");
},
QueryInterface: function(iid)
{
dump("QI.. \n");
if (iid.equals(nsIChannel))
dump("QI(nsIChannel)\n");
else if (iid.equals(nsIHttpChannel))
dump("QI(nsIHttpChannel)\n");
else if (iid.equals(Components.interfaces.nsIUploadChannel))
dump("QI(nsIUploadChannel) - not supported\n");
else if (iid.equals(Components.interfaces.nsICachingChannel))
dump("QI(nsICachingChannel) - not supported\n");
else if (iid.equals(Components.interfaces.nsIClassInfo))
dump("QI(nsIClassInfo) - not supported\n");
else if (iid.equals(Components.interfaces.nsISecurityCheckedComponent))
dump("QI(nsISecurityCheckedComponent) - not supported\n");
else if (iid.equals(Components.interfaces.nsIWyciwygChannel))
dump("QI(nsIWyciwygChannel) - not supported\n");
else if (iid.equals(Components.interfaces.nsIMultiPartChannel))
dump("QI(nsIMultiPartChannel) - not supported\n");
else if (iid.equals(Components.interfaces.nsIHttpChannelInternal))
dump("QI(nsIHttpChannelInternal) - not supported\n");
else if (iid.equals(Components.interfaces.nsIWritablePropertyBag2))
dump("QI(nsIWritablePropertyBag2) - not supported\n");
else if (iid.equals(nsIRequest))
dump("QI(nsIRequest)\n");
else if (iid.equals(nsIRequestObserver))
dump("QI(nsIRequestObserver)\n");
else if (iid.equals(nsISupports))
dump("QI(nsISupports)\n");
else if (iid.equals(nsIStreamListener))
dump("QI(nsIStreamListener)\n");
else
dump("unknown " + iid + "\n");