home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / AIMP2 / aimp_2.61.583.exe / $TEMP / YandexPackSetup.msi / fil30DDAB2C507C50CB9C33E46D22B5D685 < prev    next >
Extensible Markup Language  |  2010-07-12  |  14KB  |  294 lines

  1. <?xml version="1.0"?>
  2. <!DOCTYPE bindings [
  3.     <!ENTITY % locale SYSTEM "chrome://yasearch/locale/package-management/package-management.dtd">
  4.     %locale;
  5. ]>
  6.  
  7. <bindings xmlns="http://www.mozilla.org/xbl"
  8.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  9.           xmlns:xbl="http://www.mozilla.org/xbl"
  10.           xmlns:html="http://www.w3.org/1999/xhtml">
  11.     
  12.     <binding id="install"
  13.              extends="../package-management.xml#package-management"
  14.              inheritstyle="false">
  15.         
  16.         <resources>
  17.             <stylesheet src="install.css"/>
  18.         </resources>
  19.         
  20.         <content>
  21.             <xul:vbox step="download-preset">
  22.                 <xul:head title="&install.head.title;" description="&install.download.label;"/>
  23.                 <xul:progressmeter class="download-preset-progressmeter" mode="undetermined" flex="1"/>
  24.                 <xul:hbox class="buttons">
  25.                     <xul:button label="&button.cancel;" oncommand="dialog.close();"/>
  26.                 </xul:hbox>
  27.             </xul:vbox>
  28.             
  29.             <xul:vbox step="confirm">
  30.                 <xul:head class="confirm-head" crop="end" mode="preset"/>
  31.                 <xul:disclaimer/>
  32.                 <xul:hbox class="buttons">
  33.                     <xul:button label="&button.install;" oncommand="_stepDownloadManifests();"/>
  34.                     <xul:button label="&button.cancel;" oncommand="dialog.close();"/>
  35.                 </xul:hbox>
  36.             </xul:vbox>
  37.             
  38.             <xul:vbox step="download">
  39.                 <xul:head class="download-head" crop="end" mode="preset"/>
  40.                 <xul:label value="&install.download.label;"/>
  41.                 <xul:progressmeter class="download-progressmeter" mode="determined" max="100" value="0" flex="1"/>
  42.                 <xul:hbox class="buttons">
  43.                     <xul:button label="&button.cancel;" oncommand="dialog.close();"/>
  44.                 </xul:hbox>
  45.             </xul:vbox>
  46.             
  47.             <xul:vbox step="conflict">
  48.                 <xul:head class="conflict-head" mode="warning" title="&install.conflict.head.title;" description="&install.conflict.head.description;"/>
  49.                 <xul:components class="conflict-deleted"/>
  50.                 <xul:hbox class="buttons">
  51.                     <xul:button label="&button.accept;" oncommand="_stepConflictResolved();"/>
  52.                     <xul:button label="&button.cancel;" oncommand="dialog.close();"/>
  53.                 </xul:hbox>
  54.             </xul:vbox>
  55.             
  56.             <xul:vbox step="placement">
  57.                 <xul:head class="placement-head" title="&install.placement.head.title;" description="&install.placement.head.description;"/>
  58.                 <xul:hbox class="buttons">
  59.                     <xul:button label="&button.save;" oncommand="_stepApply();"/>
  60.                     <xul:button label="&button.cancel;" oncommand="dialog.close();"/>
  61.                 </xul:hbox>
  62.                 <xul:more label-opened="&more.opened;" label-closed="&more.closed;">
  63.                     <xul:label value="&placement.placement.label;"/>
  64.                     <xul:placement class="placement-placement"/>
  65.                     <xul:label value="&placement.list.label;"/>
  66.                     <xul:components class="placement-widgets"/>
  67.                 </xul:more>
  68.             </xul:vbox>
  69.             
  70.             <xul:vbox step="error">
  71.                 <xul:head class="error-head" mode="warning" title="&error.head.title;" description="&error.head.description;"/>
  72.                 <xul:hbox class="buttons" anonid="error-buttons">
  73.                     <xul:button action="accept" label="&button.accept;" oncommand=""/>
  74.                     <xul:button action="repeat" label="&button.repeat;" oncommand=""/>
  75.                     <xul:button action="close" label="&button.finish;" oncommand=""/>
  76.                 </xul:hbox>
  77.                 <xul:more class="error-more" label-opened="&error.more.opened;" label-closed="&error.more.closed;">
  78.                     <xul:label flex="1" class="error-details"/>
  79.                 </xul:more>
  80.             </xul:vbox>
  81.             
  82.         </content>
  83.         
  84.         <implementation>
  85.             <field name="mode">"install"</field>
  86.             
  87.             <field name="_url">this.parameters.preset</field>
  88.             
  89.             <constructor><![CDATA[
  90.                  this._stepDownloadPreset();
  91.             ]]></constructor>
  92.             
  93.             <destructor><![CDATA[
  94.             ]]></destructor>
  95.             
  96.             <method name="_stepDownloadPreset">
  97.                 <body><![CDATA[
  98.                     var trusted = false;
  99.                     try {
  100.                         var uri = this._Cc["@mozilla.org/network/io-service;1"]
  101.                             .getService(this._Ci.nsIIOService)
  102.                             .newURI(this._url, null, null);
  103.                         trusted = this._application.isTrustedPresetUri(uri);
  104.                     }
  105.                     catch (e) {
  106.                         this._logger.warn("Failed checking preset address. " + this._application.core.Lib.misc.formatError(e));
  107.                     }
  108.                     if (trusted)
  109.                         this.setAttribute("trusted", "true");
  110.                     
  111.                     this.step("download-preset");
  112.                     var context = this;
  113.                     function callback(e) { context._stepConfirm(e); }
  114.                     
  115.                     var request = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
  116.                         .createInstance(Components.interfaces.nsIXMLHttpRequest);
  117.                     
  118.                     request.mozBackgroundRequest = true;
  119.                     request.overrideMimeType("application/xml");
  120.                     
  121.                     request.open("GET", this._url, true);
  122.                     
  123.                     request.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE |
  124.                                                  Components.interfaces.nsIRequest.INHIBIT_CACHING;
  125.                     
  126.                     request.channel.QueryInterface(Components.interfaces.nsIWritablePropertyBag2);
  127.                     request.channel.setPropertyAsBool("isXBInstallRequest", true);
  128.                     
  129.                     var target = request.QueryInterface(Components.interfaces.nsIDOMEventTarget);
  130.                     target.addEventListener("load", callback, false);
  131.                     target.addEventListener("error", callback, false);
  132.                     
  133.                     request.send(null);
  134.                 ]]></body>
  135.             </method>
  136.             
  137.             <method name="_stepConfirm">
  138.                 <parameter name="event"/>
  139.                 <body><![CDATA[
  140.                     var request = event.target;
  141.                     try {
  142.                         if (request.status >= 300)
  143.                             throw new this._errors.EDownload(this._url, request.status);
  144.                         let presetDoc = request.responseXML;
  145.                         if (!(presetDoc instanceof Components.interfaces.nsIDOMDocument))
  146.                             throw new this._errors.ECustom("Response is not an XML document");
  147.                         this.preset = new this._application.core.Lib.XB.Preset(request.responseXML, this._url);
  148.                         this.preset.text = request.responseText;
  149.                         this.presets = [this.preset];
  150.                     }
  151.                     catch (e) {
  152.                         this._logger.error(this._application.core.Lib.misc.formatError(e));
  153.                         this._error(e);
  154.                         return;
  155.                     }
  156.                     
  157.                     this.step("confirm");
  158.                     
  159.                     this.info = {
  160.                         image: this.preset.icon,
  161.                         title: this.preset.name,
  162.                         description: this._bundle.get("preset.description", [this.preset.author, this.preset.version])
  163.                     };
  164.                     
  165.                     this._nodeConfirmHead.info = this.info;
  166.                 ]]></body>
  167.             </method>
  168.             
  169.             <method name="_stepDownloadManifests">
  170.                 <body><![CDATA[
  171.                     this.step("download");
  172.                     this._nodeDownloadHead.info = this.info;
  173.                     
  174.                     var packageIds = {__proto__: null},
  175.                         items = [];
  176.                     for each (info in this.preset.widgetsInfo) {
  177.                         let packageId = info.packageID;
  178.                         if (packageId in packageIds)
  179.                             continue;
  180.                         packageIds[packageId] = 1;
  181.                         
  182.                         items.push({
  183.                             info: info,
  184.                             url: packageId
  185.                         });
  186.                     }
  187.                     
  188.                     var context = this;
  189.                     this.queue = new this._misc.DownloadQueue(
  190.                         items,
  191.                         function (items) { context._stepAnalyseManifests(items); },
  192.                         this._nodeDownloadProgressmeter
  193.                     );
  194.                 ]]></body>
  195.             </method>
  196.             
  197.             <method name="_stepAnalyseManifests">
  198.                 <parameter name="manifestItems"/>
  199.                 <body><![CDATA[
  200.                     var failed = false;
  201.                     this.packages = [];
  202.                     for each (let item in manifestItems) {
  203.                         if (item.status === this._Cr.NS_OK) {
  204.                             let info = item.info,
  205.                                 packageId = info.packageID;
  206.                             try {
  207.                                 let manifest = new this._application.core.Lib.XB.PackageManifest(packageId, item.file);
  208.                                 let [packageInfo, packageInfo2] = this._application.selectBestPackage(manifest);
  209.                                 
  210.                                 if (!packageInfo) {
  211.                                     this.flags.packageError = true;
  212.                                     this.flags.availableForModernPlatform = !!packageInfo2;
  213.                                     continue;
  214.                                 }
  215.                                 
  216.                                 let install = true; 
  217.                                 if (this._packageManager.isPackageInstalled(packageId)) {
  218.                                     let packageInfoInstalled = this._packageManager.getPackageInfo(packageId);
  219.                                     install = (this._compare(packageInfo.version, packageInfoInstalled.version) > 0);
  220.                                 }
  221.                                 
  222.                                 if (install) {
  223.                                     this.packages.push({
  224.                                         type: "package",
  225.                                         manifest: manifest,
  226.                                         info: packageInfo,
  227.                                         widgets: this._knownWidgetsInPackage(manifest.packageID),
  228.                                         checked: true
  229.                                     });
  230.                                 }
  231.                             }
  232.                             catch (e) {
  233.                                 this._logger.error(this._application.core.Lib.misc.formatError(e));
  234.                                 this._error(e);
  235.                                 return;
  236.                             }
  237.                         }
  238.                         else {
  239.                             this.flags.downloadError = true;
  240.                         }
  241.                     }
  242.                     
  243.                     this.queue.clean();
  244.                     
  245.                     this._stepDownloadPackages();
  246.                 ]]></body>
  247.             </method>
  248.             
  249.             <method name="_stepCheckErrors">
  250.                 <body><![CDATA[
  251.                     if (this.flags.widgetError || this.flags.packageError) {
  252.                         if (this.flags.availableForModernPlatform) {
  253.                             this._error("error.situation.install.old-platfrom",
  254.                                 this.widgets.length ? {
  255.                                 "accept": "_stepPlacement();",
  256.                                 "close": "dialog.close();"
  257.                             } : null);
  258.                         }
  259.                         else if (this.widgets.length == 0)
  260.                             this._error("error.situation.install.generic");
  261.                         else
  262.                             this._error("error.situation.install.partially", {
  263.                                 "accept": "_stepPlacement();",
  264.                                 "close": "dialog.close();"
  265.                             });
  266.                         return;
  267.                     }
  268.                     else {
  269.                         if (this.widgets.length == 0) {
  270.                             this._error("error.situation.install.no-widgets");
  271.                             return;
  272.                         }
  273.                     }
  274.                     
  275.                     this._stepPlacement();
  276.                 ]]></body>
  277.             </method>
  278.             
  279.             <method name="_stepPlacement">
  280.                 <body><![CDATA[
  281.                     this.step("placement");
  282.                     
  283.                     if (this.widgets.length == 1) {
  284.                         this._nodePlacementPlacement.setAttribute("no-replace", "true");
  285.                     }
  286.                     else {
  287.                         this._nodePlacementWidgets.items = this.widgets;
  288.                     }
  289.                 ]]></body>
  290.             </method>
  291.             
  292.         </implementation>
  293.     </binding>
  294. </bindings>