Don't try to log in twice

This commit is contained in:
0xboobface 2018-10-30 15:24:02 +01:00
parent 7f3bedd3a1
commit c445e48d6d
3 changed files with 20 additions and 6 deletions

View File

@ -66,7 +66,10 @@ public class Cam4 extends AbstractSite {
@Override
public Integer getTokenBalance() throws IOException {
return 0;
if (!credentialsAvailable()) {
throw new IOException("Not logged in");
}
return ((Cam4HttpClient)getHttpClient()).getTokenBalance();
}
@Override

View File

@ -24,7 +24,11 @@ public class Cam4HttpClient extends HttpClient {
private static final transient Logger LOG = LoggerFactory.getLogger(Cam4HttpClient.class);
@Override
public boolean login() throws IOException {
public synchronized boolean login() throws IOException {
if(loggedIn) {
return true;
}
BlockingQueue<Boolean> queue = new LinkedBlockingQueue<>();
Runnable showDialog = () -> {
@ -94,4 +98,12 @@ public class Cam4HttpClient extends HttpClient {
}
cookieJar.saveFromResponse(origUrl, cookies);
}
protected int getTokenBalance() throws IOException {
if(!loggedIn) {
login();
}
throw new RuntimeException("Not implemented, yet");
}
}

View File

@ -124,14 +124,13 @@ public class Cam4Model extends AbstractModel {
@Override
public void invalidateCacheEntries() {
// TODO Auto-generated method stub
resolution = null;
playlistUrl = null;
}
@Override
public void receiveTip(int tokens) throws IOException {
// TODO Auto-generated method stub
throw new RuntimeException("Not implemented for Cam4, yet");
}
@Override