📄 hushapplet.java
字号:
address="\""+c.fullname(addressChoice[n].getSelectedIndex()-1)+"\" <"+c.addresses(addressChoice[n].getSelectedIndex()-1)+">"; else address=c.addresses(addressChoice[n].getSelectedIndex()-1); String fieldText = headerField[n].getText(); if (!fieldText.equals("")) headerField[n].setText(fieldText+", "+address); else headerField[n].setText(address); addressChoice[n].select(0); if (!toHushmail(address)) { encryptCheckbox.setState(false); statusBar(spaces+"Warning: mail sent to this address will not be secure"+spaces); } } composePanel.paintAll(composePanel.getGraphics()); break; } } } /************************************************************************ * The following conditionals involve the arrays of buttons associated * with lists of messages, folders, or addresses ************************************************************************/ /* The array of buttons with a list of folders */ else if (currentScreen.equals("listFolders")) { /* Iterate through list of folders currently displayed checking status of buttons on each */ for (int x=currentFolderPage*linesPerPage;x<currentFolderPage*linesPerPage+numberOfFoldersDisplayed;x++) { /* On click of "Open" button */ if (e.target==openFolderButton[x]) { lockButtons(true); clearCommands(); add(commands,commandsConstraints, new Label("Opening folder " +" "),0,0); commands.paintAll(commands.getGraphics()); try { c.use(); listMessages(c.folderName(x),0,true); c.done(); } catch (IOException e8) {error();} currentScreen = "listMessages"; mainLayout.show(main,currentScreen); clearCommands(); if (c.numberOfMessages()>0) add(commands,commandsConstraints,selectAllButton,0,0); lockButtons(false); break; } /* On click of "Select" button */ else if (e.target==selectFolderButton[x]) { if (folderSelected[x]) { unselectFolder(x); showSelectFunctionButtons(foldersSelected()>0,2); } else { selectFolder(x); showSelectFunctionButtons(true,2); } break; } } } /* The array of buttons with a list of messages */ else if (currentScreen.equals("listMessages")) { /* Iterate through list of messages checking status of buttons on each */ for (int x=currentMessagePage*linesPerPage; x<currentMessagePage*linesPerPage+numberOfMessagesDisplayed;x++) { /* On click of "Read" button */ if (e.target==readMessageButton[x]) { lockButtons(true); clearCommands(); add(commands,commandsConstraints, new Label("Retrieving message " +" "),0,0); commands.paintAll(commands.getGraphics()); try { if (c.folderName().equals("drafts")) { c.use(); getDraft(c.messageID(x)); c.deleteMessage(c.messageID(x)); currentScreen = "compose"; mainLayout.show(main, currentScreen); listMessages(c.folderName(),0,true); listFolders(0,true); c.done(); clearCommands(); add(commands,commandsConstraints,backButton,0,0); add(commands,commandsConstraints,clearButton,1,0); add(commands,commandsConstraints,saveDraftButton,2,0); add(commands,commandsConstraints,sendButton,3,0); } else { c.use(); readMessage(c.messageID(x),true); currentScreen = "read"; mainLayout.show(main,currentScreen); if (!c.read(x)) { listMessages(c.folderName(),currentMessagePage,true); listFolders(currentFolderPage,true); } c.done(); clearCommands(); add(commands,commandsConstraints,backButton,0,0); add(commands,commandsConstraints,replyButton,1,0); add(commands,commandsConstraints,forwardButton,2,0); add(commands,commandsConstraints,deleteButtonR,3,0); add(commands,commandsConstraints,saveButtonR,4,0); } } catch (IOException e9) { clearCommands(); add(commands,commandsConstraints,selectAllButton,0,0); showSelectFunctionButtons(messagesSelected()>0,1); error(); } lockButtons(false); break; } /* On click of "Select" button */ else if (e.target==selectMessageButton[x]) { if (messageSelected[x]) { unselectMessage(x); if (messagesSelected()==0) showSelectFunctionButtons(false,0); } else { selectMessage(x); showSelectFunctionButtons(true,1); } break; } } } /* The array of buttons with a list of addresses */ else if (currentScreen.equals("addresses")) { /* Iterate through list of addresses checking status of buttons on each */ for (int x=currentAddressPage*linesPerPage; x<currentAddressPage*linesPerPage+numberOfAddressesDisplayed;x++) { /* On click of "Edit" button */ if (e.target==addressEditButton[x]) { /* If the address is not yet in edit mode */ if (addressEditButton[x].getLabel().equals("Edit")) { addressEditButton[x].setLabel("Save"); lockButtons(true); add(addressesPanel,aConstraints,editNickname = new TextField(c.nickname(x),9),2,x+1,1,1,0,0,0,0,NO,NW,0,6,0,6); editNickname.setForeground(Color.black); add(addressesPanel,aConstraints,editFullname = new TextField(c.fullname(x),smallApplet?13:19),3,x+1); editFullname.setForeground(Color.black); add(addressesPanel,aConstraints,editAddresses = new TextField(c.addresses(x),smallApplet?13:19),4,x+1); editAddresses.setForeground(Color.black); addressesPanel.remove(nickname[x]); addressesPanel.remove(fullname[x]); addressesPanel.remove(addresses[x]); for (int y=0;y<c.numberOfAddresses();y++) { addressDeleteButton[y].disable(); if (addressEditButton[y].getLabel().equals("Edit")) addressEditButton[y].disable(); } addressesPanel.paintAll(addressesPanel.getGraphics()); editNickname.requestFocus(); if (c.fingerprints(x).length()>0) { if (smallApplet) statusBar(spaces+"Pub key fingerprint: "+c.fingerprints(x)+spaces); else statusBar(spaces+"Public key fingerprint: "+c.fingerprints(x)+spaces); } break; } /* If the address is already in edit mode. */ else if (addressEditButton[x].getLabel().equals("Save")) { String newNickname = editNickname.getText().trim(); if (newNickname.equals(c.nickname(x)) && editFullname.getText().equals(c.fullname(x)) && editAddresses.getText().equals(c.addresses(x))) { clearCommands(); add(commands,commandsConstraints,newAddressButton,0,0); add(commands,commandsConstraints,showFingerprintButton,1,0); commands.paintAll(commands.getGraphics()); try { listAddresses(currentAddressPage,false); } catch (IOException e1) { /* Can't happen */ } lockButtons(false); return true; } else if (newNickname.length()==0) { statusBar(spaces+"You must enter a nickname"+spaces); ignoreLostFocus = true; editNickname.requestFocus(); return true; } else if (newNickname.length()>9) { statusBar(spaces+"Nicknames must be nine characters or less"+spaces); ignoreLostFocus = true; editNickname.requestFocus(); return true; } else if (editFullname.getText().indexOf('\\')!=-1) { statusBar(spaces+"Cannot use \\ in name"+spaces); ignoreLostFocus = true; editFullname.requestFocus(); return true; } else if (validEmailAddress(editAddresses.getText().trim())) { /* Check to be sure nickname isn't a duplicate */ for (int a=0;a<c.numberOfAddresses();a++) { if (c.nickname(a).equals(newNickname) && a!=x) { statusBar(spaces+"That nickname already exists!"+spaces); ignoreLostFocus = true; editNickname.requestFocus(); return true; } } addressEditButton[x].disable(); clearCommands(); add(commands,commandsConstraints, new Label("Writing changes " +" "),0,0); commands.paintAll(commands.getGraphics()); /* Delete the old address and add the new one. */ try { c.use(); c.deleteAddress(c.nickname(x)); boolean successful = c.addAddress(newNickname, editFullname.getText().trim(),editAddresses.getText().trim()); if (successful) { listAddresses(currentAddressPage,true); lockButtons(false); } else { addressEditButton[x].enable(); editAddresses.requestFocus(); } c.done(); } catch (IOException e10) { try { listAddresses(currentAddressPage,false); } catch (IOException none) { /* can't happen */ } lockButtons(false); error(); } clearCommands(); add(commands,commandsConstraints,newAddressButton,0,0); add(commands,commandsConstraints,showFingerprintButton,1,0); } else { editAddresses.requestFocus(); statusBar(spaces+"Bad email address"+spaces); } } } /* On click of "Delete" button */ else if (e.target==addressDeleteButton[x]) { markForDelete = x; clearCommands(); lockButtons(true); confirmLabel.setText("Are you sure you want to delete this address?"); add(commands,commandsConstraints,confirmLabel,0,0); add(commands,commandsConstraints,confirmDeleteButton,1,0); add(commands,commandsConstraints,cancelDeleteButton,2,0); commands.paintAll(commands.getGraphics()); break; } } } commands.paintAll(commands.getGraphics()); return true; } public boolean lostFocus(Event e, Object o) { /* Exit if still on login screen */ if (currentScreen.equals("login")) return true; /* This takes care of substituting actual addresses for nicknames * on the compose screen, and checks for bad email addresses */ else if (e.target==headerField[0]||e.target==headerField[1]||e.target==headerField[2]) { TextField text = (TextField)e.target; text.setText(text.getText().trim()); if (text.getText().length()>0) { for (int x=0; x<c.numberOfAddresses(); x++) { if (text.getText().equalsIgnoreCase(c.nickname(x))) { if (c.fullname(x).length()>0) text.setText("\""+c.fullname(x).trim()+"\" <"+c.addresses(x).trim()+">"); else text.setText(c.addresses(x).trim()); break; //return true; } } boolean allLettersAndDigits = true; char[] addrChr = new char[text.getText().length()]; addrChr = text.getText().toCharArray(); for (int c=0;c<text.getText().length();c++) { if (!Character.isLetterOrDigit(addrChr[c]) && addrChr[c]!='_' && addrChr[c]!='-' && addrChr[c]!='.') { allLettersAndDigits = false; break; } } if (allLettersAndDigits) { text.setText(text.getText()+"@"+c.domain());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -