|
|
|
|
@ -5,14 +5,11 @@
|
|
|
|
|
*/
|
|
|
|
|
package net.java.sip.communicator.impl.gui.main.call;
|
|
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.awt.event.*;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.text.*;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
|
|
|
|
|
import net.java.sip.communicator.impl.gui.*;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.utils.*;
|
|
|
|
|
import net.java.sip.communicator.service.configuration.*;
|
|
|
|
|
@ -31,21 +28,21 @@ public class RecordButton
|
|
|
|
|
extends AbstractCallToggleButton
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Resource service.
|
|
|
|
|
* Configuration service.
|
|
|
|
|
*/
|
|
|
|
|
private static ResourceManagementService resources
|
|
|
|
|
= GuiActivator.getResources();
|
|
|
|
|
private static final ConfigurationService configuration
|
|
|
|
|
= GuiActivator.getConfigurationService();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configuration service.
|
|
|
|
|
* Resource service.
|
|
|
|
|
*/
|
|
|
|
|
private static ConfigurationService configurationService
|
|
|
|
|
= GuiActivator.getConfigurationService();
|
|
|
|
|
private static final ResourceManagementService resources
|
|
|
|
|
= GuiActivator.getResources();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The date format used in file names.
|
|
|
|
|
*/
|
|
|
|
|
private static SimpleDateFormat format
|
|
|
|
|
private static final SimpleDateFormat format
|
|
|
|
|
= new SimpleDateFormat("yyyy-MM-dd@HH.mm.ss");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -60,9 +57,9 @@ public class RecordButton
|
|
|
|
|
private String callFilename;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Input panel.
|
|
|
|
|
* Call file chooser.
|
|
|
|
|
*/
|
|
|
|
|
private InputPanel inputPanel;
|
|
|
|
|
private final SipCommFileChooser callFileChooser;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initializes a new <tt>RecordButton</tt> instance which is to record the
|
|
|
|
|
@ -91,16 +88,36 @@ public RecordButton(Call call, boolean fullScreen, boolean selected)
|
|
|
|
|
{
|
|
|
|
|
super(call, fullScreen, selected, ImageLoader.RECORD_BUTTON, null);
|
|
|
|
|
|
|
|
|
|
inputPanel = new InputPanel();
|
|
|
|
|
callFileChooser
|
|
|
|
|
= GenericFileDialog.create(
|
|
|
|
|
null,
|
|
|
|
|
resources.getI18NString(
|
|
|
|
|
"plugin.callrecordingconfig.SAVE_CALL"),
|
|
|
|
|
SipCommFileChooser.SAVE_FILE_OPERATION);
|
|
|
|
|
callFileChooser.addFilter(
|
|
|
|
|
new SipCommFileFilter()
|
|
|
|
|
{
|
|
|
|
|
public boolean accept(File f)
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
f.isDirectory() || SoundFileUtils.isRecordedCall(f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDescription()
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
"Recorded call (*.mp2, *.wav, *.au, *.aif, *.gsm)";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
String toolTip
|
|
|
|
|
= resources.getI18NString("service.gui.RECORD_BUTTON_TOOL_TIP");
|
|
|
|
|
String saveDir
|
|
|
|
|
= configurationService.getString(Recorder.SAVED_CALLS_PATH);
|
|
|
|
|
if (saveDir != null)
|
|
|
|
|
String saveDir = configuration.getString(Recorder.SAVED_CALLS_PATH);
|
|
|
|
|
|
|
|
|
|
if ((saveDir != null) && (saveDir.length() != 0))
|
|
|
|
|
{
|
|
|
|
|
isCallDirSet = true;
|
|
|
|
|
toolTip = toolTip + " (" + saveDir + ")";
|
|
|
|
|
toolTip += " (" + saveDir + ")";
|
|
|
|
|
}
|
|
|
|
|
setToolTipText(toolTip);
|
|
|
|
|
}
|
|
|
|
|
@ -125,20 +142,14 @@ public void actionPerformed(ActionEvent evt)
|
|
|
|
|
// ask user input about where to save the call
|
|
|
|
|
if (!isCallDirSet)
|
|
|
|
|
{
|
|
|
|
|
int status =
|
|
|
|
|
JOptionPane
|
|
|
|
|
.showConfirmDialog(
|
|
|
|
|
this,
|
|
|
|
|
inputPanel,
|
|
|
|
|
resources
|
|
|
|
|
.getI18NString("plugin.callrecordingconfig.SAVE_CALL"),
|
|
|
|
|
JOptionPane.OK_CANCEL_OPTION,
|
|
|
|
|
JOptionPane.QUESTION_MESSAGE);
|
|
|
|
|
if (status == JOptionPane.OK_OPTION)
|
|
|
|
|
File selectedFile = callFileChooser.getFileFromDialog();
|
|
|
|
|
|
|
|
|
|
if (selectedFile != null)
|
|
|
|
|
{
|
|
|
|
|
callFilename = inputPanel.getSelectedFilename();
|
|
|
|
|
configurationService.setProperty(Recorder.CALL_FORMAT,
|
|
|
|
|
inputPanel.getSelectedFormat());
|
|
|
|
|
callFilename = selectedFile.getAbsolutePath();
|
|
|
|
|
configuration.setProperty(
|
|
|
|
|
Recorder.CALL_FORMAT,
|
|
|
|
|
SoundFileUtils.getExtension(selectedFile));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@ -156,13 +167,14 @@ public void actionPerformed(ActionEvent evt)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
telephony.stopRecording(call);
|
|
|
|
|
JOptionPane.showMessageDialog(this,
|
|
|
|
|
resources.getI18NString(
|
|
|
|
|
"plugin.callrecordingconfig.CALL_SAVED_TO", new String[]
|
|
|
|
|
{ callFilename }),
|
|
|
|
|
resources
|
|
|
|
|
.getI18NString("plugin.callrecordingconfig.CALL_SAVED"),
|
|
|
|
|
JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
NotificationManager
|
|
|
|
|
.fireNotification(
|
|
|
|
|
NotificationManager.CALL_SAVED,
|
|
|
|
|
resources.getI18NString(
|
|
|
|
|
"plugin.callrecordingconfig.CALL_SAVED"),
|
|
|
|
|
resources.getI18NString(
|
|
|
|
|
"plugin.callrecordingconfig.CALL_SAVED_TO",
|
|
|
|
|
new String[] { callFilename }));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -171,13 +183,12 @@ public void actionPerformed(ActionEvent evt)
|
|
|
|
|
* Creates a full filename for the call by combining the directory, file
|
|
|
|
|
* prefix and extension. If the directory is <tt>null</tt> user's home
|
|
|
|
|
* directory is used.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @return a full filename for the call
|
|
|
|
|
*/
|
|
|
|
|
private String createDefaultFilename()
|
|
|
|
|
{
|
|
|
|
|
String callsDir
|
|
|
|
|
= configurationService.getString(Recorder.SAVED_CALLS_PATH);
|
|
|
|
|
String callsDir = configuration.getString(Recorder.SAVED_CALLS_PATH);
|
|
|
|
|
|
|
|
|
|
// set to user's home when null
|
|
|
|
|
if (callsDir == null)
|
|
|
|
|
@ -196,11 +207,10 @@ private String createDefaultFilename()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String ext = configurationService.getString(Recorder.CALL_FORMAT);
|
|
|
|
|
String ext = configuration.getString(Recorder.CALL_FORMAT);
|
|
|
|
|
|
|
|
|
|
if (ext == null)
|
|
|
|
|
ext = SoundFileUtils.mp2;
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
((callsDir == null) ? "" : (callsDir + File.separator))
|
|
|
|
|
+ generateCallFilename(ext);
|
|
|
|
|
@ -208,7 +218,7 @@ private String createDefaultFilename()
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generates a file name for the call based on the current date.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param ext file extension
|
|
|
|
|
* @return the file name for the call
|
|
|
|
|
*/
|
|
|
|
|
@ -216,136 +226,4 @@ private String generateCallFilename(String ext)
|
|
|
|
|
{
|
|
|
|
|
return format.format(new Date()) + "-confcall." + ext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class InputPanel
|
|
|
|
|
extends TransparentPanel
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Call file chooser.
|
|
|
|
|
*/
|
|
|
|
|
private SipCommFileChooser callFileChooser;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Selected file.
|
|
|
|
|
*/
|
|
|
|
|
private String selectedFilename;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Format combo box.
|
|
|
|
|
*/
|
|
|
|
|
private JComboBox formatComboBox;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Builds the panel.
|
|
|
|
|
*/
|
|
|
|
|
public InputPanel()
|
|
|
|
|
{
|
|
|
|
|
super(new BorderLayout());
|
|
|
|
|
|
|
|
|
|
initComponents();
|
|
|
|
|
|
|
|
|
|
callFileChooser =
|
|
|
|
|
GenericFileDialog.create(null, resources
|
|
|
|
|
.getI18NString("plugin.callrecordingconfig.SAVE_CALL"),
|
|
|
|
|
SipCommFileChooser.SAVE_FILE_OPERATION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the selected file.
|
|
|
|
|
*
|
|
|
|
|
* @return the selected file
|
|
|
|
|
*/
|
|
|
|
|
public String getSelectedFilename()
|
|
|
|
|
{
|
|
|
|
|
return selectedFilename;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the selected format.
|
|
|
|
|
*
|
|
|
|
|
* @return the selected format
|
|
|
|
|
*/
|
|
|
|
|
public String getSelectedFormat()
|
|
|
|
|
{
|
|
|
|
|
return (String) formatComboBox.getSelectedItem();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initializes the UI components.
|
|
|
|
|
*/
|
|
|
|
|
private void initComponents()
|
|
|
|
|
{
|
|
|
|
|
JPanel labelsPanel = new TransparentPanel(new GridLayout(2, 1));
|
|
|
|
|
JLabel formatLabel =
|
|
|
|
|
new JLabel(resources
|
|
|
|
|
.getI18NString("plugin.callrecordingconfig.FORMAT"));
|
|
|
|
|
JLabel locationLabel =
|
|
|
|
|
new JLabel(resources
|
|
|
|
|
.getI18NString("plugin.callrecordingconfig.LOCATION"));
|
|
|
|
|
labelsPanel.add(formatLabel);
|
|
|
|
|
labelsPanel.add(locationLabel);
|
|
|
|
|
|
|
|
|
|
JPanel dirPanel =
|
|
|
|
|
new TransparentPanel(new FlowLayout(FlowLayout.LEFT));
|
|
|
|
|
final JTextField callDirTextField = new JTextField();
|
|
|
|
|
callDirTextField.setPreferredSize(new Dimension(200, 30));
|
|
|
|
|
callDirTextField.setEditable(false);
|
|
|
|
|
dirPanel.add(callDirTextField);
|
|
|
|
|
JButton callDirChooseButton =
|
|
|
|
|
new JButton(new ImageIcon(resources
|
|
|
|
|
.getImageInBytes("plugin.notificationconfig.FOLDER_ICON")));
|
|
|
|
|
callDirChooseButton.setMinimumSize(new Dimension(30, 30));
|
|
|
|
|
callDirChooseButton.setPreferredSize(new Dimension(30, 30));
|
|
|
|
|
callDirChooseButton.addActionListener(new ActionListener()
|
|
|
|
|
{
|
|
|
|
|
public void actionPerformed(ActionEvent arg0)
|
|
|
|
|
{
|
|
|
|
|
File selectedFile = callFileChooser.getFileFromDialog();
|
|
|
|
|
|
|
|
|
|
if (selectedFile != null)
|
|
|
|
|
{
|
|
|
|
|
selectedFilename = selectedFile.getAbsolutePath();
|
|
|
|
|
callDirTextField.setText(selectedFilename);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
dirPanel.add(callDirChooseButton);
|
|
|
|
|
|
|
|
|
|
JPanel comboPanel =
|
|
|
|
|
new TransparentPanel(new FlowLayout(FlowLayout.LEFT));
|
|
|
|
|
JLabel emptyLabel = new JLabel();
|
|
|
|
|
emptyLabel.setPreferredSize(new Dimension(30, 30));
|
|
|
|
|
comboPanel.add(createFormatsComboBox());
|
|
|
|
|
comboPanel.add(emptyLabel);
|
|
|
|
|
|
|
|
|
|
JPanel valuesPanel = new TransparentPanel(new GridLayout(2, 1));
|
|
|
|
|
valuesPanel.add(comboPanel);
|
|
|
|
|
valuesPanel.add(dirPanel);
|
|
|
|
|
|
|
|
|
|
this.add(labelsPanel, BorderLayout.WEST);
|
|
|
|
|
this.add(valuesPanel, BorderLayout.CENTER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a combo box with supported audio formats.
|
|
|
|
|
*
|
|
|
|
|
* @return a combo box with supported audio formats
|
|
|
|
|
*/
|
|
|
|
|
private Component createFormatsComboBox()
|
|
|
|
|
{
|
|
|
|
|
ComboBoxModel formatsComboBoxModel =
|
|
|
|
|
new DefaultComboBoxModel(
|
|
|
|
|
new String[] {
|
|
|
|
|
SoundFileUtils.mp2,
|
|
|
|
|
SoundFileUtils.wav,
|
|
|
|
|
SoundFileUtils.au,
|
|
|
|
|
SoundFileUtils.aif,
|
|
|
|
|
SoundFileUtils.gsm });
|
|
|
|
|
|
|
|
|
|
formatComboBox = new JComboBox();
|
|
|
|
|
formatComboBox.setPreferredSize(new Dimension(200, 30));
|
|
|
|
|
formatComboBox.setModel(formatsComboBoxModel);
|
|
|
|
|
return formatComboBox;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|