diff --git a/mozilla/extensions/cck/browser/install.rdf b/mozilla/extensions/cck/browser/install.rdf new file mode 100755 index 00000000000..80c5fa595de --- /dev/null +++ b/mozilla/extensions/cck/browser/install.rdf @@ -0,0 +1,24 @@ + + + + + cckwizard@extensions.mozilla.org + CCK Wizard + 1.0.3 + + Michael Kaply + http://www.mozilla.org/projects/cck/firefox + chrome://cckwizard/content/cckwizard.png + + + + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} + 1.5 + 3.0 + + + + + + diff --git a/mozilla/extensions/cck/browser/locales/en-US/chrome/cckWizard.dtd b/mozilla/extensions/cck/browser/locales/en-US/chrome/cckWizard.dtd new file mode 100755 index 00000000000..787e50d98cf --- /dev/null +++ b/mozilla/extensions/cck/browser/locales/en-US/chrome/cckWizard.dtd @@ -0,0 +1,256 @@ + + + + + + Custom animation files for browser's animated logo + Search engines (SRC files and the corresponding images) + Browser plug-ins + Extensions/themes + "> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Mozilla Firefox: Companyname Edition"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +IMPORTANT: If you add certificates to Firefox, you CANNOT + ship a browser outside of your company or institution and call it Firefox. + This feature is intended primarily for corporate and institutional users + that will be deploying Firefox inside their organization."> + + + + + + + + + + +IMPORTANT: If you add extensions and/or themes to your CCK, + you can no longer install the CCK as part of a Firefox install. You must + install through the browser or use the -install-global-extension mechanism. + "> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mozilla/extensions/cck/browser/locales/en-US/chrome/cckwizard.properties b/mozilla/extensions/cck/browser/locales/en-US/chrome/cckwizard.properties new file mode 100755 index 00000000000..2af15e9d25d --- /dev/null +++ b/mozilla/extensions/cck/browser/locales/en-US/chrome/cckwizard.properties @@ -0,0 +1,22 @@ +windowTitle=Firefox CCK +deleteConfirm=Are you sure you want to delete this configuration? +outputLocation=Firefox CCK Wizard is completed. XPI is available at:\n +cancelConfirm=Do you want to save your changes? +zipError=Unable to create JAR or XPI file. Please ensure that a command line version of ZIP is in your path or that you have specified a path to ZIP. +intError=The value must be an integer +lockError=You cannot set this value here, you can only lock it. +prefExistsError=This preference already exists in the list. +chooseFile=Choose File... +chooseDirectory=Choose Directory... +chooseImage=Choose Image... +createDir=The following directory does not exist: %S\nWould you like to create it? +createDirError=Could not create folder: %S\nMake sure you have access to create the folder. +extensions.cckwizard@extensions.mozilla.org.description=XUL Wizard to create CCK Packages +id.error=Unique ID is required and is of the format extensionname@organization.tld. It can only contain the letters a-z, the numbers 0-9, and the following symbols: . _ - +name.error=Name is required +version.error=Version is required +orgName.error=Company Identifier is required and cannot contain any spaces. +BookmarkFolder1.error=You must specify a folder name +ToolbarFolder1.error=You must specify a folder name + + diff --git a/mozilla/extensions/cck/browser/resources/content/cckwizard/cckwizard.js b/mozilla/extensions/cck/browser/resources/content/cckwizard/cckwizard.js new file mode 100755 index 00000000000..cc20eda07a6 --- /dev/null +++ b/mozilla/extensions/cck/browser/resources/content/cckwizard/cckwizard.js @@ -0,0 +1,2582 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Client Customization Kit (CCK). + * + * The Initial Developer of the Original Code is IBM Corp. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * 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 + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var currentconfigname; +var currentconfigpath; +var configarray = new Array(); + +const nsIPrefBranch = Components.interfaces.nsIPrefBranch; +var gPrefBranch = Components.classes["@mozilla.org/preferences-service;1"] + .getService(nsIPrefBranch); + +var gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + +function choosefile(labelname) +{ + try { + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + var bundle = document.getElementById("bundle_cckwizard"); + fp.init(window, bundle.getString("chooseFile"), nsIFilePicker.modeOpen); + fp.appendFilters(nsIFilePicker.filterAll); + + if (fp.show() == nsIFilePicker.returnOK && fp.fileURL.spec && fp.fileURL.spec.length > 0) { + var label = document.getElementById(labelname); + label.value = fp.file.path; + } + } + catch(ex) { + } +} + +function choosedir(labelname) +{ + try { + var keepgoing = true; + while (keepgoing) { + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + var bundle = document.getElementById("bundle_cckwizard"); + fp.init(window, bundle.getString("chooseDirectory"), nsIFilePicker.modeGetFolder); + fp.appendFilters(nsIFilePicker.filterHTML | nsIFilePicker.filterText | + nsIFilePicker.filterAll | nsIFilePicker.filterImages | nsIFilePicker.filterXML); + + if (fp.show() == nsIFilePicker.returnOK && fp.fileURL.spec && fp.fileURL.spec.length > 0) { + var label = document.getElementById(labelname); + label.value = fp.file.path; + } + keepgoing = false; + } + } + catch(ex) { + } +} + +function chooseimage(labelname, imagename) +{ + try { + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + var bundle = document.getElementById("bundle_cckwizard"); + fp.init(window, bundle.getString("chooseImage"), nsIFilePicker.modeOpen); + fp.appendFilters(nsIFilePicker.filterImages); + + if (fp.show() == nsIFilePicker.returnOK && fp.fileURL.spec && fp.fileURL.spec.length > 0) { + var label = document.getElementById(labelname); + label.value = fp.file.path; + document.getElementById(imagename).src = fp.fileURL.spec; + } + } + catch(ex) { + } +} + +function initimage(labelname, imagename) +{ + var sourcefile = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + try { + sourcefile.initWithPath(document.getElementById(labelname).value); + var ioServ = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + var foo = ioServ.newFileURI(sourcefile); + document.getElementById(imagename).src = foo.spec; + } catch (e) { + document.getElementById(imagename).src = ''; + } +} + + + +function CreateConfig() +{ + window.openDialog("chrome://cckwizard/content/config.xul","createconfig","chrome,centerscreen,modal"); + updateconfiglist(); +} + +function CopyConfig() +{ + window.openDialog("chrome://cckwizard/content/config.xul","copyconfig","chrome,centerscreen,modal"); + + updateconfiglist(); +} + +function DeleteConfig() +{ + var bundle = document.getElementById("bundle_cckwizard"); + + var button = gPromptService.confirmEx(window, bundle.getString("windowTitle"), bundle.getString("deleteConfirm"), + gPromptService.BUTTON_TITLE_YES * gPromptService.BUTTON_POS_0 + + gPromptService.BUTTON_TITLE_NO * gPromptService.BUTTON_POS_1, + null, null, null, null, {}); + if (button == 0) { + gPrefBranch.deleteBranch("cck.config."+currentconfigname); + currentconfigname = ""; + currentconfigpath = ""; + updateconfiglist(); + } +} + +function SetSaveOnExitPref() +{ + gPrefBranch.setBoolPref("cck.save_on_exit", document.getElementById("saveOnExit").checked); +} + +function OpenCCKWizard() +{ + try { + document.getElementById("saveOnExit").checked = gPrefBranch.getBoolPref("cck.save_on_exit"); + } catch (ex) { + } + try { + document.getElementById("zipLocation").value = gPrefBranch.getCharPref("cck.path_to_zip"); + } catch (ex) { + } + + +} + +function ShowMain() +{ + document.getElementById('example-window').canRewind = false; + updateconfiglist(); +} + +function updateconfiglist() +{ + var menulist = document.getElementById('byb-configs') + menulist.selectedIndex = -1; + menulist.removeAllItems(); + var configname; + var selecteditem = false; + + + + var list = gPrefBranch.getChildList("cck.config.", {}); + for (var i = 0; i < list.length; ++i) { + configname = list[i].replace(/cck.config./g, ""); + var menulistitem = menulist.appendItem(configname,configname); + menulistitem.minWidth=menulist.width; + if (configname == currentconfigname) { + menulist.selectedItem = menulistitem; + selecteditem = true; + document.getElementById('example-window').canAdvance = true; + document.getElementById('byb-configs').disabled = false; + document.getElementById('deleteconfig').disabled = false; + document.getElementById('showconfig').disabled = false; + document.getElementById('copyconfig').disabled = false; + } + } + if ((!selecteditem) && (list.length > 0)) { + menulist.selectedIndex = 0; + setcurrentconfig(list[0].replace(/cck.config./g, "")); + } + if (list.length == 0) { + document.getElementById('example-window').canAdvance = false; + document.getElementById('byb-configs').disabled = true; + document.getElementById('deleteconfig').disabled = true; + document.getElementById('showconfig').disabled = true; + document.getElementById('copyconfig').disabled = true; + currentconfigname = ""; + currentconfigpath = ""; + } +} + +function setcurrentconfig(newconfig) +{ + var destdir = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + + if (currentconfigpath) { + destdir.initWithPath(currentconfigpath); + CCKWriteConfigFile(destdir); + } + currentconfigname = newconfig; + currentconfigpath = gPrefBranch.getCharPref("cck.config." + currentconfigname); + destdir.initWithPath(currentconfigpath); + ClearAll(); + CCKReadConfigFile(destdir); +} + +function saveconfig() +{ + + + if (currentconfigpath) { + var destdir = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + + + + destdir.initWithPath(currentconfigpath); + CCKWriteConfigFile(destdir); + } + +} + +function CloseCCKWizard() +{ + if (document.getElementById('example-window').pageIndex == 0) + return; + var saveOnExit; + try { + saveOnExit = gPrefBranch.getBoolPref("cck.save_on_exit"); + } catch (ex) { + saveOnExit = false; + } + + var button; + if (!saveOnExit) { + var bundle = document.getElementById("bundle_cckwizard"); + + var button = gPromptService.confirmEx(window, bundle.getString("windowTitle"), bundle.getString("cancelConfirm"), + (gPromptService.BUTTON_TITLE_YES * gPromptService.BUTTON_POS_0) + + (gPromptService.BUTTON_TITLE_NO * gPromptService.BUTTON_POS_1), + null, null, null, null, {}); + } else { + button = 0; + } + + if (button == 0) { + saveconfig(); + } + gPrefBranch.setCharPref("cck.path_to_zip", document.getElementById("zipLocation").value); +} + + +function OnConfigLoad() +{ + configCheckOKButton(); +} + + +function ClearAll() +{ + /* clear out all data */ + var elements = document.getElementsByAttribute("id", "*"); + for (var i=0; i < elements.length; i++) { + if ((elements[i].nodeName == "textbox") || + (elements[i].nodeName == "radiogroup") || + (elements[i].id == "RootKey1") || + (elements[i].id == "Type1")) { + if ((elements[i].id != "saveOnExit") && (elements[i].id != "zipLocation")) { + elements[i].value = ""; + } + } else if (elements[i].nodeName == "checkbox") { + if (elements[i].id != "saveOnExit") + elements[i].checked = false; + } else if (elements[i].className == "ccklist") { + document.getElementById(elements[i].id).clear(); + } + } +} + +function OnConfigOK() +{ + if (!(ValidateDir('cnc-location'))) { + return false; + } + var configname = document.getElementById('cnc-name').value; + var configlocation = document.getElementById('cnc-location').value; + if (window.name == 'copyconfig') { + var destdir = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + destdir.initWithPath(configlocation); + this.opener.CCKWriteConfigFile(destdir); + } + gPrefBranch.setCharPref("cck.config." + configname, configlocation); + this.opener.setcurrentconfig(configname); + +} + +function configCheckOKButton() +{ + if ((document.getElementById("cnc-name").value) && (document.getElementById("cnc-location").value)) { + document.documentElement.getButton("accept").setAttribute( "disabled", "false" ); + } else { + document.documentElement.getButton("accept").setAttribute( "disabled", "true" ); + } +} + +function onNewPreference() +{ + window.openDialog("chrome://cckwizard/content/pref.xul","newpref","chrome,centerscreen,modal"); +} + +function onEditPreference() +{ + window.openDialog("chrome://cckwizard/content/pref.xul","editpref","chrome,centerscreen,modal"); +} + +function OnPrefLoad() +{ + listbox = this.opener.document.getElementById('prefList'); + if (window.name == 'editpref') { + window.title = listbox.selectedItem.cck['type']; + if (listbox.selectedItem.cck['type'] == "integer") { + document.getElementById('prefvalue').preftype = nsIPrefBranch.PREF_INT; + } + document.getElementById('prefname').value = listbox.selectedItem.label; + document.getElementById('prefvalue').value = listbox.selectedItem.value; + document.getElementById('prefname').disabled = true; + if (listbox.selectedItem.cck['lock'] == "true") + document.getElementById('lockPref').checked = true; + if (listbox.selectedItem.cck['type'] == "boolean") { + document.getElementById('prefvalue').hidden = true; + document.getElementById('prefvalueboolean').hidden = false; + document.getElementById('prefvalueboolean').value = listbox.selectedItem.value; + } + } + prefCheckOKButton(); + +} + +function prefCheckOKButton() +{ + if (document.getElementById("prefname").value) { + document.documentElement.getButton("accept").setAttribute( "disabled", "false" ); + } else { + document.documentElement.getButton("accept").setAttribute( "disabled", "true" ); + } +} + +function prefSetPrefValue() +{ + var prefname = document.getElementById('prefname').value; + try { + var preftype = gPrefBranch.getPrefType(prefname); + switch (preftype) { + case nsIPrefBranch.PREF_STRING: + document.getElementById('prefvalue').value = gPrefBranch.getCharPref(prefname); + document.getElementById('prefvalue').hidden = false; + document.getElementById('prefvalueboolean').hidden = true; + document.getElementById('prefvalue').preftype = nsIPrefBranch.PREF_STRING; + break; + case nsIPrefBranch.PREF_INT: + document.getElementById('prefvalue').value = gPrefBranch.getIntPref(prefname); + document.getElementById('prefvalue').hidden = false; + document.getElementById('prefvalueboolean').hidden = true; + document.getElementById('prefvalue').preftype = nsIPrefBranch.PREF_INT; + break; + case nsIPrefBranch.PREF_BOOL: + document.getElementById('prefvalue').value = gPrefBranch.getBoolPref(prefname); + document.getElementById('prefvalue').hidden = true; + document.getElementById('prefvalueboolean').hidden = false; + document.getElementById('prefvalueboolean').value = gPrefBranch.getBoolPref(prefname); + document.getElementById('prefvalue').preftype = nsIPrefBranch.PREF_BOOL; + break; + default: + document.getElementById('prefvalue').hidden = false; + document.getElementById('prefvalueboolean').hidden = true; + break; + } + } catch (ex) { + document.getElementById('prefvalue').hidden = false; + document.getElementById('prefvalueboolean').hidden = true; + } +} + +function OnPrefOK() +{ + var bundle = this.opener.document.getElementById("bundle_cckwizard"); + + listbox = this.opener.document.getElementById("prefList"); + for (var i=0; i < listbox.getRowCount(); i++) { + if ((document.getElementById('prefname').value == listbox.getItemAtIndex(i).label) && (window.name == 'newpref')) { + gPromptService.alert(window, bundle.getString("windowTitle"), + bundle.getString("prefExistsError")); + return false; + } + } + + + + if (((document.getElementById('prefname').value == "browser.startup.homepage") || (document.getElementById('prefname').value == "browser.throbber.url")) && + (document.getElementById('prefvalue').value.length > 0)) { + gPromptService.alert(window, bundle.getString("windowTitle"), + bundle.getString("lockError")); + return false; + } + + var value = document.getElementById('prefvalue').value; + + if (document.getElementById('prefvalue').preftype == nsIPrefBranch.PREF_INT) { + if (parseInt(value) != value) { + gPromptService.alert(window, bundle.getString("windowTitle"), + bundle.getString("intError")); + return false; + } + } + + listbox = this.opener.document.getElementById('prefList'); + var listitem; + if (window.name == 'newpref') { + var preftype; + if ((value.toLowerCase() == "true") || (value.toLowerCase() == "false")) { + preftype = "boolean"; + } else if (parseInt(value) == value) { + preftype = "integer"; + } else { + preftype = "string"; + if (value.charAt(0) == '"') + value = value.substring(1,value.length); + if (value.charAt(value.length-1) == '"') + if (value.charAt(value.length-2) != '\\') + value = value.substring(0,value.length-1); + } + listitem = listbox.appendItem(document.getElementById('prefname').value, value); + listitem.cck['type'] = preftype; + } else { + listitem = listbox.selectedItem; + listitem.setAttribute("label", document.getElementById('prefname').value); + value = document.getElementById('prefvalue').value; + if (value.charAt(0) == '"') + value = value.substring(1,value.length); + if (value.charAt(value.length-1) == '"') + if (value.charAt(value.length-2) != '\\') + value = value.substring(0,value.length-1); + listitem.setAttribute("value", value); + } + if (document.getElementById('lockPref').checked) { + listitem.cck['lock'] = "true"; + } else { + listitem.cck['lock'] = ""; + } +} + +function getPageId() +{ + temp = document.getElementById('example-window'); + if (!temp) + temp = this.opener.document.getElementById('example-window'); + return temp.currentPage.id; +} + + +function onNewBookmark() +{ + window.openDialog("chrome://cckwizard/content/bookmark.xul","newbookmark","chrome,centerscreen,modal"); +} + +function onEditBookmark() +{ + window.openDialog("chrome://cckwizard/content/bookmark.xul","editbookmark","chrome,centerscreen,modal"); +} + +function OnBookmarkLoad() +{ + listbox = this.opener.document.getElementById(getPageId() +'.bookmarkList'); + if (window.name == 'editbookmark') { + document.getElementById('bookmarkname').value = listbox.selectedItem.label; + document.getElementById('bookmarkurl').value = listbox.selectedItem.value; + if (listbox.selectedItem.cck['type'] == "live") + document.getElementById('liveBookmark').checked = true; + } + bookmarkCheckOKButton(); +} + +function bookmarkCheckOKButton() +{ + if ((document.getElementById("bookmarkname").value) && (document.getElementById("bookmarkurl").value)) { + document.documentElement.getButton("accept").setAttribute( "disabled", "false" ); + } else { + document.documentElement.getButton("accept").setAttribute( "disabled", "true" ); + } +} + +function OnBookmarkOK() +{ + + listbox = this.opener.document.getElementById(getPageId() +'.bookmarkList'); + var listitem; + if (window.name == 'newbookmark') { + listitem = listbox.appendItem(document.getElementById('bookmarkname').value, document.getElementById('bookmarkurl').value); + listitem.setAttribute("class", "listitem-iconic"); + } else { + listitem = listbox.selectedItem; + listitem.setAttribute("label", document.getElementById('bookmarkname').value); + listitem.setAttribute("value", document.getElementById('bookmarkurl').value); + } + if (document.getElementById('liveBookmark').checked) { + listitem.cck['type'] = "live"; + listitem.setAttribute("image", "chrome://browser/skin/page-livemarks.png"); + } else { + listitem.setAttribute("image", "chrome://browser/skin/Bookmarks-folder.png"); + listitem.cck['type'] = ""; + } +} + +function enableBookmarkButtons() { + listbox = document.getElementById(getPageId() +'.bookmarkList'); + if (listbox.selectedItem) { + document.getElementById(getPageId() +'editBookmarkButton').disabled = false; + document.getElementById(getPageId() +'deleteBookmarkButton').disabled = false; + } else { + document.getElementById(getPageId() +'editBookmarkButton').disabled = true; + document.getElementById(getPageId() +'deleteBookmarkButton').disabled = true; + } +} + +function onNewBrowserPlugin() +{ + window.openDialog("chrome://cckwizard/content/plugin.xul","newplugin","chrome,centerscreen,modal"); +} + +function onEditBrowserPlugin() +{ + window.openDialog("chrome://cckwizard/content/plugin.xul","editplugin","chrome,centerscreen,modal"); +} + +function OnPluginLoad() +{ + listbox = this.opener.document.getElementById('browserPluginList'); + if (window.name == 'editplugin') { + document.getElementById('pluginpath').value = listbox.selectedItem.label; + document.getElementById('plugintype').value = listbox.selectedItem.value; + } + pluginCheckOKButton(); + +} + +function pluginCheckOKButton() +{ + if (document.getElementById("pluginpath").value) { + document.documentElement.getButton("accept").setAttribute( "disabled", "false" ); + } else { + document.documentElement.getButton("accept").setAttribute( "disabled", "true" ); + } +} + +function OnBrowserPluginOK() +{ + if (!(ValidateFile('pluginpath'))) { + return false; + } + + listbox = this.opener.document.getElementById('browserPluginList'); + if (window.name == 'newplugin') { + listitem = listbox.appendItem(document.getElementById('pluginpath').value, document.getElementById('plugintype').value); + } else { + listbox.selectedItem.label = document.getElementById('pluginpath').value; + listbox.selectedItem.value = document.getElementById('plugintype').selectedItem.value; + } +} + +function onNewRegKey() +{ + window.openDialog("chrome://cckwizard/content/reg.xul","newreg","chrome,centerscreen,modal"); +} + +function onEditRegKey() +{ + window.openDialog("chrome://cckwizard/content/reg.xul","editreg","chrome,centerscreen,modal"); +} + +function OnRegLoad() +{ + listbox = this.opener.document.getElementById('regList'); + if (window.name == 'editreg') { + document.getElementById('PrettyName').value = listbox.selectedItem.label; + document.getElementById('RootKey').value = listbox.selectedItem.cck['rootkey']; + document.getElementById('Key').value = listbox.selectedItem.cck['key']; + document.getElementById('Name').value = listbox.selectedItem.cck['name']; + document.getElementById('NameValue').value = listbox.selectedItem.cck['namevalue']; + document.getElementById('Type').value = listbox.selectedItem.cck['type']; + } + regCheckOKButton(); +} + +function regCheckOKButton() +{ + if ((document.getElementById("PrettyName").value) && + (document.getElementById("Key").value) && + (document.getElementById("Name").value) && + (document.getElementById("NameValue").value)) { + document.documentElement.getButton("accept").setAttribute( "disabled", "false" ); + } else { + document.documentElement.getButton("accept").setAttribute( "disabled", "true" ); + } +} + +function OnRegOK() +{ + listbox = this.opener.document.getElementById('regList'); + var listitem; + if (window.name == 'newreg') { + listitem = listbox.appendItem(document.getElementById('PrettyName').value, ""); + } else { + listitem = listbox.selectedItem; + listitem.setAttribute("label", document.getElementById('PrettyName').value); + } + listitem.cck['rootkey'] = document.getElementById('RootKey').value; + listitem.cck['key'] = document.getElementById('Key').value; + listitem.cck['name'] = document.getElementById('Name').value; + listitem.cck['namevalue'] = document.getElementById('NameValue').value; + listitem.cck['type'] = document.getElementById('Type').value; +} + +function onNewSearchEngine() +{ + window.openDialog("chrome://cckwizard/content/searchengine.xul","newsearchengine","chrome,centerscreen,modal"); +} + +function onEditSearchEngine() +{ + window.openDialog("chrome://cckwizard/content/searchengine.xul","editsearchengine","chrome,centerscreen,modal"); +} + +function OnSearchEngineLoad() +{ + listbox = this.opener.document.getElementById('searchEngineList'); + if (window.name == 'editsearchengine') { + document.getElementById('searchengine').value = listbox.selectedItem.label; + document.getElementById('searchengineicon').value = listbox.selectedItem.value; + document.getElementById('icon').src = listbox.selectedItem.value; + } + searchEngineCheckOKButton(); + +} + +function searchEngineCheckOKButton() +{ + if ((document.getElementById("searchengine").value) && (document.getElementById("searchengineicon").value)) { + document.documentElement.getButton("accept").setAttribute( "disabled", "false" ); + } else { + document.documentElement.getButton("accept").setAttribute( "disabled", "true" ); + } +} + +function OnSearchEngineOK() +{ + if (!(ValidateFile('searchengine', 'searchengineicon'))) { + return false; + } + + + + listbox = this.opener.document.getElementById('searchEngineList'); + var listitem; + if (window.name == 'newsearchengine') { + listitem = listbox.appendItem(document.getElementById('searchengine').value, document.getElementById('searchengineicon').value); + listitem.setAttribute("class", "listitem-iconic"); + } else { + listitem = listbox.selectedItem; + listbox.selectedItem.label = document.getElementById('searchengine').value; + listbox.selectedItem.value = document.getElementById('searchengineicon').value; + } + var sourcefile = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + sourcefile.initWithPath(document.getElementById('searchengineicon').value); + var ioServ = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + var imgfile = ioServ.newFileURI(sourcefile); + listitem.setAttribute("image", imgfile.spec); +} + +function onNewCert() +{ + window.openDialog("chrome://cckwizard/content/cert.xul","newcert","chrome,centerscreen,modal"); +} + +function onEditCert() +{ + window.openDialog("chrome://cckwizard/content/cert.xul","editcert","chrome,centerscreen,modal") +} + +function OnCertLoad() +{ + listbox = this.opener.document.getElementById('certList'); + if (window.name == 'editcert') { + document.getElementById('certpath').value = listbox.selectedItem.label; + var trustString = listbox.selectedItem.value; + if (trustString.charAt(0) == 'C') { + document.getElementById("trustSSL").checked = true; + } + if (trustString.charAt(2) == 'C') { + document.getElementById("trustEmail").checked = true; + } + if (trustString.charAt(4) == 'C') { + document.getElementById("trustObjSign").checked = true; + } + } + certCheckOKButton(); +} + +function certCheckOKButton() +{ + if (document.getElementById("certpath").value) { + document.documentElement.getButton("accept").setAttribute( "disabled", "false" ); + } else { + document.documentElement.getButton("accept").setAttribute( "disabled", "true" ); + } +} + +function OnCertOK() +{ + if (!(ValidateFile('certpath'))) { + return false; + } + + var trustString = ""; + if (document.getElementById("trustSSL").checked) { + trustString += "C," + } else { + trustString += "c," + } + if (document.getElementById("trustEmail").checked) { + trustString += "C," + } else { + trustString += "c," + } + if (document.getElementById("trustObjSign").checked) { + trustString += "C" + } else { + trustString += "c" + } + + listbox = this.opener.document.getElementById('certList'); + var listitem; + if (window.name == 'newcert') { + listitem = listbox.appendItem(document.getElementById('certpath').value, trustString); + } else { + listitem = listbox.selectedItem; + listbox.selectedItem.label = document.getElementById('certpath').value; + listbox.selectedItem.value = trustString; + } +} + + + + +function onNewBundle() +{ + try { + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + fp.init(window, "Choose File...", nsIFilePicker.modeOpen); + fp.appendFilters(nsIFilePicker.filterHTML | nsIFilePicker.filterText | + nsIFilePicker.filterAll | nsIFilePicker.filterImages | nsIFilePicker.filterXML); + + if (fp.show() == nsIFilePicker.returnOK && fp.fileURL.spec && fp.fileURL.spec.length > 0) { + listbox = document.getElementById('bundleList'); + listitem = listbox.appendItem(fp.file.path, ""); + } + } + catch(ex) { + } +} + +function onEditBundle() +{ + listbox = document.getElementById('bundleList'); + filename = listbox.selectedItem.label; + var sourcefile = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + try { + sourcefile.initWithPath(filename); + var ioServ = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + + } catch (ex) { + } + + try { + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + var bundle = document.getElementById("bundle_cckwizard"); + fp.init(window, bundle.getString("chooseFile"), nsIFilePicker.modeOpen); + fp.displayDirectory = sourcefile.parent; + fp.defaultString = sourcefile.leafName; + fp.appendFilters(nsIFilePicker.filterAll); + if (fp.show() == nsIFilePicker.returnOK && fp.fileURL.spec && fp.fileURL.spec.length > 0) { + listbox.selectedItem.label = fp.file.path; + } + } + catch(ex) { + } +} + +function CreateCCK() +{ + gPrefBranch.setCharPref("cck.path_to_zip", document.getElementById("zipLocation").value); +/* ---------- */ + var destdir = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + destdir.initWithPath(currentconfigpath); + + CCKWriteConfigFile(destdir); + + destdir.append("jar"); + try { + destdir.remove(true); + } catch(ex) {} + + destdir.append("content"); + destdir.append("cck"); + try { + destdir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0775); + } catch(ex) {} + + CCKWriteXULOverlay(destdir); + CCKWriteDTD(destdir); + CCKWriteCSS(destdir); + CCKWriteProperties(destdir); + CCKCopyFile(document.getElementById("iconURL").value, destdir); + CCKCopyFile(document.getElementById("LargeAnimPath").value, destdir); + CCKCopyFile(document.getElementById("LargeStillPath").value, destdir); + CCKCopyChromeToFile("cck.js", destdir) + if (document.getElementById("noaboutconfig").checked) + CCKCopyChromeToFile("cck-config.css", destdir) + + listbox = document.getElementById('certList'); + + for (var i=0; i < listbox.getRowCount(); i++) { + listitem = listbox.getItemAtIndex(i); + CCKCopyFile(listitem.getAttribute("label"), destdir); + } + +/* copy/create contents.rdf if 1.0 */ + var zipdir = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + zipdir.initWithPath(currentconfigpath); + zipdir.append("jar"); + CCKZip("cck.jar", zipdir, "content"); + +/* ---------- */ + + destdir.initWithPath(currentconfigpath); + destdir.append("xpi"); + try { + destdir.remove(true); + } catch(ex) {} + try { + destdir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0775); + } catch(ex) {} + + CCKWriteConfigFile(destdir); + destdir.append("chrome"); + try { + destdir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0775); + } catch(ex) {} + + zipdir.append("cck.jar"); + + CCKCopyFile(zipdir.path, destdir); + +/* ---------- */ + + destdir.initWithPath(currentconfigpath); + destdir.append("xpi"); + destdir.append("components"); + try { + destdir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0775); + } catch(ex) {} + + CCKCopyChromeToFile("cckService.js", destdir); + if (document.getElementById("noaboutconfig").checked) + CCKCopyChromeToFile("disableAboutConfig.js", destdir); + +/* ---------- */ + + destdir.initWithPath(currentconfigpath); + destdir.append("xpi"); + destdir.append("defaults"); + destdir.append("preferences"); + try { + destdir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0775); + } catch(ex) {} + + CCKWriteDefaultJS(destdir) + +/* ---------- */ + + destdir.initWithPath(currentconfigpath); + destdir.append("xpi"); + destdir.append("platform"); + try { + destdir.remove(true); + destdir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0775); + } catch(ex) {} + + listbox = document.getElementById('browserPluginList'); + + for (var i=0; i < listbox.getRowCount(); i++) { + listitem = listbox.getItemAtIndex(i); + var pluginsubdir = destdir.clone(); + /* If there is no value, assume windows - this should only happen for migration */ + if (listitem.getAttribute("value")) { + pluginsubdir.append(listitem.getAttribute("value")); + } else { + pluginsubdir.append("WINNT_x86-msvc"); + } + pluginsubdir.append("plugins"); + try { + pluginsubdir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0775); + } catch(ex) {} + CCKCopyFile(listitem.getAttribute("label"), pluginsubdir); + } + + destdir.initWithPath(currentconfigpath); + destdir.append("xpi"); + destdir.append("searchplugins"); + try { + destdir.remove(true); + destdir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0775); + } catch(ex) {} + + listbox = document.getElementById('searchEngineList'); + + for (var i=0; i < listbox.getRowCount(); i++) { + listitem = listbox.getItemAtIndex(i); + CCKCopyFile(listitem.getAttribute("label"), destdir); + CCKCopyFile(listitem.getAttribute("value"), destdir); + } + + destdir.initWithPath(currentconfigpath); + destdir.append("xpi"); + + CCKCopyChromeToFile("chrome.manifest", destdir) + CCKWriteInstallRDF(destdir); + + CCKWriteInstallJS(destdir); + var filename = document.getElementById("filename").value; + if (filename.length == 0) + filename = "cck"; + filename += ".xpi"; + + CCKZip("cck.xpi", destdir, + "chrome", "components", "defaults", "platform", "searchplugins", "chrome.manifest", "install.rdf", "install.js", "cck.config"); + + var outputdir = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + + outputdir.initWithPath(currentconfigpath); + destdir.append("cck.xpi"); + + if (document.getElementById('bundleList').getRowCount() == 0) { + outputdir.append(filename); + try { + outputdir.remove(true); + } catch(ex) {} + outputdir = outputdir.parent; + destdir.copyTo(outputdir, filename); + } else { + var packagedir = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + + packagedir.initWithPath(currentconfigpath); + packagedir.append("package"); + + try { + packagedir.remove(true); + packagedir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0775); + } catch(ex) {} + + CCKCopyFile(destdir.path, packagedir); + + listbox = document.getElementById('bundleList'); + + for (var i=0; i < listbox.getRowCount(); i++) { + listitem = listbox.getItemAtIndex(i); + CCKCopyFile(listitem.getAttribute("label"), packagedir); + } + + CCKCopyChromeToFile("install.rdf.mip", packagedir) + + packagedir.append("install.rdf.mip"); + packagedir.moveTo(packagedir.parent, "install.rdf"); + + packagedir = packagedir.parent; + + CCKZip("cck.zip", packagedir, "*.xpi", "*.jar", "install.rdf"); + packagedir.append("cck.zip"); + outputdir.append(filename); + try { + outputdir.remove(true); + } catch(ex) {} + outputdir = outputdir.parent; + packagedir.copyTo(outputdir, filename); + } + + var bundle = document.getElementById("bundle_cckwizard"); + + outputdir.append(filename); + + gPromptService.alert(window, bundle.getString("windowTitle"), + bundle.getString("outputLocation") + outputdir.path); +} + +/* This function takes a file in the chromedir and creates a real file */ + +function CCKCopyChromeToFile(chromefile, location) +{ + var file = location.clone(); + file.append(chromefile); + + try { + file.remove(false); + } catch (ex) { + } + var fos = Components.classes["@mozilla.org/network/file-output-stream;1"] + .createInstance(Components.interfaces.nsIFileOutputStream); + + fos.init(file, -1, -1, false); + + var ioService=Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + var scriptableStream=Components + .classes["@mozilla.org/scriptableinputstream;1"] + .getService(Components.interfaces.nsIScriptableInputStream); + + var channel=ioService.newChannel("chrome://cckwizard/content/srcfiles/" + chromefile + ".in",null,null); + var input=channel.open(); + scriptableStream.init(input); + var str=scriptableStream.read(input.available()); + scriptableStream.close(); + input.close(); + + fos.write(str, str.length); + fos.close(); +} + + +/* This function creates a given zipfile in a given location */ +/* It takes as parameters the names of all the files/directories to be contained in the ZIP file */ +/* It works by creating a CMD file to generate the ZIP */ +/* unless we have the spiffy ZipWriterCompoent from maf.mozdev.org */ + +function CCKZip(zipfile, location) +{ + var file = location.clone(); + file.append(zipfile); + try { + file.remove(false); + } catch (ex) {} + + if ((document.getElementById("zipLocation").value == "") && (Components.interfaces.IZipWriterComponent)) { + var archivefileobj = location.clone(); + archivefileobj.append(zipfile); + + try { + var zipwriterobj = Components.classes["@ottley.org/libzip/zip-writer;1"] + .createInstance(Components.interfaces.IZipWriterComponent); + + zipwriterobj.CURR_COMPRESS_LEVEL = Components.interfaces.IZipWriterComponent.COMPRESS_LEVEL9; + + var sourcepathobj = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + sourcepathobj.initWithPath(location.path); + + zipwriterobj.init(archivefileobj); + + zipwriterobj.basepath = sourcepathobj; + + var zipentriestoadd = new Array(); + + for (var i=2; i < arguments.length; i++) { + var sourcepathobj = location.clone(); + sourcepathobj.append(arguments[i]); + if (sourcepathobj.exists() && sourcepathobj.isDirectory()) { + var entries = sourcepathobj.directoryEntries; + + while (entries.hasMoreElements()) { + zipentriestoadd.push(entries.getNext()); + } + } else if (sourcepathobj.exists()) { + zipentriestoadd.push(sourcepathobj); + } + } + + // Add files depth first + while (zipentriestoadd.length > 0) { + var zipentry = zipentriestoadd.pop(); + + zipentry.QueryInterface(Components.interfaces.nsILocalFile); + + if (!zipentry.isDirectory()) { + zipwriterobj.add(zipentry); + } + + if (zipentry.exists() && zipentry.isDirectory()) { + var entries = zipentry.directoryEntries; + + while (entries.hasMoreElements()) { + zipentriestoadd.push(entries.getNext()); + } + } + } + + zipwriterobj.commitUpdates(); + return; + } catch (e) { + gPromptService.alert(window, "", "ZIPWriterComponent error - attempting ZIP"); + } + } + + var zipLocation = document.getElementById("zipLocation").value; + if (zipLocation.length == 0) { + zipLocation = "zip"; + } + + platform = navigator.platform; + var scriptfile = location.clone(); + + if ((navigator.platform == "Win32") || (navigator.platform == "OS/2")) + scriptfile.append("ccktemp.cmd"); + else + scriptfile.append("ccktemp.sh"); + var fos = Components.classes["@mozilla.org/network/file-output-stream;1"] + .createInstance(Components.interfaces.nsIFileOutputStream); + fos.init(scriptfile, -1, -1, false); + + var line = "cd "; + // this param causes a drive switch on win32 + if (navigator.platform == "Win32") + line += "/d "; + line += "\"" + location.path + "\"\n"; + fos.write(line, line.length); + if ((navigator.platform == "Win32") || (navigator.platform == "OS/2")) + line = "\"" + zipLocation + "\" -r \"" + location.path + "\\" + zipfile + "\""; + else + line = zipLocation + " -r \"" + location.path + "/" + zipfile + "\""; + for (var i=2; i < arguments.length; i++) { + line += " " + arguments[i]; + } + line += "\n"; + fos.write(line, line.length); + fos.close(); + + var sh; + + // create an nsILocalFile for the executable + if ((navigator.platform != "Win32") && (navigator.platform != "OS/2")) { + sh = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + sh.initWithPath("/bin/sh"); + } + // create an nsIProcess + var process = Components.classes["@mozilla.org/process/util;1"] + .createInstance(Components.interfaces.nsIProcess); + + if ((navigator.platform == "Win32") || (navigator.platform == "OS/2")) + process.init(scriptfile); + else + process.init(sh); + + var args = [scriptfile.path]; + + try { + process.run(true, args, args.length); + } catch (ex) { + } + + var file = location.clone(); + file.append(zipfile); + if (navigator.platform == "OS/2") { + var bundle = document.getElementById("bundle_cckwizard"); + gPromptService.alert(window, bundle.getString("windowTitle"), + "OS/2 problem workaround - Click OK to continue"); + } + if (!file.exists()) { + var bundle = document.getElementById("bundle_cckwizard"); + gPromptService.alert(window, bundle.getString("windowTitle"), + bundle.getString("zipError")); + } + scriptfile.remove(false); +} + +function CCKWriteXULOverlay(destdir) +{ + var tooltipXUL = '