Tài liệu Creating Applications with Mozilla-Chapter 6. Packaging and Installing Applications-P3 - Pdf 87

Chapter 6. Packaging and Installing Applications-P3
When you have very simple installations -- such as when you want to install
a new skin -- you may not need to use the services from the Install
object. Besides providing the services necessary for "triggering" the
downloading of a package from a web site, the InstallTrigger object
offers some simple methods for installing when you do not need to rearrange
of the disk, register complications, or do other install-type preparation (see
Table 6-2
).
Table 6-2. InstallTrigger interface showing the role of the InstallTrigger
object in the overall installation process
Method Description
compareVersion
Compares the version of a file or
package with the version of an
existing file or package.
Enabled
Indicates whether the Software
Installation is enabled for this client
machine.
getVersionInfo
Returns an InstallVersion
object representing the version
number from the Client Version
Registry for the specified software or
component.
Method Description
Install
Installs one or more XPI files on the
local machine.
installChrome

href="javascript:install('xFly','xfly.xpi');">insta
ll</a>
6.3.3.3. Installing non-Mozilla software
The XPInstall technology downloads and installs any software on any
machine using Mozilla or Netscape 6/7. The same Install object methods
that download, register, and install new Mozilla packages (e.g., new themes
or new Mozilla applications like xFly) can be used to download other
executables and software into any location on the local machine.
As with Mozilla application installs, you use an installation script within a
XPI to initialize the installation, add the files you want to the installation,
and then perform the install and put the software in the designated locations.
Note that non-Mozilla software installations do not include a registration
step, since the chrome registry does not track non-Mozilla software or any
more general additions to the operating system. Example 6-18 shows a
simple and typical non-Mozilla installation.
Example 6-18. Non-Mozilla software installation script
var xpiSrc = "file.txt";
initInstall(
"Adding A File",
"testFile",
"1.0.1.7",
1);
f = getFolder("Program"); // keyword for the main
program
// directory on the
target platform
// (e.g., the "Program
Files" dir on win32)
setPackageFolder(f);
addFile(xpiSrc);

package as defined in the manifest for that package. The xFly package
manifest, for example, defines "xfly" as the name of the package, as shown
in Example 6-19
.
Example 6-19. Package metadata in the xFly manifest
<!-- xFly package information -->
<RDF:Description about="urn:mozilla:package:xfly"
chrome:displayName="xFly"
chrome:author="frillies"
chrome:name="xfly">
</RDF:Description>
Example 6-9
comes from the content package manifest for xFly, which is
similar to the full content manifest for the XMLTerm application you saw in
Example 6-4
.
To uninstall the xFly package, then -- as you should do to the working
version you have as you develop before installing the final version -- hook
up a menuitem to call the uninstall routine:
<menuitem id="uninstall-item" label="Uninstall
xFly" oncommand="unInstall("xfly")" />
This menuitem should have access to a JavaScript file and contains the
following code:
include("chrome://jslib/install/uninstall.js");
function unInstall(pkg) {


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status