1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public License Version
5
* 1.1 (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/MPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is distro-mods.
16
* The Initial Developer of the Original Code is
18
* Portions created by the Initial Developer are Copyright (C) 2007
19
* the Initial Developer. All Rights Reserved.
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
35
* ***** END LICENSE BLOCK ***** */
37
function getAppVersion ()
39
var versionString = null;
41
versionString = Components.classes["@mozilla.org/fuel/application;1"].getService(Components.interfaces.extIApplication).version;
45
if (versionString == null)
48
if (String_startsWith (versionString, "3.0"))
49
versionString = "3.0";
50
else if (String_startsWith (versionString, "3.5"))
51
versionString = "3.5";
52
else // Return null for > 3.6 as firefox is unversioned now
58
function getSourcePackageName ()
60
var sourcePackageName = "firefox";
61
var versionString = getAppVersion();
63
sourcePackageName = sourcePackageName + "-" + versionString;
65
return sourcePackageName;
69
onAddonsLoad: function () {
71
var labelGetUbuntu = document.getElementById("getUbuntu"); // ffox 2
72
var extensions = document.getElementById("extensions-view");
73
this.strings = document.getElementById("ubufox-strings");
75
if (!labelGetUbuntu) {
76
labelGetUbuntu = document.getElementById("getUbuntu3");
79
this.initialized = true;
81
if (!ubufoxCheckExecutable("/usr/bin/gnome-app-install"))
82
labelGetUbuntu.setAttribute("hidden", "true");
83
else if (!this.isffox3) {
84
// this is ffox2 only because ffox3 uses a distinct overlay anchor
85
if (extensions.getAttribute("selected") != "true") {
86
labelGetUbuntu.setAttribute("hidden", "true");
88
if (extensions.getAttribute("selected") == "true") {
89
labelGetUbuntu.setAttribute("hidden", "false");
91
extensions.addEventListener("DOMAttrModified", function (e) { ubufox.onAttrModified(e); }, false);
94
onMenuItemCommand: function(e) {
95
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
96
.getService(Components.interfaces.nsIPromptService);
97
promptService.alert(window, this.strings.getString("helloMessageTitle"),
98
this.strings.getString("helloMessage"));
100
onAttrModified: function(e) {
101
var labelGetUbuntu = document.getElementById("getUbuntu");
102
var extensions = document.getElementById("extensions-view");
104
if (!ubufoxCheckExecutable("/usr/bin/gnome-app-install")) {
105
labelGetUbuntu.setAttribute("hidden", "true");
108
if (extensions.getAttribute("selected") != "true") {
109
labelGetUbuntu.setAttribute("hidden", "true");
111
if (extensions.getAttribute("selected") == "true") {
112
labelGetUbuntu.setAttribute("hidden", "false");
116
window.addEventListener("load", function(e) { ubufox.onAddonsLoad(e); }, false);
118
function startUbuntuAddonsWizard(ev)
121
Components.classes['@mozilla.org/file/local;1']
122
.createInstance(Components.interfaces.nsILocalFile);
124
executable.initWithPath("/usr/bin/gnome-app-install");
126
if(!executable.exists() || !executable.isExecutable())
127
alert('Unexpected error!');
130
Components.classes['@mozilla.org/process/util;1']
131
.createInstance(Components.interfaces.nsIProcess);
133
var nsFile = executable.QueryInterface(Components.interfaces.nsIFile);
135
procUtil.init(executable);
137
var args = new Array("--xul-extensions=firefox");
138
// we care for firefox 2 and use a special mime type to document
139
// compatibility of extensions with it
140
if (!ubufox.isffox3) {
141
args = new Array("--xul-extensions=firefox-2");
143
var res = procUtil.run(false, args, args.length);
148
function ubufoxReportBug(event) {
151
Components.classes['@mozilla.org/file/local;1']
152
.createInstance(Components.interfaces.nsILocalFile);
154
executable.initWithPath("/usr/bin/ubuntu-bug");
156
if(!executable.exists () || !executable.isExecutable())
157
alert('Unexpected error!');
160
Components.classes['@mozilla.org/process/util;1']
161
.createInstance(Components.interfaces.nsIProcess);
163
var nsFile = executable.QueryInterface(Components.interfaces.nsIFile);
165
procUtil.init(executable);
168
args = new Array("-p", getSourcePackageName());
170
var res = procUtil.run(false, args, args.length);
174
function ubufoxGetHelpOnline(event)
176
var getHelpUrl = "https://launchpad.net/distros/ubuntu/lucid/+sources/" + getSourcePackageName() + "/+gethelp";
177
openUILink(getHelpUrl, event, false, true);
180
function ubufoxHelpTranslateLaunchpad(event)
182
var translateUrl = "https://launchpad.net/distros/ubuntu/lucid/+sources/" + getSourcePackageName() + "/+translate";
183
openUILink(translateUrl, event, false, true);
186
function ubufoxCheckExecutable(filename)
189
Components.classes['@mozilla.org/file/local;1']
190
.createInstance(Components.interfaces.nsILocalFile);
192
executable.initWithPath(filename);
193
return executable.exists();