Skip to content

Commit e872bb6

Browse files
author
Chris Warren-Smith
committed
ANDROID: replace MUI based portal with native js implementation
- implemented proxy handling to the web build
1 parent 78a80a0 commit e872bb6

13 files changed

Lines changed: 252 additions & 113 deletions

File tree

configure.ac

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
77
dnl Download the GNU Public License (GPL) from www.gnu.org
88
dnl
99

10-
AC_INIT([smallbasic], [12.31])
10+
AC_INIT([smallbasic], [12.32])
1111
AC_CONFIG_SRCDIR([configure.ac])
1212

1313
AC_CANONICAL_TARGET
@@ -271,7 +271,6 @@ function buildAndroid() {
271271
TEST_DIR="src/platform/android"
272272
AC_SUBST(TEST_DIR)
273273
if test $with_library = no; then
274-
(cd src/platform/android/webui && npm run build)
275274
TARGET="Building for Android."
276275
else
277276
TARGET="Building for Android library."
@@ -351,6 +350,14 @@ function buildWeb() {
351350
PACKAGE_LIBS="${PACKAGE_LIBS} -lm -ldl -lpthread -lmicrohttpd"
352351
AC_CHECK_HEADERS([microhttpd.h], [], [AC_MSG_ERROR([microhttpd is not installed])])
353352
fi
353+
354+
AC_CHECK_HEADERS([curl/curl.h], [have_curl_h=yes; break;])
355+
356+
if test "x${have_curl_h}" = "xyes" ; then
357+
AC_DEFINE(USE_LIB_CURL, 1, [use the curl library.])
358+
PACKAGE_LIBS="${PACKAGE_LIBS} -lcurl"
359+
fi
360+
354361
BUILD_SUBDIRS="src/common src/platform/web"
355362
AM_CONDITIONAL(WITH_CYGWIN_CONSOLE, false)
356363
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
@@ -482,7 +489,7 @@ checkProfiling
482489
checkForWindows
483490

484491
CFLAGS="${CFLAGS} -std=gnu11"
485-
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} -Wall -Wno-unused-result"
492+
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} -Wall -Werror -Wno-unused-result"
486493
BUILD_DATE=`date +"%a, %d %b %Y"`
487494
AC_DEFINE_UNQUOTED([BUILD_DATE],["$BUILD_DATE"],[Build date])
488495

src/platform/android/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ library:
5656
(cp -R app/build/intermediates/stripped_native_libs/release/out/lib/ dist)
5757
(cp app/build/intermediates/dex/release/minifyReleaseWithR8/classes.dex dist)
5858

59+
# launch WebServerTest in intellij
60+
start-ui:
61+
(cd app/src/main/assets/webui && valgrind ../../../../../../web/sbasicw -p 3000 -a 'api' -o 'http://localhost:8080')
File renamed without changes.
File renamed without changes.

src/platform/android/portal-ui/main.js renamed to src/platform/android/app/src/main/assets/webui/main.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
const mainContent = document.getElementById('main-content');
1414
if (token) {
1515
renderFileList(mainContent);
16-
setupFileListEventListeners();
1716
} else {
1817
renderTokenInput(mainContent);
1918
}
@@ -90,6 +89,7 @@
9089

9190
renderTableRows();
9291
updateToolbarState();
92+
setupFileListEventListeners();
9393
}
9494

9595
function renderTableRows() {
@@ -322,6 +322,7 @@
322322
rows = data;
323323
renderContent();
324324
} catch (error) {
325+
console.log(error);
325326
tokenInput.classList.add('error');
326327
helperText.textContent = 'Invalid token. Enter the access token displayed on the SmallBASIC [About] screen.';
327328
helperText.classList.add('error');
@@ -342,8 +343,7 @@
342343
for (let i = 0; i < files.length; i++) {
343344
const file = files[i];
344345
const dataUrl = await fileToDataURL(file);
345-
await callApi('/api/upload',
346-
`fileName=${encodeURIComponent(file.name)}&data=${dataUrl}`);
346+
await callApi('/api/upload', `fileName=${encodeURIComponent(file.name)}&data=${dataUrl}`);
347347

348348
if (files.length > 1) {
349349
showSnackbar(`Uploaded ${i + 1}/${files.length} files`, 'info');
@@ -413,8 +413,7 @@
413413
`Are you sure you want to permanently delete ${selectedRow.fileName}? You cannot undo `
414414
)) {
415415
try {
416-
const data = await callApi('/api/delete',
417-
`fileName=${encodeURIComponent(selectedRow.fileName)}`);
416+
const data = await callApi('/api/delete', `fileName=${encodeURIComponent(selectedRow.fileName)}`);
418417
rows = data;
419418
selectedRows.clear();
420419
renderTableRows();
@@ -434,8 +433,7 @@
434433
if (oldName === newName) return;
435434

436435
try {
437-
await callApi('/api/rename',
438-
`from=${encodeURIComponent(oldName)}&to=${encodeURIComponent(newName)}`);
436+
await callApi('/api/rename', `from=${encodeURIComponent(oldName)}&to=${encodeURIComponent(newName)}`);
439437
row.fileName = newName;
440438
showSnackbar('File renamed successfully', 'success');
441439
} catch (error) {
@@ -454,6 +452,7 @@
454452

455453
const data = await response.json();
456454
if (data.error) {
455+
console.log(data);
457456
throw new Error(data.error);
458457
}
459458
return data;

src/platform/android/webui/package.json

Lines changed: 0 additions & 58 deletions
This file was deleted.
-5.59 KB
Binary file not shown.

src/platform/android/webui/vite.config.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/platform/web/Makefile.am

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# SmallBASIC web server version
2-
# Copyright(C) 2001-2016 Chris Warren-Smith.
2+
# Copyright(C) 2001-2025 Chris Warren-Smith.
33
#
44
# This program is distributed under the terms of the GPL v2.0 or later
55
# Download the GNU Public License (GPL) from www.gnu.org
66
#
77

8+
#
9+
# sudo apt install libcurl4-openssl-dev
10+
#
11+
812
AM_CPPFLAGS = -I$(top_builddir)/src -I. @PACKAGE_CFLAGS@
913
bin_PROGRAMS = sbasicw
10-
sbasicw_SOURCES = main.cpp canvas.cpp ../../ui/strlib.cpp
14+
sbasicw_SOURCES = main.cpp canvas.cpp config.cpp ../../ui/strlib.cpp
1115
sbasicw_LDADD = -L$(top_srcdir)/src/common -lsb_common @PACKAGE_LIBS@
1216
sbasicw_DEPENDENCIES = $(top_srcdir)/src/common/libsb_common.a
17+

src/platform/web/config.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This file is part of SmallBASIC
2+
//
3+
// Copyright(C) 2001-2025 Chris Warren-Smith.
4+
//
5+
// This program is distributed under the terms of the GPL v2.0 or later
6+
// Download the GNU Public License (GPL) from www.gnu.org
7+
//
8+
9+
#include <config.h>
10+
11+
#if defined(USE_LIB_CURL)
12+
#include "proxy.cpp"
13+
#else
14+
#include <microhttpd.h>
15+
void proxy_init(const char *path, const char *host) {}
16+
void proxy_cleanup() {}
17+
bool proxy_accept(MHD_Connection *connection, const char *path) { return false; }
18+
MHD_Response *proxy_request(MHD_Connection *connection, const char *path, const char *method, const char *body) { return nullptr; }
19+
#endif

0 commit comments

Comments
 (0)