use of org.openecard.gui.MessageDialog in project open-ecard by ecsec.
the class CardRecognitionImpl method waitForExclusiveCardAccess.
/**
* This method tries to get exclusive card access until it is granted.
* The waiting delay between the attempts is determined by the fibonacci numbers.
*
* @param slotHandle slot handle specifying the card to get exclusive access for
* @param ifdName Name of the IFD in which the card is inserted
*/
private void waitForExclusiveCardAccess(byte[] slotHandle, String ifdName) throws RecognitionException {
String resultMajor;
int i = 2;
do {
// try to get exclusive card access for the recognition run
BeginTransaction trans = new BeginTransaction();
trans.setSlotHandle(slotHandle);
BeginTransactionResponse resp = (BeginTransactionResponse) env.getDispatcher().safeDeliver(trans);
resultMajor = resp.getResult().getResultMajor();
if (!resultMajor.equals(ECardConstants.Major.OK)) {
String resultMinor = resp.getResult().getResultMinor();
if (ECardConstants.Minor.IFD.INVALID_SLOT_HANDLE.equals(resultMinor)) {
throw new RecognitionException("Card is not available anymore.");
}
// could not get exclusive card access, wait in increasingly longer intervals and retry
try {
long waitInSeconds = fibonacci(i);
i++;
LOG.debug("Could not get exclusive card access. Trying again in {} seconds.", waitInSeconds);
if (i == 6 && gui != null) {
MessageDialog dialog = gui.obtainMessageDialog();
String message = LANG.translationForKey("message", AppVersion.getName(), ifdName);
String title = LANG.translationForKey("error", ifdName);
dialog.showMessageDialog(message, title, DialogType.WARNING_MESSAGE);
}
Thread.sleep(1000 * waitInSeconds);
} catch (InterruptedException e) {
// ignore
}
}
} while (!resultMajor.equals(ECardConstants.Major.OK));
}
use of org.openecard.gui.MessageDialog in project open-ecard by ecsec.
the class RunMessageBox method showMessage2.
@Test(enabled = !true)
public void showMessage2() {
MessageDialog messageBox = uc.obtainMessageDialog();
messageBox.showMessageDialog(MSG, TITLE, DialogType.ERROR_MESSAGE);
}
use of org.openecard.gui.MessageDialog in project open-ecard by ecsec.
the class RunMessageBox method showConfirmDialog3.
@Test(enabled = !true)
public void showConfirmDialog3() {
MessageDialog messageBox = uc.obtainMessageDialog();
MessageDialogResult result = messageBox.showConfirmDialog("Press ok!", TITLE, OptionType.OK_CANCEL_OPTION, DialogType.ERROR_MESSAGE);
Assert.assertEquals(result.getReturnValue(), ReturnType.OK);
}
use of org.openecard.gui.MessageDialog in project open-ecard by ecsec.
the class RunMessageBox method showMessage.
@Test(enabled = !true)
public void showMessage() {
MessageDialog messageBox = uc.obtainMessageDialog();
messageBox.showMessageDialog(MSG, TITLE);
}
use of org.openecard.gui.MessageDialog in project open-ecard by ecsec.
the class RunMessageBox method showInputDialog.
@Test(enabled = !true)
public void showInputDialog() {
MessageDialog messageBox = uc.obtainMessageDialog();
MessageDialogResult result = messageBox.showInputDialog("Enter the text \"test\"!", TITLE);
Assert.assertEquals(result.getReturnValue(), ReturnType.OK);
Assert.assertEquals(result.getUserInput(), "test");
}
Aggregations