|
@ -244,6 +244,15 @@ public class SessionManager { |
|
|
guestLogin(); |
|
|
guestLogin(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void refreshSescFromUrl(String url){ |
|
|
|
|
|
String sesc = extractSescFromLink(url); |
|
|
|
|
|
if(sesc!=null){ |
|
|
|
|
|
setSesc(sesc); |
|
|
|
|
|
setLogoutLink(generateLogoutLink(sesc)); |
|
|
|
|
|
setMarkAsReadLink(sesc); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
//--------------------------------------AUTH ENDS-----------------------------------------------
|
|
|
//--------------------------------------AUTH ENDS-----------------------------------------------
|
|
|
|
|
|
|
|
|
//---------------------------------------GETTERS------------------------------------------------
|
|
|
//---------------------------------------GETTERS------------------------------------------------
|
|
@ -271,7 +280,7 @@ public class SessionManager { |
|
|
public String getMarkAllAsReadLink() { |
|
|
public String getMarkAllAsReadLink() { |
|
|
String markAsReadLink = sharedPrefs.getString(MARK_ALL_AS_READ_LINK, null); |
|
|
String markAsReadLink = sharedPrefs.getString(MARK_ALL_AS_READ_LINK, null); |
|
|
if(markAsReadLink == null){ //For older versions, extract it from logout link (otherwise user would have to login again)
|
|
|
if(markAsReadLink == null){ //For older versions, extract it from logout link (otherwise user would have to login again)
|
|
|
String sesc = extractSescFromLogoutLink(getLogoutLink()); |
|
|
String sesc = extractSescFromLink(getLogoutLink()); |
|
|
if(sesc!=null) { |
|
|
if(sesc!=null) { |
|
|
setSesc(sesc); |
|
|
setSesc(sesc); |
|
|
markAsReadLink = generateMarkAllAsReadLink(sesc); |
|
|
markAsReadLink = generateMarkAllAsReadLink(sesc); |
|
@ -313,6 +322,12 @@ public class SessionManager { |
|
|
editor.apply(); |
|
|
editor.apply(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setLogoutLink(String logoutLink){ |
|
|
|
|
|
SharedPreferences.Editor editor = sharedPrefs.edit(); |
|
|
|
|
|
editor.putString(LOGOUT_LINK, logoutLink); |
|
|
|
|
|
editor.apply(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//--------------------------------------SETTERS END---------------------------------------------
|
|
|
//--------------------------------------SETTERS END---------------------------------------------
|
|
|
|
|
|
|
|
|
//------------------------------------OTHER FUNCTIONS-------------------------------------------
|
|
|
//------------------------------------OTHER FUNCTIONS-------------------------------------------
|
|
@ -421,16 +436,16 @@ public class SessionManager { |
|
|
Elements logoutLink = doc.select("a[href^=https://www.thmmy.gr/smf/index.php?action=logout;sesc=]"); |
|
|
Elements logoutLink = doc.select("a[href^=https://www.thmmy.gr/smf/index.php?action=logout;sesc=]"); |
|
|
if (!logoutLink.isEmpty()) { |
|
|
if (!logoutLink.isEmpty()) { |
|
|
String link = logoutLink.first().attr("href"); |
|
|
String link = logoutLink.first().attr("href"); |
|
|
return extractSescFromLogoutLink(link); |
|
|
return extractSescFromLink(link); |
|
|
} |
|
|
} |
|
|
Timber.e(new ParseException("Parsing failed(extractSesc)"),"ParseException"); |
|
|
Timber.e(new ParseException("Parsing failed(extractSesc)"),"ParseException"); |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private String extractSescFromLogoutLink(String logoutLink){ |
|
|
private String extractSescFromLink(String link){ |
|
|
if (logoutLink != null){ |
|
|
if (link != null){ |
|
|
Pattern pattern = Pattern.compile(".+;sesc=(\\w+)"); |
|
|
Pattern pattern = Pattern.compile(".+;sesc=(\\w+)"); |
|
|
Matcher matcher = pattern.matcher(logoutLink); |
|
|
Matcher matcher = pattern.matcher(link); |
|
|
if (matcher.find()) |
|
|
if (matcher.find()) |
|
|
return matcher.group(1); |
|
|
return matcher.group(1); |
|
|
} |
|
|
} |
|
|