Merge branch 'dev'

This commit is contained in:
0xboobface 2018-12-10 20:20:52 +01:00
commit c9a5cc3adc
8 changed files with 77 additions and 37 deletions

View File

@ -207,21 +207,23 @@ public class CamrecApplication extends Application {
}
private void registerAlertSystem() {
try {
// don't register before 1 minute has passed, because directly after
// the start of ctbrec, an event for every online model would be fired,
// which is annoying as f
Thread.sleep(TimeUnit.MINUTES.toMillis(1));
new Thread(() -> {
try {
// don't register before 1 minute has passed, because directly after
// the start of ctbrec, an event for every online model would be fired,
// which is annoying as f
Thread.sleep(TimeUnit.MINUTES.toMillis(1));
for (EventHandlerConfiguration config : Config.getInstance().getSettings().eventHandlers) {
EventHandler handler = new EventHandler(config);
EventBusHolder.register(handler);
LOG.debug("Registered event handler for {} {}", config.getEvent(), config.getName());
for (EventHandlerConfiguration config : Config.getInstance().getSettings().eventHandlers) {
EventHandler handler = new EventHandler(config);
EventBusHolder.register(handler);
LOG.debug("Registered event handler for {} {}", config.getEvent(), config.getName());
}
LOG.debug("Alert System registered");
} catch (InterruptedException e) {
e.printStackTrace();
}
LOG.debug("Alert System registered");
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
private void writeColorSchemeStyleSheet(Stage primaryStage) {

View File

@ -47,8 +47,11 @@ public class BongaCamsConfigUI extends AbstractConfigUI {
layout.add(new Label("BongaCams User"), 0, row);
TextField username = new TextField(settings.bongaUsername);
username.textProperty().addListener((ob, o, n) -> {
settings.bongaUsername = username.getText();
save();
if(!n.equals(Config.getInstance().getSettings().bongaUsername)) {
Config.getInstance().getSettings().bongaUsername = username.getText();
bongaCams.getHttpClient().logout();
save();
}
});
GridPane.setFillWidth(username, true);
GridPane.setHgrow(username, Priority.ALWAYS);
@ -58,9 +61,12 @@ public class BongaCamsConfigUI extends AbstractConfigUI {
layout.add(new Label("BongaCams Password"), 0, row);
PasswordField password = new PasswordField();
password.setText(settings.bongaPassword);
password.focusedProperty().addListener((e) -> {
settings.bongaPassword = password.getText();
save();
password.textProperty().addListener((ob, o, n) -> {
if(!n.equals(Config.getInstance().getSettings().bongaPassword)) {
Config.getInstance().getSettings().bongaPassword = password.getText();
bongaCams.getHttpClient().logout();
save();
}
});
GridPane.setFillWidth(password, true);
GridPane.setHgrow(password, Priority.ALWAYS);

View File

@ -47,8 +47,11 @@ public class Cam4ConfigUI extends AbstractConfigUI {
layout.add(new Label("Cam4 User"), 0, row);
TextField username = new TextField(Config.getInstance().getSettings().cam4Username);
username.textProperty().addListener((ob, o, n) -> {
Config.getInstance().getSettings().cam4Username = username.getText();
save();
if(!n.equals(Config.getInstance().getSettings().cam4Username)) {
Config.getInstance().getSettings().cam4Username = username.getText();
cam4.getHttpClient().logout();
save();
}
});
GridPane.setFillWidth(username, true);
GridPane.setHgrow(username, Priority.ALWAYS);
@ -58,9 +61,12 @@ public class Cam4ConfigUI extends AbstractConfigUI {
layout.add(new Label("Cam4 Password"), 0, row);
PasswordField password = new PasswordField();
password.setText(Config.getInstance().getSettings().cam4Password);
password.focusedProperty().addListener((e) -> {
Config.getInstance().getSettings().cam4Password = password.getText();
save();
password.textProperty().addListener((ob, o, n) -> {
if(!n.equals(Config.getInstance().getSettings().cam4Password)) {
Config.getInstance().getSettings().cam4Password = password.getText();
cam4.getHttpClient().logout();
save();
}
});
GridPane.setFillWidth(password, true);
GridPane.setHgrow(password, Priority.ALWAYS);

View File

@ -47,8 +47,11 @@ public class CamsodaConfigUI extends AbstractConfigUI {
layout.add(new Label("CamSoda User"), 0, row);
TextField username = new TextField(Config.getInstance().getSettings().camsodaUsername);
username.textProperty().addListener((ob, o, n) -> {
Config.getInstance().getSettings().camsodaUsername = username.getText();
save();
if(!n.equals(Config.getInstance().getSettings().camsodaUsername)) {
Config.getInstance().getSettings().camsodaUsername = username.getText();
camsoda.getHttpClient().logout();
save();
}
});
GridPane.setFillWidth(username, true);
GridPane.setHgrow(username, Priority.ALWAYS);
@ -59,8 +62,11 @@ public class CamsodaConfigUI extends AbstractConfigUI {
PasswordField password = new PasswordField();
password.setText(Config.getInstance().getSettings().camsodaPassword);
password.textProperty().addListener((ob, o, n) -> {
Config.getInstance().getSettings().camsodaPassword = password.getText();
save();
if(!n.equals(Config.getInstance().getSettings().camsodaPassword)) {
Config.getInstance().getSettings().camsodaPassword = password.getText();
camsoda.getHttpClient().logout();
save();
}
});
GridPane.setFillWidth(password, true);
GridPane.setHgrow(password, Priority.ALWAYS);

View File

@ -47,8 +47,11 @@ public class ChaturbateConfigUi extends AbstractConfigUI {
layout.add(new Label("Chaturbate User"), 0, row);
TextField username = new TextField(Config.getInstance().getSettings().username);
username.textProperty().addListener((ob, o, n) -> {
Config.getInstance().getSettings().username = username.getText();
save();
if(!n.equals(Config.getInstance().getSettings().username)) {
Config.getInstance().getSettings().username = n;
chaturbate.getHttpClient().logout();
save();
}
});
GridPane.setFillWidth(username, true);
GridPane.setHgrow(username, Priority.ALWAYS);
@ -59,8 +62,11 @@ public class ChaturbateConfigUi extends AbstractConfigUI {
PasswordField password = new PasswordField();
password.setText(Config.getInstance().getSettings().password);
password.textProperty().addListener((ob, o, n) -> {
Config.getInstance().getSettings().password = password.getText();
save();
if(!n.equals(Config.getInstance().getSettings().password)) {
Config.getInstance().getSettings().password = n;
chaturbate.getHttpClient().logout();
save();
}
});
GridPane.setFillWidth(password, true);
GridPane.setHgrow(password, Priority.ALWAYS);

View File

@ -48,8 +48,11 @@ public class MyFreeCamsConfigUI extends AbstractConfigUI {
TextField username = new TextField(Config.getInstance().getSettings().mfcUsername);
username.setPrefWidth(300);
username.textProperty().addListener((ob, o, n) -> {
Config.getInstance().getSettings().mfcUsername = username.getText();
save();
if(!n.equals(Config.getInstance().getSettings().mfcUsername)) {
Config.getInstance().getSettings().mfcUsername = username.getText();
myFreeCams.getHttpClient().logout();
save();
}
});
GridPane.setFillWidth(username, true);
GridPane.setHgrow(username, Priority.ALWAYS);
@ -60,8 +63,11 @@ public class MyFreeCamsConfigUI extends AbstractConfigUI {
PasswordField password = new PasswordField();
password.setText(Config.getInstance().getSettings().mfcPassword);
password.textProperty().addListener((ob, o, n) -> {
Config.getInstance().getSettings().mfcPassword = password.getText();
save();
if(!n.equals(Config.getInstance().getSettings().mfcPassword)) {
Config.getInstance().getSettings().mfcPassword = password.getText();
myFreeCams.getHttpClient().logout();
save();
}
});
GridPane.setFillWidth(password, true);
GridPane.setHgrow(password, Priority.ALWAYS);

View File

@ -92,4 +92,8 @@ public class CookieJarImpl implements CookieJar {
public Map<String, List<Cookie>> getCookies() {
return cookieStore;
}
public void clear() {
cookieStore.clear();
}
}

View File

@ -23,7 +23,6 @@ import ctbrec.Config;
import ctbrec.Settings.ProxyType;
import okhttp3.ConnectionPool;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.Credentials;
import okhttp3.OkHttpClient;
import okhttp3.OkHttpClient.Builder;
@ -212,7 +211,12 @@ public abstract class HttpClient {
}
}
public CookieJar getCookieJar() {
public CookieJarImpl getCookieJar() {
return cookieJar;
}
public void logout() {
getCookieJar().clear();
loggedIn = false;
}
}