diff options
Diffstat (limited to 'files/de/mozilla/tech')
8 files changed, 0 insertions, 850 deletions
diff --git a/files/de/mozilla/tech/index.html b/files/de/mozilla/tech/index.html deleted file mode 100644 index f9682e62e1..0000000000 --- a/files/de/mozilla/tech/index.html +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: Mozilla technologies -slug: Mozilla/Tech -tags: - - Landing - - Mozilla - - NeedsTranslation - - Reference - - TopicStub - - XUL -translation_of: Mozilla/Tech ---- -<p>Mozilla has several technologies used as components of its projects. These are documented here. (flesh out this text).</p> -<p>{{LandingPageListSubpages}}</p> diff --git a/files/de/mozilla/tech/xpcom/guide/empfang_von_benachrichtigungen_zum_startprozess/index.html b/files/de/mozilla/tech/xpcom/guide/empfang_von_benachrichtigungen_zum_startprozess/index.html deleted file mode 100644 index a81f28519f..0000000000 --- a/files/de/mozilla/tech/xpcom/guide/empfang_von_benachrichtigungen_zum_startprozess/index.html +++ /dev/null @@ -1,56 +0,0 @@ ---- -title: Empfang von Benachrichtigungen zum Startprozeß -slug: Mozilla/Tech/XPCOM/Guide/empfang_von_benachrichtigungen_zum_startprozess -translation_of: Mozilla/Tech/XPCOM/Guide/Receiving_startup_notifications ---- -<p>Manchmal brauchen XPCOM Komponenten Benachrichtigungen über den Fortschritt beim Hochfahren der Anwendung, zum Beispiel um neue Dienste zur passenden Zeit starten können</p> -<h2 id="Empfang_von_Benachrichtigungen_zum_Startprozeß_ab_Gecko_2.0_(Firefox_4)">Empfang von Benachrichtigungen zum Startprozeß ab Gecko 2.0 (Firefox 4)</h2> -<p>Der XPCOM Startprozeß wurde verändert um die zum Hochfahren benötigte Zeit zu verbessern. Siehe <a href="#der_startprozess">Der Startprozeß</a> für Details über die Funktionsweise, wenn dich die Einzelheiten interessieren.</p> -<p>Die entscheidende Änderung ist, daß man jetzt entsprechende Zeilen zum <a href="/en/Chrome_registration" title="en/Chrome registration"><code>chrome.manifest</code></a> hinzufügt damit die Anwendung sich darum kümmert, anstelle die Registrierung programmatisch mit dem Category Manager durchzuführen wie früher. Zum Beispiel:</p> -<pre>category profile-after-change MyComponent @foobar/mycomponent;1</pre> -<div class="warning"> - <strong>Wichtig:</strong> Bisher begann die Contract ID des Kategorie-EIntrags mit "service," wenn die Komponente als Dienst (Service) implementiert war. Das ist nicht länger der Fall, dieses muß bei der Codemigration entfernt werden..</div> -<p>Hinzu kommt, daß die früheste Benachrichtigung beim Startprozeß, die man erhalten kann, jetzt <code>profile-after-change</code> ist. Dein Add-On wird keine <code><code>xpcom-startup</code></code> oder <code>app-startup</code> Benachrichtigungen mehr erhalten.</p> -<h3 id="Der_Startprozeß"><a name="der_startprozess">Der Startprozeß</a></h3> -<p>Während des Startprozesses wird aus dem Manifest der Anwendung die Liste der Komponenten ausgelesen, die registriert werden müssen, und diese Komponenten werden dann gestartet. Damit sind dann XPCOM und die Anwendung soweit hochgefahren, daß der Erweiterungs-Manager geladen werden kann, um sich um Installation, Deinstallation und Aktualisierung von Erweiterungen zu kümmern.</p> -<p>Sobald dieser Prozess abgeschlossen ist, können Erweiterungen einfach dadurch geladen werden, daß ihr Manifest gelesen, ihre Komponenten geladen und der Anwendungsstart fortgesetzt wird, ohne den Browser neu starten zu müssen.</p> -<h2 id="Empfang_von_Benachrichtigungen_zum_Startprozeß_vor_Gecko_2.0_(Firefox_4)">Empfang von Benachrichtigungen zum Startprozeß vor Gecko 2.0 (Firefox 4)</h2> -<p>Um Benachrichtigungen zum Startprozeß zu empfangen muß man {{ interface("nsICategoryManager") }} benutzen um sich für die "app-startup" Kategorie zu registrieren. Damit wird die Komponente dann unter anderem folgende Benachrichtigungen zum Anwendungsstart erhalten:</p> -<dl> - <dt> - <code>xpcom-startup</code></dt> - <dd> - Wird gesendet, wenn XPCOM fertig mit dem Hochfahren ist. Die meisten Anwendungsdienste sind dann noch nicht verfügbar, aber XPCOM selbst steht bereit.</dd> - <dt> - <code>app-startup</code></dt> - <dd> - Wird gesendet, wenn die Anwendung mit dem Startprozess fertig ist.</dd> - <dt> - <code>final-ui-startup</code></dt> - <dd> - Wird gesendet eben bevor das erste Anwendungsfenster dargestellt wird.</dd> -</dl> -<h3 id="Registrierung_am_Kategorien-Manager">Registrierung am Kategorien-Manager</h3> -<p>Um sich beim Kategorien-Manager anzumelden, muß man nur dessen Methode {{ ifmethod("nsICategoryManager", "AddCategoryEntry") }} aufrufen:</p> -<pre>categoryManager->AddCategoryEntry(APPSTARTUP_CATEGORY, - "mycomponentname", - "contract-id", - PR_TRUE, PR_TRUE, - getter_Copies(previous)); -</pre> -<p>Das bewirkt, daß die Komponente mit {{ ifmethod("nsIComponentManager","createInstance") }} instanziiert wird.</p> -<p>Wenn die Komponente als Dienst (Service) laufen soll, laß die Contract ID mit "service," beginnen:</p> -<pre>categoryManager->AddCategoryEntry(APPSTARTUP_CATEGORY, - "mycomponentname", - "service,contract-id", - PR_TRUE, PR_TRUE, - getter_Copies(previous));</pre> -<p>Wenn "service," angegeben ist, wird die Komponente mit {{ ifmethod("nsIComponentManager","getService") }} instanziiert.</p> -<p>In beiden Fällen braucht man keine weitere Registrierung für die Benachrichtigungen zum Startprozeß, die Registrierung am Kategorien-Manager reicht dazu aus.</p> -<h3 id="Wie_es_weitergeht">Wie es weitergeht</h3> -<p>Nachdem die Registrierung am Kategorien-Manager erfolgt ist, wird zum Zeitpunkt des Starts von Mozilla (oder wenn bei einer eingebetteten Anwendung die Funktion <code>NS_InitEmbedding()</code> aufgerufen wurde) die AppStartupNotifier Komponente instanziiert und ihre <code>Observe()</code> Methode aufgerufen; Diese wiederum läuft über alle Komponenten in der <code>app-startup</code> Kategorie und sendet ihnen die passenden Benachrichtigungen.</p> -<h2 id="Siehe_auch">Siehe auch</h2> -<ul> - <li>{{ interface("nsICategoryManager") }}</li> - <li><a href="/en/Observer_Notifications" title="en/Observer Notifications">Observer Notifications</a></li> -</ul> diff --git a/files/de/mozilla/tech/xpcom/guide/index.html b/files/de/mozilla/tech/xpcom/guide/index.html deleted file mode 100644 index 781a596b2e..0000000000 --- a/files/de/mozilla/tech/xpcom/guide/index.html +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: XPCOM guide -slug: Mozilla/Tech/XPCOM/Guide -tags: - - Landing - - Mozilla - - NeedsTranslation - - TopicStub - - XPCOM -translation_of: Mozilla/Tech/XPCOM/Guide ---- -<p><span class="seoSummary">These articles provide tutorials and usage documentation for XPCOM, including how to use it in your own projects and how to build XPCOM components for your Firefox add-ons and the like.</span></p> -<p>{{LandingPageListSubpages}}</p> diff --git a/files/de/mozilla/tech/xpcom/reference/index.html b/files/de/mozilla/tech/xpcom/reference/index.html deleted file mode 100644 index 29d07953d6..0000000000 --- a/files/de/mozilla/tech/xpcom/reference/index.html +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: XPCOM reference -slug: Mozilla/Tech/XPCOM/Reference -tags: - - Add-ons - - Extensions - - Landing - - Mozilla - - NeedsTranslation - - Reference - - TopicStub - - XPCOM -translation_of: Mozilla/Tech/XPCOM/Reference ---- -<p>This reference describes the interfaces and functions provided by the <a href="/en-US/docs/Mozilla/Tech/XPCOM">XPCOM</a> library. In addition, it details the various helper classes and functions, as well as the components, provided by the <a href="/en-US/docs/Mozilla/Tech/XPCOM/Glue">XPCOM glue</a> library. The contents herein are oriented primarily toward extension developers and people embedding XPCOM in other projects.</p> - -<div class="warning"> -<p><strong>WebExtensions are becoming the new standard for creating add-ons. </strong>Eventually support for XPCOM add-ons will be deprecated, so you should begin to investigate porting your add-ons to use the <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions">WebExtensions</a> API, and <a href="https://mzl.la/webext-feature-needed">report any missing functionality</a> so we can be sure to address your concerns. Work is ongoing on WebExtension capabilities, so your input will help prioritize and plan the work. To learn more about the kinds of changes that will be needed, see <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Comparison_with_XUL_XPCOM_extensions">Comparison with XUL/XPCOM extensions</a>. In addition, any binaries you use will then need to be converted for use with the WebExtensions <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging">native messaging</a> API, or compiled using <a href="https://webassembly.github.io/">WebAssembly</a> or <a href="/en-US/docs/Mozilla/Projects/Emscripten">Emscripten</a>.</p> -</div> - -<div class="note"> -<p>If you're working on a module in the Mozilla codebase that's compiled with the <code>MOZILLA_INTERNAL_API</code> flag set, some of these APIs -- the string functions and classes in particular -- are not the ones you should be using. See the <a href="/en-US/docs/Mozilla/Tech/XPCOM/Guide/Internal_strings">XPCOM internal string guide</a> for documentation of the internal string API used within the Mozilla codebase.</p> -</div> - -<p>{{LandingPageListSubpages}}</p> - -<p>Many XPCOM pages return an <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Core_functions/nsresult">nsresult</a></code>. Prior to Gecko 19 {{geckoRelease(19)}}, this was an integer that simply returned an error code. It is now a strongly typed <code>enum</code> when XPCOM is built using a C++11 compiler. This causes compile-time errors to occur when improper values are returned as nsresult values, thereby making it easier to catch many bugs.</p> diff --git a/files/de/mozilla/tech/xpcom/reference/interface/index.html b/files/de/mozilla/tech/xpcom/reference/interface/index.html deleted file mode 100644 index d098cf8402..0000000000 --- a/files/de/mozilla/tech/xpcom/reference/interface/index.html +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: XPCOM Interface Reference -slug: Mozilla/Tech/XPCOM/Reference/Interface -tags: - - NeedsTranslation - - TopicStub - - XPCOM - - XPCOM Interface Reference -translation_of: Mozilla/Tech/XPCOM/Reference/Interface ---- -<p><span class="seoSummary">This is a reference to the XPCOM interfaces provided by the Mozilla platform.</span></p> - -<div class="cols-3">{{tree('','1')}}</div> - -<h2 id="See_also" name="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/XPCOM_Interface_Reference_group" title="XPCOM_Interface_Reference_group">Interfaces grouped by function</a></li> -</ul> diff --git a/files/de/mozilla/tech/xpcom/reference/interface/nsiloginmanager/index.html b/files/de/mozilla/tech/xpcom/reference/interface/nsiloginmanager/index.html deleted file mode 100644 index 2c354b2b2b..0000000000 --- a/files/de/mozilla/tech/xpcom/reference/interface/nsiloginmanager/index.html +++ /dev/null @@ -1,420 +0,0 @@ ---- -title: nsILoginManager -slug: Mozilla/Tech/XPCOM/Reference/Interface/nsILoginManager -tags: - - Firefox 3 - - Interfaces - - 'Interfaces:Scriptable' - - Login Manager - - NeedsTranslation - - Thunderbird 3 - - TopicStub - - XPCOM - - XPCOM API Reference - - thunderbird -translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsILoginManager ---- -<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;"> -<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/toolkit/components/passwordmgr/public/nsILoginManager.idl" rel="custom">toolkit/components/passwordmgr/public/nsILoginManager.idl</a></code><span style="text-align: right; float: right;"><a href="/en-US/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">Scriptable</a></span></div> -<span style="padding: 4px 2px;"> - -Used to interface with the built-in Password Manager -</span> - - <div style="height: 42px; position: relative; padding: 2px; width: auto;"> - - <div style="top: 22px; font-size: 11px; position: absolute;">1.0</div> - - <div style="top: 22px; font-size: 11px; position: absolute; left: 0px; text-align: right; float: right; width: 100%;">66</div> - - <div style="height: 8px; top: 16px; background: #dd0000; left: 0px; position: absolute; width: 8.571428571428571%;"></div> - -<div style="height: 8px; top: 16px; left: 8.571428571428571%; background: #00dd00; position: absolute; width: 91.42857142857143%;" title="Introduced in Gecko 1.9 (Firefox 3)"></div> - -<div style="top: 0px; font-size: 11px; position: absolute; left: 8.571428571428571%;">Introduced</div> -<div style="top: 22px; font-size: 11px; position: absolute; left: 8.571428571428571%;">Gecko 1.9</div> - - <div style="height: 8px; top: 16px; left: 9.976190285714287%; background: #eeee00; position: absolute; width: 1%; border-radius: 4px; -webkit-border-radius: 4px;" title="Last changed in Gecko 1.9.2 (Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)"></div> - -</div> - -<div style="background: #eee; padding: 2px;"> -Inherits from: <code><a href="/de/docs/XPCOM_Interface_Referenz/nsISupports" title="">nsISupports</a></code> -<span style="text-align: right; float: right;">Last changed in Gecko 1.9.2 (Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)</span></div> -</div><p></p> - -<p>Replaces <code><a href="/de/docs/XPCOM_Interface_Referenz/nsIPasswordManager" title="">nsIPasswordManager</a></code> which was used in older versions of Gecko.</p> - -<p>Implemented by: <code>@mozilla.org/login-manager;1</code>. To create an instance, use:</p> - -<pre class="eval">var loginManager = Components.classes["@mozilla.org/login-manager;1"] - .getService(Components.interfaces.nsILoginManager); -</pre> - -<h2 id="Method_overview" name="Method_overview">Method overview</h2> - -<table class="standard-table"> - <tbody> - <tr> - <td><code>void <a href="#addLogin()">addLogin</a>(in nsILoginInfo aLogin);</code></td> - </tr> - <tr> - <td><code>nsIAutoCompleteResult <a href="#autoCompleteSearch()">autoCompleteSearch</a>(in AString aSearchString, in nsIAutoCompleteResult aPreviousResult, in nsIDOMHTMLInputElement aElement);</code></td> - </tr> - <tr> - <td><code>unsigned long <a href="#countLogins()">countLogins</a>(in AString aHostname, in AString aActionURL, in AString aHttpRealm);</code></td> - </tr> - <tr> - <td><code>boolean <a href="#fillForm()">fillForm</a>(in nsIDOMHTMLFormElement aForm);</code> </td> - </tr> - <tr> - <td><code>void <a href="#findLogins()">findLogins</a>(out unsigned long count, in AString aHostname, in AString aActionURL, in AString aHttpRealm, [retval, array, size_is(count)] out nsILoginInfo logins);</code></td> - </tr> - <tr> - <td><code>void <a href="#getAllDisabledHosts()">getAllDisabledHosts</a>([optional] out unsigned long count, [retval, array, size_is(count)] out wstring hostnames);</code></td> - </tr> - <tr> - <td><code>void <a href="#getAllLogins()">getAllLogins</a>([optional] out unsigned long count, [retval, array, size_is(count)] out nsILoginInfo logins);</code></td> - </tr> - <tr> - <td><code>boolean <a href="#getLoginSavingEnabled()">getLoginSavingEnabled</a>(in AString aHost);</code></td> - </tr> - <tr> - <td><code>void <a href="#modifyLogin()">modifyLogin</a>(in nsILoginInfo oldLogin, in nsISupports newLoginData);</code></td> - </tr> - <tr> - <td><code>void <a href="#removeAllLogins()">removeAllLogins</a>();</code></td> - </tr> - <tr> - <td><code>void <a href="#removeLogin()">removeLogin</a>(in nsILoginInfo aLogin);</code></td> - </tr> - <tr> - <td><code>void <a href="#searchLogins()">searchLogins</a>(out unsigned long count, in nsIPropertyBag matchData, [retval, array, size_is(count)] out nsILoginInfo logins);</code> </td> - </tr> - <tr> - <td><code>void <a href="#setLoginSavingEnabled()">setLoginSavingEnabled</a>(in AString aHost, in boolean isEnabled);</code></td> - </tr> - </tbody> -</table> - -<h2 id="Methods" name="Methods">Methods</h2> - -<h3 id="addLogin()" name="addLogin()">addLogin()</h3> - -<p>Stores a new login in the Login Manager.</p> - -<p></p><div class="blockIndicator note"><strong>Hinweis:</strong> Default values for the <code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginMetaInfo" title="">nsILoginMetaInfo</a></code> properties are created if the specified login doesn't explicitly specify them.</div><p></p> - -<pre class="eval">void addLogin( - in nsILoginInfo aLogin -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>aLogin</code></dt> - <dd>The login to store.</dd> -</dl> - -<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6> - -<dl> - <dt> </dt> - <dd>An exception is thrown if the login information is already stored in the Login Manager. To change a login, you have to use <code><a href="https://developer.mozilla.org/de/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILoginManager#modifyLogin()">modifyLogin()</a></code>.</dd> -</dl> - -<h3 id="autoCompleteSearch()" name="autoCompleteSearch()">autoCompleteSearch()</h3> - -<p>Generates results for a user field autocomplete menu.</p> - -<p></p><div class="blockIndicator note"><strong>Hinweis:</strong> This method is provided for use only by the <code>FormFillController</code>, which calls it directly. It should not be used for any other purpose.</div><p></p> - -<pre class="eval">nsIAutoCompleteResult autoCompleteSearch( - in AString aSearchString, - in nsIAutoCompleteResult aPreviousResult, - in nsIDOMHTMLInputElement aElement -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>aSearchString</code></dt> - <dd>Missing Description</dd> - <dt><code>aPreviousResult</code></dt> - <dd>Missing Description</dd> - <dt><code>aElement</code></dt> - <dd>Missing Description</dd> -</dl> - -<h6 id="Return_value" name="Return_value">Return value</h6> - -<p>Missing Description</p> - -<h3 id="countLogins()" name="countLogins()">countLogins()</h3> - -<p>Returns the number of logins matching the specified criteria. Called when only the number of logins is needed, and not the actual logins (which avoids prompting the user for a Master Password, as the logins don't need to be decrypted).</p> - -<pre class="eval">unsigned long countLogins( - in AString aHostname, - in AString aActionURL, - in AString aHttpRealm -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>aHostname</code></dt> - <dd>The hostname to which to restrict searches, formatted as a URL. For example, "<a class="external" href="http://www.bar.com" rel="freelink">http://www.bar.com</a>". To match all hostnames, specify <code>""</code> (empty string). A value of <code>null</code> will cause countLogins() to not match any logins.</dd> - <dt><code>aActionURL</code></dt> - <dd>For form logins, this parameter should specify the URL to which the form will be submitted. To match any form login, specify <code>""</code> (empty string). To not match any form logins (For example when interested in protocol logins only), specify <code>null</code>.</dd> - <dt><code>aHttpRealm</code></dt> - <dd>For protocol logins, specify the HTTP Realm for which the login applies; this is obtained from the WWW-Authenticate header (see <a class="external" href="http://tools.ietf.org/html/rfc2617" title="http://tools.ietf.org/html/rfc2617">RFC 2617</a>). To match any protocol login, specify <code>""</code> (empty string). To not match any protocol logins (For example when interested in form logins only), specify <code>null</code>.</dd> -</dl> - -<h6 id="Return_value" name="Return_value">Return value</h6> - -<p>The number of logins matching the parameters passed.</p> - -<p></p><h3 id="fillForm()">fillForm()</h3><p></p> - -<p>Fills out a form with login information, if appropriate information is available.</p> - -<p></p><div class="blockIndicator note"><strong>Hinweis:</strong> This method will attempt to fill out the form regardless of the setting of the <code>signon.autofillForms</code> preference.</div><p></p> - -<pre class="eval">boolean fillForm( - in nsIDOMHTMLFormElement aForm -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>aForm</code></dt> - <dd>The HTMLform to attempt to fill out.</dd> -</dl> - -<h6 id="Return_value" name="Return_value">Return value</h6> - -<p><code>true</code> if the form was successfully filled out; otherwise <code>false</code>.</p> - -<h3 id="findLogins()" name="findLogins()">findLogins()</h3> - -<p>Searches for logins matching the specified criteria. Called when looking for logins that might be applicable to a given form or authentication request.</p> - -<pre class="eval">void findLogins( - out unsigned long count, - in AString aHostname, - in AString aActionURL, - in AString aHttpRealm, - [retval, array, size_is(count)] out nsILoginInfo logins -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>count</code></dt> - <dd>The number of elements in the returned array. JavaScript callers can simply use the array's <code>length</code> property and supply a dummy argument for this parameter.</dd> - <dt><code>aHostname</code></dt> - <dd>The hostname to restrict searches to, formatted as a URL. For example, "<a class="external" href="http://www.bar.com" rel="freelink">http://www.bar.com</a>".</dd> - <dt><code>aActionURL</code></dt> - <dd>For form logins, this parameter should specify the URL to which the form will be submitted. For protocol logins, specify <code>null</code>. An empty string ("") will match any value (except <code>null</code>).</dd> - <dt><code>aHttpRealm</code></dt> - <dd>For protocol logins, specify the HTTP Realm for which the login applies; this is obtained from the WWW-Authenticate header (see <a class="external" href="http://tools.ietf.org/html/rfc2617" title="http://tools.ietf.org/html/rfc2617">RFC 2617</a>). For form logins, this parameter should be <code>null</code>. An empty string ("") will match any value (except <code>null</code>).</dd> - <dt><code>logins</code></dt> - <dd>An array of <code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginInfo" title="">nsILoginInfo</a></code> objects.</dd> -</dl> - -<h6 id="Example" name="Example">Example</h6> - -<p>This method can be called from JavaScript like this:</p> - -<pre class="brush: js"> var logins = myLoginMgr.findLogins({}, 'https://bugzilla.mozilla.org', '', '', {}); -</pre> - -<h3 id="getAllDisabledHosts()" name="getAllDisabledHosts()">getAllDisabledHosts()</h3> - -<p>Returns a list of all hosts for which login saving is disabled.</p> - -<pre class="eval">void getAllDisabledHosts( - [optional] out unsigned long count, - [retval, array, size_is(count)] out wstring hostnames -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>count</code></dt> - <dd>The number of elements in the returned array. JavaScript callers can simply use the array's <code>length</code> property and supply a dummy argument for this parameter.</dd> - <dt><code>hostnames</code></dt> - <dd>An array of hostname strings in URL format without a pathname. For example: <span class="nowiki">"https://www.site.com"</span>.</dd> -</dl> - -<h6 id="Example" name="Example">Example</h6> - -<p>You can call this method from JavaScript like this:</p> - -<pre class="brush: js"> var disabledHosts = myLoginMgr.getAllDisabledHosts({}); -</pre> - -<h3 id="getAllLogins()" name="getAllLogins()">getAllLogins()</h3> - -<p>Returns an array containing all logins recorded by the Login Manager.</p> - -<p>If you just want to see if any logins are stored, use <code><a href="https://developer.mozilla.org/de/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILoginManager#countLogins()">countLogins()</a></code> instead. It's more efficient, and avoids the possibility of the user being prompted for their master password.</p> - -<pre class="eval">void getAllLogins( - [optional] out unsigned long count, - [retval, array, size_is(count)] out nsILoginInfo logins -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>count</code></dt> - <dd>The number of elements in the returned array. JavaScript callers can simply use the array's <code>length</code> property and supply a dummy argument for this parameter.</dd> - <dt><code>logins</code></dt> - <dd>An array of <code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginInfo" title="">nsILoginInfo</a></code> objects containing all the logins the Login Manager has on record.</dd> -</dl> - -<h6 id="Example" name="Example">Example</h6> - -<p>You can call this method from JavaScript like this:</p> - -<pre class="brush: js"> var logins = myLoginMgr.getAllLogins({}); -</pre> - -<h3 id="getLoginSavingEnabled()" name="getLoginSavingEnabled()">getLoginSavingEnabled()</h3> - -<p>Reports whether or not saving login information is enabled for a host.</p> - -<pre class="eval">boolean getLoginSavingEnabled( - in AString aHost -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>aHost</code></dt> - <dd>The hostname to check. This argument should be in the origin URL format, with no pathname. For example: <span class="nowiki">"https://www.site.com"</span>.</dd> -</dl> - -<h6 id="Return_value" name="Return_value">Return value</h6> - -<p><code>true</code> if login saving is enabled for the host, otherwise <code>false</code>.</p> - -<h3 id="modifyLogin()" name="modifyLogin()">modifyLogin()</h3> - -<p>Modifies an existing login by replacing it with a new one.</p> - -<p>If newLoginData is a <code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginInfo" title="">nsILoginInfo</a></code>, all of the old login's <code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginInfo" title="">nsILoginInfo</a></code> properties are changed to the values from newLoginData (but the old login's <code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginMetaInfo" title="">nsILoginMetaInfo</a></code> properties are unmodified).</p> - -<p>If newLoginData is a <code><a href="/de/docs/XPCOM_Interface_Referenz/nsIPropertyBag" title="">nsIPropertyBag</a></code>, only the specified properties will be changed. The <code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginMetaInfo" title="">nsILoginMetaInfo</a></code> properties of oldLogin can be changed in this manner.</p> - -<p>If the propertybag contains an item named "timesUsedIncrement", the login's timesUsed property will be incremented by the item's value.</p> - -<pre class="eval">void modifyLogin( - in nsILoginInfo oldLogin, - in nsISupports newLoginData -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>oldLogin</code></dt> - <dd>The login to be modified.</dd> - <dt><code>newLoginData</code></dt> - <dd>The login information to replace the <code>oldLogin</code> with. This may be specified as either an <code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginInfo" title="">nsILoginInfo</a></code> or an <code><a href="/de/docs/XPCOM_Interface_Referenz/nsIPropertyBag2" title="">nsIPropertyBag2</a></code> object.</dd> -</dl> - -<h3 id="removeAllLogins()" name="removeAllLogins()">removeAllLogins()</h3> - -<p>Removes all logins known by the Login Manager. This works without a need for the master password, if one is set.</p> - -<pre class="eval">void removeAllLogins(); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<p>None.</p> - -<h3 id="removeLogin()" name="removeLogin()">removeLogin()</h3> - -<p>Removes a login from the Login Manager.</p> - -<p></p><div class="blockIndicator note"><strong>Hinweis:</strong> The specified login must exactly match a stored login. However, the values of any <code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginMetaInfo" title="">nsILoginMetaInfo</a></code> properties are ignored.</div><p></p> - -<pre class="eval">void removeLogin( - in nsILoginInfo aLogin -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>aLogin</code></dt> - <dd>The login to remove from the Login Manager. Only a login that is an exact match is deleted.</dd> -</dl> - -<p></p><h3 id="searchLogins()">searchLogins()</h3><p></p> - -<p>Searches for logins in the login manager's data store, returning an array of matching logins. If there are no matching logins, an empty array is returned.</p> - -<pre class="eval">void searchLogins( - out unsigned long count, - in nsIPropertyBag matchData, - [retval, array, size_is(count)] out nsILoginInfo logins -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>count</code></dt> - <dd>The number of elements in the returned array.</dd> - <dt><code>matchData</code></dt> - <dd>The data used for the search. This does not follow the same requirements as <code><a href="https://developer.mozilla.org/de/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILoginManager#findLogins()">findLogins()</a></code> for those fields; wildcard matches are not specified.</dd> - <dt><code>logins</code></dt> - <dd>An array of matching <code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginInfo" title="">nsILoginInfo</a></code> objects.</dd> -</dl> - -<h6 id="Example" name="Example">Example</h6> - -<p>This method can be called from JavaScript like this:</p> - -<pre class="brush: js"> var logins = myLoginMgr.searchLogins({}, matchData); - var numLogins = logins.length; -</pre> - -<h3 id="setLoginSavingEnabled()" name="setLoginSavingEnabled()">setLoginSavingEnabled()</h3> - -<p>Enables or disables storing logins for a specified host. When login storing is disabled, the Login Manager won't prompt the user to store logins for that host. Existing logins are not affected.</p> - -<pre class="eval">void setLoginSavingEnabled( - in AString aHost, - in boolean isEnabled -); -</pre> - -<h6 id="Parameters" name="Parameters">Parameters</h6> - -<dl> - <dt><code>aHost</code></dt> - <dd>The hostname to adjust the setting for. This argument should be in the origin URL format, with no pathname. For example: <span class="nowiki">"https://www.site.com"</span>.</dd> - <dt><code>isEnabled</code></dt> - <dd>If <code>true</code>, login saving is enabled for the specified host. If <code>false</code>, login saving is disabled.</dd> -</dl> - -<h2 id="See_also" name="See_also">See also</h2> - -<ul> - <li><code><a href="/de/docs/XPCOM_Interface_Referenz/nsILoginInfo" title="">nsILoginInfo</a></code></li> - <li><a href="/en/XPCOM_Interface_Reference/nsILoginManager/Using_nsILoginManager" title="en/Using_nsILoginManager">Using nsILoginManager</a></li> -</ul> diff --git a/files/de/mozilla/tech/xpcom/reference/interface/nsiloginmanager/using_nsiloginmanager/index.html b/files/de/mozilla/tech/xpcom/reference/interface/nsiloginmanager/using_nsiloginmanager/index.html deleted file mode 100644 index 2cc68a291f..0000000000 --- a/files/de/mozilla/tech/xpcom/reference/interface/nsiloginmanager/using_nsiloginmanager/index.html +++ /dev/null @@ -1,212 +0,0 @@ ---- -title: Using nsILoginManager -slug: Mozilla/Tech/XPCOM/Reference/Interface/nsILoginManager/Using_nsILoginManager -translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsILoginManager/Using_nsILoginManager ---- -<div>{{ Gecko_minversion_header("1.9") }}</div> - -<h2 id="Working_with_the_Login_Manager" name="Working_with_the_Login_Manager">Den Login-Manager verwenden</h2> - -<p>Extensions speichern oftmals - auch wenn es eigentlich gar nicht wirklich nötig wäre - Paßwörter zu Webseiten, web-apps und so weiter. To do so securely, they can use <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginManager" title="en-US/docs/nsILoginManager">nsILoginManager</a></code>, which provides for secure storage of sensitive password information and <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginInfo" title="en-US/docs/nsILoginInfo">nsILoginInfo</a></code>, which provides a way of storing login information.</p> - -<h2 id="Getting_nsILoginManager" name="Getting_nsILoginManager">Getting <code>nsILoginManager</code></h2> - -<p>To get a component implementing <code>nsILoginManager</code>, use the following:</p> - -<div style="margin-right: 270px;"> -<pre class="brush: js">var passwordManager = Components.classes["@mozilla.org/login-manager;1"].getService( - Components.interfaces.nsILoginManager -);</pre> -</div> - -<p>Most Login Manager functions take an <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginInfo" title="en-US/docs/nsILoginInfo">nsILoginInfo</a></code> object as a parameter. An <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginInfo" title="en-US/docs/nsILoginInfo">nsILoginInfo</a></code> object contains the following attributes: hostname, form submit URL, HTTP realm, username, username field, password, and password field. The hostname, username and password attributes are mandatory, while the other fields are set based on whether the login is for a web page form or an HTTP/FTP authentication site login. See the <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginInfo" title="en-US/docs/nsILoginInfo">nsILoginInfo</a></code> attribute definitions for more details. Defining an <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginInfo" title="en-US/docs/nsILoginInfo">nsILoginInfo</a></code> object is simple:</p> - -<div style="margin-right: 270px;"> -<pre class="brush: js">var nsLoginInfo = new Components.Constructor( - "@mozilla.org/login-manager/loginInfo;1", - Components.interfaces.nsILoginInfo, - "init" -); - -var loginInfo = new nsLoginInfo( - hostname, formSubmitURL, httprealm, username, password, usernameField, passwordField -); -</pre> -</div> - -<h2 id="Examples" name="Examples">Examples</h2> - -<h3 id="Creating_a_login_for_a_web_page" name="Creating_a_login_for_a_web_page">Creating a login for a web page</h3> - -<pre class="brush: js">var formLoginInfo = new nsLoginInfo( - 'http://www.example.com', - 'http://login.example.com', - null, - 'joe', - 'SeCrEt123', - 'uname', - 'pword' -);</pre> - -<p>This login would correspond to a HTML form such as:</p> - -<pre class="brush: html"><form action="http://login.example.com/foo/authenticate.cgi"> - <div>Please log in.</div> - <label>Username:</label> <input type="text" name="uname"> - <label>Password:</label> <input type="password" name="pword"> -</form> -</pre> - -<h3 id="Creating_a_site_authentication_login" name="Creating_a_site_authentication_login">Creating a site authentication login</h3> - -<pre class="brush: js">var authLoginInfo = new nsLoginInfo( - 'http://www.example.com', - null, - 'ExampleCo Login', - 'alice', - 'SeCrEt321', - "", - "" -); -</pre> - -<p>This would correspond to a login on <span class="nowiki">http://www.example.com</span> when the server sends a reply such as:</p> - -<pre class="eval"> HTTP/1.0 401 Authorization Required - Server: Apache/1.3.27 - WWW-Authenticate: Basic realm="ExampleCo Login" - -</pre> - -<h3 id="Creating_a_local_extension_login" name="Creating_a_local_extension_login">Creating a local extension login</h3> - -<pre class="brush: js">var extLoginInfo = new nsLoginInfo( - 'chrome://firefoo', - null, - 'User Registration', - 'bob', - '123sEcReT', - "", - "" -);</pre> - -<p>From a component creating a new info block is done slightly differently:</p> - -<pre>var nsLoginInfo = <span class="k"><span class="s0">new</span></span> <a class="r" title='Search for references of "Components"'>Components</a>.<a class="r" title='Search for references of "Constructor"'>Constructor</a>("@<a class="r" title='Search for references of "mozilla"'>mozilla</a>.<a class="r" title='Search for references of "org"'>org</a>/<a class="r" title='Search for references of "login"'>login</a>-<a class="r" title='Search for references of "manager"'>manager</a>/<a class="r" title='Search for references of "loginInfo"'>loginInfo</a>;1", <a class="r" title='Search for references of "Ci"'>Ci</a>.<a class="r" title='Search for references of "nsILoginInfo"'>nsILoginInfo</a>, "<a class="r" title='Search for references of "init"'>init</a>"); -<span class="k">var</span> extLoginInfo = <span class="k"><span class="s0">new</span></span> <a class="r" title='Search for references of "nsLoginInfo"'><span class="s1">nsLoginInfo</span></a>('<a class="r" title='Search for references of "chrome"'>chrome</a>:<span class="c">//firefoo',</span> null, 'User Registration', 'bob', '123sEcReT', '', ''); -//var extLoginInfo = new nsLoginInfo(<a class="r" title='Search for references of "aHostname"'>aHostname</a>, <a class="r" title='Search for references of "aFormSubmitURL"'>aFormSubmitURL</a>, <a class="r" title='Search for references of "aHttpRealm"'>aHttpRealm</a>, <a class="r" title='Search for references of "aUsername"'>aUsername</a>, <a class="r" title='Search for references of "aPassword"'>aPassword</a>, <a class="r" title='Search for references of "aUsernameField"'>aUsernameField</a>, <a class="r" title='Search for references of "aPasswordField"'>aPasswordField)</a> -</pre> - -<p>The Login Manager treats this as if it was a web site login. You should use your extension's chrome:// URL to prevent conflicts with other extensions, and a realm string which briefly denotes the login's purpose.</p> - -<h2 id="Storing_a_password" name="Storing_a_password">Storing a password</h2> - -<p>To store a password in the Login Manager, you first need to create an <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginInfo" title="en-US/docs/nsILoginInfo">nsILoginInfo</a></code> object as defined above. Then you simply need to call the <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginManager" title="en-US/docs/nsILoginManager">nsILoginManager</a></code> method <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginManager#addLogin.28.29" title="en-US/docs/nsILoginManager#addLogin.28.29">addLogin()</a></code>.</p> - -<pre class="brush: js">myLoginManager.addLogin(loginInfo); -</pre> - -<p>{{ Note("This will throw an exception if both the <code>httprealm</code> and <code>formSubmitURL</code> parameters are <code>NULL</code>. One must be specified when storing a password. The <code>hostname</code>, <code>username</code> and <code>password</code> parameters are also mandatory.") }}</p> - -<h2 id="Retrieving_a_password" name="Retrieving_a_password">Retrieving a password</h2> - -<p>Retrieving a password from the Login Manager is slightly more difficult. In order to locate a password, the <code>hostname</code>, <code>formSubmitURL</code> and <code>httprealm</code> must <strong>match exactly</strong> what is stored for the password to be found. The only exception is that if the stored <code>formSubmitURL</code> is blank, in which case the <code>formSubmitURL</code> parameter is ignored. Note that the <code>hostname</code> and <code>formSubmitURL</code> arguments should not include the path from the full URL. The example below should serve as a starting point for matching form logins:</p> - -<pre class="brush: js">var hostname = 'http://www.example.com'; -var formSubmitURL = 'http://www.example.com'; // not http://www.example.com/foo/auth.cgi -var httprealm = null; -var username = 'user'; -var password; - -try { - // Get Login Manager - var myLoginManager = Components.classes["@mozilla.org/login-manager;1"]. - getService(Components.interfaces.nsILoginManager); - - // Find users for the given parameters - var logins = myLoginManager.findLogins({}, hostname, formSubmitURL, httprealm); - - // Find user from returned array of nsILoginInfo objects - for (var i = 0; i < logins.length; i++) { - if (logins[i].username == username) { - password = logins[i].password; - break; - } - } -} - -catch(ex) { - // This will only happen if there is no nsILoginManager component class -}</pre> - -<p>Note that the user will be prompted for their master password if they have chosen to set one to secure their passwords.</p> - -<h2 id="Removing_a_password" name="Removing_a_password">Removing a password</h2> - -<p>Removing a password is simple:</p> - -<pre class="brush: js">myLoginManager.removeLogin(loginInfo); -</pre> - -<p>When removing a password the specified <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginInfo" title="en-US/docs/nsILoginInfo">nsILoginInfo</a></code> object must <strong>exactly match</strong> what was stored or an exception will be thrown. This includes the password attribute. Here's an example on how to remove the password without actually knowing what the password is:</p> - -<pre class="brush: js">// example values -var hostname = 'http://www.example.com'; -var formSubmitURL = 'http://www.example.com'; -var httprealm = null; -var username = 'user'; - -try { - // Get Login Manager - var passwordManager = Components.classes["@mozilla.org/login-manager;1"]. - getService(Components.interfaces.nsILoginManager); - - // Find users for this extension - var logins = passwordManager.findLogins({}, hostname, formSubmitURL, httprealm); - - for (var i = 0; i < logins.length; i++) { - if (logins[i].username == username) { - passwordManager.removeLogin(logins[i]); - break; - } - } -} -catch(ex) { - // This will only happen if there is no nsILoginManager component class -}</pre> - -<h2 id="Changing_stored_login_information" name="Changing_stored_login_information">Changing stored login information</h2> - -<p>Changing a password is rather simple. Since all this does is make a <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginManager#removeLogin.28.29" title="en-US/docs/nsILoginManager#removeLogin.28.29">removeLogin()</a></code> call followed by an <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginManager#addLogin.28.29" title="en-US/docs/nsILoginManager#addLogin.28.29">addLogin()</a></code> call, it has the same caveats as both of them: namely that the <code>oldLogin</code> must match an existing login exactly (see above) and that the <code>newLogin</code> attributes must be set correctly.:</p> - -<pre class="brush: js">myLoginManager.modifyLogin(oldLogin, newLogin);</pre> - -<h2 id="Debugging" name="Debugging">Login Manager notifications</h2> - -<p>{{ fx_minversion_note("3.5", "The Login Manager notifications were added in Firefox 3.5.") }}</p> - -<p>Firefox 3.5 and later send assorted notifications when various Login Manager related events occur, including when form autofill does not occur for various reasons, as well as when changes are made to the Login Manager's database. See the <a class="internal" href="/en-US/docs/Observer_Notifications#Login_Manager" title="en-US/docs/Observer Notifications#Login Manager">Login Manager</a> section of the article on observer notifications for details.</p> - -<h2 id="Debugging" name="Debugging">Debugging</h2> - -<p>The login manager implementation has the ability to send debug messages to the Error Console, which can provide some visibility into what it's doing. To enable the debug logging, see <a class="external" href="http://wiki.mozilla.org/Firefox:Password_Manager_Debugging" rel="freelink">http://wiki.mozilla.org/Firefox:Pass...ager_Debugging</a>.</p> - -<h2 id="Supporting_older_versions_of_Firefox" name="Supporting_older_versions_of_Firefox">Supporting older versions of Gecko</h2> - -<p>If you want your extension to support both Gecko 1.9 (Firefox 3, Thunderbird 3, SeaMonkey 2) and older versions it will need to implement both the <code><a href="/en-US/docs/XPCOM_Interface_Reference/nsILoginManager" title="en-US/docs/nsILoginManager">nsILoginManager</a></code> and <code><a href="/en-US/docs/nsIPasswordManager" title="en-US/docs/nsIPasswordManager">nsIPasswordManager</a></code> components. A simple method to do this is as follows:</p> - -<pre class="brush: js">if ("@mozilla.org/passwordmanager;1" in Components.classes) { - // Password Manager exists so this is not Firefox 3 (could be Firefox 2, Netscape, SeaMonkey, etc). - // Password Manager code -} else if ("@mozilla.org/login-manager;1" in Components.classes) { - // Login Manager exists so this is Firefox 3 - // Login Manager code -}</pre> - -<h2 id="See_also" name="See_also">See also</h2> - -<ul> - <li>{{ Interface("nsILoginManager") }}</li> - <li>{{ Interface("nsILoginInfo") }}</li> - <li><a href="/en-US/docs/Creating_a_Login_Manager_storage_module" title="en-US/docs/Creating_a_Login_Manager_storage_module">Creating a Login Manager storage module</a></li> -</ul> diff --git a/files/de/mozilla/tech/xpcom/reference/interface/nsixmlhttprequest/index.html b/files/de/mozilla/tech/xpcom/reference/interface/nsixmlhttprequest/index.html deleted file mode 100644 index 3907d126bd..0000000000 --- a/files/de/mozilla/tech/xpcom/reference/interface/nsixmlhttprequest/index.html +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: nsIXMLHttpRequest -slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIXMLHttpRequest -translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIXMLHttpRequest ---- -<div class="blockIndicator obsolete obsoleteHeader"> -<p><strong>Obsolete since Gecko 60 (Firefox 60 / Thunderbird 60 / SeaMonkey 2.57)</strong><br> - This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.</p> -</div> - - - -<p><code>nsIXMLHttpRequest</code> along with <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIJSXMLHttpRequest" title="">nsIJSXMLHttpRequest</a></code> and <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIXMLHttpRequestEventTarget" title="">nsIXMLHttpRequestEventTarget</a></code> are Mozilla's implementation details of the DOM <a href="/en/DOM/XMLHttpRequest" title="en/DOM/XMLHttpRequest">XMLHttpRequest</a> object.</p> - -<div class="note"><strong>Note:</strong> If you're a web developer or a Mozilla add-on developer, please refer to the <a href="/en/DOM/XMLHttpRequest" title="en/DOM/XMLHttpRequest">XMLHttpRequest</a> documentation instead.</div> - -<p>This page contains documentation, specific to Mozilla application and add-on developers.</p> - -<p>The interface definition: <a href="https://dxr.mozilla.org/mozilla-central/source/dom/xhr/nsIXMLHttpRequest.idl">https://dxr.mozilla.org/mozilla-central/source/dom/xhr/nsIXMLHttpRequest.idl</a></p> - -<h3 id="Elevated_Privileges">Elevated Privileges</h3> - -<p>As mentioned in the "Non-Standard Properties" the property of <code>channel</code> was read-only. When using the XPCOM interface, as seen below in <a href="#Example_code">Example 2</a>, we can get access to this. The most obvious benefit is that we can set <a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/NsIRequest#Constants">nsiRequest - Constants</a> in the <code>xhr.channel.loadFlags</code>. For instance, as done in <a href="#Example_code">Example 2</a>, the flag of <code>LOAD_ANONYMOUS</code> is added, this strips all user data (cookies, tokens, etc).</p> - -<h3 id="Using_event_handlers_from_native_code">Using event handlers from native code</h3> - -<p>(Not sure if it's up-to-date)</p> - -<p>From native code, the way to set up onload and onerror handlers is a bit different. Here is a comment from Johnny Stenback <<a class="link-mailto" href="mailto:jst@netscape.com" rel="freelink">jst@netscape.com</a>>:</p> - -<blockquote>The mozilla implementation of nsIXMLHttpRequest implements the interface nsIDOMEventTarget and that's how you're supported to add event listeners. Try something like this: nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(myxmlhttpreq)); target->AddEventListener(NS_LITERAL_STRING("load"), mylistener, PR_FALSE) where mylistener is your event listener object that implements the interface nsIDOMEventListener. The 'onload', 'onerror', and 'onreadystatechange' attributes moved to nsIJSXMLHttpRequest, but if you're coding in C++ you should avoid using those.</blockquote> - -<p>Though actually, if you use addEventListener from C++ weird things will happen too, since the result will depend on what JS happens to be on the stack when you do it....</p> - -<p>Conclusion: Do not use event listeners on XMLHttpRequest from C++, unless you're aware of all the security implications. And then think twice about it.</p> - -<h2 id="Example_code" name="Example_code">Example code</h2> - -<p>This is a simple example code for opening a simple HTTP request from a xul application (like a Mozilla extension) without using observers:</p> - -<pre class="eval notranslate"> var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(); - req.open('POST', "<a class="external" href="http://www.foo.bar:8080/nietzsche.do" rel="freelink">http://www.foo.bar:8080/nietzsche.do</a>", true); - req.send('your=data&and=more&stuff=here'); -</pre> - -<h2 id="Example_code" name="Example_code">Example 2</h2> - -<pre class="notranslate"><code>var {Cu: utils, Cc: classes, Ci: instances} = Components; -Cu.import('resource://gre/modules/Services.jsm'); -function xhr(url, cb) { - let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); - - let handler = ev => { - evf(m => xhr.removeEventListener(m, handler, !1)); - switch (ev.type) { - case 'load': - if (xhr.status == 200) { - cb(xhr.response); - break; - } - default: - Services.prompt.alert(null, 'XHR Error', 'Error Fetching Package: ' + xhr.statusText + ' [' + ev.type + ':' + xhr.status + ']'); - break; - } - }; - - let evf = f => ['load', 'error', 'abort'].forEach(f); - evf(m => xhr.addEventListener(m, handler, false)); - - xhr.mozBackgroundRequest = true; - xhr.open('GET', url, true); - xhr.channel.loadFlags |= Ci.nsIRequest.LOAD_ANONYMOUS | Ci.nsIRequest.LOAD_BYPASS_CACHE | Ci.nsIRequest.INHIBIT_PERSISTENT_CACHING; - xhr.responseType = "arraybuffer"; //dont set it, so it returns string, you dont want arraybuffer. you only want this if your url is to a zip file or some file you want to download and make a nsIArrayBufferInputStream out of it or something - xhr.send(null); -} - -xhr('https://www.gravatar.com/avatar/eb9895ade1bd6627e054429d1e18b576?s=24&d=identicon&r=PG&f=1', data => { - Services.prompt.alert(null, 'XHR Success', data); - var file = OS.Path.join(OS.Constants.Path.desktopDir, "test.png"); - var promised = OS.File.writeAtomic(file, new UInt8Array(data)); - promised.then( - function() { - alert('succesfully saved image to desktop') - }, - function(ex) { - alert('FAILED in saving image to desktop') - } - ); -});</code></pre> |