Skip to content

Commit

Permalink
* TelnetProtocol.js : use XPCOMUtils.jsm instead and Fx4/Gecko 2 issues.
Browse files Browse the repository at this point in the history
* chrome.manifest: Chrome registration for Gecko 2.
* install.rdf: version up (0.2.1), Compatibility change: 3.6.* -> 4.0b5pre.
  • Loading branch information
sst.dreams committed Aug 29, 2010
1 parent ee643a8 commit f659e1a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 86 deletions.
5 changes: 4 additions & 1 deletion chrome.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ locale pcmanfx2 en-US chrome/locale/en-US/
locale pcmanfx2 zh-TW chrome/locale/zh-TW/
skin pcmanfx2 classic/1.0 chrome/skin/classic/

style chrome://browser/content/browser.xul chrome://pcmanfx2/content/bindings.css
style chrome://browser/content/browser.xul chrome://pcmanfx2/content/bindings.css

component {5FAF83FD-708D-45c0-988B-C7404FB25376} components/TelnetProtocol.js
contract @mozilla.org/network/protocol;1?name=telnet {5FAF83FD-708D-45c0-988B-C7404FB25376}
93 changes: 18 additions & 75 deletions components/TelnetProtocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* Contributor(s):
* Darin Fisher <[email protected]>
* Doron Rosenberg <[email protected]>
* Hong Jen Yee (PCMan) <[email protected]>
* Hsiao-Ting Yu <[email protected]>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
Expand All @@ -35,15 +37,8 @@
*
* ***** END LICENSE BLOCK ***** */

// Modified by Hong Jen Yee (PCMan) <[email protected]> on 2009-11-23 to be
// used in PCMan firefox extension.

// Test protocol related
const kSCHEME = "telnet";
const kPROTOCOL_NAME = "Telnet Protocol";
const kPROTOCOL_CONTRACTID = "@mozilla.org/network/protocol;1?name=" + kSCHEME;
const kPROTOCOL_CID = Components.ID("5FAF83FD-708D-45c0-988B-C7404FB25376");

// Mozilla defined
const kSIMPLEURI_CONTRACTID = "@mozilla.org/network/simple-uri;1";
const kSTANDARDURL_CONTRACTID = "@mozilla.org/network/standard-url;1";
Expand All @@ -54,34 +49,31 @@ const nsIProtocolHandler = Components.interfaces.nsIProtocolHandler;
const nsIURI = Components.interfaces.nsIURI;
const nsIStandardURL = Components.interfaces.nsIStandardURL;

// Compatiblity notice: 1.9+ only
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function Protocol()
{
}

