diff --git a/app_installer.c b/app_installer.c index 971ef77..b901571 100644 --- a/app_installer.c +++ b/app_installer.c @@ -51,7 +51,7 @@ static int write_file(const char *p, const uint8_t *d, size_t s) { return w == s ? 0 : -1; } -void smplus_install_if_needed(int icon_always_front) { +void smplus_install_if_needed(int icon_always_front, int http_port) { /* In once-only mode, skip if marker exists */ if(!icon_always_front) { FILE *m = fopen(MARKER, "r"); @@ -70,6 +70,16 @@ void smplus_install_if_needed(int icon_always_front) { mkdir(sdir, 0755); if (write_file(par, sm_param_json, sm_param_json_size) != 0) goto done; + /* patch deeplink port in the written param.json */ + {FILE *pf=fopen(par,"r+");if(pf){ + char buf[1024]={0};fread(buf,1,sizeof(buf)-1,pf); + char old_url[64],new_url[64]; + snprintf(old_url,sizeof(old_url),"http://127.0.0.1:7777/"); + snprintf(new_url,sizeof(new_url),"http://127.0.0.1:%d/",http_port>1024?http_port:7777); + char *pos=strstr(buf,old_url); + if(pos&&strlen(old_url)==strlen(new_url)){memcpy(pos,new_url,strlen(new_url)); + fseek(pf,0,SEEK_SET);fwrite(buf,1,strlen(buf),pf);} + fclose(pf);}} if (write_file(ico, sm_icon0_png, sm_icon0_png_size) != 0) goto done; install_title_dir(TITLE_ID, APP_ROOT "/"); diff --git a/app_installer.h b/app_installer.h index 3f41eff..cf25723 100644 --- a/app_installer.h +++ b/app_installer.h @@ -1,4 +1,4 @@ #ifndef APP_INSTALLER_H #define APP_INSTALLER_H -void smplus_install_if_needed(int icon_always_front); +void smplus_install_if_needed(int icon_always_front, int http_port); #endif diff --git a/assets-app/param.json b/assets-app/param.json index 434f5eb..67152b8 100644 --- a/assets-app/param.json +++ b/assets-app/param.json @@ -1,7 +1,7 @@ { "applicationCategoryType": 0, "titleId": "SMPL00001", - "deeplinkUri": "http://127.0.0.1:7070/", + "deeplinkUri": "http://127.0.0.1:7777/", "localizedParameters": { "defaultLanguage": "de-DE", "de-DE": { diff --git a/main.c b/main.c index 71a7d3a..95b465f 100644 --- a/main.c +++ b/main.c @@ -3265,7 +3265,7 @@ int payload_main(void) { { SMPrefs _p; read_prefs(&_p); /* read icon pref once at start */ while(1){ mg_mgr_poll(&mgr,1000); usleep(100000); - if(++polls==3) smplus_install_if_needed(_p.icon_always_front); + if(++polls==3) smplus_install_if_needed(_p.icon_always_front, _p.http_port>1024?_p.http_port:7777); /* send pending ELF after browser got its {ok:true} response */ if(smg_pending_elf[0]){ send_elf_to_elfldr(smg_pending_elf); smg_pending_elf[0]=0; } if(polls==6 && !as_done){ /* ~6s after start — give elfldr time to initialize */