blob: 006b785484ec3ba4fb2da4ec7d8a53583435e759 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
---
title: Install Object
slug: Archive/Mozilla/XPInstall/Reference/Install_Object
tags:
- NeedsTranslation
- TopicStub
- XPInstall_API_reference
translation_of: Archive/Mozilla/XPInstall/Reference/Install_Object
---
<p></p><div class="warning"><p>Parts of this page show the use of the <a class="new" href="https://developer.mozilla.org/pt-BR/docs/XPInstall_API_Reference" rel="nofollow">XPInstall API</a>. The majority of this API is now deprecated and as of Gecko 1.9 no longer available. <a class="new" href="https://developer.mozilla.org/pt-BR/docs/Extensions" rel="nofollow">Extension</a>, <a class="new" href="https://developer.mozilla.org/pt-BR/docs/Themes" rel="nofollow">Theme</a>, and <a class="new" href="https://developer.mozilla.org/pt-BR/docs/Plugins" rel="nofollow">plug-in</a> developers must switch away from <code>install.js</code> based packages to the new <a class="new" href="https://developer.mozilla.org/pt-BR/docs/Bundles" rel="nofollow">packaging scheme</a> with an <code><a class="new" href="https://developer.mozilla.org/pt-BR/docs/Install_Manifests" rel="nofollow">install.rdf</a></code> manifest. In particular plugin developers should see <a class="new" href="https://developer.mozilla.org/pt-BR/docs/Shipping_a_plugin_as_a_Toolkit_bundle" rel="nofollow">how to package a plugin as an extension</a>.</p></div><p></p>
<h2 id="Install" name="Install">Install</h2>
<p>Use the <code>Install</code> object to manage the downloading and installation of software with the XPI Installation Manager.</p>
<h3 id="Overview" name="Overview">Overview</h3>
<p>The Install object is used primarily in installation scripts. In all cases, the <code>Install</code> object is implicit--like the <code>window</code> object in regular web page scripts--and needn't be prefixed to the object methods. The following two lines, for example, are equivalent:</p>
<pre>f = getFolder("Program");
f = Install.getFolder("Program");
</pre>
<p>An installation script is composed of calls to the Install object, and generally takes the following form:</p>
<dl>
<dt>Initialize the installation</dt>
<dd>Call <a href="en/XPInstall_API_Reference/Install_Object/Methods/initInstall"> initInstall</a> with the name of the installation and the necessary registry and version information.</dd>
<dt>Add the files to the installation</dt>
<dd>Add files to the installation by calling <a href="en/XPInstall_API_Reference/Install_Object/Methods/getFolder"> getFolder</a> to get file objects and passing those object refs to <a href="en/XPInstall_API_Reference/Install_Object/Methods/addFile"> addFile</a> as many times as necessary.</dd>
<dt>Perform installation</dt>
<dd>Check that the files have been added successfully (e.g., by checking the error <a href="en/XPInstall_API_Reference/Return_Codes"> Return Codes</a> from many of the main installation methods, and go ahead with the install if everything is in order:</dd>
</dl>
<pre>performOrCancel();
function performOrCancel()
{
if (0 == getLastError())
performInstall();
else
cancelInstall();
}
</pre>
<p>For complete script examples, see <a href="en/XPInstall_API_Reference/Examples"> Script Examples</a>.</p>
|