moving to private repo

This commit is contained in:
Shane Harris
2020-08-17 13:31:48 +01:00
committed by Your Name
parent fe20b27432
commit afcc6e58f8
16 changed files with 211 additions and 117 deletions
+111 -95
View File
@@ -510,76 +510,87 @@ export class AdbClientService {
shouldUninstall?: boolean,
number?: number,
total?: number,
deleteAfter?: boolean
deleteAfter?: boolean,
name?: string
) {
return this.processService.addItem('apk_install', task => {
if (this.deviceStatus !== ConnectionStatus.CONNECTED) {
return Promise.reject('Apk install failed: No device connected! ' + filePath);
}
const showTotal = number && total ? '(' + number + '/' + total + ') ' : '';
const updateStatus = (text: string): void => {
const newStatus = `${showTotal}${text} `;
if (task.status !== newStatus) {
task.status = newStatus;
return this.processService.addItem(
'apk_install',
task => {
name = name ? name + ': ' : '';
if (this.deviceStatus !== ConnectionStatus.CONNECTED) {
return Promise.reject(name + 'Apk install failed - No device connected! ' + filePath);
}
};
const checkReported: Promise<InstallDecision> = isLocal
? this.checkIsAPKReported(updateStatus, filePath)
: Promise.resolve('DoInstall');
return checkReported.then(installDecision => {
if (installDecision === 'DoInstall') {
task.status = showTotal + 'Installing Apk... ';
return this.adbCommand('install', { serial: this.deviceSerial, path: filePath, isLocal: !!isLocal }, status => {
task.status =
(status.percent === 1
? showTotal + 'Installing Apk... '
: showTotal + 'Downloading APK... ' + Math.round(status.percent * 100) + '% ') +
' <span style="font-style:italic">' +
filePath +
'</span>';
})
.then(r => {
task.status = 'APK file installed ok!! ' + filePath;
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
}
if (filePath.indexOf('com.weloveoculus.BMBF') > -1) {
return this.beatonService.setBeatOnPermission(this);
}
if (filePath.toLowerCase().indexOf('sidequest.legends') > -1) {
return this.setPermission('com.sidequest.legends', 'android.permission.RECORD_AUDIO');
}
if (filePath.toLowerCase().indexOf('pavlov') > -1) {
return this.setPermission('com.vankrupt.pavlov', 'android.permission.RECORD_AUDIO')
.then(() =>
this.setPermission('com.vankrupt.pavlov', 'android.permission.READ_EXTERNAL_STORAGE')
)
.then(() =>
this.setPermission('com.vankrupt.pavlov', 'android.permission.WRITE_EXTERNAL_STORAGE')
)
.then(() =>
this.adbCommand('shell', {
serial: this.deviceSerial,
command: 'echo null > /sdcard/pavlov.name.txt',
})
);
}
})
.catch(e => {
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
}
return Promise.reject(e.message ? e.message : e.code ? e.code : e.toString() + ' ' + filePath);
});
} else {
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
const showTotal = number && total ? '(' + number + '/' + total + ') ' : '';
const updateStatus = (text: string): void => {
const newStatus = `${showTotal}${text} `;
if (task.status !== newStatus) {
task.status = newStatus;
}
updateStatus('Canceled Install.');
return Promise.resolve();
}
});
});
};
const checkReported: Promise<InstallDecision> = isLocal
? this.checkIsAPKReported(updateStatus, filePath)
: Promise.resolve('DoInstall');
return checkReported.then(installDecision => {
task.app_name = name;
if (installDecision === 'DoInstall') {
task.status = name + showTotal + 'Installing Apk... ';
return this.adbCommand(
'install',
{ serial: this.deviceSerial, path: filePath, isLocal: !!isLocal },
status => {
task.status =
(status.percent === 1
? name + showTotal + 'Installing Apk... '
: name + showTotal + 'Downloading APK... ' + Math.round(status.percent * 100) + '% ') +
' <span style="font-style:italic">' +
filePath +
'</span>';
}
)
.then(r => {
task.status = name + 'APK file installed ok!! ' + filePath;
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
}
if (filePath.indexOf('com.weloveoculus.BMBF') > -1) {
return this.beatonService.setBeatOnPermission(this);
}
if (filePath.toLowerCase().indexOf('sidequest.legends') > -1) {
return this.setPermission('com.sidequest.legends', 'android.permission.RECORD_AUDIO');
}
if (filePath.toLowerCase().indexOf('pavlov') > -1) {
return this.setPermission('com.vankrupt.pavlov', 'android.permission.RECORD_AUDIO')
.then(() =>
this.setPermission('com.vankrupt.pavlov', 'android.permission.READ_EXTERNAL_STORAGE')
)
.then(() =>
this.setPermission('com.vankrupt.pavlov', 'android.permission.WRITE_EXTERNAL_STORAGE')
)
.then(() =>
this.adbCommand('shell', {
serial: this.deviceSerial,
command: 'echo null > /sdcard/pavlov.name.txt',
})
);
}
})
.catch(e => {
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
}
return Promise.reject(e.message ? e.message : e.code ? e.code : e.toString() + ' ' + filePath);
});
} else {
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
}
updateStatus('Canceled Install.');
return Promise.resolve();
}
});
},
name
);
}
async checkIsAPKReported(updateStatus: (string) => void, filePath: string): Promise<InstallDecision> {
let isReported: boolean;
@@ -904,33 +915,38 @@ export class AdbClientService {
});
});
}
installObb(url, number?: number, total?: number) {
return this.processService.addItem('file_install', async task => {
task.status = 'Downloading OBB file...';
return this.appService
.downloadFile(
url,
url,
url,
downloadUrl => {
return this.appService.path.join(
this.appService.appData,
downloadUrl
.split('/')
.pop()
.split('?')
.shift()
);
},
task
)
.then((_path: string) => {
task.status = 'Installing OBB file...';
return this.installLocalObb(_path, false, null, number, total, task);
});
});
installObb(url, number?: number, total?: number, name?: string) {
return this.processService.addItem(
'file_install',
async task => {
task.app_name = name;
task.status = (name ? name + ': ' : '') + 'Downloading OBB file...';
return this.appService
.downloadFile(
url,
url,
url,
downloadUrl => {
return this.appService.path.join(
this.appService.appData,
downloadUrl
.split('/')
.pop()
.split('?')
.shift()
);
},
task
)
.then((_path: string) => {
task.status = name + 'Installing OBB file...';
return this.installLocalObb(_path, false, null, number, total, task, name);
});
},
name
);
}
installLocalObb(filepath: string, dontCatchError = false, cb = null, number?: number, total?: number, task?) {
installLocalObb(filepath: string, dontCatchError = false, cb = null, number?: number, total?: number, task?, name?: string) {
let filename = this.appService.path.basename(filepath);
let packageId = filename.match(/main.[0-9]{1,}.([a-z]{1,}.[A-z]{1,}.[A-z]{1,}).obb/)[1];
const showTotal = number && total ? '(' + number + '/' + total + ') ' : '';
@@ -941,7 +957,7 @@ export class AdbClientService {
}
p = p.then(() => {
if (task) {
task.status = 'File transferred successfully! ' + filepath;
task.status = name + 'File transferred successfully! ' + filepath;
} else {
this.statusService.showStatus('File transferred successfully!');
}
@@ -950,7 +966,7 @@ export class AdbClientService {
p = p.catch(e => {
if (task) {
task.failed = true;
task.status = 'Failed to transfer file!! - ' + filepath;
task.status = name + 'Failed to transfer file!! - ' + filepath;
} else {
this.spinnerService.hideLoader();
this.statusService.showStatus(e.toString(), true);
+1 -1
View File
@@ -25,7 +25,7 @@
border-top-left-radius: 40px;
z-index: 9;
}
#beatView{
#mainWebView{
width: 100%;
height: calc(100% - 35px);
top: 35px;
+2 -1
View File
@@ -6,7 +6,8 @@
<app-loading-spinner #spinner></app-loading-spinner>
<app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event"></app-status-bar>
<webview id="beatView" #webview src="https://sidequestvr.com" allowpopups
<webview id="mainWebView" #webview src="https://sidequestvr.com" allowpopups disablewebsecurity
useragent="Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko electron/ SideQuestAgent"
[ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview"></webview>
<mz-modal #getHelpModal [fixedFooter]="true">
+1
View File
@@ -47,6 +47,7 @@ export class AppComponent {
ngAfterViewInit() {
this.spinnerService.setSpinner(this.spinner);
this.statusService.setStatus(this.status);
console.log(this.webview);
this.webService.setWebView(this.webview.nativeElement);
}
}
+10 -3
View File
@@ -104,6 +104,12 @@ export class AppService {
this.extractResolves[data.token].scb(data.stats);
}
});
this.electron.ipcRenderer.on('download-url-fail', (event, data) => {
if (!!this.downloadResolves[data.token]) {
this.downloadResolves[data.token].reject(data.e);
delete this.downloadResolves[data.token];
}
});
this.electron.ipcRenderer.on('download-url', (event, data) => {
if (!!this.downloadResolves[data.token]) {
this.downloadResolves[data.token].resolve();
@@ -125,7 +131,7 @@ export class AppService {
this.extractResolves[token] = {
scb: stats => {
if (task) {
task.status = 'Extracting... ' + stats;
task.status = (task.app_name ? task.app_name + ': ' : '') + 'Extracting... ' + stats;
}
},
resolve,
@@ -267,15 +273,16 @@ export class AppService {
}
downloadFileAPI(url, directory, filename, task?) {
// Send request to application thread to download a file. Store the callback for the response.
return new Promise(resolve => {
return new Promise((resolve, reject) => {
let token = this.uuidv4();
this.downloadResolves[token] = {
scb: stats => {
if (task) {
task.status = 'Downloading... ' + stats + '%';
task.status = (task.app_name ? task.app_name + ': ' : '') + 'Downloading... ' + stats + '%';
}
},
resolve,
reject,
};
this.electron.ipcRenderer.send('download-url', { token, url, directory, filename });
});
-1
View File
@@ -211,7 +211,6 @@ export class BeatOnService {
return this.processService.addItem('song_download', async task => {
let parts = downloadUrl.split('/');
let zipPath = this.appService.path.join(this.appService.appData, this.appService.uuidv4() + '.zip');
//let name = parts[parts.length - 1].split('.')[0];
const requestOptions = {
timeout: 30000,
'User-Agent': this.appService.getUserAgent(),
@@ -6,5 +6,5 @@
</div>
</div>
<div class="col s2 package-height centered package-item">
<i *ngIf="task.status === 'Waiting...'||(task.running&&!task.succeeded&&!task.failed)" class="material-icons red-text cursor settings" (click)="task.running?processService.skipCurrent(task):deleteItem()">close</i>
<i class="material-icons red-text cursor settings" (click)="task.running?processService.skipCurrent(task):deleteItem()">close</i>
</div>
+55 -2
View File
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, isDevMode } from '@angular/core';
import { AppService } from './app.service';
import { RepoService } from './repo.service';
import { StatusBarService } from './status-bar.service';
@@ -65,6 +65,55 @@ export class ElectronService {
}
}
installFromToken(token) {
let options = {
url: 'https://api.sidequestvr.com/install-from-key',
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Origin: 'https://sidequestvr.com',
},
rejectUnauthorized: !isDevMode(),
json: { token: token },
};
console.log(options);
this.appService.request(options, async (error, response, body) => {
console.log(error, body);
if (!error && body.data && body.data.apps && body.data.apps.length) {
for (let i = 0; i < body.data.apps.length; i++) {
let app = body.data.apps[i];
if (Number(app.app_categories_id) === 1) {
let urls = app.urls.filter(l => l && ~['Github Release', 'APK', 'OBB'].indexOf(l.provider));
for (let i = 0; i < urls.length; i++) {
const etx = urls[i].link_url
.split('?')[0]
.split('.')
.pop()
.toLowerCase();
switch (etx) {
case 'obb':
await this.adbService.installObb(urls[i].link_url, i + 1, urls.length, app.name);
break;
default:
await this.adbService.installAPK(
urls[i].link_url,
false,
false,
i + 1,
urls.length,
false,
app.name
);
break;
}
}
}
}
}
});
}
setupIPC() {
this.appService.electron.ipcRenderer.on('pre-open-url', (event, data) => {
this.spinnerService.showLoader();
@@ -104,10 +153,14 @@ export class ElectronService {
console.log(data.status);
}
});
this.appService.electron.ipcRenderer.on('open-url', (event, data) => {
this.appService.electron.ipcRenderer.on('open-url', async (event, data) => {
if (data) {
let url = data.split('#');
switch (url[0]) {
case 'sidequest://i/':
console.log(data);
this.installFromToken(url[1]);
break;
case 'sidequest://unload/':
this.adbService.uninstallAPK(url[1]);
break;
@@ -259,6 +259,11 @@
Clear Failed
</div>
&nbsp;&nbsp;
<div class="waves-effect waves-light btn small-button red" mz-tooltip position="bottom"
tooltip="Clear out the finished tasks." (click)="processService.clearAll()">
Clear All
</div>
&nbsp;&nbsp;
</div>
<div id="searchFilterContainer" *ngIf="appService.showSearch">
+13 -5
View File
@@ -3,6 +3,7 @@ import { StatusBarService } from './status-bar.service';
export interface ProcessTask {
key: string;
name: string;
app_name?: string;
icon: string;
status?: string;
running?: boolean;
@@ -26,9 +27,9 @@ export class ProcessBucketService {
this.processBucket();
}
addItem(name, resolve) {
addItem(name, resolve, app_name?) {
const key = (<any>window).require('uuid/v4')();
const status = 'Waiting...';
const status = (app_name ? app_name + ': ' : '') + 'Waiting...';
let icon = 'list';
let _name = 'app install';
switch (name) {
@@ -67,15 +68,16 @@ export class ProcessBucketService {
this.tasks.push({
key,
name,
app_name,
icon,
status,
resolve,
});
this.left_length = this.tasks.filter(t => t.status === 'Waiting...').length;
this.left_length = this.tasks.filter(t => !t.failed && !t.running && !t.cancelled && !t.succeeded).length;
}
async processBucket() {
const objects = this.tasks.filter(t => t.status === 'Waiting...');
const objects = this.tasks.filter(t => !t.failed && !t.running && !t.cancelled && !t.succeeded);
const timeout = new Promise(resolve => setTimeout(() => resolve(), 1000));
this.left_length = objects.length;
if (objects.length) {
@@ -85,6 +87,7 @@ export class ProcessBucketService {
await task
.resolve(task)
.then(() => {
task.running = false;
task.succeeded = true;
if (!task.cancelled) {
return timeout.then(() => this.processBucket());
@@ -92,7 +95,8 @@ export class ProcessBucketService {
})
.catch(e => {
task.running = false;
task.status = e.message ? e.message : e.code ? e.code : e.toString();
task.status =
(task.app_name ? task.app_name + ': ' : '') + (e.message ? e.message : e.code ? e.code : e.toString());
task.failed = true;
this.statusService.showStatus(task.status, true);
if (!task.cancelled) {
@@ -144,4 +148,8 @@ export class ProcessBucketService {
clearFailed() {
this.tasks = this.tasks.filter(t => !t.failed);
}
clearAll() {
igin;
this.tasks = [];
}
}
+1
View File
@@ -14,6 +14,7 @@ export class WebviewService {
appService.setWebviewService(this);
}
setWebView(webView) {
console.log({ webView });
this.webView = webView;
this.setupWebview();
}
@@ -14,7 +14,6 @@ export class WebviewComponent implements OnInit {
appService.resetTop();
webService.isWebviewOpen = true;
appService.showBrowserBar = true;
appService.setTitle('<img src="assets/images/logo-textual.png" class="logo-img"/>');
}
ngOnInit() {}
+4 -3
View File
@@ -248,10 +248,11 @@ function setupApp() {
const adb = new ADB();
ipcMain.on('download-url', async (event, { url, token, directory, filename }) => {
await download(url, path.join(directory, filename), stats => {
download(url, path.join(directory, filename), stats => {
return event.sender.send('download-progress', { stats, token });
}).catch(e => console.log(e));
event.sender.send('download-url', { token });
})
.then(() => event.sender.send('download-url', { token }))
.catch(e => event.sender.send('download-url-fail', { e, token }));
});
ipcMain.on('extract-file', async (event, { token, directory, filename }) => {
extract(
+4 -2
View File
@@ -21,7 +21,9 @@ module.exports = function(url, path, progress) {
callback(null, response);
}
});
request.on('error', function(err) {
callback(err);
});
request.setTimeout(TIMEOUT, function() {
request.abort();
callback(new Error(`request timeout after ${TIMEOUT / 1000.0}s`));
@@ -31,7 +33,7 @@ module.exports = function(url, path, progress) {
return new Promise(function(resolve, reject) {
get(uri.href, (err, res) => {
if (err) {
return console.log(err);
return reject(err);
}
const len = parseInt(res.headers['content-length'], 10);
let downloaded = 0;
+1
View File
@@ -59,6 +59,7 @@ export class AppWindow {
show: !showAfterSetup,
frame: false,
webPreferences: {
webviewTag: true,
nodeIntegration: true,
},
};
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "SideQuest",
"version": "0.10.3",
"version": "0.10.2",
"description": "A open app store for mobile android based VR devices such as the Levovo Mirage, Oculus Go, Oculus Quest, Vive Focus.",
"repository": "https://github.com/the-expanse/SideQuest.git",
"license": "MIT",
@@ -97,7 +97,7 @@
},
"devDependencies": {
"@angular/cli": "^8.0.3",
"electron": "^8.2.0",
"electron": "^4.1.4",
"electron-builder": "^22.4.0",
"electron-notarize": "^0.1.1",
"husky": "^2.3.0",