@Override public void actionPerformed(ActionEvent e) { try { int selectedRow = ListMailController.this.view.getSelectedRow(); if (-1 == selectedRow) { return; } int result = JOptionPane.showConfirmDialog( ListMailController.this.view, String.format("Are you sure you want to delete this mail?"), "Confirm", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { TotalListItem item = ListMailController.this.model.getItemAtRow(selectedRow); EncryptedListItem decryptedItem = item.getEncryptedListItem( null); // was already decrypted and cached, don't need private key WebServiceClient.deleteMessage(item.getId(), decryptedItem.getAttachments()); new RefreshListWorker().execute(); } } catch (IOException | FailedCryptException | JavaInstallationMissingComponentsException | IllegalStateException | CommunicationFailureException e1) { ListMailController.this.view.setInfo(Utils.ppStackTrace(e1)); } }
@Override protected Void doInBackground() { try { publish("Retrieving and decrypting mail list"); String myMailboxName = Configuration.getMyMailboxName(); if (myMailboxName != null) { TotalListItem[] listItems = WebServiceClient.getMailList(myMailboxName); for (TotalListItem item : listItems) { // decrypt them now, object will cache decrypted--doing it for the side effect item.getEncryptedListItem(Configuration.getMyPrivateKey()); } ListMailController.this.model.setItems(listItems); publish("Mail list ready."); return null; } publish("No mailbox currently selected"); ListMailController.this.model.clearItems(); return null; } catch (CommunicationFailureException e) { publish(Utils.ppStackTrace(e)); return null; } catch (FailedCryptException | JavaInstallationMissingComponentsException e) { publish(Utils.ppStackTrace(e)); return null; } catch (RuntimeException e) { System.out.println(Utils.ppStackTrace(e)); return null; } }