Package page.codeberg.friedolyn.client
Class HeadlessBrowser.Login
java.lang.Object
page.codeberg.friedolyn.util.Task<Boolean>
page.codeberg.friedolyn.client.FriedolinClient.Login
page.codeberg.friedolyn.client.HeadlessBrowser.Login
-
Nested Class Summary
Nested classes/interfaces inherited from class page.codeberg.friedolyn.util.Task
Task.CancelListener, Task.FailureListener<ResultType>, Task.ProgressListener, Task.SuccessListener<ResultType>, Task.TaskListener<ResultType> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether the student's clear name should be fetched after logging in.private booleanWhether the student's email address should be fetched after logging in.private booleanWhether the task was prematurelyfinishedby outside intervention.private final @NonNull HashSet<Task.TaskListener<Boolean>> The subscribers interested in the progress and status updates of this task.private BooleanWhether logging in was successful.static final intThe total number of steps required to log in. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Prematurely terminates the action.private voidNotifies allsubscribersthat logging in has been prematurelyterminatedby outside intervention.private voidfailed()Notifies allsubscribersthat logging in has failed.voidregisterListener(@NonNull Task.TaskListener<Boolean> taskListener) Adds a subscriber that is interested in status updates of the action's progress.booleanremoveListener(@NonNull Task.TaskListener<Boolean> taskListener) Removes a subscriber that was previously added to receive status updates of the action's progress.voidrun()Begins the execution of the action.voidsetFetchPersonalData(boolean fetchClearname, boolean fetchEmailAddress) Updates the setting whether the student'sclear nameandemail addressshould be fetched from the University of Jena's Friedolin system along with the login.private voidstarted()Notifies allsubscribersthat logging in has begun.private voidNotifies allsubscribersthat logging in has succeeded.private voidupdateProgress(int current, int total) Notifies allsubscribersabout the progress of this task.Methods inherited from class page.codeberg.friedolyn.util.Task
setOnCancelled, setOnFailed, setOnProgressUpdate, setOnSucceeded
-
Field Details
-
TOTAL_WORK
public static final int TOTAL_WORKThe total number of steps required to log in.- See Also:
-
LISTENERS
The subscribers interested in the progress and status updates of this task. -
fetchClearname
private boolean fetchClearnameWhether the student's clear name should be fetched after logging in. -
fetchEmailAddress
private boolean fetchEmailAddressWhether the student's email address should be fetched after logging in. -
success
Whether logging in was successful. -
isCancelled
private boolean isCancelledWhether the task was prematurelyfinishedby outside intervention.
-
-
Constructor Details
-
Login
public Login()
-
-
Method Details
-
updateProgress
private void updateProgress(int current, int total) Notifies allsubscribersabout the progress of this task.- Parameters:
current- The amount of work that has been done so far.total- The total number of steps required to complete this task.
-
started
private void started()Notifies allsubscribersthat logging in has begun. -
succeeded
private void succeeded()Notifies allsubscribersthat logging in has succeeded. -
failed
private void failed()Notifies allsubscribersthat logging in has failed. -
cancelled
private void cancelled()Notifies allsubscribersthat logging in has been prematurelyterminatedby outside intervention. -
cancel
-
run
Begins the execution of the action. The action will run in the same thread that it was envoked from. UseTask.cancel()to prematurely terminate the action. The end product of the action can be retrieved usingTask.getResult(). -
registerListener
Adds a subscriber that is interested in status updates of the action's progress. Does NOT remove or replace any existing listeners.- Specified by:
registerListenerin classTask<Boolean>- Parameters:
taskListener- The subscriber that wants to be informed about the progress of the action.- See Also:
-
removeListener
Removes a subscriber that was previously added to receive status updates of the action's progress.- Specified by:
removeListenerin classTask<Boolean>- Parameters:
taskListener- The subscriber that no longer wants to be informed about the progress of the action. Must be the exact same reference that was previously registered.- Returns:
trueif the subscriber was removed,falseif it hadn't been registered in the first place.- See Also:
-
getResult
- Specified by:
getResultin classTask<Boolean>- Returns:
- The end product generated by the action. Empty if the action has not finished yet.
The presence of
Result.getResult()does NOT indicate success. OnlyResult.getSuccess()can be used to determine success or failure.
-
setFetchPersonalData
public void setFetchPersonalData(boolean fetchClearname, boolean fetchEmailAddress) Updates the setting whether the student'sclear nameandemail addressshould be fetched from the University of Jena's Friedolin system along with the login. May require additional network requests, slowing down the login process.The results of the fetches will be stored in the
configurationasConfiguration.getClearname()andConfiguration.getEmail().- Specified by:
setFetchPersonalDatain classFriedolinClient.Login- Parameters:
fetchClearname- Whether the student's clear name should be found out. True by default.fetchEmailAddress- Whether the student's email address should be found out. False by default.
-