/* ***** 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 Annodex Firefox Extension. * * The Initial Developer of the Original Code is * Commonwealth Scientific and Industrial Research Organisation (CSIRO) * Australia. * Portions created by the Initial Developer are Copyright (C) 2004-2005 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Andre Pang * Chris Ford * Marcin Lubonski * Michael Martin * * 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 ***** */ const PLID = "CSIRO.au/Oggplay,version=1.0"; const VERSION = "1.0.0.0"; const PLUGIN_NAME = "Oggplay media player"; // Size values are for unpacked files, in kb var pluginName; var pluginSize; var useAddDir; var installDir; var xptName = "nsILibOggPlugin.xpt"; var xptSize = 10; // wrap everything in a function so it's easier to exit on error doInstall(); function doInstall() { // Initialise the installer var error = initInstall(PLUGIN_NAME, PLID, VERSION); if (error != SUCCESS) { logComment("initInstall() failed: " + error); return; } // Set up platform-specific details switch (getPlatform()) { case "unix": pluginName = "libnpoggplugin.so"; pluginSize = 2000; installDir = getFolder("Current User", "../../plugins"); useAddDir = false; break; case "windows": xptName = "npliboggplugin.xpt"; pluginName = "npliboggplugin.dll"; pluginSize = 2000; installDir = getFolder("Plugins"); useAddDir = false; break; case "mac": pluginName = "liboggplay.plugin"; pluginSize = 2000; installDir = getFolder("MacOSX User Internet PlugIn"); useAddDir = true; break; default: alert("You are attempting to install the Oggplay plug-in on " + "an unsupported platform.\n" + "Please email annodex-dev@lists.annodex.net for assistance."); } // Check if there is enough disk space to install the plugin if (!verifyDiskSpace(installDir, pluginSize + xptSize)) { alert("There is not enough disk space to install the Oggplay plug-in."); cancelInstall(INSUFFICIENT_DISK_SPACE); return; } // Copy the plugin files to the installation directory if (useAddDir) { error = addDirectory(PLID, VERSION, pluginName, installDir, pluginName); } else { error = addFile(PLID, VERSION, pluginName, installDir, null); } if (error != SUCCESS) { alert("Oggplay plug-in installation failed; could not copy plug-in files to " + installDir); logComment("Could not add " + pluginName + " to " + installDir + ":" + error); cancelInstall(error); return; } error = addFile(PLID, VERSION, xptName, installDir, null); if (error != SUCCESS) { alert("Oggplay plug-in installation failed; could not copy plug-in files to " + installDir); logComment("Could not add " + xptName + " to " + installDir + ":" + error); cancelInstall(error); return; } // Perform the install error = performInstall(); if (error != SUCCESS) { logComment("performInstall() failed: " + error); } else { refreshPlugins(true); alert("Completed installation of Oggplay plug-in"); } } // -- Utility functions -- function verifyDiskSpace(dirPath, spaceRequired) { var spaceAvailable; // Get the available disk space on the given path spaceAvailable = fileGetDiskSpaceAvailable(dirPath); // Convert the available disk space into kilobytes spaceAvailable = parseInt(spaceAvailable / 1024); // Do the verification if (spaceAvailable < spaceRequired) { logComment("Insufficient disk space to install Oggplay plug-in:"); logComment(" destination path: " + dirPath); logComment(" required : " + spaceRequired + " kb"); logComment(" available: " + spaceAvailable + " kb"); return false; } return true; } function getPlatform() { var platformString = new String(Install.platform); if (!platformString.search(/^Macintosh/)) return "mac"; else if (!platformString.search(/^Win/)) return "windows"; else return "unix"; }