Commits the patch callrec-ui.patch provided by Dmitri Melnikov on the dev mailing list in the thread "Call Recording".

cusax-fix
Lyubomir Marinov 16 years ago
parent 923e76aed0
commit b073675685

@ -914,11 +914,9 @@ plugin.callrecordingconfig.CALL_RECORDING_CONFIG=Call Recording
plugin.callrecordingconfig.SAVE_CALLS=Save calls to:
plugin.callrecordingconfig.SAVE_CALL=Save call to...
plugin.callrecordingconfig.CHOOSE_DIR=Choose a directory...
plugin.callrecordingconfig.SUPPORTED_FORMATS=Supported formats:
plugin.callrecordingconfig.SUPPORTED_FORMATS=Save calls in format:
plugin.callrecordingconfig.CALL_SAVED=Call saved successfully
plugin.callrecordingconfig.CALL_SAVED_TO=Call has been saved to {0}
plugin.callrecordingconfig.FORMAT=Format:
plugin.callrecordingconfig.LOCATION=Location:
plugin.callrecordingconfig.CALL_SAVED_TO={0}
# Security configuration form title
plugin.securityconfig.TITLE=Security

@ -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;
}
}
}

@ -33,6 +33,8 @@ public class NotificationManager
public static final String INCOMING_FILE = "IncomingFile";
public static final String CALL_SAVED = "CallSaved";
public static void registerGuiNotifications()
{
NotificationService notificationService
@ -143,6 +145,12 @@ public static void registerGuiNotifications()
SoundProperties.INCOMING_FILE,
null);
// Register notification for saved calls.
notificationService.registerDefaultNotificationForEvent(
CALL_SAVED,
NotificationService.ACTION_POPUP_MESSAGE,
null,
null);
}
/**

@ -102,54 +102,61 @@ private void loadValues()
private void initComponents()
{
// labels panel
JPanel labelsPanel = new TransparentPanel(new GridLayout(2, 1));
JLabel formatsLabel = new JLabel(
resources.getI18NString("plugin.callrecordingconfig.SUPPORTED_FORMATS"));
saveCallsToCheckBox =
new SIPCommCheckBox(resources
.getI18NString("plugin.callrecordingconfig.SAVE_CALLS"));
JPanel labelsPanel = new TransparentPanel(new GridLayout(2, 1));
JLabel formatsLabel
= new JLabel(
resources.getI18NString(
"plugin.callrecordingconfig.SUPPORTED_FORMATS"));
saveCallsToCheckBox
= new SIPCommCheckBox(
resources.getI18NString(
"plugin.callrecordingconfig.SAVE_CALLS"));
saveCallsToCheckBox.addActionListener(this);
labelsPanel.add(formatsLabel);
labelsPanel.add(saveCallsToCheckBox);
// combo box panel
JPanel comboPanel =
new TransparentPanel(new FlowLayout(FlowLayout.LEFT));
JPanel comboPanel
= new TransparentPanel(new FlowLayout(FlowLayout.LEFT));
JLabel emptyLabel = new JLabel();
emptyLabel.setPreferredSize(new Dimension(30, 30));
comboPanel.add(createFormatsComboBox());
comboPanel.add(emptyLabel);
// saved calls directory panel
JPanel callDirPanel =
new TransparentPanel(new FlowLayout(FlowLayout.LEFT));
JPanel callDirPanel
= new TransparentPanel(new FlowLayout(FlowLayout.LEFT));
callDirTextField = new JTextField();
callDirTextField.setPreferredSize(new Dimension(200, 30));
callDirTextField.addActionListener(this);
callDirPanel.add(callDirTextField);
callDirChooseButton =
new JButton(new ImageIcon(resources
.getImageInBytes("plugin.notificationconfig.FOLDER_ICON")));
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(this);
callDirPanel.add(callDirChooseButton);
// values panel
JPanel valuesPanel = new TransparentPanel(new GridLayout(2, 1));
valuesPanel.add(comboPanel);
valuesPanel.add(callDirPanel);
// main panel
JPanel mainPanel = new TransparentPanel(new BorderLayout());
mainPanel.add(labelsPanel, BorderLayout.WEST);
mainPanel.add(valuesPanel, BorderLayout.CENTER);
this.add(mainPanel, BorderLayout.NORTH);
}

@ -56,6 +56,28 @@ public static boolean isSoundFile(File f)
return false;
}
/**
* Checks whether this file is a recorded call. Only some
* sound file formats are used in call recording.
*
* @param f <tt>File</tt> to check
* @return <tt>true</tt> if it's a call file, <tt>false</tt> otherwise
*/
public static boolean isRecordedCall(File f)
{
String extension = SoundFileUtils.getExtension(f);
if (extension != null)
{
return extension.equals(SoundFileUtils.mp2) ||
extension.equals(SoundFileUtils.wav) ||
extension.equals(SoundFileUtils.au) ||
extension.equals(SoundFileUtils.aif) ||
extension.equals(SoundFileUtils.gsm);
}
return false;
}
/**
* Gets the file extension.
* TODO: There are at least 2 other methods like this scattered around
@ -64,7 +86,7 @@ public static boolean isSoundFile(File f)
* @param f which wants the extension
* @return Return the extension as a String
*/
private static String getExtension(File f)
public static String getExtension(File f)
{
String ext = null;
String s = f.getName();

Loading…
Cancel
Save