summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src
diff options
context:
space:
mode:
authorAndreas Abraham <andreas.abraham@egiz.gv.at>2021-01-26 16:17:43 +0100
committerAndreas Abraham <andreas.abraham@egiz.gv.at>2021-01-26 16:17:43 +0100
commit5caa941790750bba85a8f830abf04a50d3b049b0 (patch)
tree78f3eb3de8cfde322b565026c8c3673a11564ab1 /pdf-over-gui/src
parent66a53df1563d85de5e3c2b8ea3344cc94a08d9ca (diff)
downloadpdf-over-5caa941790750bba85a8f830abf04a50d3b049b0.tar.gz
pdf-over-5caa941790750bba85a8f830abf04a50d3b049b0.tar.bz2
pdf-over-5caa941790750bba85a8f830abf04a50d3b049b0.zip
New Thread for polling implemented
Diffstat (limited to 'pdf-over-gui/src')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java98
1 files changed, 49 insertions, 49 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
index 8a416676..6485c270 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
@@ -15,11 +15,13 @@
*/
package at.asit.pdfover.gui.workflow.states;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Timer;
import java.util.TimerTask;
// Imports
+import at.asit.pdfover.gui.exceptions.ATrustConnectionException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.slf4j.Logger;
@@ -451,67 +453,65 @@ public class MobileBKUState extends State {
public void showOpenAppMessageWithSMSandCancel() {
final ATrustStatus status = (ATrustStatus) this.getStatus();
- final ATrustHandler handler = (ATrustHandler) this.getHandler();
- final Timer checkDone = new Timer(true);
- checkDone.scheduleAtFixedRate(new TimerTask() {
+ Display.getDefault().syncExec(() -> {
+ WaitingForAppComposite waitingForAppcomposite = MobileBKUState.this.getWaitingForAppComposite();
+ getStateMachine().getGUIProvider().display(waitingForAppcomposite);
- @Override
- public void run() {
- // ping signature page
- try {
- String resp = handler.getSignaturePage();
- if (handler.handleWaitforAppResponse(resp) || handler.handlePolling()) {
- log.debug("Signature page response: " + resp); //$NON-NLS-1$
- getWaitingForAppComposite().setIsDone(true);
- Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
- display.wake();
- }
- Display.getDefault().wake();
- } catch (Exception e) {
- log.error("Error getting signature page", e); //$NON-NLS-1$
+ Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
+ undecidedPolling();
+
+ while (!waitingForAppcomposite.getUserCancel() && !waitingForAppcomposite.getUserSMS()
+ && !waitingForAppcomposite.getIsDone()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
}
}
- }, 0, 5000);
-
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- WaitingForAppComposite waitingForAppcomposite = MobileBKUState.this.getWaitingForAppComposite();// getWaitingForAppComposite();
- getStateMachine().getGUIProvider().display(waitingForAppcomposite);
- Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
- while (!waitingForAppcomposite.getUserCancel() && !waitingForAppcomposite.getUserSMS()
- && !waitingForAppcomposite.getIsDone()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
+ if (waitingForAppcomposite.getUserCancel()) {
+ waitingForAppcomposite.setUserCancel(false);
+ status.setErrorMessage("cancel"); //$NON-NLS-1$
+ return;
+ }
- if (waitingForAppcomposite.getUserCancel()) {
- waitingForAppcomposite.setUserCancel(false);
- status.setErrorMessage("cancel"); //$NON-NLS-1$
- return;
- }
+ if (waitingForAppcomposite.getUserSMS()) {
+ status.setQRCode(null);
+ waitingForAppcomposite.setUserSMS(false);
+ status.setErrorMessage("sms"); //$NON-NLS-1$
+ status.setSmsTan(true);
+ // show waiting composite
+ getStateMachine().getGUIProvider().display(MobileBKUState.this.getWaitingComposite());
+ return;
- if (waitingForAppcomposite.getUserSMS()) {
- status.setQRCode(null);
- waitingForAppcomposite.setUserSMS(false);
- status.setErrorMessage("sms"); //$NON-NLS-1$
- status.setSmsTan(true);
- // show waiting composite
- getStateMachine().getGUIProvider().display(MobileBKUState.this.getWaitingComposite());
- return;
+ }
- }
+ if (waitingForAppcomposite.getIsDone())
+ waitingForAppcomposite.setIsDone(false);
+ });
+ }
- if (waitingForAppcomposite.getIsDone())
- waitingForAppcomposite.setIsDone(false);
+ private void undecidedPolling(){
+ final ATrustHandler handler = (ATrustHandler) this.getHandler();
- // show waiting composite
- //getStateMachine().getGUIProvider().display(MobileBKUState.this.getWaitingComposite());
+ Thread pollingThread = new Thread(() -> {
+ try {
+ if (handler.handlePolling()){
+ String response = handler.getSignaturePage();
+ handler.handleCredentialsResponse(response);
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ getWaitingForAppComposite().setIsDone(true);
+ }
+ });
+ }
+ } catch (ATrustConnectionException e) {
+ log.error("Error when calling polling endpoint");
+ } catch (Exception e) {
+ log.error("Exception occurred during calling polling endpoint");
}
});
+ pollingThread.start();
}
/**