Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit a017171

Browse files
committed
Refactored core modules; lib update; docs update
1 parent 8114d38 commit a017171

File tree

10 files changed

+209
-150
lines changed

10 files changed

+209
-150
lines changed

PrivacyPolicy.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Privacy Policy
2+
I respect your privacy, so does this tool itself. However, things are being logged
3+
to enhance the user experience. No, this is not a lie that businesses usually do.
4+
5+
Effective Date: 13. May 2024
6+
7+
## What is being collected
8+
To keep it concise and minimal, this information is being collected within the log
9+
files themselves:
10+
11+
- Running Operating System
12+
- User Home Directory Path to the Osintgram4j entry (e.g.
13+
`/home/my_user/.config/net.bc100dev/osintgram4j`)
14+
- Commands being executed as a full command line
15+
- Count of entries within a network-related data fetch
16+
- Java Errors/Exceptions
17+
18+
## What is NOT being collected
19+
Most to all things are not being collected via this tool itself. The entries that
20+
are not included within the log file are:
21+
22+
- Data retrieved from Instagram (profile info, metadata, media etc.)
23+
- Sensitive information during transmission (Network communication to Instagram)
24+
25+
## Data Usage
26+
To help me with specific stuff, within its Logging mechanism, this is, why the
27+
log files are helpful in enhancing the user experience, and keep this project a
28+
bug-free experience.
29+
30+
- Troubleshooting: The log files help me diagnose the errors in more detail
31+
- Development: Usage patterns from logs can guide me into diving deeper into the
32+
code to diagnose, what part of its project is at fault.
33+
- Data Storage: Log data is stored locally on your device.
34+
- No Transmission: Log data is NEVER automatically being sent to me, nor any
35+
(unauthorized) third-parties.
36+
37+
## Contact
38+
I am available on specific platforms. Might not be immediate due to specific
39+
schedules, but responses can be expected within 24-72 hours. The platforms include:
40+
41+
- [Instagram](https://instagram.com/bc100dev)
42+
- Discord (@bc100dev)
43+
- [E-Mail](mailto:[email protected])

cxx/CMakeLists.txt

+4-14
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,20 @@ set(CMAKE_CXX_STANDARD 17)
55

66
include_directories("include/java_natives")
77

8-
if (${CMAKE_CXX_COMPILER} MATCHES "linux")
9-
find_package(Curses REQUIRED)
10-
endif ()
11-
128
if (${CMAKE_CXX_COMPILER} MATCHES "mingw" OR ${CMAKE_SYSTEM_NAME} MATCHES "win")
139
include_directories("include/java_natives/win32")
1410
elseif (${CMAKE_CXX_COMPILER} MATCHES "linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "nux")
1511
include_directories("include/java_natives/linux")
1612
endif ()
1713

18-
add_library(osintgram4j-cxx SHARED
14+
add_library(osintgram4j SHARED
1915
src/ConsoleSize.cpp src/ConsoleSize.h
2016
src/UserIO.cpp src/UserIO.h
2117
src/ExceptionHandle.cpp src/ExceptionHandle.h
22-
src/MemoryInfo.cpp src/MemoryInfo.h
23-
src/shell/Terminal.cpp)
18+
src/MemoryInfo.cpp src/MemoryInfo.h)
2419

2520
# Windows on Linux compilation
2621
if (${CMAKE_CXX_COMPILER} MATCHES "mingw" OR ${CMAKE_SYSTEM_NAME} MATCHES "win")
27-
set_target_properties(osintgram4j-cxx PROPERTIES PREFIX "")
28-
set_target_properties(osintgram4j-cxx PROPERTIES SUFFIX ".dll")
29-
endif ()
30-
31-
if (${CMAKE_CXX_COMPILER} MATCHES "linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "nux")
32-
target_include_directories(osintgram4j-cxx PRIVATE ${CURSES_INCLUDE_PATH})
33-
target_link_libraries(osintgram4j-cxx PRIVATE ${CURSES_LIBRARIES})
22+
set_target_properties(osintgram4j PROPERTIES PREFIX "")
23+
set_target_properties(osintgram4j PROPERTIES SUFFIX ".dll")
3424
endif ()

cxx/src/ExceptionHandle.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
#include "ExceptionHandle.h"
22

3-
void throwJavaAppException(JNIEnv* env, const char* msg) {
4-
jclass cls = env->FindClass("net/bc100dev/commons/ApplicationException");
3+
void throwJavaException(JNIEnv* env, const char* _cls, const char* msg) {
4+
jclass cls = env->FindClass(_cls);
5+
if (cls == nullptr)
6+
return;
7+
58
env->ThrowNew(cls, msg);
69
}
710

11+
void throwJavaAppException(JNIEnv* env, const char* msg) {
12+
throwJavaException(env, "net/bc100dev/commons/ApplicationException", msg);
13+
}
14+
815
void throwJavaAppIOException(JNIEnv* env, const char* msg) {
9-
jclass cls = env->FindClass("net/bc100dev/commons/ApplicationIOException");
10-
env->ThrowNew(cls, msg);
16+
throwJavaException(env, "net/bc100dev/commons/ApplicationIOException", msg);
1117
}
1218

1319
void throwJavaAppRuntimeException(JNIEnv* env, const char* msg) {
14-
jclass cls = env->FindClass("net/bc100dev/commons/ApplicationRuntimeException");
15-
env->ThrowNew(cls, msg);
20+
throwJavaException(env, "net/bc100dev/commons/ApplicationRuntimeException", msg);
1621
}

cxx/src/ExceptionHandle.h

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ void throwJavaAppIOException(JNIEnv* env, const char* msg);
99

1010
void throwJavaAppRuntimeException(JNIEnv* env, const char* msg);
1111

12+
void throwJavaException(JNIEnv* env, const char* _cls, const char* msg);
13+
1214
#endif //OSINTGRAM4J_NATIVES_EXCEPTIONHANDLE_H

cxx/src/shell/Terminal.cpp

-77
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
package osintgram4j.api;
2+
3+
import net.bc100dev.commons.ApplicationException;
4+
import net.bc100dev.commons.Terminal;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
import java.util.Scanner;
9+
10+
public class OptionSelect {
11+
12+
private String title, message;
13+
14+
private final List<ButtonAction> buttons = new ArrayList<>();
15+
16+
private int mismatchCount = 0;
17+
private int mismatchMaxCount = 3;
18+
19+
public OptionSelect() {
20+
}
21+
22+
public OptionSelect(String title, String message) {
23+
this.title = title;
24+
this.message = message;
25+
}
26+
27+
public String getTitle() {
28+
return title;
29+
}
30+
31+
public String getMessage() {
32+
return message;
33+
}
34+
35+
public void setTitle(String title) {
36+
this.title = title;
37+
}
38+
39+
public void setMessage(String message) {
40+
this.message = message;
41+
}
42+
43+
public int getMismatchMaxCount() {
44+
return mismatchMaxCount;
45+
}
46+
47+
public void setMismatchMaxCount(int mismatchMaxCount) {
48+
if (mismatchMaxCount < 0)
49+
throw new IllegalArgumentException("Cannot set max count in negative bounds");
50+
51+
if (mismatchMaxCount == 0)
52+
throw new IllegalArgumentException("Mismatch count cannot be zero");
53+
54+
this.mismatchMaxCount = mismatchMaxCount;
55+
}
56+
57+
public void addButton(boolean defBtn, String text, Runnable rn) {
58+
if (defBtn) {
59+
if (!buttons.isEmpty()) {
60+
for (int i = 0; i < buttons.size(); i++) {
61+
ButtonAction btn = buttons.get(i);
62+
if (btn.defButton())
63+
buttons.set(i, new ButtonAction(new Button(btn.btn.text, btn.btn.rn), false));
64+
}
65+
}
66+
}
67+
68+
buttons.add(new ButtonAction(new Button(text, rn), defBtn));
69+
}
70+
71+
public void show() {
72+
if (buttons.isEmpty())
73+
return;
74+
75+
System.out.println(title);
76+
System.out.println("-".repeat(title.length()));
77+
System.out.println();
78+
System.out.println(message);
79+
System.out.println();
80+
81+
for (int i = 0; i < buttons.size(); i++) {
82+
ButtonAction btnAction = buttons.get(i);
83+
Button btn = btnAction.btn;
84+
85+
System.out.println("( " + (i + 1) + (btnAction.defButton ? "; Default" : "") + " ) " + btn.text);
86+
}
87+
88+
Scanner in = new Scanner(System.in);
89+
System.out.print("==> ");
90+
91+
try {
92+
String v = in.nextLine();
93+
if (v.trim().isEmpty()) {
94+
if (invokeDefault())
95+
return;
96+
97+
throw new ApplicationException("No value specified");
98+
}
99+
100+
int index = Integer.parseInt(v) - 1;
101+
if (index < 0 || index >= buttons.size()) {
102+
if (invokeDefault())
103+
return;
104+
105+
throw new ApplicationException("No such button");
106+
}
107+
108+
buttons.get(index).btn.rn.run();
109+
} catch (NumberFormatException | ApplicationException ex) {
110+
mismatchCount++;
111+
112+
if (mismatchCount == mismatchMaxCount) {
113+
System.err.println("You have provided the wrong value several times; expected a numeric value");
114+
return;
115+
}
116+
117+
Terminal.clearTerminal();
118+
119+
System.err.println(ex.getMessage());
120+
System.err.println();
121+
show();
122+
}
123+
}
124+
125+
private boolean invokeDefault() {
126+
boolean found = false;
127+
128+
for (ButtonAction btn : buttons) {
129+
if (btn.defButton) {
130+
found = true;
131+
btn.btn.rn.run();
132+
}
133+
}
134+
135+
return found;
136+
}
137+
138+
private record ButtonAction(Button btn, boolean defButton) {
139+
}
140+
141+
public record Button(String text, Runnable rn) {
142+
}
143+
144+
}

setup.sh

+2-8
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ function get_jdk() {
152152
fi
153153
fi
154154

155-
# Script Update: migrate to v21.0.2 from v21.0.1
156155
if [ "$RUN_DOWNLOAD" == "true" ]; then
157156
if [[ "$IS_LINUX" == "true" ]]; then
158157
wget "https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_linux-x64_bin.tar.gz" \
@@ -196,16 +195,11 @@ function get_libs() {
196195
fi
197196

198197
if [ "$RUN_DOWNLOAD" == "true" ]; then
199-
## Update: 20231013 -> 20240205
200-
wget "https://repo1.maven.org/maven2/org/json/json/20240205/json-20240205.jar" -O out/libs/json.jar
198+
# update version to 20240303
199+
wget "https://repo1.maven.org/maven2/org/json/json/20240303/json-20240303.jar" -O out/libs/json.jar
201200
fi
202201
}
203202

204-
if [ -f "extres/ee.enc" ]; then
205-
# fuck you lookin at? git don't give me no hook availability (I assume)
206-
rm extres/ee.enc
207-
fi
208-
209203
if [ "$#" -ge 1 ]; then
210204
if [ "$1" == "--force-download" ]; then
211205
FORCE_DOWNLOAD="true"

src/net/bc100dev/osintgram4j/MainClass.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
import java.util.logging.Level;
1818

1919
import static net.bc100dev.commons.utils.RuntimeEnvironment.*;
20-
import static net.bc100dev.commons.utils.RuntimeEnvironment.USER_HOME;
2120
import static net.bc100dev.osintgram4j.Settings.app_adminSecurityWarningEnabled;
2221
import static net.bc100dev.osintgram4j.Settings.loadSettings;
22+
import static osintgram4j.commons.AppConstants.log;
2323
import static osintgram4j.commons.TitleBlock.DISPLAY;
2424
import static osintgram4j.commons.TitleBlock.TITLE_BLOCK;
25-
import static osintgram4j.commons.AppConstants.log;
2625

2726
public class MainClass {
2827

src/net/bc100dev/osintgram4j/NativeLoader.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static boolean hasLibrary() {
1717

1818
String[] paths = System.getProperty("java.library.path").split(File.pathSeparator);
1919
for (String path : paths) {
20-
File libFile = new File(path, System.mapLibraryName("osintgram4j-cxx"));
20+
File libFile = new File(path, System.mapLibraryName("osintgram4j"));
2121

2222
if (libFile.exists())
2323
return true;
@@ -44,7 +44,7 @@ public static void load() {
4444
}
4545
}
4646

47-
System.loadLibrary("osintgram4j-cxx");
47+
System.loadLibrary("osintgram4j");
4848
loaded = true;
4949
}
5050

0 commit comments

Comments
 (0)