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
/
fil3DD1AE30F0E519337F60FC9D3C19333A
< prev
next >
Wrap
Text File
|
2010-07-12
|
21KB
|
577 lines
var gYaInstaller = {
__installed: true,
__lastEmActionRequestedName: "",
get isBarUninstalled() {
return this.__installed == false;
},
APP_ACTION_QUIT_TOPIC: "quit-application",
EM_ACTION_REQUESTED_TOPIC: "em-action-requested",
LASTVERSION_PREF_NAME: "yasearch.general.lastVersion",
NEW_ADDONS_LIST_PREF_NAME: "extensions.newAddons",
CHECK_GLOBAL_INSTALL_PREF_NAME: "yasearch.general.checkGlobalInstall",
CHECK_GLOBAL_INSTALL_POST_CHECK: 1,
CHECK_GLOBAL_INSTALL_CHECKED: 2,
CHECK_TOOLBAR_COLLAPSED_PREF_NAME: "yasearch.general.checkToolbarCollapsed",
init: function() {
this._checkGlobalPostInstall();
OBSERVER_SERVICE.addObserver(this, "Ya-GUID-Response", false);
OBSERVER_SERVICE.addObserver(this, this.EM_ACTION_REQUESTED_TOPIC, false);
OBSERVER_SERVICE.addObserver(this, this.APP_ACTION_QUIT_TOPIC, false);
this.proccessInstall();
},
uninit: function() {
OBSERVER_SERVICE.removeObserver(this, "Ya-GUID-Response");
OBSERVER_SERVICE.removeObserver(this, this.APP_ACTION_QUIT_TOPIC);
OBSERVER_SERVICE.removeObserver(this, this.EM_ACTION_REQUESTED_TOPIC);
if (this.isBarUninstalled)
this.proccessUninstall();
else
this._checkGlobalInstall();
},
observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
case "Ya-GUID-Response":
if (aData === "SENDED")
this.sttInstall = true;
break;
case this.EM_ACTION_REQUESTED_TOPIC:
aSubject.QueryInterface(Ci.nsIUpdateItem);
if (aSubject.id === EXT_ID) {
switch (aData) {
case "item-uninstalled":
case "item-upgraded":
gYaSearchService.setIntPref(this.CHECK_TOOLBAR_COLLAPSED_PREF_NAME, 1);
break;
case "item-cancel-action":
if (this.__lastEmActionRequestedName && this.__lastEmActionRequestedName == aData)
gYaSearchService.resetPref(this.CHECK_TOOLBAR_COLLAPSED_PREF_NAME);
break;
}
this.__installed = !(aData == "item-uninstalled");
this.__lastEmActionRequestedName = aData;
}
break;
case this.APP_ACTION_QUIT_TOPIC:
this.uninit();
break;
default:
break;
}
},
_checkGlobalInstall: function() {
let yaSearchService = gYaSearchService;
try {
let installCheckValue = yaSearchService.getIntPref(this.CHECK_GLOBAL_INSTALL_PREF_NAME);
yaSearchService.setIntPref(this.CHECK_GLOBAL_INSTALL_PREF_NAME, this.CHECK_GLOBAL_INSTALL_CHECKED);
if (installCheckValue)
return;
if (!(yaSearchService.AppBarType == "barff" && yaSearchService.getCharPref("app.distributor") == "yandex"))
return;
let extManager = Cc["@mozilla.org/extensions/manager;1"].getService(Ci.nsIExtensionManager);
let barExtItem = extManager.getItemForID(EXT_ID);
if (barExtItem.installLocationKey !== "app-global")
return;
let barInstallDir = yaSearchService.getInstallDir();
let profileDir = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("ProfD", Ci.nsIFile);
if (profileDir.contains(barInstallDir.parent, false))
return;
let currentProcDir = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("CurProcD", Ci.nsIFile);
if (!currentProcDir.contains(barInstallDir.parent, false))
return;
profileDir.append("extensions");
let barInstallProfileDir = profileDir.clone();
barInstallProfileDir.append(EXT_ID);
if (barInstallProfileDir.exists() && barInstallProfileDir.isDirectory())
return;
try {
barInstallDir.copyTo(profileDir, "");
} catch (ex) {
barInstallProfileDir.remove(true);
return;
}
yaSearchService.setIntPref(this.CHECK_GLOBAL_INSTALL_PREF_NAME, this.CHECK_GLOBAL_INSTALL_POST_CHECK);
} catch (e) {
yaSearchService.log(e);
}
},
_checkGlobalPostInstall: function() {
if (gYaSearchService.getIntPref(this.CHECK_GLOBAL_INSTALL_PREF_NAME) == this.CHECK_GLOBAL_INSTALL_POST_CHECK) {
if (gYaSearchService.getCharPref(this.NEW_ADDONS_LIST_PREF_NAME) === EXT_ID)
gYaSearchService.resetPref(this.NEW_ADDONS_LIST_PREF_NAME);
}
},
proccessInstall: function() {
var currentVersion = gYaSearchService.barExtensionMajorVersion;
var lastVersion = gYaSearchService.getCharPref(this.LASTVERSION_PREF_NAME);
this._checkToolbarCollapsed(lastVersion, currentVersion);
if (lastVersion == currentVersion)
return;
gYaSearchService.setCharPref(this.LASTVERSION_PREF_NAME, currentVersion);
if ("vendorDataMergeClids" in gYaSearchService)
gYaSearchService.vendorDataMergeClids();
if (lastVersion == "0") {
gYaSearchService.timeGuid = null;
gYaSearchService.checkNeedSendGuid();
this._changePreferencesOnInstall();
if (!gYaSearchService.checkKeywordURL)
gYaSearchService.checkKeywordURL = "check";
} else {
try {
if (typeof(gYaOverlay) === "object" && "migrateWidgets" in gYaOverlay)
gYaOverlay.migrateWidgets(lastVersion);
} catch(e) {
gYaSearchService.log(e);
}
this._migratePreferencesOnInstall(lastVersion);
}
var versionComparator = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator);
if (versionComparator.compare(currentVersion, lastVersion) == 1) {
gYaSearchService.showLocalWelcomePage = true;
var welcomepageVersion = gYaSearchService.getCharPref("yasearch.welcomepage.version");
var welcomepageVersionIntroduced = gYaSearchService.getCharPref("yasearch.welcomepage.version.introduced");
if (welcomepageVersionIntroduced == "0" && lastVersion == "4.0.0")
welcomepageVersionIntroduced = "4.0.0";
if (gYaSearchService.getBoolPref("yasearch.welcomepage.dontshow")) {
gYaSearchService.resetPref("yasearch.welcomepage.dontshow");
gYaSearchService.showLocalWelcomePage = false;
}
var regKeyPath = "Software\\Yandex\\Toolbar",
regKeyParam = "VersionIntroducedFx";
var versionFromWinReg = gYaSearchService.WinReg.read("HKCU", regKeyPath, regKeyParam) ||
gYaSearchService.WinReg.read("HKLM", regKeyPath, regKeyParam);
if (versionFromWinReg && versionComparator.compare(welcomepageVersionIntroduced, versionFromWinReg) == -1)
welcomepageVersionIntroduced = versionFromWinReg;
if (welcomepageVersionIntroduced && versionComparator.compare(welcomepageVersion, welcomepageVersionIntroduced) < 1) {
gYaSearchService.showLocalWelcomePage = false;
} else {
welcomepageVersionIntroduced = welcomepageVersion;
}
gYaSearchService.setCharPref("yasearch.welcomepage.version.introduced", welcomepageVersionIntroduced);
}
if (lastVersion == "0") {
try {
this._addStartMenuLinks();
} catch(e) {}
}
},
_checkToolbarCollapsed: function(aLastVersion, aCurrentVersion) {
let checkToolbarCollapsed = gYaSearchService.getIntPref(this.CHECK_TOOLBAR_COLLAPSED_PREF_NAME);
if (checkToolbarCollapsed) {
gYaSearchService.resetPref(this.CHECK_TOOLBAR_COLLAPSED_PREF_NAME);
if (checkToolbarCollapsed == 1 && typeof(gYaOverlay) === "object" && "setToolbarCollapsedState" in gYaOverlay) {
if (aLastVersion == "0" || aLastVersion === aCurrentVersion) {
gYaOverlay.setToolbarCollapsedState(false);
}
}
}
},
_changePreferencesOnInstall: function() {
var exportCheckedName = "yasearch.general.ui.bookmarks.prefs.yaruExportChecked";
if (!gYaSearchService.prefBranch.prefHasUserValue(exportCheckedName)) {
gYaSearchService.setBoolPref(exportCheckedName, true);
}
this._checkFTabData();
try {
if (gYaSearchService.isYaOnlineInstalled) {
gYaSearchService.setBoolPref("yasearch.mail.ui.notification.enabled", false);
gYaSearchService.setBoolPref("yasearch.feeds.ui.notification.enabled", false);
}
} catch (ex) {}
},
_migratePreferencesOnInstall: function(aLastVersion) {
var versionComparator = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator);
if (versionComparator.compare(aLastVersion, "4.2.2") < 1) {
this.sttInstall = true;
}
if (aLastVersion == "3.5.3") {
let oldPublicBookmarksPrefName = "yasearch.general.ui.bookmarks.prefs.yaruPublicValue",
newPublicBookmarksPrefName = "yasearch.general.ui.bookmarks.prefs.yaruPublicVal";
let oldPublicBookmarksPrefValue = gYaSearchService.getIntPref(oldPublicBookmarksPrefName) || 10;
if (oldPublicBookmarksPrefValue) {
gYaSearchService.setIntPref(newPublicBookmarksPrefName, oldPublicBookmarksPrefValue);
}
} else if (aLastVersion == "4.0.0") {
let hpDefencePrefName = "yasearch.defence.homepage.changes";
let hpDefencePrefValues = (gYaSearchService.getCharPref(hpDefencePrefName) || "").split("|");
if (hpDefencePrefValues.length == 3) {
hpDefencePrefValues.push("0");
gYaSearchService.setCharPref(hpDefencePrefName, hpDefencePrefValues.join("|"));
}
}
let oldBookmarksPrefName = "yasearch.general.ui.boomarks.open";
if (gYaSearchService.getBoolPref(oldBookmarksPrefName)) {
gYaSearchService.setIntPref("yasearch.general.ui.bookmarks.action", 0);
}
// aLastVersion <= 5.0.1 (remove old services data file)
if (versionComparator.compare(aLastVersion, "5.0.1") < 1) {
let yandexDir = gYaSearchService.getYandexDir();
if (yandexDir) {
let fileToRemove = yandexDir.clone();
fileToRemove.append("services.mybar.xml");
if (fileToRemove.exists() && fileToRemove.isFile()) {
try {
fileToRemove.remove(true);
} catch(e) {}
}
}
}
this._checkFTabData();
},
_checkFTabData: function() {
try {
let yandexDir = gYaSearchService.getYandexDir();
if (!yandexDir)
return;
let ftabFileName = "ftab.data.xml";
let ftabFile = yandexDir.clone();
ftabFile.append(ftabFileName);
if (ftabFile.exists() && ftabFile.isFile())
return;
let ftabDefaultFile = gYaSearchService.getContentDir();
ftabDefaultFile.append("ftab");
ftabDefaultFile.append("def." + ftabFileName);
if (!(ftabDefaultFile.exists() && ftabDefaultFile.isFile()))
return;
let ftabContent = gYaSearchService.readFile(ftabDefaultFile);
if (!ftabContent)
return;
let clid = gYaSearchService.vendorData.clid7;
let urlPrefix = "http://clck.yandex.ru/redir/dtype=stred/pid=12/cid=70328/path=";
let yandexLink = urlPrefix + "Yandex/url*http://" +
gYaSearchService.getLocaleDependedUrl("YandexWwwHost") + "/" + (clid ? "?clid=" + clid : "");
let mailLink = urlPrefix + "Mail/url*http://" + gYaSearchService.getLocaleDependedUrl("MailHost") + "/";
let fotkiLink = urlPrefix + "Fotki/url*http://" + gYaSearchService.getLocaleDependedUrl("FotkiHost") + "/";
ftabContent = ftabContent.replace(/%yandex%/g, yandexLink)
.replace(/%mail%/g, mailLink)
.replace(/%fotki%/g, fotkiLink);
let ftabDoc = gYaSearchService.domParser.parseFromString(ftabContent, "text/xml");
let ftabXML = gYaSearchService.safeE4Xml(ftabDoc, null, "data");
if (ftabXML)
gYaSearchService.writeFile(ftabFile, ftabXML.toXMLString());
} catch(e) {}
},
_write1251File: function(aFile, aData) {
var uConverter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
uConverter.charset = "windows-1251";
var chunk = uConverter.ConvertFromUnicode(aData);
var os = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
os.init(aFile, 0x02 | 0x08 | 0x20, 0755, 0);
var result = os.write(chunk, chunk.length);
os.close();
},
_addStartMenuLinks: function() {
if (!gYaSearchService.windowsOS || gYaSearchService.AppBarType === "barffport")
return;
this._removeStartMenuLinks();
var iconFile = gYaSearchService.getChromeDir();
iconFile.append("skin");
iconFile.append("classic");
iconFile.append("images");
iconFile.append("bar-logo.ico");
var iconFilePath = iconFile.path;
var progsBarDir = this._getProgsBarDir();
if (!progsBarDir)
return;
var welcomeLocalFilePath = function __welcomeLocalFilePath() {
try {
var reg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
var ioSvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var chromeURL = ioSvc.newURI("chrome://yasearch/locale/first-start/welcome.html", null, null);
var fileURL = reg.convertChromeURL(chromeURL);
return decodeURIComponent(fileURL.path).replace(/\//g, '\\').replace(/\\/,'');
} catch(e) {}
return gYaSearchService.getString("windowsStartMenuUrlWelcomePage");
}();
["OnlineHelp", "WelcomePage"].forEach(function(aLinkType) {
var shortcutURL = aLinkType == "WelcomePage" ? welcomeLocalFilePath :
gYaSearchService.getString("windowsStartMenuUrl" + aLinkType);
var linkFile = progsBarDir.clone();
linkFile.append(gYaSearchService.getString("windowsStartMenuName" + aLinkType) + ".url");
if (!linkFile.exists() || !linkFile.isFile()) {
try {
linkFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0755);
if (linkFile.exists() && linkFile.isFile()) {
var fileContent = "[InternetShortcut]" +
"\r\nURL=" + shortcutURL +
"\r\nIconFile=" + iconFilePath +
"\r\nIconIndex=0" +
"\r\n";
this._write1251File(linkFile, fileContent);
}
} catch(e) {}
}
}, this);
},
_removeStartMenuLinks: function() {
if (!gYaSearchService.windowsOS)
return;
var progsBarDir = this._getProgsBarDir();
if (!progsBarDir)
return;
["OnlineHelp", "WelcomePage"].forEach(function(aLinkType) {
var linkFile = progsBarDir.clone();
linkFile.append(gYaSearchService.getString("windowsStartMenuName" + aLinkType) + ".url");
if (linkFile.exists() && linkFile.isFile()) {
try { linkFile.remove(true); } catch(e) {}
}
}, this)
if (!progsBarDir.directoryEntries.hasMoreElements()) {
var parentDir = progsBarDir.parent;
try {
progsBarDir.remove(true);
if (!parentDir.directoryEntries.hasMoreElements()) {
parentDir.remove(true);
}
} catch(e) {}
}
try {
var cmPrgs = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("CmPrgs", Ci.nsIFile);
if (cmPrgs && cmPrgs.exists() && cmPrgs.isDirectory()) {
cmPrgs.append(this._YandexName);
if (cmPrgs.exists() && cmPrgs.isDirectory() && !cmPrgs.directoryEntries.hasMoreElements()) {
cmPrgs.remove(true);
}
}
} catch(e) {}
},
_getProgsBarDir: function() {
try {
var programsDir = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("Progs", Ci.nsIFile);
if (programsDir && programsDir.exists() && programsDir.isDirectory()) {
programsDir.append(this._YandexName);
if (!programsDir.exists() || !programsDir.isDirectory()) {
try {
programsDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
} catch(e) {}
}
if (programsDir.exists() && programsDir.isDirectory()) {
var barFolder = programsDir.clone();
barFolder.append(this._YandexBarName);
if (!barFolder.exists() || !barFolder.isDirectory()) {
try {
barFolder.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
} catch(e) {}
}
if (barFolder.exists() && barFolder.isDirectory())
return barFolder;
}
}
} catch(e){}
return null;
},
get _YandexName() {
return UConverter.ConvertToUnicode("Яндекс");
},
get _YandexBarName() {
return UConverter.ConvertToUnicode("Яндекс.Бар");
},
STT_PREF_NAME: "yasearch.general.stt",
get sttInstall() {
let stt = gYaSearchService.getCharPref(this.STT_PREF_NAME);
return stt !== '{"s":{"i":4}}';
},
set sttInstall() {
gYaSearchService.setCharPref(this.STT_PREF_NAME, '{"s":{"i":4}}');
},
proccessUninstall: function() {
//if (gYaSearchService.getCharPref("general.useragent.extra.yandexp"))
//gYaSearchService.setCharPref("general.useragent.extra.yandexp", "s027vp");
gYaSearchService.resetPref(this.LASTVERSION_PREF_NAME);
gYaSearchService.resetPref("yasearch.license.accepted");
gYaSearchService.resetPref("yasearch.welcomepage.version.introduced");
gYaSearchService.resetPref(this.STT_PREF_NAME);
let vendorFileName = gYaSearchService.vendorFileName;
gYaSearchService.resetPref("yasearch.general.app.bar.type");
if (typeof(gYaStorage) === "object" && "shutdown" in gYaStorage)
gYaStorage.shutdown();
try {
gYaSearchService.yaAuth.PasswordManager.removeAllUsersData();
} catch (ex) {}
var yandexDir = gYaSearchService.getYandexDir();
if (yandexDir) {
["cities.data.xml", "regions.data.xml", "services.mybar.xml", "maps.data.xml",
"services.data.xml", "ftab.data.xml", "yasearch-storage.sqlite"]
.forEach(function(aFileName) {
var fileToRemove = yandexDir.clone();
fileToRemove.append(aFileName);
if (fileToRemove.exists() && fileToRemove.isFile()) {
try {
fileToRemove.remove(true);
} catch(e) {}
}
}, this);
if (!yandexDir.directoryEntries.hasMoreElements()) {
try {
yandexDir.remove(true);
} catch(e) {}
}
}
var yaAppDir = gYaSearchService.getYaAppDir();
if (yaAppDir) {
["r1-barff", vendorFileName]
.forEach(function(aFileName) {
if (aFileName) {
var fileToRemove = yaAppDir.clone();
fileToRemove.append(aFileName);
if (fileToRemove.exists() && fileToRemove.isFile()) {
try {
fileToRemove.remove(true);
} catch(e) {}
}
}
}, this);
}
this._removeStartMenuLinks();
this._sendUninstallRequest();
},
_sendUninstallRequest: function() {
let url = gYaSearchService.generateGUIDStatusURL;
if (!url)
return;
let versionData = gYaSearchService.versionData;
let data2Server = [];
for each (var prop in ["yasoft", "ui", "ver", "os", "clid"])
if (versionData[prop])
data2Server.push(prop + "=" + encodeURIComponent(versionData[prop]));
data2Server.push("stat=uninstall");
url += data2Server.join("&");
let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
req.open("GET", url, false);
req.send(null);
}
}