From cc702f3a05e4aaa8be930b992748196f29dcf823 Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Mon, 11 Feb 2013 08:51:06 +0000 Subject: [PATCH] Adds the username of the remote party to the recored call file name. Patch provided by Hristo Terezov on dev mailing list (subject: "[PATCH] Change for the filename format of the recorded call file"). --- .../impl/gui/main/call/RecordButton.java | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/call/RecordButton.java b/src/net/java/sip/communicator/impl/gui/main/call/RecordButton.java index 7fa7927c6..050b6d1af 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/RecordButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/RecordButton.java @@ -52,6 +52,11 @@ public class RecordButton */ private static final ResourceManagementService resources = GuiActivator.getResources(); + + /** + * Maximum allowed file name length. + */ + private static final int MAX_FILENAME_LENGTH = 64; /** * The full filename of the saved call on the file system. @@ -198,14 +203,47 @@ private String createDefaultFilename(String savedCallsPath) } /** - * Generates a file name for the call based on the current date. + * Generates a file name for the call based on the current date and + * the names of the peers in the call. * * @param ext file extension * @return the file name for the call */ private String generateCallFilename(String ext) { - return FORMAT.format(new Date()) + "-call." + ext; + String filename = FORMAT.format(new Date()) + "-call"; + int maxLength + = MAX_FILENAME_LENGTH - 2 - filename.length() - ext.length(); + String peerName = getCallPeerName(maxLength); + filename += ((!peerName.equals("")) ? "-" : "") + peerName + "." + ext; + return filename; + } + + /** + * Gets and formats the names of the peers in the call. + * + * @param maxLength maximum length of the filename + * @return the name of the peer in the call formated + */ + private String getCallPeerName(int maxLength) + { + List callPeers = call.getConference().getCallPeers(); + CallPeer callPeer = null; + String peerName = ""; + if (!callPeers.isEmpty()) + { + callPeer = callPeers.get(0); + if (callPeer != null) + { + peerName = callPeer.getDisplayName(); + peerName = peerName.replaceAll("[^\\da-zA-Z\\_\\-]",""); + if(peerName.length() > maxLength) + { + peerName = peerName.substring(0, maxLength); + } + } + } + return peerName; } /**