Navigation Menu

Skip to content

Commit

Permalink
Reorganisation
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.getfiregpg.org/firegpg@524 1e1cc2a3-b62a-0410-bc93-fb3b3b0a0737
  • Loading branch information
theglu committed Jan 31, 2009
1 parent 9fb1d0e commit b2fa147
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 86 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2009-01-31 Maximilien Cuony
* Keyring -> inline (FireGPGInline)
* Reorganisation of FireGPG structure in progress.
* Fixed the about windows

2009-01-26 Maximilien Cuony
* Fix a problem with form value, thanks to Mateusz Baszczyk for his help

Expand Down
4 changes: 2 additions & 2 deletions chrome.manifest
Expand Up @@ -30,6 +30,6 @@ locale firegpg fa locale/fa/
locale firegpg ja locale/ja/
locale firegpg da locale/da/
skin firegpg classic/1.0 skin/
overlay chrome://browser/content/browser.xul chrome://firegpg/content/firefoxOverlay.xul
overlay chrome://webrunner/content/webrunner.xul chrome://firegpg/content/prismeOverlay.xul
overlay chrome://browser/content/browser.xul chrome://firegpg/content/Core/firefoxOverlay.xul
overlay chrome://webrunner/content/webrunner.xul chrome://firegpg/content/Core/prismeOverlay.xul
style chrome://global/content/customizeToolbar.xul chrome://firegpg/skin/overlay.css
2 changes: 1 addition & 1 deletion content/Core/firefoxOverlay.xul
Expand Up @@ -48,7 +48,7 @@
<script src="../GpgAuth/gpgauth.js"/>
<script src="../Api/api.js"/>
<script src="./Api/new_api.js"/>
<script src="keyring.js"/>
<script src="inline.js"/>
<script src="../Mime/mime.js" />
<stringbundleset id="stringbundleset">
<stringbundle id="firegpg-strings" src="chrome://firegpg/locale/firegpg.properties"/>
Expand Down
158 changes: 79 additions & 79 deletions content/Core/keyring.js → content/Core/inline.js
Expand Up @@ -34,25 +34,25 @@
*
* ***** END LICENSE BLOCK ***** */

var Keyring = { };
var FireGPGInline = { };

