File: install.js

package info (click to toggle)
tabextensions 2.1.2006031301-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,440 kB
  • ctags: 424
  • sloc: xml: 6,135; makefile: 38; sh: 35
file content (122 lines) | stat: -rwxr-xr-x 3,313 bytes parent folder | download
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
var version     = '2.1.2006031301',
	displayName = 'Tabbrowser Extensions',
	appName     = 'tabextensions',
	author      = 'SHIMODA Hiroshi',
	hasLangPack = true,
	hasJLP      = true,
	hasSkin     = true,
	options     = [
					'eventhandler',
					'sessionManager',
					'ctrlPopup'
				];


var err         = initInstall(
		displayName,
		appName,
		version
		),
	UChrome     = getFolder('Chrome'),
	messages    = loadResources('locale.inf'),
	optionsMsg  = ('options' in this && options.length ? loadResources('options.inf') : null ),
	installedOptions = [],
	files       = [],
	jarName     = appName+'.jar',
	contentFlag = CONTENT | DELAYED_CHROME,
	localeFlag  = LOCALE | DELAYED_CHROME,
	skinFlag    = SKIN | DELAYED_CHROME,
	i;


var existsInGlobal  = File.exists(getFolder(UChrome, jarName));
var existsInProfile = File.exists(getFolder(getFolder('Current User', 'chrome'), jarName));
var isNewType       = File.exists(getFolder(UChrome, 'browser.jar'));

if ('newTypeOnly' in this && newTypeOnly && !isNewType) {
	alert(messages.newTypeOnly);
	cancelInstall(err);
}
else if (existsInGlobal && existsInProfile) {
	cancelInstall(err);
}
else {

	if (existsInProfile ||
		(!existsInGlobal && confirm(messages.installToProfile))) {
		UChrome = getFolder('Current User', 'chrome');
		contentFlag = CONTENT | PROFILE_CHROME;
		localeFlag  = LOCALE | PROFILE_CHROME;
		skinFlag    = SKIN | PROFILE_CHROME;
	}


	logComment('initInstall: ' + err);
	setPackageFolder(UChrome);

//	if (File.exists(getFolder(UChrome, jarName))) {
//		alert(messages.exists);
//		cancelInstall(err);
//	}
//	else {
	var i = 0;
		addFile(author, 'chrome/'+jarName, UChrome, '');
		var folder = getFolder(UChrome, jarName);
		files.push(folder);

		registerChrome(contentFlag, folder, 'content/'+appName+'/');


		if ('options' in this && options.length) {
			var confirmMessage;
			for (i = 0; i < options.length; i++)
			{
				confirmMessage = null;
				try {
					confirmMessage = optionsMsg[options[i]];
				}
				catch(e) {
				}
				if (!confirmMessage || confirm(optionsMsg[options[i]])) {
					registerChrome(contentFlag, folder, 'content/'+options[i]+'/');
					if (confirmMessage)
						installedOptions.push(options[i]);
				}
			}
		}


		// Language packs
		if ('hasLangPack' in this && hasLangPack) {
			registerChrome(localeFlag, folder, 'locale/en-US/'+appName+'/');
			for (i = 0; i < installedOptions.length; i++)
				registerChrome(localeFlag, folder, 'locale/en-US/'+installedOptions[i]+'/');

			if ('hasJLP' in this && hasJLP && confirm(messages.JLP)) {
				registerChrome(localeFlag, folder, 'locale/ja-JP/'+appName+'/');

				for (i = 0; i < installedOptions.length; i++)
					registerChrome(localeFlag, folder, 'locale/ja-JP/'+installedOptions[i]+'/');
			}
		}

		if ('hasSkin' in this && hasSkin) {
			registerChrome(skinFlag, folder, 'skin/classic/'+appName+'/');
		}

		err = getLastError();
		if (err == SUCCESS) {
			performInstall();
			alert(
				'Ver.'+version+'\n\n'+
				messages.installed+'\n'+
				files.join('\n')+'\n\n\n'+
				messages.complete+
				(contentFlag & PROFILE_CHROME ? '' : '\n\n'+messages.permissionNotes)
			);
		}
		else {
			cancelInstall(err);
		}
//	}
}