Protocol.prototype =
{
QueryInterface: function(iid)
{
if (!iid.equals(nsIProtocolHandler) &&
!iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
},

classDescription: "Telnet protocol support for BBS",
classID: Components.ID("5FAF83FD-708D-45c0-988B-C7404FB25376"),
contractID: "@mozilla.org/network/protocol;1?name="+ kSCHEME,
QueryInterface: XPCOMUtils.generateQI([nsIProtocolHandler]),
scheme: kSCHEME,
defaultPort: 23,
protocolFlags: nsIProtocolHandler.URI_NORELATIVE |
nsIProtocolHandler.URI_NOAUTH |
nsIProtocolHandler.URI_LOADABLE_BY_ANYONE |
nsIProtocolHandler.URI_NON_PERSISTABLE, // We can not save URL from telnet :D

allowPort: function(port, scheme)
{
allowPort: function(port, scheme) {
return false;
},

newURI: function(spec, charset, baseURI)
{
newURI: function(spec, charset, baseURI) {
// for nsStandardURL test - http://groups.google.com.tw/group/pcmanfx/browse_thread/thread/ec757aa8c73b1432#
// Parameters:
// * aUrlType: URLTYPE_AUTHORITY will always convert telnet:, telnet:/, telnet://, telnet:/// to telnet://
Expand All @@ -95,8 +87,7 @@ Protocol.prototype =
return cleanURI;
},

newChannel: function(aURI)
{
newChannel: function(aURI) {
/* create dummy nsIURI and nsIChannel instances */
var ios = Components.classes[kIOSERVICE_CONTRACTID]
.getService(nsIIOService);
Expand All @@ -105,59 +96,11 @@ Protocol.prototype =
},
}

var ProtocolFactory = new Object();

ProtocolFactory.createInstance = function (outer, iid)
{
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;

if (!iid.equals(nsIProtocolHandler) &&
!iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;

return new Protocol();
}


/**
* JS XPCOM component registration goop:
*
* We set ourselves up to observe the xpcom-startup category. This provides
* us with a starting point.
*/

var ThisModule = new Object();

ThisModule.registerSelf = function (compMgr, fileSpec, location, type)
{
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(kPROTOCOL_CID,
kPROTOCOL_NAME,
kPROTOCOL_CONTRACTID,
fileSpec,
location,
type);
}

ThisModule.getClassObject = function (compMgr, cid, iid)
{
if (!cid.equals(kPROTOCOL_CID))
throw Components.results.NS_ERROR_NO_INTERFACE;

if (!iid.equals(Components.interfaces.nsIFactory))
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;

return ProtocolFactory;
// Use NSGetFactory for Firefox 4 / Gecko 2
// https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0
if (XPCOMUtils.generateNSGetFactory) {
var NSGetFactory = XPCOMUtils.generateNSGetFactory([Protocol]);
} else {
var NSGetModule = XPCOMUtils.generateNSGetModule([Protocol]);
}

ThisModule.canUnload = function (compMgr)
{
return true;
}

function NSGetModule(compMgr, fileSpec)
{
return ThisModule;
}

23 changes: 13 additions & 10 deletions install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:version>0.2.0</em:version>
<em:version>0.2.1</em:version>
<em:type>2</em:type>

<!-- Target Application this extension can install into,
Expand All @@ -14,7 +14,7 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3.5</em:minVersion>
<em:maxVersion>3.6.*</em:maxVersion>
<em:maxVersion>4.0b5pre</em:maxVersion>
</Description>
</em:targetApplication>

Expand All @@ -24,27 +24,30 @@
<em:creator>洪任諭 (Hong Jen Yee) &lt;[email protected]&gt;</em:creator>
<em:developer>bootleq &lt;[email protected]&gt;</em:developer>
<em:developer>呂康豪 (Kang Hao Lu) &lt;http://dig.csail.mit.edu/People/kennyluck#I&gt;</em:developer>
<em:developer>littlebtc &lt;http://blog.littleb.tc/&gt;</em:developer>
<em:homepageURL>http://code.google.com/p/pcmanfx/</em:homepageURL>

<em:localized>
<Description>
<em:locale>zh-TW</em:locale>
<em:name>PCMan Firefox 擴充套件</em:name>
<em:description>專為 BBS 瀏覽設計,採 GNU/GPL 授權的 telnet 連線程式套件</em:description>
<em:creator>洪任諭 &lt;[email protected]&gt;</em:creator>
<em:developer>bootleq &lt;[email protected]&gt;</em:developer>
<em:developer>呂康豪 &lt;http://dig.csail.mit.edu/People/kennyluck#I&gt;</em:developer>
<em:description>專為 BBS 瀏覽設計,採 GNU/GPL 授權的 telnet 連線程式套件</em:description>
<em:creator>洪任諭 &lt;[email protected]&gt;</em:creator>
<em:developer>bootleq &lt;[email protected]&gt;</em:developer>
<em:developer>呂康豪 &lt;http://dig.csail.mit.edu/People/kennyluck#I&gt;</em:developer>
<em:developer>littlebtc &lt;http://blog.littleb.tc/&gt;</em:developer>
</Description>
</em:localized>

<em:localized>
<Description>
<em:locale>zh-CN</em:locale>
<em:name>PCMan Firefox 扩充</em:name>
<em:description>专为 BBS 浏览设计,采 GNU/GPL 授权的 telnet 程序套件</em:description>
<em:creator>洪任谕 &lt;[email protected]&gt;</em:creator>
<em:developer>bootleq &lt;[email protected]&gt;</em:developer>
<em:developer>吕康豪 &lt;http://dig.csail.mit.edu/People/kennyluck#I&gt;</em:developer>
<em:description>专为 BBS 浏览设计,采 GNU/GPL 授权的 telnet 程序套件</em:description>
<em:creator>洪任谕 &lt;[email protected]&gt;</em:creator>
<em:developer>bootleq &lt;[email protected]&gt;</em:developer>
<em:developer>吕康豪 &lt;http://dig.csail.mit.edu/People/kennyluck#I&gt;</em:developer>
<em:developer>littlebtc &lt;http://blog.littleb.tc/&gt;</em:developer>
</Description>
</em:localized>

Expand Down

0 comments on commit f659e1a

Please sign in to comment.