Delete some old things from core, mostly.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3838 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
5ffc505ce2
commit
e4e763b7a0
66
core/core.js
66
core/core.js
@ -101,16 +101,25 @@ function getUser(caller, process) {
|
||||
};
|
||||
}
|
||||
|
||||
function getUsers(packageOwner, packageName) {
|
||||
var result = [];
|
||||
for (var key in gProcesses) {
|
||||
var process = gProcesses[key];
|
||||
if ((!packageOwner || process.packageOwner == packageOwner)
|
||||
&& (!packageName || process.packageName == packageName)) {
|
||||
result.push(getUser(this, process));
|
||||
function getApps(user, process) {
|
||||
if (process.credentials &&
|
||||
process.credentials.session &&
|
||||
process.credentials.session.name) {
|
||||
if (user && user !== process.credentials.session.name && user !== 'core') {
|
||||
return {};
|
||||
} else if (!user) {
|
||||
user = process.credentials.session.name;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
if (user) {
|
||||
var db = new Database(user);
|
||||
try {
|
||||
var names = JSON.parse(db.get('apps'));
|
||||
return Object.fromEntries(names.map(name => [name, db.get('path:' + name)]));
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
function postMessageInternal(from, to, message) {
|
||||
@ -129,12 +138,6 @@ async function getSessionProcessBlob(blobId, session, options) {
|
||||
return getProcessBlob(blobId, 'session_' + session, actualOptions);
|
||||
}
|
||||
|
||||
async function readFileUtf8(fileName) {
|
||||
let data = await File.readFile(fileName);
|
||||
data = utf8Decode(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
let gManifestCache = {};
|
||||
|
||||
async function getProcessBlob(blobId, key, options) {
|
||||
@ -169,7 +172,6 @@ async function getProcessBlob(blobId, key, options) {
|
||||
var imports = {
|
||||
'core': {
|
||||
'broadcast': broadcast.bind(process),
|
||||
'getUsers': getUsers.bind(process),
|
||||
'register': function(eventName, handler) {
|
||||
if (!process.eventHandlers[eventName]) {
|
||||
process.eventHandlers[eventName] = [];
|
||||
@ -187,28 +189,8 @@ async function getProcessBlob(blobId, key, options) {
|
||||
}
|
||||
}
|
||||
},
|
||||
'getUser': getUser.bind(null, process, process),
|
||||
'user': getUser(process, process),
|
||||
'apps': function(name) {
|
||||
if (process.credentials &&
|
||||
process.credentials.session &&
|
||||
process.credentials.session.name) {
|
||||
if (name && name !== process.credentials.session.name && name !== 'core') {
|
||||
return {};
|
||||
} else if (!name) {
|
||||
name = process.credentials.session.name;
|
||||
}
|
||||
}
|
||||
if (name) {
|
||||
var db = new Database(name);
|
||||
try {
|
||||
var names = JSON.parse(db.get('apps'));
|
||||
return Object.fromEntries(names.map(name => [name, db.get('path:' + name)]));
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
'apps': user => getApps(user, process),
|
||||
}
|
||||
};
|
||||
if (options.api) {
|
||||
@ -271,16 +253,6 @@ async function getProcessBlob(blobId, key, options) {
|
||||
return process;
|
||||
}
|
||||
|
||||
function makeDirectoryForFile(fileName) {
|
||||
var parts = fileName.split("/");
|
||||
var path = "";
|
||||
for (var i = 0; i < parts.length - 1; i++) {
|
||||
path += parts[i];
|
||||
File.makeDirectory(path);
|
||||
path += "/";
|
||||
}
|
||||
}
|
||||
|
||||
function setGlobalSettings(settings) {
|
||||
gGlobalSettings = settings;
|
||||
try {
|
||||
@ -560,7 +532,7 @@ async function loadSettings() {
|
||||
|
||||
if (!data) {
|
||||
try {
|
||||
data = JSON.parse(await readFileUtf8(kGlobalSettingsFile));
|
||||
data = JSON.parse(utf8Decode(await File.readFile(kGlobalSettingsFile)));
|
||||
new Database('core').set('settings', JSON.stringify(data));
|
||||
} catch (error) {
|
||||
print("Unable to load settings from " + kGlobalSettingsFile + ":", error);
|
||||
|
Loading…
Reference in New Issue
Block a user