This commit is contained in:
Nick Chan committed 2023-02-04 21:29:49 +08:00
1 parent ad2cb43392
commit f22bee6870
9 files changed
+102 -287

No files matched your search

+3 -81
View File
@@ -27,7 +27,6 @@ jobs:
MBEDTLS_VERSION: 3.3.0 MBEDTLS_VERSION: 3.3.0
LIBUSB_VERSION: 1.0.26 LIBUSB_VERSION: 1.0.26
READLINE_VERSION: 8.2 READLINE_VERSION: 8.2
NCURSES_VERSION: 6.4
SLANG_VERSION: 2.3.3 SLANG_VERSION: 2.3.3
NEWT_VERSION: 0.52.23 NEWT_VERSION: 0.52.23
POPT_VERSION: 1.19 POPT_VERSION: 1.19
@@ -41,7 +40,7 @@ jobs:
- name: Install dependencies (packages) - name: Install dependencies (packages)
run: | run: |
sudo /usr/local/bin/pip3 install jsonschema jinja2 sudo /usr/local/bin/pip3 install jsonschema jinja2
brew install make autoconf automake pkg-config gnu-sed ncurses gettext brew install make autoconf automake pkg-config gnu-sed gettext
sudo rm -rf /usr/local/Frameworks/Python* sudo rm -rf /usr/local/Frameworks/Python*
curl -LO https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_macosx_x86_64 curl -LO https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_macosx_x86_64
sudo install -m755 ldid_macosx_x86_64 /usr/local/bin/ldid sudo install -m755 ldid_macosx_x86_64 /usr/local/bin/ldid
@@ -57,7 +56,6 @@ jobs:
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \ https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \ https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \ https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \
https://mirror-hk.koddos.net/gnu/ncurses/ncurses-${{ env.NCURSES_VERSION }}.tar.gz \
https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \ https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \
https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \ https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \
https://github.com/rpm-software-management/popt/archive/refs/tags/popt-${{ env.POPT_VERSION }}-release.tar.gz https://github.com/rpm-software-management/popt/archive/refs/tags/popt-${{ env.POPT_VERSION }}-release.tar.gz
@@ -65,7 +63,6 @@ jobs:
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
tar -xf ncurses-${{ env.NCURSES_VERSION }}.tar.gz
tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2 tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2
tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz
tar -xf popt-${{ env.POPT_VERSION }}-release.tar.gz tar -xf popt-${{ env.POPT_VERSION }}-release.tar.gz
@@ -93,7 +90,6 @@ jobs:
echo "CXXFLAGS_FOR_BUILD=-stdlib=libc++ -arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV echo "CXXFLAGS_FOR_BUILD=-stdlib=libc++ -arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "CPPFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Wno-error-implicit-function-declaration" >> $GITHUB_ENV echo "CPPFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Wno-error-implicit-function-declaration" >> $GITHUB_ENV
echo "LDFLAGS_FOR_BUILD=-Wl,-dead_strip" >> $GITHUB_ENV echo "LDFLAGS_FOR_BUILD=-Wl,-dead_strip" >> $GITHUB_ENV
echo $(echo $(brew --cellar)/ncurses/*/bin/tic | sed 's|/tic||') >> $GITHUB_PATH
mkdir -p $(pwd)/sysroot/usr/local/lib mkdir -p $(pwd)/sysroot/usr/local/lib
ln -sf $(pwd)/sysroot/usr/local/lib{,64} ln -sf $(pwd)/sysroot/usr/local/lib{,64}
@@ -129,43 +125,6 @@ jobs:
gsed -E /'__API_UNAVAILABLE'/d < ${TARGET_SYSROOT}/usr/include/pthread.h > sysroot/usr/local/include/pthread.h gsed -E /'__API_UNAVAILABLE'/d < ${TARGET_SYSROOT}/usr/include/pthread.h > sysroot/usr/local/include/pthread.h
gsed -i -E s/'__API_UNAVAILABLE\(.*\)'// sysroot/usr/local/include/IOKit/IOKitLib.h gsed -i -E s/'__API_UNAVAILABLE\(.*\)'// sysroot/usr/local/include/IOKit/IOKitLib.h
- name: Build ncurses
run: |
cd ncurses-${{ env.NCURSES_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--with-build-cc="${{ env.CC }}" \
--with-build-cflags="${{ env.CFLAGS_FOR_NUILD }}" \
--with-build-cpp="${{ env.CC }} -E" \
--with-build-cppflags="${{ env.CPPFLAGS_FOR_BUILD }}" \
--with-build-ldflags="${{ env.LDFLAGS_FOR_BUILD }}" \
--with-pthread \
--enable-const \
--enable-ext-colors \
--enable-ext-mouse \
--enable-ext-putwin \
--enable-wattr-macros \
--disable-overwrite \
--without-debug \
--without-tests \
--enable-sigwinch \
--enable-const \
--enable-symlinks \
--enable-termcap \
--enable-pc-files \
--without-x11-rgb \
--with-tic-path=$(echo $(brew --cellar)/ncurses/*/bin/tic) \
--includedir="${{ env.PREFIX }}/include" \
--with-pkg-config-libdir="${{ env.PREFIX }}/lib/pkgconfig" \
--enable-widec \
--with-default-terminfo-dir="/opt/procursus/share/terminfo" \
--with-terminfo-dirs="/var/jb/usr/share/terminfo:/opt/procursus/share/terminfo:/opt/local/share/terminfo:/opt/homebrew/share/terminfo:/usr/local/share/terminfo:/opt/sw/share/terminfo:/sw/share/terminfo:/usr/share/terminfo" \
LDFLAGS="${{ env.LDFLAGS }}" \
PKG_CONFIG_LIBDIR="${{ env.PREFIX }}/lib/pkgconfig" || (cat config.log && exit 1)
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build Mbed TLS - name: Build Mbed TLS
run: | run: |
cd mbedtls-${{ env.MBEDTLS_VERSION }} cd mbedtls-${{ env.MBEDTLS_VERSION }}
@@ -310,6 +269,8 @@ jobs:
- name: Build palera1n - name: Build palera1n
run: | run: |
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
find dep_root -name '*.dylib' -delete
find dep_root -name '*.la' -delete
if [ "${{ matrix.os }}" = "macosx" ]; then if [ "${{ matrix.os }}" = "macosx" ]; then
gmake -j$(sysctl -n hw.ncpu) gmake -j$(sysctl -n hw.ncpu)
elif [ "${{ matrix.os }}" = "iphoneos" ]; then elif [ "${{ matrix.os }}" = "iphoneos" ]; then
@@ -419,7 +380,6 @@ jobs:
MBEDTLS_VERSION: 3.3.0 MBEDTLS_VERSION: 3.3.0
LIBUSB_VERSION: 1.0.26 LIBUSB_VERSION: 1.0.26
READLINE_VERSION: 8.2 READLINE_VERSION: 8.2
NCURSES_VERSION: 6.4
SLANG_VERSION: 2.3.3 SLANG_VERSION: 2.3.3
NEWT_VERSION: 0.52.23 NEWT_VERSION: 0.52.23
GPM_VERSION: 1.20.7 GPM_VERSION: 1.20.7
@@ -495,7 +455,6 @@ jobs:
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \ https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \ https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \ https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \
https://mirror-hk.koddos.net/gnu/ncurses/ncurses-${{ env.NCURSES_VERSION }}.tar.gz \
https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \ https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \
https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \ https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \
http://www.nico.schottelius.org/software/gpm/archives/gpm-${{ env.GPM_VERSION }}.tar.gz \ http://www.nico.schottelius.org/software/gpm/archives/gpm-${{ env.GPM_VERSION }}.tar.gz \
@@ -504,7 +463,6 @@ jobs:
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
tar -xf ncurses-${{ env.NCURSES_VERSION }}.tar.gz
tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2 tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2
tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz
tar -xf gpm-${{ env.GPM_VERSION }}.tar.gz tar -xf gpm-${{ env.GPM_VERSION }}.tar.gz
@@ -515,42 +473,6 @@ jobs:
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
- name: Build ncurses
run: |
cd ncurses-${{ env.NCURSES_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--with-build-cc="cc" \
--with-build-cflags=" " \
--with-build-cpp="cc -E" \
--with-build-cppflags=" " \
--with-build-ldflags=" " \
--enable-const \
--enable-ext-colors \
--enable-ext-mouse \
--enable-ext-putwin \
--enable-wattr-macros \
--with-pthread \
--disable-overwrite \
--without-debug \
--without-tests \
--enable-sigwinch \
--enable-const \
--enable-symlinks \
--enable-termcap \
--enable-pc-files \
--without-x11-rgb \
--with-pkg-config-libdir="${{ env.PREFIX }}/lib/pkgconfig" \
--includedir="${{ env.PREFIX }}/include" \
--enable-widec \
--with-default-terminfo-dir="/usr/share/terminfo" \
--with-terminfo-dirs="/usr/share/terminfo:/lib/terminfo:/usr/lib/terminfo:/usr/local/share/terminfo:/usr/local/lib/terminfo:/data/data/com.termux/files/usr/share/terminfo" \
LDFLAGS="${{ env.LDFLAGS }}" \
PKG_CONFIG_LIBDIR="${{ env.PREFIX }}/lib/pkgconfig"
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build Mbed TLS - name: Build Mbed TLS
run: | run: |
cd mbedtls-${{ env.MBEDTLS_VERSION }} cd mbedtls-${{ env.MBEDTLS_VERSION }}
+2 -2
View File
@@ -2,7 +2,7 @@ SRC = $(shell pwd)
DEP = $(SRC)/dep_root DEP = $(SRC)/dep_root
STRIP = strip STRIP = strip
CC ?= cc CC ?= cc
CFLAGS += -I$(DEP)/include -I$(DEP)/include/ncursestw -I$(SRC)/include -I$(SRC) CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC)
CFLAGS += -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\" -Wall -Wextra -Wno-unused-parameter CFLAGS += -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\" -Wall -Wextra -Wno-unused-parameter
CFLAGS += -Wno-unused-variable -I$(SRC)/src CFLAGS += -Wno-unused-variable -I$(SRC)/src
LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a
@@ -24,7 +24,7 @@ LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx50
LIBS += $(DEP)/lib/libusb-1.0.a LIBS += $(DEP)/lib/libusb-1.0.a
ifeq ($(DEV_BUILD),1) ifeq ($(DEV_BUILD),1)
LIBS += $(DEP)/lib/libmenutw.a $(DEP)/lib/libncursestw.a LIBS += $(DEP)/lib/libnewt.a $(DEP)/lib/libpopt.a $(DEP)/lib/libslang.a
CFLAGS += -O0 -g -DDEV_BUILD -fno-omit-frame-pointer CFLAGS += -O0 -g -DDEV_BUILD -fno-omit-frame-pointer
ifeq ($(ASAN),1) ifeq ($(ASAN),1)
BUILD_STYLE=ASAN BUILD_STYLE=ASAN
+8 -3
View File
@@ -1,8 +1,5 @@
#ifndef TUI_H #ifndef TUI_H
#define TUI_H #define TUI_H
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@@ -13,6 +10,7 @@
#include <string.h> #include <string.h>
#include <locale.h> #include <locale.h>
#include <unistd.h> #include <unistd.h>
#include <newt.h>
#define MAIN_OPTIONS "Options" #define MAIN_OPTIONS "Options"
#define MAIN_START "Start" #define MAIN_START "Start"
@@ -22,6 +20,8 @@
#define MSG_COLOR 1 #define MSG_COLOR 1
#define ICON_COLOR 2 #define ICON_COLOR 2
#define CHECKBOX_STATE(flags, opt) checkrain_option_enabled(flags, opt) ? '*' : ' '
typedef enum tui_screens { typedef enum tui_screens {
ERROR_SCREEN = -1, ERROR_SCREEN = -1,
EXIT_SCREEN = 0, EXIT_SCREEN = 0,
@@ -32,6 +32,11 @@ typedef enum tui_screens {
ENTER_RECOVERY_SCREEN = 5 ENTER_RECOVERY_SCREEN = 5
} tui_screen_t; } tui_screen_t;
typedef struct bitfield_checkbox_info {
checkrain_option_p flags_p;
checkrain_option_t opt;
} tui_bit_info_t;
tui_screen_t tui_screen_main(); tui_screen_t tui_screen_main();
tui_screen_t tui_screen_options(); tui_screen_t tui_screen_options();
tui_screen_t tui_screen_enter_recovery(); tui_screen_t tui_screen_enter_recovery();
+33 -56
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@@ -18,74 +13,56 @@
#include <tui.h> #include <tui.h>
int redraw_screen() { int redraw_screen() {
erase();
resizeterm(24, 80);
box(stdscr, 0, 0);
mvaddstr(0, 80 - strlen("[palera1n version " PALERAIN_VERSION "]") - 2 , "[palera1n version " PALERAIN_VERSION "]");
return 0; return 0;
} }
int destroy_window() { int destroy_window() {
endwin();
return 0; return 0;
} }
int init_window() { int init_window() {
setlocale(LC_ALL, NULL); setlocale(LC_ALL, NULL);
initscr(); newtInit();
if (has_colors() == TRUE) { newtCls();
start_color(); newtDrawRootText(0, 0, "Package Configuration");
init_pair(MSG_COLOR, COLOR_YELLOW, COLOR_BLACK); newtPushHelpLine(NULL);
init_pair(ICON_COLOR, COLOR_WHITE, COLOR_BLACK);
}
int height, width;
getmaxyx(stdscr, height, width);
if (width < 80 || height < 24) {
LOG(LOG_ERROR, "Terminal size must be at least 80x24");
return -1;
}
if (has_colors() == FALSE) {
LOG(LOG_VERBOSE2, "Terminal without color support detected");
}
cbreak();
noecho();
keypad(stdscr, TRUE);
return 0; return 0;
} }
int tui() { int tui() {
int ret = MAIN_SCREEN;
init_window(); init_window();
int ret = MAIN_SCREEN;
while (1) { while (1) {
redraw_screen();
switch (ret) { switch (ret) {
case ERROR_SCREEN: case ERROR_SCREEN:
goto out; goto out;
break; break;
case EXIT_SCREEN: case EXIT_SCREEN:
goto out; goto out;
break; break;
case MAIN_SCREEN: case MAIN_SCREEN:
ret = tui_screen_main(); ret = tui_screen_main();
break; break;
case OPTIONS_SCREEN: case OPTIONS_SCREEN:
ret = tui_screen_options(); ret = tui_screen_options();
break; break;
case ENTER_RECOVERY_SCREEN: case ENTER_RECOVERY_SCREEN:
ret = tui_screen_enter_recovery(); ret = tui_screen_enter_recovery();
break; break;
case ENTER_DFU_SCREEN: case ENTER_DFU_SCREEN:
ret = tui_screen_enter_dfu(); ret = tui_screen_enter_dfu();
break; break;
case JAILBREAKING_SCREEN: case JAILBREAKING_SCREEN:
ret = tui_screen_jailbreak(); ret = tui_screen_jailbreak();
break; break;
default: default:
assert(0); assert(0);
goto out; goto out;
} }
newtPopWindow();
} }
out: out:
destroy_window(); newtFinished();
return ret; return 0;
} }
-5
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
-5
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
-5
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
+21 -92
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@@ -18,93 +13,27 @@
#include <tui.h> #include <tui.h>
tui_screen_t tui_screen_main() { tui_screen_t tui_screen_main() {
int ret = -1; int ret = MAIN_SCREEN;
mvaddstr(1, 2, "Welcome to palera1n!"); bool can_start = false;
move(2,1); newtCenteredWindow(60, 16, "palera1n version 2.0.0");
whline(stdscr, ACS_HLINE, 80 - 2); newtComponent optionsButton = newtCompactButton(30, 14, "Options");
move(5,2); newtComponent startButton = newtCompactButton(41, 14, "Start");
attron(COLOR_PAIR(MSG_COLOR)); newtComponent exitButton = newtCompactButton(50, 14, "Exit");
mvaddstr(4,2, "Connect your iPhone, iPad, or iPod Touch"); newtComponent welcome = newtLabel(1, 0, "Welcome to palera1n!");
mvaddstr(5,2, "to begin."); newtComponent form = newtForm(NULL, NULL, 0);
attroff(COLOR_PAIR(MSG_COLOR)); newtFormAddComponents(form, optionsButton, startButton, exitButton, welcome, NULL);
attron(COLOR_PAIR(ICON_COLOR)); newtRunForm(form);
mvaddwstr(2, 43, L" MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM "); newtRefresh();
mvaddwstr(3, 44, L"MMMMMMMMMMMMMWNOddONWMMMMMMMMMMMMM"); newtComponent buttonPressed = newtFormGetCurrent(form);
mvaddwstr(4, 44, L"MMMMMMMMMMMMWNx. .xNWMMMMMMMMMMMM"); if (buttonPressed == optionsButton) {
mvaddwstr(5, 44, L"MMMMMMMMMMMMW0;....;OWMMMMMMMMMMMM"); ret = OPTIONS_SCREEN;
mvaddwstr(6, 44, L"MMMMMMMMMMMMW0;....;OWMMMMMMMMMMMM"); } else if (buttonPressed == startButton) {
mvaddwstr(7, 44, L"MMMMMMMMMMMWXo'.....lKWMMMMMMMMMMM"); if (can_start)
mvaddwstr(8, 44, L"MMMMMMMMMMWNkc;'....'dNWMMMMMMMMMM"); ret = ENTER_RECOVERY_SCREEN;
mvaddwstr(9, 44, L"MMMMMMMMMMN0dc:,''''.:ONWMMMMMMMMM"); else
mvaddwstr(10, 44, L"MMMMMMMMMWKxllc;,'''',lKWMMMMMMMMM"); ret = MAIN_SCREEN;
mvaddwstr(11, 44, L"MMMMMMMMWNkoolc;,,,,;;:xXWMMMMMMMM"); } else if (buttonPressed == exitButton) {
mvaddwstr(12, 44, L"MMMMMMMMW0olllc;,,,,,,,:OWMMMMMMMM"); ret = EXIT_SCREEN;
mvaddwstr(13, 44, L"MMMMMMMMNOollc:,'....'';xNMMMMMMMM");
mvaddwstr(14, 44, L"MMMMMMMMW0dllc:,''''''':OWMMMMMMMM");
mvaddwstr(15, 44, L"MMMMMMMMWN0dc::;;,,,,,cONWMMMMMMMM");
mvaddwstr(16, 44, L"MMMMMMMMMMWXOxoc::cldkXWMMMMMMMMMM");
mvaddwstr(17, 44, L"MMMMMMMMMMMMWWNNXXNNWWMMMMMMMMMMMM");
mvaddwstr(18, 44, L"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
mvaddstr(7, 2, "Made by: Nick Chan, Mineek, Tom, Nebula,");
mvaddstr(8, 2, "llsc12, Nathan");
move(9, 2);
whline(stdscr, ACS_HLINE, 40);
mvaddstr(10, 2, "Thanks to: nyuszika7h, Procursus Team");
mvaddstr(11, 2, "dora2ios, m1sta, Serena, xerub, tihmstar");
mvaddstr(12, 2, "sbingner, checkra1n team (Siguza, Axi0mx");
mvaddstr(13, 2, "argp et al.)");
move(14, 2);
whline(stdscr, ACS_HLINE, 40);
mvaddstr(19, 2, "palera1n is NOT affinated with checkra1n");
mvaddstr(20, 2, "Note: Backup your stuff. Use at your own risk.");
mvaddstr(19, 78 - strlen("@palera1n"), "@palera1n");
mvaddstr(20, 78 - strlen("https://palera.in"), "https://palera.in");
attroff(COLOR_PAIR(ICON_COLOR));
move(21,1);
whline(stdscr, ACS_HLINE, 80 - 2);
move(22, 40);
ITEM* main_buttons[4];
MENU* main_menu;
main_buttons[0] = new_item(MAIN_OPTIONS, "");
main_buttons[1] = new_item(MAIN_START, "");
main_buttons[2] = new_item(MAIN_EXIT, "");
main_buttons[3] = NULL;
main_menu = new_menu(main_buttons);
item_opts_off(main_buttons[1], O_SELECTABLE);
set_menu_format(main_menu, 1, 40);
set_menu_sub(main_menu, derwin(stdscr, 0, 0, 22, 50));
post_menu(main_menu);
raw();
refresh();
while (1) {
int ch = getch();
if (ch == KEY_LEFT) {
menu_driver(main_menu, REQ_LEFT_ITEM);
} else if (ch == KEY_RIGHT) {
menu_driver(main_menu, REQ_RIGHT_ITEM);
} else if (ch == 10) {
if (!(item_opts(current_item(main_menu)) & O_SELECTABLE)) continue;
// fprintf(stderr, "Button %s pressed\n", current_item(main_menu)->name.str);
if (!strcmp(current_item(main_menu)->name.str, MAIN_EXIT)) {
ret = EXIT_SCREEN;
} else if (!strcmp(current_item(main_menu)->name.str, MAIN_START)) {
ret = ENTER_RECOVERY_SCREEN;
} else if (!strcmp(current_item(main_menu)->name.str, MAIN_OPTIONS)) {
ret = OPTIONS_SCREEN;
}
goto end;
}
refresh();
} }
end:
noraw();
unpost_menu(main_menu);
free_menu(main_menu);
free_item(main_buttons[0]);
free_item(main_buttons[1]);
free_item(main_buttons[2]);
return ret; return ret;
} }
+35 -38
View File
@@ -1,8 +1,3 @@
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <form.h>
#include <menu.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@@ -17,44 +12,46 @@
#include <common.h> #include <common.h>
#include <tui.h> #include <tui.h>
void bitfield_check_cb(newtComponent box, void* data) {
if (newtCheckboxGetValue(box) == ' ') {
*((tui_bit_info_t*)data)->flags_p = *((tui_bit_info_t*)data)->flags_p &~ ((tui_bit_info_t*)data)->opt;
} else if (newtCheckboxGetValue(box) == '*') {
*((tui_bit_info_t*)data)->flags_p |= ((tui_bit_info_t*)data)->opt;
} else assert(0);
}
tui_screen_t tui_screen_options() { tui_screen_t tui_screen_options() {
tui_screen_t ret = EXIT_SCREEN; tui_bit_info_t verbose_info = { &kpf_flags, checkrain_option_verbose_boot };
ITEM* back_button[2]; tui_bit_info_t rootful_info = { &palerain_flags, palerain_option_rootful };
MENU* back_menu; tui_bit_info_t setup_rootful_info = { &palerain_flags, palerain_option_setup_rootful };
back_button[0] = new_item("Back", ""); tui_bit_info_t force_revert_info = { &checkrain_flags, checkrain_option_force_revert };
back_button[1] = NULL; tui_bit_info_t safemode_info = { &checkrain_flags, checkrain_option_safemode };
back_menu = new_menu(back_button);
move(21, 1); int ret = MAIN_SCREEN;
hline(ACS_HLINE, 80 - 2);
set_menu_format(back_menu, 1, 10); newtCenteredWindow(60, 16, "palera1n version 2.0.0");
set_menu_sub(back_menu, derwin(stdscr, 0, 0, 22, 68)); newtComponent backButton = newtCompactButton(50, 14, "Back");
post_menu(back_menu);
FORM* options_form; newtComponent verboseBootBox = newtCheckbox(1, 1, "Verbose boot", CHECKBOX_STATE(kpf_flags, checkrain_option_verbose_boot), NULL, NULL);
FIELD* options[3]; newtComponent rootfulBox = newtCheckbox(1, 2, "Rootful", CHECKBOX_STATE(palerain_flags, palerain_option_rootful), NULL, NULL);
newtComponent rootfulSetupBox = newtCheckbox(1, 3, "Setup fakefs", CHECKBOX_STATE(palerain_flags, palerain_option_setup_rootful), NULL, NULL);
options[0] = new_field(2, 2, 2, 2); newtComponent forceRevertBox = newtCheckbox(1, 4, "Restore system", CHECKBOX_STATE(checkrain_flags, checkrain_option_force_revert), NULL, NULL);
options[1] = new_field(); newtComponent safeModeBox = newtCheckbox(1, 5, "Safe mode", CHECKBOX_STATE(checkrain_flags, checkrain_option_safemode), NULL, NULL);
options[2] = NULL;
refresh(); newtComponentAddCallback(verboseBootBox, bitfield_check_cb, &verbose_info);
newtComponentAddCallback(rootfulBox, bitfield_check_cb, &rootful_info);
newtComponentAddCallback(rootfulSetupBox, bitfield_check_cb, &setup_rootful_info);
newtComponentAddCallback(forceRevertBox, bitfield_check_cb, &force_revert_info);
newtComponentAddCallback(safeModeBox, bitfield_check_cb, &safemode_info);
while(1) { newtComponent form = newtForm(NULL, NULL, 0);
int ch = getch(); newtFormAddComponents(form, backButton, verboseBootBox, rootfulBox,
if (ch == 10) { rootfulSetupBox, forceRevertBox, safeModeBox, NULL);
if (!(item_opts(current_item(back_menu)) & O_SELECTABLE)) continue; newtRunForm(form);
if (!strcmp(current_item(back_menu)->name.str, BACK_BUTTON)) { newtRefresh();
ret = MAIN_SCREEN; newtComponent buttonPressed = newtFormGetCurrent(form);
} if (buttonPressed == backButton) {
goto end; ret = MAIN_SCREEN;
} } else assert(0);
refresh();
}
end:
unpost_menu(back_menu);
free_item(back_button[0]);
free_menu(back_menu);
return ret; return ret;
} }