bug 521479: Change personas extension to use headerURL and footerURL instead of header and footer client-1.4
authorJose E. Bolanos<jose@appcoast.com>
Tue, 10 Nov 2009 16:09:27 -0800
branchclient-1.4
changeset 1216 10fa889db5e3c40d956d98cd2c6102a68dd4c36c
parent 1208 1bb9eaeb297a7ee42926c51e065b10aa13f88ddf
child 1217 3918747df4a2c047e94f548b94c6148690e3ace6
push id778
push usermyk@mozilla.com
push dateWed, 11 Nov 2009 00:19:44 +0000
bugs521479
bug 521479: Change personas extension to use headerURL and footerURL instead of header and footer
client/content/customPersonaEditor.js
client/content/personas.js
client/modules/service.js
--- a/client/content/customPersonaEditor.js
+++ b/client/content/customPersonaEditor.js
@@ -141,18 +141,18 @@ let CustomPersonaEditor = {
     try {
       this.customPersona = JSON.parse(this._prefs.get("custom"));
       this.customPersona.custom = true;
     }
     catch(ex) {
       this.customPersona = { custom: true };
     }
 
-    this._header.value = this.customPersona.header || "";
-    this._footer.value = this.customPersona.footer || "";
+    this._header.value = this.customPersona.headerURL || "";
+    this._footer.value = this.customPersona.footerURL || "";
     this._customName.value = this.customPersona.name || "";
     this._textColorPicker.color = this.customPersona.textcolor || "#000000";
     this._accentColorPicker.color = this.customPersona.accentcolor || "#C9C9C9";
 
     PersonaService.previewPersona(this.customPersona);
   },
 
   onChangeName: function(aEvent) {
--- a/client/content/personas.js
+++ b/client/content/personas.js
@@ -355,22 +355,22 @@ let PersonaController = {
     let images = PersonaService.getCachedPersonaImages(persona);
     if (images && images.header && images.footer) {
       this._header.style.backgroundImage = "url(" + images.header + ")";
       this._footer.style.backgroundImage = "url(" + images.footer + ")";
     }
     // Else set them from their original source
     else {
       // Use the URI module to resolve the possibly relative URI to an absolute one.
-      let headerURI = this.URI.get(persona.header,
+      let headerURI = this.URI.get(persona.headerURL,
                                    null,
                                    this.URI.get(PersonaService.dataURL));
       this._header.style.backgroundImage = "url(" + this._escapeURLForCSS(headerURI.spec) + ")";
       // Use the URI module to resolve the possibly relative URI to an absolute one.
-      let footerURI = this.URI.get(persona.footer,
+      let footerURI = this.URI.get(persona.footerURL,
                                    null,
                                    this.URI.get(PersonaService.dataURL));
       this._footer.style.backgroundImage = "url(" + this._escapeURLForCSS(footerURI.spec) + ")";
     }
 
     // Style the text color.
     if (this._prefs.get("useTextColor")) {
       // FIXME: fall back on the default text color instead of "black".
@@ -1023,17 +1023,17 @@ let PersonaController = {
       customMenu.hidden = true;
   },
 
   _createPersonaItem: function(persona) {
     let item = document.createElement("menuitem");
 
     let headerURI;
     if (persona.custom) {
-      headerURI = persona.header;
+      headerURI = persona.headerURL;
     } else {
       headerURI = persona.dataurl;
     }
 
     item.setAttribute("class", "menuitem-iconic");
     item.setAttribute("image", headerURI);
     item.setAttribute("label", persona.name);
 //    item.setAttribute("type", "checkbox");
--- a/client/modules/service.js
+++ b/client/modules/service.js
@@ -950,36 +950,36 @@ let PersonaService = {
       if (subdirs[i].isDirectory())
         subdirs[i].remove(true);
     }
 
     // Create directory for the given persona
     let personaDir = FileUtils.getDirectory(cacheDirectory, aPersona.id);
 
     // Save header
-    let headerURI = URI.get(aPersona.header, null, URI.get(this.dataURL));
+    let headerURI = URI.get(aPersona.headerURL, null, URI.get(this.dataURL));
     let headerCallback = function(aEvent) {
       let request = aEvent.target;
       if (request.status == 200) {
         FileUtils.writeBinaryFile(
           personaDir.clone(),
-          "header" + FileUtils.getFileExtension(aPersona.header),
+          "header" + FileUtils.getFileExtension(aPersona.headerURL),
           request.responseText);
       }
     };
     this._makeRequest(headerURI.spec, headerCallback, null, true);
 
     // Save footer
-    let footerURI = URI.get(aPersona.footer, null, URI.get(this.dataURL));
+    let footerURI = URI.get(aPersona.footerURL, null, URI.get(this.dataURL));
     let footerCallback = function(aEvent) {
       let request = aEvent.target;
       if (request.status == 200) {
         FileUtils.writeBinaryFile(
           personaDir.clone(),
-          "footer" + FileUtils.getFileExtension(aPersona.footer),
+          "footer" + FileUtils.getFileExtension(aPersona.footerURL),
           request.responseText);
       }
     };
     this._makeRequest(footerURI.spec, footerCallback, null, true);
   },
 
   /**
    * Obtains the cached images of the given persona. This are stored in the
@@ -994,18 +994,18 @@ let PersonaService = {
       FileUtils.getDirectory(FileUtils.getPersonasDirectory(), "cache");
 
     let personaDir = FileUtils.getDirectory(cacheDirectory, aPersona.id, true);
     if (personaDir.exists()) {
 
       let headerFile = personaDir.clone();
       let footerFile = personaDir.clone();
 
-      headerFile.append("header" + FileUtils.getFileExtension(aPersona.header));
-      footerFile.append("footer" + FileUtils.getFileExtension(aPersona.footer));
+      headerFile.append("header" + FileUtils.getFileExtension(aPersona.headerURL));
+      footerFile.append("footer" + FileUtils.getFileExtension(aPersona.footerURL));
 
       if (headerFile.exists() && footerFile.exists()) {
         let ios =
           Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
 
         let headerURI = ios.newFileURI(headerFile);
         let footerURI = ios.newFileURI(footerFile);