diff --git a/compile-interface.sh b/compile-interface.sh
index 1557f43..97d7bfd 100755
--- a/compile-interface.sh
+++ b/compile-interface.sh
@@ -4,12 +4,12 @@
# REM Modify this file to suite your environment
# set XPIDL_EXE=c:\software\gecko-sdk\bin\xpidl.exe
# set XPIDL_INC=C:\software\gecko-sdk\idl
-export XPIDL_EXE='/opt/xulrunner-sdk/bin/xpidl'
+export TYPELIB_EXE='/opt/xulrunner-sdk/sdk/bin/typelib.py'
export XPIDL_INC='/opt/xulrunner-sdk/idl'
export TPL_SRC='src/interface'
export TPL_TRG='target/interface'
# @echo on
-$XPIDL_EXE -m typelib -v -I $XPIDL_INC -w -o $TPL_TRG/nsIModifyheaders $TPL_SRC/nsIModifyheaders.idl
-$XPIDL_EXE -m typelib -v -I $XPIDL_INC -w -o $TPL_TRG/mhIHeader $TPL_SRC/mhIHeader.idl
+$TYPELIB_EXE src/interface/nsIModifyheaders.idl -o target/interface/nsIModifyheaders.xpt -I $XPIDL_INC
+$TYPELIB_EXE src/interface/mhIHeader.idl -o target/interface/mhIHeader.xpt -I $XPIDL_INC
diff --git a/src-nvu/jar/content/modifyheaders.js b/src-nvu/jar/content/modifyheaders.js
index e415499..c0f73b2 100644
--- a/src-nvu/jar/content/modifyheaders.js
+++ b/src-nvu/jar/content/modifyheaders.js
@@ -10,8 +10,8 @@ var initialized = false;
// Opens the modifyheaders interface in a new window
function openModifyHeaders() {
- // Open Modify Headers in a global window
- window.open("chrome://modifyheaders/content/modifyheaders.xul", "modifyheaders", "chrome,centerscreen,resizable,scrollbars");
+ // Open Modify Headers in a global window
+ window.open("chrome://modifyheaders/content/modifyheaders.xul", "modifyheaders", "chrome,centerscreen,resizable,scrollbars");
}
// Inits the Config tab
@@ -20,8 +20,8 @@ function initConfig() {
}
function toggleAlwaysOn() {
- var alwaysOn = modifyheadersService.alwaysOn;
- modifyheadersService.alwaysOn = !alwaysOn;
+ var alwaysOn = modifyheadersService.alwaysOn;
+ modifyheadersService.alwaysOn = !alwaysOn;
}
function startModifyHeaders() {
@@ -35,7 +35,7 @@ function startModifyHeaders() {
}
function stopModifyHeaders() {
- oModifyHeaders = null;
+ oModifyHeaders = null;
modifyheadersService.windowOpen = false;
}
@@ -48,242 +48,243 @@ ModifyHeaders.prototype = {
// Control constants
headersTree: null,
- actionMenuList: null,
- nameTextbox: null,
- valueTextbox: null,
- addButton: null,
- saveButton: null,
+ actionMenuList: null,
+ nameTextbox: null,
+ valueTextbox: null,
+ addButton: null,
+ saveButton: null,
- // nsITreeView interface properties
- treeSelection: null, // nsiTreeSelection
- treeBox: null, // The tree
- editedRowID: null, // The row currently being edited
-
- // Getters and Setters
- set rowCount(i) { throw "rowCount is a readonly property"; },
- //get rowCount() { return this.rows.length; },
- get rowCount() { return modifyheadersService.count; },
-
- set selection(s) { this.treeSelection = s; },
- get selection() { return this.treeSelection; },
-
- // START nsITreeView interface methods
-// canDropBeforeAfter: function(index, before) { return false; },
-// canDropOn : function(index) { return false; },
-// cycleCell : function(row, columnID) { /* do nothing */ },
- cycleHeader: function(columnID, element) {
- /* do nothing */
- alert("Cycling: " + columnID);
- },
-// drop: function(row, orientation) { /* do nothing */ return false; },
- getCellProperties: function(row, columnID, properties) { /* do nothing */ },
- getCellText: function(row, column) {
- if (column == "actioncol" || column.id == "actioncol") {
- return modifyheadersService.getHeaderAction(row);
- } else if (column == "namecol" || column.id == "namecol") {
- return modifyheadersService.getHeaderName(row);
- } else if (column == "valuecol" || column.id == "valuecol") {
- return modifyheadersService.getHeaderValue(row);
- }
-
- return null;
+ // nsITreeView interface properties
+ treeSelection: null, // nsiTreeSelection
+ treeBox: null, // The tree
+ editedRowID: null, // The row currently being edited
+
+ // Getters and Setters
+ set rowCount(i) { throw "rowCount is a readonly property"; },
+ //get rowCount() { return this.rows.length; },
+ get rowCount() { return modifyheadersService.count; },
+
+ set selection(s) { this.treeSelection = s; },
+ get selection() { return this.treeSelection; },
+
+ // START nsITreeView interface methods
+// canDropBeforeAfter: function(index, before) { return false; },
+// canDropOn : function(index) { return false; },
+// cycleCell : function(row, columnID) { /* do nothing */ },
+ cycleHeader: function(columnID, element) {
+ /* do nothing */
+ alert("Cycling: " + columnID);
},
-// getCellValue: function(row, columnID) { /* return null; */ },
- getColumnProperties: function(columnID, element, properties) { /* do nothing */ },
- getImageSrc: function(rowIndex, column) {
- if (column == "enabledcol" || column.id == "enabledcol") {
- if (modifyheadersService.isHeaderEnabled(rowIndex)) {
- return "chrome://modifyheaders/content/enabled.gif";
- } else {
- return "chrome://modifyheaders/content/disabled.gif";
- }
- }
-
- return null;
- },
-// getLevel: function(index) { return 0; },
-// getParentIndex: function(rowIndex) { return 0; },
-// getProgressMode: function(rowIndex, columnID) { /* return 0; */ },
- getRowProperties: function(rowIndex, properties) { /* do nothing */ },
-// hasNextSibling: function(rowIndex, afterIndex) { return false; },
- isContainer: function(index) { return false; },
-// isContainerEmpty: function(index) { return false; },
-// isContainerOpen: function(index) { /* return false; */ },
-// isEditable: function(rowIndex, columnID) { return false; },
- isSeparator: function(index) { return false; },
- isSorted: function(index) { /* return false; */ },
-// performAction: function(action) { /* do nothing */ },
-// performActionOnCell: function(action, rowIndex, columnID) { /* do nothing */ },
-// performActionOnRow: function(action, rowIndex) { /* do nothing */ },
-// selectionChanged: function() { /* do nothing */ },
-// setCellText: function(rowIndex, columnID, value) { /* do nothing */ },
- setTree: function(tree) { this.treeBox=tree; },
-// toggleOpenState: function(index) { /* do nothing */ },
- // END nsITreeView interface methods
-
- start: function() {
- // Initialize the form controls
- this.headersTree = document.getElementById("modifyheaders-tree");
- this.actionMenuList = document.getElementById("action-menulist");
- this.nameTextbox = document.getElementById("headername-text-box");
- this.valueTextbox = document.getElementById("headervalue-text-box");
- this.addButton = document.getElementById("add-header-button");
- this.saveButton = document.getElementById("save-header-button");
-
- // Set this view for the treeBoxObject
- this.headersTree.treeBoxObject.view = this;
- },
-
- addHeader: function() {
-
- // Values
- // TODO Make the enabled default value a preference, true for now
- var enabled = true;
- var action = document.getElementById("action-menulist").selectedItem.label;
- var name = document.getElementById("headername-text-box").value;
- var value = document.getElementById("headervalue-text-box").value;
-
- modifyheadersService.addHeader(name, value, action, enabled);
-
+// drop: function(row, orientation) { /* do nothing */ return false; },
+ getCellProperties: function(row, columnID, properties) { /* do nothing */ },
+ getCellText: function(row, column) {
+ if (column == "actioncol" || column.id == "actioncol") {
+ return modifyheadersService.getHeaderAction(row);
+ } else if (column == "namecol" || column.id == "namecol") {
+ return modifyheadersService.getHeaderName(row);
+ } else if (column == "valuecol" || column.id == "valuecol") {
+ return modifyheadersService.getHeaderValue(row);
+ }
+
+ return null;
+ },
+// getCellValue: function(row, columnID) { /* return null; */ },
+ getColumnProperties: function(columnID, element, properties) { /* do nothing */ },
+ getImageSrc: function(rowIndex, column) {
+ if (column == "enabledcol" || column.id == "enabledcol") {
+ if (modifyheadersService.isHeaderEnabled(rowIndex)) {
+ return "chrome://modifyheaders/content/enabled.gif";
+ } else {
+ return "chrome://modifyheaders/content/disabled.gif";
+ }
+ }
+
+ return null;
+ },
+// getLevel: function(index) { return 0; },
+// getParentIndex: function(rowIndex) { return 0; },
+// getProgressMode: function(rowIndex, columnID) { /* return 0; */ },
+ getRowProperties: function(rowIndex, properties) { /* do nothing */ },
+// hasNextSibling: function(rowIndex, afterIndex) { return false; },
+ isContainer: function(index) { return false; },
+// isContainerEmpty: function(index) { return false; },
+// isContainerOpen: function(index) { /* return false; */ },
+// isEditable: function(rowIndex, columnID) { return false; },
+ isSeparator: function(index) { return false; },
+ isSorted: function(index) { /* return false; */ },
+// performAction: function(action) { /* do nothing */ },
+// performActionOnCell: function(action, rowIndex, columnID) { /* do nothing */ },
+// performActionOnRow: function(action, rowIndex) { /* do nothing */ },
+// selectionChanged: function() { /* do nothing */ },
+// setCellText: function(rowIndex, columnID, value) { /* do nothing */ },
+ setTree: function(tree) { this.treeBox=tree; },
+// toggleOpenState: function(index) { /* do nothing */ },
+ // END nsITreeView interface methods
+
+ start: function() {
+ // Initialize the form controls
+ this.headersTree = document.getElementById("modifyheaders-tree");
+ this.actionMenuList = document.getElementById("action-menulist");
+ this.nameTextbox = document.getElementById("headername-text-box");
+ this.valueTextbox = document.getElementById("headervalue-text-box");
+ this.addButton = document.getElementById("add-header-button");
+ this.saveButton = document.getElementById("save-header-button");
+
+ // Set this view for the treeBoxObject
+ this.headersTree.treeBoxObject.view = this;
+ },
+
+ addHeader: function() {
+
+ // Values
+ // TODO Make the enabled default value a preference, true for now
+ var enabled = true;
+ var action = document.getElementById("action-menulist").selectedItem.label;
+ var name = document.getElementById("headername-text-box").value;
+ var value = document.getElementById("headervalue-text-box").value;
+ var pattern = document.getElementById("headerpattern-text-box").value;
+
+ modifyheadersService.addHeader(name, value, action, enabled);
+
// Notify the treeBoxObject that a row has been added,
// Select the row
this.treeBox.rowCountChanged(this.rowCount-1, 1);
this.treeSelection.select(this.rowCount-1);
-
- this.clearForm();
- },
-
- // Delete the header from the list
- deleteHeader: function(mesg) {
- if (confirm(mesg)) {
-
- var deleteIndex = this.treeSelection.currentIndex;
-
- modifyheadersService.removeHeader(deleteIndex);
+
+ this.clearForm();
+ },
+
+ // Delete the header from the list
+ deleteHeader: function(mesg) {
+ if (confirm(mesg)) {
+
+ var deleteIndex = this.treeSelection.currentIndex;
+
+ modifyheadersService.removeHeader(deleteIndex);
- // Notify the treeBoxObject that a row has been deleted
- // Select the next row if there is one
- this.treeBox.rowCountChanged(deleteIndex, -1);
- this.treeSelection.select(deleteIndex);
- }
- },
-
- editHeader: function() {
- var selectedRowIndex = this.treeSelection.currentIndex;
-
- // Set the form values to the value of the selected item
- if (selectedRowIndex > -1) {
- // TODO - get the action selected correctly
- //this.actionMenuList.label = modifyheadersService.getHeaderAction(selectedRowIndex);
- this.nameTextbox.value = modifyheadersService.getHeaderName(selectedRowIndex);
- this.valueTextbox.value = modifyheadersService.getHeaderValue(selectedRowIndex);
-
- this.editedRowID = selectedRowIndex;
-
- // Hide the add button and display the save button
- this.addButton.setAttribute("hidden", "true");
- this.saveButton.setAttribute("hidden", "false");
- }
- },
-
- saveHeader: function() {
-
- if (this.editedRowID != null) {
-
- var index = this.editedRowID;
- var name = this.nameTextbox.value;
- var value = this.valueTextbox.value;
- var action = this.actionMenuList.selectedItem.label;
- var enabled = modifyheadersService.isHeaderEnabled(index);
-
- modifyheadersService.setHeader(index, name, value, action, enabled);
-
+ // Notify the treeBoxObject that a row has been deleted
+ // Select the next row if there is one
+ this.treeBox.rowCountChanged(deleteIndex, -1);
+ this.treeSelection.select(deleteIndex);
+ }
+ },
+
+ editHeader: function() {
+ var selectedRowIndex = this.treeSelection.currentIndex;
+
+ // Set the form values to the value of the selected item
+ if (selectedRowIndex > -1) {
+ // TODO - get the action selected correctly
+ //this.actionMenuList.label = modifyheadersService.getHeaderAction(selectedRowIndex);
+ this.nameTextbox.value = modifyheadersService.getHeaderName(selectedRowIndex);
+ this.valueTextbox.value = modifyheadersService.getHeaderValue(selectedRowIndex);
+
+ this.editedRowID = selectedRowIndex;
+
+ // Hide the add button and display the save button
+ this.addButton.setAttribute("hidden", "true");
+ this.saveButton.setAttribute("hidden", "false");
+ }
+ },
+
+ saveHeader: function() {
+
+ if (this.editedRowID != null) {
+
+ var index = this.editedRowID;
+ var name = this.nameTextbox.value;
+ var value = this.valueTextbox.value;
+ var action = this.actionMenuList.selectedItem.label;
+ var enabled = modifyheadersService.isHeaderEnabled(index);
+
+ modifyheadersService.setHeader(index, name, value, action, enabled);
+
// Notify the treeBoxObject that a row has been edited
this.treeBox.rowCountChanged(this.editedRowID, 0);
// Select the row
this.treeSelection.select(this.editedRowID);
- // Set the editedRow to null
- this.editedRowID = null;
+ // Set the editedRow to null
+ this.editedRowID = null;
- this.clearForm();
+ this.clearForm();
}
- },
-
- clearForm: function() {
- this.nameTextbox.value = "";
- this.valueTextbox.value = "";
+ },
+
+ clearForm: function() {
+ this.nameTextbox.value = "";
+ this.valueTextbox.value = "";
- this.saveButton.setAttribute("hidden", "true");
- this.addButton.setAttribute("hidden", "false");
+ this.saveButton.setAttribute("hidden", "true");
+ this.addButton.setAttribute("hidden", "false");
// Ensure that the selected index is set back to null
- var selectedRowIndex = null;
- },
-
- enableHeader: function() {
- // Change the enabled parameter to true
- var enabled = modifyheadersService.isHeaderEnabled(this.treeSelection.currentIndex);
-
- modifyheadersService.setHeaderEnabled(this.treeSelection.currentIndex, !enabled);
-
+ var selectedRowIndex = null;
+ },
+
+ enableHeader: function() {
+ // Change the enabled parameter to true
+ var enabled = modifyheadersService.isHeaderEnabled(this.treeSelection.currentIndex);
+
+ modifyheadersService.setHeaderEnabled(this.treeSelection.currentIndex, !enabled);
+
// Notify the treeBoxObject that a row has been edited
this.treeSelection.select(this.treeSelection.currentIndex);
this.treeBox.rowCountChanged(this.treeSelection.currentIndex, 0);
- },
-
- enableAllHeaders: function() {
- var tempSelectedIndex = this.treeSelection.currentIndex;
-
- for (var i=0; i < modifyheadersService.count; i++) {
- modifyheadersService.setHeaderEnabled(i, true);
-
- // Notify the treeBoxObject that a row has been edited
- this.treeSelection.select(i);
- this.treeBox.rowCountChanged(i, 0);
- }
-
- // Revert to the previous selectedIndex
- this.treeSelection.select(tempSelectedIndex);
- },
-
- disableAllHeaders: function() {
- var tempSelectedIndex = this.treeSelection.currentIndex;
-
- for (var i=0; i < modifyheadersService.count; i++) {
- modifyheadersService.setHeaderEnabled(i, false);
-
- // Notify the treeBoxObject that a row has been edited
- this.treeSelection.select(i);
- this.treeBox.rowCountChanged(i, 0);
- }
-
- // Revert to the previous selectedIndex
- this.treeSelection.select(tempSelectedIndex);
- },
-
- moveRowDown: function() {
- if (this.treeSelection && this.treeSelection.currentIndex != this.rowCount - 1) {
- var selectedIndex = this.treeSelection.currentIndex;
-
- modifyheadersService.switchHeaders(selectedIndex, selectedIndex + 1);
+ },
+
+ enableAllHeaders: function() {
+ var tempSelectedIndex = this.treeSelection.currentIndex;
+
+ for (var i=0; i < modifyheadersService.count; i++) {
+ modifyheadersService.setHeaderEnabled(i, true);
+
+ // Notify the treeBoxObject that a row has been edited
+ this.treeSelection.select(i);
+ this.treeBox.rowCountChanged(i, 0);
+ }
+
+ // Revert to the previous selectedIndex
+ this.treeSelection.select(tempSelectedIndex);
+ },
+
+ disableAllHeaders: function() {
+ var tempSelectedIndex = this.treeSelection.currentIndex;
+
+ for (var i=0; i < modifyheadersService.count; i++) {
+ modifyheadersService.setHeaderEnabled(i, false);
+
+ // Notify the treeBoxObject that a row has been edited
+ this.treeSelection.select(i);
+ this.treeBox.rowCountChanged(i, 0);
+ }
+
+ // Revert to the previous selectedIndex
+ this.treeSelection.select(tempSelectedIndex);
+ },
+
+ moveRowDown: function() {
+ if (this.treeSelection && this.treeSelection.currentIndex != this.rowCount - 1) {
+ var selectedIndex = this.treeSelection.currentIndex;
+
+ modifyheadersService.switchHeaders(selectedIndex, selectedIndex + 1);
// Change the selection
this.treeSelection.select(this.treeSelection.currentIndex + 1);
this.treeBox.rowCountChanged(this.selection.currentIndex, 0);
- }
- },
-
- moveRowUp: function() {
- if (this.treeSelection && this.treeSelection.currentIndex != 0) {
-
- var selectedIndex = this.treeSelection.currentIndex;
-
- modifyheadersService.switchHeaders(selectedIndex, selectedIndex - 1);
-
+ }
+ },
+
+ moveRowUp: function() {
+ if (this.treeSelection && this.treeSelection.currentIndex != 0) {
+
+ var selectedIndex = this.treeSelection.currentIndex;
+
+ modifyheadersService.switchHeaders(selectedIndex, selectedIndex - 1);
+
this.treeSelection.select(this.treeSelection.currentIndex - 1);
this.treeBox.rowCountChanged(this.selection.currentIndex-1, 0);
- }
- }
+ }
+ }
};
diff --git a/src/chrome/content/export.js b/src/chrome/content/export.js
index c12a466..1979529 100644
--- a/src/chrome/content/export.js
+++ b/src/chrome/content/export.js
@@ -122,7 +122,9 @@ ModifyHeaders.ExportImport.ExportWizard = (function () {
} else if (column == "col-header-value" || column.id == "col-header-value") {
return this.data[row].value;
} else if (column == "col-comment" || column.id == "col-comment") {
- return this.data[row].comment
+ return this.data[row].comment;
+ } else if (column == "col-pattern" || column.id == "col-pattern") {
+ return this.data[row].pattern;
}
return null;
},
@@ -158,4 +160,4 @@ ModifyHeaders.ExportImport.ExportWizard = (function () {
}
}
}
-})();
\ No newline at end of file
+})();
diff --git a/src/chrome/content/exportwizard.xul b/src/chrome/content/exportwizard.xul
index d075f9f..059e93c 100644
--- a/src/chrome/content/exportwizard.xul
+++ b/src/chrome/content/exportwizard.xul
@@ -35,6 +35,7 @@
+
diff --git a/src/chrome/content/import.js b/src/chrome/content/import.js
index 636e8a3..23366dc 100644
--- a/src/chrome/content/import.js
+++ b/src/chrome/content/import.js
@@ -110,6 +110,7 @@ ModifyHeaders.ExportImport.ImportWizard = (function () {
case "name":
case "value":
case "comment":
+ case "pattern":
characters = "";
break;
default:
@@ -140,6 +141,9 @@ ModifyHeaders.ExportImport.ImportWizard = (function () {
case "comment":
this.addHeaderProperty("comment");
break;
+ case "pattern":
+ this.addHeaderProperty("pattern");
+ break;
default:
throw "End Element: " + localName;
}
@@ -220,6 +224,8 @@ ModifyHeaders.ExportImport.ImportWizard = (function () {
return ModifyHeaders.ExportImport.ImportWizard.importedConfig[row].value;
} else if (column == "col-comment" || column.id == "col-comment") {
return ModifyHeaders.ExportImport.ImportWizard.importedConfig[row].comment;
+ } else if (column == "col-pattern" || column.id == "col-pattern") {
+ return ModifyHeaders.ExportImport.ImportWizard.importedConfig[row].pattern;
}
return null;
},
@@ -289,7 +295,8 @@ ModifyHeaders.ExportImport.ImportWizard = (function () {
action : ModifyHeaders.ExportImport.ImportWizard.importedConfig[i].action,
name : ModifyHeaders.ExportImport.ImportWizard.importedConfig[i].name,
value : ModifyHeaders.ExportImport.ImportWizard.importedConfig[i].value,
- comment : ModifyHeaders.ExportImport.ImportWizard.importedConfig[i].comment
+ comment : ModifyHeaders.ExportImport.ImportWizard.importedConfig[i].comment,
+ pattern : ModifyHeaders.ExportImport.ImportWizard.importedConfig[i].pattern
};
headers.push(header);
count++;
@@ -299,4 +306,4 @@ ModifyHeaders.ExportImport.ImportWizard = (function () {
this.retVal.importedHeaderCount = count;
}
}
-})();
\ No newline at end of file
+})();
diff --git a/src/chrome/content/importwizard.xul b/src/chrome/content/importwizard.xul
index 8e2430b..a4cc4e5 100644
--- a/src/chrome/content/importwizard.xul
+++ b/src/chrome/content/importwizard.xul
@@ -35,6 +35,7 @@
+
diff --git a/src/chrome/content/modifyheaders.js b/src/chrome/content/modifyheaders.js
index 7eaf14a..4fb207e 100644
--- a/src/chrome/content/modifyheaders.js
+++ b/src/chrome/content/modifyheaders.js
@@ -44,6 +44,7 @@ var ModifyHeaders = {
nameTextbox: null,
valueTextbox: null,
commentTextbox: null,
+ patternTextbox: null,
addButton: null,
saveButton: null,
@@ -93,6 +94,8 @@ var ModifyHeaders = {
return this.data[row].value;
} else if (column == "commentcol" || column.id == "commentcol") {
return this.data[row].comment;
+ } else if (column == "patterncol" || column.id == "patterncol") {
+ return this.data[row].pattern;
}
return null;
},
@@ -167,6 +170,7 @@ var ModifyHeaders = {
this.nameTextbox = document.getElementById("headername-text-box");
this.valueTextbox = document.getElementById("headervalue-text-box");
this.commentTextbox = document.getElementById("headercomment-text-box");
+ this.patternTextbox = document.getElementById("headerpattern-text-box");
this.addButton = document.getElementById("add-header-button");
this.saveButton = document.getElementById("save-header-button");
@@ -237,6 +241,7 @@ var ModifyHeaders = {
"name" : document.getElementById("headername-text-box").value,
"value" : document.getElementById("headervalue-text-box").value,
"comment": document.getElementById("headercomment-text-box").value,
+ "pattern": document.getElementById("headerpattern-text-box").value,
"enabled": true
}
this.headerListTreeView.data.push(header);
@@ -278,6 +283,9 @@ var ModifyHeaders = {
if (this.headerListTreeView.data[selectedRowIndex].comment != "") {
this.commentTextbox.value = this.headerListTreeView.data[selectedRowIndex].comment;
}
+ if (this.headerListTreeView.data[selectedRowIndex].pattern != "") {
+ this.patternTextbox.value = this.headerListTreeView.data[selectedRowIndex].pattern;
+ }
this.headerListTreeView.editedRowID = selectedRowIndex;
@@ -290,6 +298,7 @@ var ModifyHeaders = {
this.valueTextbox.disabled = false;
}
this.commentTextbox.disabled = false;
+ this.patternTextbox.disabled = false;
this.addButton.disabled = false;
this.saveButton.disabled = false;
}
@@ -303,6 +312,7 @@ var ModifyHeaders = {
"name" : this.nameTextbox.value,
"value" : this.valueTextbox.value,
"comment": this.commentTextbox.value,
+ "pattern": this.patternTextbox.value,
"enabled": this.headerListTreeView.data[this.headerListTreeView.editedRowID].enabled
}
this.headerListTreeView.data[this.headerListTreeView.editedRowID] = header;
@@ -332,10 +342,12 @@ var ModifyHeaders = {
this.nameTextbox.value = "";
this.valueTextbox.value = "";
this.commentTextbox.value = "";
+ this.patternTextbox.value = "";
this.nameTextbox.disabled = true;
this.valueTextbox.disabled = true;
this.commentTextbox.disabled = true;
+ this.patternTextbox.disabled = true;
this.addButton.setAttribute("hidden", "false");
this.saveButton.setAttribute("hidden", "true");
@@ -449,6 +461,7 @@ var ModifyHeaders = {
this.nameTextbox.disabled = false;
this.valueTextbox.disabled = false;
this.commentTextbox.disabled = false;
+ this.patternTextbox.disabled = false;
this.addButton.disabled = false;
this.saveButton.disabled = false;
break
@@ -457,6 +470,7 @@ var ModifyHeaders = {
this.valueTextbox.value = "";
this.valueTextbox.disabled = true;
this.commentTextbox.disabled = false;
+ this.patternTextbox.disabled = false;
this.addButton.disabled = false;
this.saveButton.disabled = false;
break
diff --git a/src/chrome/content/prefs-headers.xul b/src/chrome/content/prefs-headers.xul
index 0cdd9a9..60169c0 100644
--- a/src/chrome/content/prefs-headers.xul
+++ b/src/chrome/content/prefs-headers.xul
@@ -21,6 +21,7 @@
+
@@ -41,6 +42,8 @@
+
+
diff --git a/src/chrome/locale/en-US/modifyheaders.dtd b/src/chrome/locale/en-US/modifyheaders.dtd
index aeafb3a..8ea5a0c 100644
--- a/src/chrome/locale/en-US/modifyheaders.dtd
+++ b/src/chrome/locale/en-US/modifyheaders.dtd
@@ -86,6 +86,7 @@
+
@@ -96,12 +97,14 @@
+
+
diff --git a/src/components/modifyheaders-service.js b/src/components/modifyheaders-service.js
index e82f503..94e0519 100644
--- a/src/components/modifyheaders-service.js
+++ b/src/components/modifyheaders-service.js
@@ -29,6 +29,7 @@ if (!ModifyHeaders.Header) {
this.aComment = "";
this.aEnabled = false;
this.aSelected = true;
+ this.pattern = "";
};
ModifyHeaders.Header.prototype = {
@@ -56,8 +57,11 @@ if (!ModifyHeaders.Header) {
get selected () { return this.aSelected },
set selected (selected) { this.aSelected = selected },
+ get pattern () { return this.pattern },
+ set pattern (selected) { this.pattern = pattern },
+
equals: function (obj) {
- return (this.action.toLowerCase() == obj.action.toLowerCase() && this.name.toLowerCase() == obj.name.toLowerCase() && this.value.toLowerCase() == obj.value.toLowerCase()) ? true : false;
+ return (this.action.toLowerCase() == obj.action.toLowerCase() && this.name.toLowerCase() == obj.name.toLowerCase() && this.value.toLowerCase() == obj.value.toLowerCase() && this.pattern == obj.pattern);
}
};
}
@@ -97,7 +101,7 @@ if (!ModifyHeaders.Service) {
this.preferencesUtil.setPreference("bool", this.preferencesUtil.prefActive, active);
},
- get openAsTab () {
+ get openAsTab () {
return this.preferencesUtil.getPreference("bool", this.preferencesUtil.prefOpenAsTab);
},
@@ -180,6 +184,7 @@ if (!ModifyHeaders.Service) {
value: this.preferencesUtil.getPreference("char", this.preferencesUtil.prefHeaderValue + i),
action: this.preferencesUtil.getPreference("char", this.preferencesUtil.prefHeaderAction + i),
comment: this.preferencesUtil.getPreference("char", this.preferencesUtil.prefHeaderComment + i),
+ pattern: this.preferencesUtil.getPreference("char", this.preferencesUtil.prefHeaderPattern + i),
enabled: this.preferencesUtil.getPreference("bool", this.preferencesUtil.prefHeaderEnabled + i)
};
@@ -255,7 +260,19 @@ if (!ModifyHeaders.Proxy) {
category: "profile-after-change",
entry: "Modify Headers Proxy"
}],
-
+
+ isPatternMatch: function (header, url) {
+ try {
+ if(!header.pattern || header.pattern.length==0) {
+ return true; // pattern not set so ignore it
+ }
+ var pattern = new RegExp(".*"+header.pattern+".*", "i");
+ return pattern.test(url);
+ } catch(e) {
+ return false; // default if pattern is invalid
+ }
+ },
+
// nsIObserver interface method
observe: function (subject, topic, data) {
if (topic == 'http-on-modify-request') {
@@ -265,9 +282,11 @@ if (!ModifyHeaders.Proxy) {
// TODO Fetch only enabled headers
var headers = JSON.parse(this.modifyheadersService.getHeaders());
+ var url = subject.URI.spec;
+
// TODO See if a foreach is better here
for (var i=0; i < headers.length; i++) {
- if (headers[i].enabled) {
+ if (headers[i].enabled && this.isPatternMatch(headers[i], url)) {
var headerName = headers[i].name;
// This is the default for action = Modify
@@ -329,6 +348,7 @@ if (!ModifyHeaders.PreferencesUtil) {
this.prefHeaderName = "modifyheaders.headers.name";
this.prefHeaderValue = "modifyheaders.headers.value";
this.prefHeaderComment = "modifyheaders.headers.comment";
+ this.prefHeaderPattern = "modifyheaders.headers.pattern";
this.prefMigratedHeaders = "modifyheaders.config.migrated";
this.prefOpenAsTab = "modifyheaders.config.openNewTab";
};
diff --git a/src/interface/mhIHeader.idl b/src/interface/mhIHeader.idl
index 8d4cff5..682de5c 100644
--- a/src/interface/mhIHeader.idl
+++ b/src/interface/mhIHeader.idl
@@ -5,9 +5,10 @@ interface mhIHeader : nsISupports
attribute string action;
attribute string name;
attribute string value;
- attribute string comment;
+ attribute string comment;
attribute boolean enabled;
attribute boolean selected;
+ attribute string pattern;
boolean equals(in mhIHeader obj);
-};
\ No newline at end of file
+};
diff --git a/src/interface/nsIModifyheaders.idl b/src/interface/nsIModifyheaders.idl
index c85e5a4..423076b 100644
--- a/src/interface/nsIModifyheaders.idl
+++ b/src/interface/nsIModifyheaders.idl
@@ -1,15 +1,15 @@
-#include "nsISupports.idl"
-
-interface mhIHeader;
-
-[scriptable, uuid(feb80fc3-9e72-4fc5-bc72-986957ada6cc)]
-interface nsIModifyheaders : nsISupports
-{
- attribute unsigned long count;
- attribute boolean active;
- attribute boolean openAsTab;
- attribute boolean windowOpen;
-
- string getHeaders();
- void saveHeaders(in string headersJSON);
-};
\ No newline at end of file
+#include "nsISupports.idl"
+
+interface mhIHeader;
+
+[scriptable, uuid(feb80fc3-9e72-4fc5-bc72-986957ada6cc)]
+interface nsIModifyheaders : nsISupports
+{
+ attribute unsigned long count;
+ attribute boolean active;
+ attribute boolean openAsTab;
+ attribute boolean windowOpen;
+
+ string getHeaders();
+ void saveHeaders(in string headersJSON);
+};