@Override
public void voiceRequest(VoiceConnexionPacket clp) {
c.getVerbose().addConsoleMsg("MainView.voiceRequest()", EnumSet.of(EnumVerbose.ToConsole));
// notice user who want to talk with you
final JOptionPane optionPane = new JOptionPane("Do you want to talk with : " + clp.getContactName(), JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
final JDialog dialog = new JDialog(this, "Incoming Call ... ", true);
dialog.setContentPane(optionPane);
// listener for user response user
optionPane.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
String prop = e.getPropertyName();
if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
dialog.setVisible(false);
}
}
});
// afficher le dialogue
dialog.pack();
dialog.setVisible(true);
// if yes, contact user
int value = ((Integer) optionPane.getValue()).intValue();
if (value == JOptionPane.YES_OPTION) {
new ConfirmVoiceAction(c, clp.getUserIp(), new VoiceConnexionPacket(me.getUsername(), me.getIp(), clp.getUsername()));
getContactListHash().get(clp.getUsername()).swapChat(true);
} else {
// if no, ignore demands