/*
Constants: Tags of PGP's blocks
Keyring.Tags.PgpBlockStart - Start of a PGP block
Keyring.Tags.KeyStart - Start of a PGP key
Keyring.Tags.KeyEnd - End of a PGP key
Keyring.Tags.PrivateKeyStart - Start of a PGP private key
Keyring.Tags.PrivateKeyEnd - End of a PGP private key
Keyring.Tags.SignedMessageStart - Start of a signed message
Keyring.Tags.SignatureStart - Start of a sign
Keyring.Tags.SignatureEnd - End of a sign
Keyring.Tags.EncryptedMessageStart - Start of an encrypted message
Keyring.Tags.EncryptedMessageEnd - End of an encrypted message
FireGPGInline.Tags.PgpBlockStart - Start of a PGP block
FireGPGInline.Tags.KeyStart - Start of a PGP key
FireGPGInline.Tags.KeyEnd - End of a PGP key
FireGPGInline.Tags.PrivateKeyStart - Start of a PGP private key
FireGPGInline.Tags.PrivateKeyEnd - End of a PGP private key
FireGPGInline.Tags.SignedMessageStart - Start of a signed message
FireGPGInline.Tags.SignatureStart - Start of a sign
FireGPGInline.Tags.SignatureEnd - End of a sign
FireGPGInline.Tags.EncryptedMessageStart - Start of an encrypted message
FireGPGInline.Tags.EncryptedMessageEnd - End of an encrypted message
*/
Keyring.Tags = {
FireGPGInline.Tags = {
PgpBlockStart: "-----BEGIN PGP",
KeyStart: "-----BEGIN PGP PUBLIC KEY BLOCK-----",
KeyEnd: "-----END PGP PUBLIC KEY BLOCK-----",
Expand All @@ -68,19 +68,19 @@ Keyring.Tags = {
/*
Constants: Types of blocks
Keyring.KEY_BLOCK - It's a key block
Keyring.PRIVATE_KEY_BLOCK - It's a private key block
Keyring.SIGN_BLOCK - It's a sign block
Keyring.MESSAGE_BLOCK - It's a message block
FireGPGInline.KEY_BLOCK - It's a key block
FireGPGInline.PRIVATE_KEY_BLOCK - It's a private key block
FireGPGInline.SIGN_BLOCK - It's a sign block
FireGPGInline.MESSAGE_BLOCK - It's a message block
*/
Keyring.KEY_BLOCK = 1;
Keyring.PRIVATE_KEY_BLOCK = 2;
Keyring.SIGN_BLOCK = 3;
Keyring.MESSAGE_BLOCK = 4;
FireGPGInline.KEY_BLOCK = 1;
FireGPGInline.PRIVATE_KEY_BLOCK = 2;
FireGPGInline.SIGN_BLOCK = 3;
FireGPGInline.MESSAGE_BLOCK = 4;


/*
Class: Keyring
Class: FireGPGInline
This class a system to detect and manage PGP block found in pages
*/

Expand All @@ -93,7 +93,7 @@ Keyring.MESSAGE_BLOCK = 4;
range - A range with the PGP block selected
blockType - The type of block, see <Types of blocs>
*/
Keyring.HandleBlock = function(document, range, blockType) {
FireGPGInline.HandleBlock = function(document, range, blockType) {

var i18n = document.getElementById("firegpg-strings");

Expand Down Expand Up @@ -126,38 +126,38 @@ Keyring.HandleBlock = function(document, range, blockType) {
original: frame.contentDocument.getElementById("original")
}

frame.contentDocument.getElementById("toggle-original").textContent = Keyring.i18n.getString("show-original")
frame.contentDocument.getElementById("toggle-original").textContent = FireGPGInline.i18n.getString("show-original")

// Universal set up
block.original.textContent = content;
frame.contentDocument.getElementById("toggle-original").addEventListener("click", function() {
var style = block.original.style;
if(style.display == "block") {
style.display = "none";
this.textContent = Keyring.i18n.getString("show-original");
this.textContent = FireGPGInline.i18n.getString("show-original");
}
else {
style.display = "block";
this.textContent = Keyring.i18n.getString("hide-original");
this.textContent = FireGPGInline.i18n.getString("hide-original");
}
frame.style.width = block.body.scrollWidth + "px";
frame.style.height = block.body.scrollHeight + "px";
}, false);
var actionHandler = function() {
switch(blockType) {
case Keyring.KEY_BLOCK:
Keyring.ImportKey(block.original.textContent, block);
case FireGPGInline.KEY_BLOCK:
FireGPGInline.ImportKey(block.original.textContent, block);
break;
case Keyring.PRIVATE_KEY_BLOCK:
case FireGPGInline.PRIVATE_KEY_BLOCK:
block.body.className = "failure";
block.output.style.display = "block";
block.output.textContent = Keyring.i18n.getString("private-key-block-message").replace(/\. /g, ".\n");
block.output.textContent = FireGPGInline.i18n.getString("private-key-block-message").replace(/\. /g, ".\n");
break;
case Keyring.SIGN_BLOCK:
Keyring.VerifySignature(block.original.textContent, block);
case FireGPGInline.SIGN_BLOCK:
FireGPGInline.VerifySignature(block.original.textContent, block);
break;
case Keyring.MESSAGE_BLOCK:
Keyring.DecryptMessage(block.original.textContent, block);
case FireGPGInline.MESSAGE_BLOCK:
FireGPGInline.DecryptMessage(block.original.textContent, block);
break;
}
frame.style.width = block.body.scrollWidth + "px";
Expand All @@ -167,27 +167,27 @@ Keyring.HandleBlock = function(document, range, blockType) {
block.action.addEventListener("click", actionHandler, false);

switch(blockType) {
case Keyring.KEY_BLOCK:
case FireGPGInline.KEY_BLOCK:
block.body.className = "information";
block.header.textContent = Keyring.i18n.getString("key-block");
block.action.textContent = Keyring.i18n.getString("import");
block.header.textContent = FireGPGInline.i18n.getString("key-block");
block.action.textContent = FireGPGInline.i18n.getString("import");
break;
case Keyring.PRIVATE_KEY_BLOCK:
case FireGPGInline.PRIVATE_KEY_BLOCK:
block.body.className = "information";
block.header.textContent = Keyring.i18n.getString("private-key-block");
block.action.textContent = Keyring.i18n.getString("import");
block.header.textContent = FireGPGInline.i18n.getString("private-key-block");
block.action.textContent = FireGPGInline.i18n.getString("import");
break;
case Keyring.SIGN_BLOCK:
case FireGPGInline.SIGN_BLOCK:
block.body.className = "caution";
block.header.textContent = Keyring.i18n.getString("signed-message") + ", " + Keyring.i18n.getString("unverified");
block.action.textContent = Keyring.i18n.getString("verify");
block.header.textContent = FireGPGInline.i18n.getString("signed-message") + ", " + FireGPGInline.i18n.getString("unverified");
block.action.textContent = FireGPGInline.i18n.getString("verify");
// Extract the message without the header and signature
block.message.innerHTML = content.substring(content.indexOf("\n\n") + 2, content.indexOf(Keyring.Tags.SignatureStart)).replace(/</gi,"&lt;").replace(/>/gi,"&gt;").replace(/\n/gi,"<br />");
block.message.innerHTML = content.substring(content.indexOf("\n\n") + 2, content.indexOf(FireGPGInline.Tags.SignatureStart)).replace(/</gi,"&lt;").replace(/>/gi,"&gt;").replace(/\n/gi,"<br />");
break;
case Keyring.MESSAGE_BLOCK:
case FireGPGInline.MESSAGE_BLOCK:
block.body.className = "caution";
block.header.textContent = Keyring.i18n.getString("encrypted-message") ;
block.action.textContent = Keyring.i18n.getString("decrypt");
block.header.textContent = FireGPGInline.i18n.getString("encrypted-message") ;
block.action.textContent = FireGPGInline.i18n.getString("decrypt");
break;
}
frame.style.width = block.body.scrollWidth + "px";
Expand All @@ -203,7 +203,7 @@ Keyring.HandleBlock = function(document, range, blockType) {
document - The current document
*/
Keyring.HandlePage = function(document) {
FireGPGInline.HandlePage = function(document) {

var filter = function(node) {
return NodeFilter.FILTER_ACCEPT;
Expand All @@ -218,33 +218,33 @@ Keyring.HandlePage = function(document) {
while(true) {
if(!haveStart) {

if (node.textContent.indexOf(Keyring.Tags.PgpBlockStart, idx) == -1)
if (node.textContent.indexOf(FireGPGInline.Tags.PgpBlockStart, idx) == -1)
break;

if (node.parentNode.nodeName == 'TEXTAREA')
if (node.parentNode && node.parentNode.nodeName == 'TEXTAREA')
break;

if (node.parentNode.nodeName == 'PRE')
if (node.parentNode && node.parentNode.nodeName == 'PRE')
break;

baseIdx = idx;
idx = node.textContent.indexOf(Keyring.Tags.KeyStart, baseIdx);
blockType = Keyring.KEY_BLOCK;
search = Keyring.Tags.KeyEnd;
idx = node.textContent.indexOf(FireGPGInline.Tags.KeyStart, baseIdx);
blockType = FireGPGInline.KEY_BLOCK;
search = FireGPGInline.Tags.KeyEnd;
if(idx == -1) {
idx = node.textContent.indexOf(Keyring.Tags.SignedMessageStart, baseIdx);
search = Keyring.Tags.SignatureEnd;
blockType = Keyring.SIGN_BLOCK;
idx = node.textContent.indexOf(FireGPGInline.Tags.SignedMessageStart, baseIdx);
search = FireGPGInline.Tags.SignatureEnd;
blockType = FireGPGInline.SIGN_BLOCK;
}
if(idx == -1) {
idx = node.textContent.indexOf(Keyring.Tags.EncryptedMessageStart, baseIdx);
search = Keyring.Tags.EncryptedMessageEnd;
blockType = Keyring.MESSAGE_BLOCK;
idx = node.textContent.indexOf(FireGPGInline.Tags.EncryptedMessageStart, baseIdx);
search = FireGPGInline.Tags.EncryptedMessageEnd;
blockType = FireGPGInline.MESSAGE_BLOCK;
}
if(idx == -1) {
idx = node.textContent.indexOf(Keyring.Tags.PrivateKeyStart, baseIdx);
blockType = Keyring.PRIVATE_KEY_BLOCK;
search = Keyring.Tags.PrivateKeyEnd;
idx = node.textContent.indexOf(FireGPGInline.Tags.PrivateKeyStart, baseIdx);
blockType = FireGPGInline.PRIVATE_KEY_BLOCK;
search = FireGPGInline.Tags.PrivateKeyEnd;
}

if(idx == -1)
Expand All @@ -270,7 +270,7 @@ Keyring.HandlePage = function(document) {

haveStart = false;
range.setEnd(node, idx + search.length);
Keyring.HandleBlock(document, range, blockType);
FireGPGInline.HandleBlock(document, range, blockType);
range.detach();
idx =0; //+= search.length;
}
Expand All @@ -290,22 +290,22 @@ Keyring.HandlePage = function(document) {
node - The node where we works
*/
Keyring.ignoreInners = function(idx, end,node) {
FireGPGInline.ignoreInners = function(idx, end,node) {

if (end == -1)
return -1;


baseIdx = idx;
idx = node.indexOf(Keyring.Tags.KeyStart, baseIdx);
search = Keyring.Tags.KeyEnd;
idx = node.indexOf(FireGPGInline.Tags.KeyStart, baseIdx);
search = FireGPGInline.Tags.KeyEnd;
if(idx == -1) {
idx = node.indexOf(Keyring.Tags.SignedMessageStart, baseIdx);
search = Keyring.Tags.SignatureEnd;
idx = node.indexOf(FireGPGInline.Tags.SignedMessageStart, baseIdx);
search = FireGPGInline.Tags.SignatureEnd;
}
if(idx == -1) {
idx = node.indexOf(Keyring.Tags.EncryptedMessageStart, baseIdx);
search = Keyring.Tags.EncryptedMessageEnd;
idx = node.indexOf(FireGPGInline.Tags.EncryptedMessageStart, baseIdx);
search = FireGPGInline.Tags.EncryptedMessageEnd;
}

if(idx == -1 || idx > end)
Expand All @@ -327,7 +327,7 @@ Keyring.ignoreInners = function(idx, end,node) {
block - The block who contain the iframe
*/
Keyring.ImportKey = function(content, block) {
FireGPGInline.ImportKey = function(content, block) {

result = FireGPG.kimport(true,content);

Expand All @@ -350,7 +350,7 @@ Keyring.ImportKey = function(content, block) {
block - The block who contain the iframe
*/
Keyring.VerifySignature = function(content, block) {
FireGPGInline.VerifySignature = function(content, block) {

var i18n = document.getElementById("firegpg-strings");

Expand Down Expand Up @@ -386,7 +386,7 @@ Keyring.VerifySignature = function(content, block) {
block - The block who contain the iframe
*/
Keyring.DecryptMessage = function(content, block) {
FireGPGInline.DecryptMessage = function(content, block) {

var i18n = document.getElementById("firegpg-strings");

Expand Down Expand Up @@ -423,7 +423,7 @@ Keyring.DecryptMessage = function(content, block) {
aEvent - The event of the loading
*/
Keyring.onPageLoad = function(aEvent) {
FireGPGInline.onPageLoad = function(aEvent) {
var doc = aEvent.originalTarget;
if(doc.nodeName != "#document")
return;
Expand All @@ -435,7 +435,7 @@ Keyring.onPageLoad = function(aEvent) {
if (doc.location.href.indexOf("mail.google.com") != -1)
return;

Keyring.HandlePage(doc);
FireGPGInline.HandlePage(doc);


};
Expand All @@ -445,7 +445,7 @@ Keyring.onPageLoad = function(aEvent) {
This function is called by FireGPG when a new Firefox's windows is created.
*/
Keyring.initSystem = function() {
FireGPGInline.initSystem = function() {

var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefService);
Expand All @@ -462,11 +462,11 @@ Keyring.initSystem = function() {

try {
if (document.getElementById("appcontent"))
document.getElementById("appcontent").addEventListener("DOMContentLoaded", Keyring.onPageLoad, false);
document.getElementById("appcontent").addEventListener("DOMContentLoaded", FireGPGInline.onPageLoad, false);
else
document.getElementById("browser_content").addEventListener("DOMContentLoaded", Keyring.onPageLoad, false);
document.getElementById("browser_content").addEventListener("DOMContentLoaded", FireGPGInline.onPageLoad, false);

} catch (e) { fireGPGDebug(e,'keyring.initSystem',true); }

Keyring.i18n = document.getElementById("firegpg-strings");
FireGPGInline.i18n = document.getElementById("firegpg-strings");
};
2 changes: 1 addition & 1 deletion content/Core/overlay.js
Expand Up @@ -78,7 +78,7 @@ var firegpg = {

cGmail.initSystem();
cGmail2.initSystem();
Keyring.initSystem();
FireGPGInline.initSystem();
//APIListener.init();

// initialization code
Expand Down
2 changes: 1 addition & 1 deletion content/Core/prismeOverlay.xul
Expand Up @@ -51,7 +51,7 @@
<script src="../Api/new_api.js"/>
<script src="prisme.js"/>
<script src="../Mime/mime.js" />
<script src="keyring.js"/>
<script src="inline.js"/>

</overlay>

Expand Down
4 changes: 2 additions & 2 deletions install.rdf
Expand Up @@ -16,8 +16,8 @@
em:creator="FireGPG Team"
em:homepageURL="http://www.getfiregpg.org/"
em:updateURL="http://www.getfiregpg.org/stable/update.rdf"
em:aboutURL="chrome://firegpg/content/about.xul"
em:optionsURL="chrome://firegpg/content/options.xul"
em:aboutURL="chrome://firegpg/content/Dialogs/about.xul"
em:optionsURL="chrome://firegpg/content/Dialogs/options.xul"
em:iconURL="chrome://firegpg/content/firegpg.png"
em:updateKey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC39KBStycIN2Bk8KyCnMOGs0yi6k7fVpQjG7g7xJy/yPqBBXXYZ2E5zqCy/lLynnuWGqAhWrb4b1/i7U9Qt2uojwKoNELqb7nx219Hv753OH5jLFUwZ5GMjIJ9DxEhfjg7UG9pN2l6XZqXQqJMXz9oJf6bWZBegw0auEx1EzLzZQIDAQAB">
<em:targetApplication RDF:resource="rdf:#$g5s0x"/>
Expand Down

0 comments on commit b2fa147

Please sign in to comment.