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 boolean
Whether the student's clear name should be fetched after logging in.private boolean
Whether the student's email address should be fetched after logging in.private boolean
Whether the task was prematurelyfinished
by outside intervention.private final @NonNull HashSet
<Task.TaskListener<Boolean>> The subscribers interested in the progress and status updates of this task.private Boolean
Whether logging in was successful.static final int
The total number of steps required to log in. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Prematurely terminates the action.private void
Notifies allsubscribers
that logging in has been prematurelyterminated
by outside intervention.private void
failed()
Notifies allsubscribers
that logging in has failed.void
registerListener
(@NonNull Task.TaskListener<Boolean> taskListener) Adds a subscriber that is interested in status updates of the action's progress.boolean
removeListener
(@NonNull Task.TaskListener<Boolean> taskListener) Removes a subscriber that was previously added to receive status updates of the action's progress.void
run()
Begins the execution of the action.void
setFetchPersonalData
(boolean fetchClearname, boolean fetchEmailAddress) Updates the setting whether the student'sclear name
andemail address
should be fetched from the University of Jena's Friedolin system along with the login.private void
started()
Notifies allsubscribers
that logging in has begun.private void
Notifies allsubscribers
that logging in has succeeded.private void
updateProgress
(int current, int total) Notifies allsubscribers
about 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 prematurelyfinished
by outside intervention.
-
-
Constructor Details
-
Login
public Login()
-
-
Method Details
-
updateProgress
private void updateProgress(int current, int total) Notifies allsubscribers
about 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 allsubscribers
that logging in has begun. -
succeeded
private void succeeded()Notifies allsubscribers
that logging in has succeeded. -
failed
private void failed()Notifies allsubscribers
that logging in has failed. -
cancelled
private void cancelled()Notifies allsubscribers
that logging in has been prematurelyterminated
by 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:
registerListener
in 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:
removeListener
in 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:
true
if the subscriber was removed,false
if it hadn't been registered in the first place.- See Also:
-
getResult
- Specified by:
getResult
in 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 name
andemail address
should 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
configuration
asConfiguration.getClearname()
andConfiguration.getEmail()
.- Specified by:
setFetchPersonalData
in 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.
-