diff options
15 files changed, 1613 insertions, 697 deletions
@@ -925,6 +925,7 @@ bundle-vimeo,bundle-vbox7,bundle-metacafe,bundle-flickr,bundle-hulu, bundle-twitpic,bundle-directimage,bundle-bliptv,bundle-viddler, bundle-plugin-chatconfig,bundle-certificate,bundle-packetlogging, + bundle-plugin-loggingutils, bundle-provdisc,bundle-provdisc-dhcp,bundle-provdisc-mdns, bundle-provisioning,bundle-addrbook"/> @@ -2372,11 +2373,11 @@ org.apache.http.util"/> <zipfileset src="${lib.noinst}/lcrypto-jdk16-143.jar"/> <manifest> <attribute name="Export-Package" value="org.bouncycastle.asn1, - org.bouncycastle.asn1.nist, - org.bouncycastle.asn1.sec, - org.bouncycastle.asn1.x9, - org.bouncycastle.crypto, - org.bouncycastle.crypto.agreement, + org.bouncycastle.asn1.nist, + org.bouncycastle.asn1.sec, + org.bouncycastle.asn1.x9, + org.bouncycastle.crypto, + org.bouncycastle.crypto.agreement, org.bouncycastle.crypto.digests, org.bouncycastle.crypto.engines, org.bouncycastle.crypto.generators, @@ -2669,4 +2670,11 @@ org.apache.http.util"/> prefix="net/java/sip/communicator/impl/packetlogging" /> </jar> </target> + <target name="bundle-plugin-loggingutils"> + <jar compress="false" destfile="${bundles.dest}/plugin-loggingutils.jar" + manifest="${src}/net/java/sip/communicator/plugin/loggingutils/loggingutils.manifest.mf"> + <zipfileset dir="${dest}/net/java/sip/communicator/plugin/loggingutils" + prefix="net/java/sip/communicator/plugin/loggingutils" /> + </jar> + </target> </project> diff --git a/lib/felix.client.run.properties b/lib/felix.client.run.properties index 4cdf662..cd2954e 100644 --- a/lib/felix.client.run.properties +++ b/lib/felix.client.run.properties @@ -131,6 +131,7 @@ felix.auto.start.67= \ reference:file:sc-bundles/facebookaccregwizz.jar \ reference:file:sc-bundles/spellChecker.jar \ reference:file:sc-bundles/advancedconfig.jar \ + reference:file:sc-bundles/plugin-loggingutils.jar \ reference:file:sc-bundles/replacement-youtube.jar \ reference:file:sc-bundles/replacement-dailymotion.jar \ reference:file:sc-bundles/replacement-smiley.jar \ diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index 87f7463..1db20cd 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -1106,12 +1106,15 @@ plugin.provisioning.MANUAL=Manually specify a provisioning URI plugin.provisioning.URI=URI
# packet logging service
-impl.packetlogging.PACKET_LOGGING_CONFIG=Packet Logging
-impl.packetlogging.ENABLE_DISABLE=Enable packet logging
-impl.packetlogging.PACKET_LOGGING_RTP=RTP
-impl.packetlogging.PACKET_LOGGING_RTP_DESCRIPTION=(stores 1 packet out of every 5000)
-impl.packetlogging.PACKET_LOGGING_ICE4J=ice4j.org
-impl.packetlogging.PACKET_LOGGING_DESCRIPTION=<html>Logs debug packets of various protocols in the <br>log folder using pcap format (tcpdump/wireshark).</html>
-impl.packetlogging.PACKET_LOGGING_FILE_COUNT=Number of log files
-impl.packetlogging.PACKET_LOGGING_FILE_SIZE=Maximum file size (in KB)
-
+plugin.loggingutils.PACKET_LOGGING_CONFIG=Logging
+plugin.loggingutils.ENABLE_DISABLE=Enable packet logging
+plugin.loggingutils.PACKET_LOGGING_RTP=RTP
+plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION=(stores 1 packet out of every 5000)
+plugin.loggingutils.PACKET_LOGGING_ICE4J=ice4j.org
+plugin.loggingutils.PACKET_LOGGING_DESCRIPTION=<html>Logs debug packets of various protocols in the <br>log folder using pcap format (tcpdump/wireshark).</html>
+plugin.loggingutils.PACKET_LOGGING_FILE_COUNT=Number of log files
+plugin.loggingutils.PACKET_LOGGING_FILE_SIZE=Maximum file size (in KB)
+plugin.loggingutils.ARCHIVE_BUTTON=Archive Logs
+plugin.loggingutils.UPLOAD_LOGS_BUTTON=Upload Logs
+plugin.loggingutils.ARCHIVE_MESSAGE_OK=Archiving logs successful \n{0}
+plugin.loggingutils.ARCHIVE_MESSAGE_NOTOK=Error archiving logs \n{0}
diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java index cd8c1ed..2be6cdb 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java +++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java @@ -8,19 +8,11 @@ package net.java.sip.communicator.impl.packetlogging; import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.fileaccess.*; -import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.neomedia.*; import net.java.sip.communicator.service.packetlogging.*; -import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.Logger; import org.osgi.framework.*; -import java.util.*; - -import static net.java.sip.communicator.service.protocol.ProtocolProviderFactory.*; - /** * Creates and registers Packet Logging service into OSGi. * Also handles saving and retrieving configuration options for @@ -58,80 +50,9 @@ public class PacketLoggingActivator private static FileAccessService fileAccessService; /** - * The resource service. - */ - private static ResourceManagementService resourceService; - - /** - * Configuration property for packet logging enabled/disabled. - */ - private final static String PACKET_LOGGING_ENABLED_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_ENABLED"; - - /** - * Configuration property for packet logging for - * sip protocol enabled/disabled. - */ - private final static String PACKET_LOGGING_SIP_ENABLED_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_SIP_ENABLED"; - - /** - * Configuration property for packet logging for - * jabber protocol enabled/disabled. - */ - private final static String PACKET_LOGGING_JABBER_ENABLED_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_JABBER_ENABLED"; - - /** - * Configuration property for packet logging for - * RTP enabled/disabled. - */ - private final static String PACKET_LOGGING_RTP_ENABLED_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_RTP_ENABLED"; - - /** - * Configuration property for packet logging for - * ICE4J enabled/disabled. - */ - private final static String PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_ICE4J_ENABLED"; - - /** - * Configuration property for packet logging file count. - */ - final static String PACKET_LOGGING_FILE_COUNT_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_FILE_COUNT"; - - /** - * Configuration property for packet logging file size. - */ - final static String PACKET_LOGGING_FILE_SIZE_PROPERTY_NAME - = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_FILE_SIZE"; - - /** - * Is Packet Logging Service enabled. - */ - private static boolean globalLoggingEnabled = true; - - /** - * Is Packet Logging Service enabled for sip protocol. - */ - private static boolean sipLoggingEnabled = true; - - /** - * Is Packet Logging Service enabled for jabber protocol. + * The name of the log dir. */ - private static boolean jabberLoggingEnabled = true; - - /** - * Is Packet Logging Service enabled for rtp. - */ - private static boolean rtpLoggingEnabled = true; - - /** - * Is Packet Logging Service enabled for ice4j. - */ - private static boolean ice4jLoggingEnabled = true; + final static String LOGGING_DIR_NAME = "log"; /** * Creates a PacketLoggingServiceImpl, starts it, and registers it as a @@ -148,32 +69,13 @@ public class PacketLoggingActivator packetLoggingService = new PacketLoggingServiceImpl(); - getPacketLoggingService().start(); - - loadConfig(); + packetLoggingService.start(); bundleContext.registerService(PacketLoggingService.class.getName(), - getPacketLoggingService(), null); + packetLoggingService, null); if (logger.isInfoEnabled()) logger.info("Packet Logging Service ...[REGISTERED]"); - - // Config Form - Dictionary<String, String> packetLoggingProps - = new Hashtable<String, String>(); - packetLoggingProps.put( - ConfigurationForm.FORM_TYPE, - ConfigurationForm.ADVANCED_TYPE); - bundleContext.registerService( - ConfigurationForm.class.getName(), - new LazyConfigurationForm( - PacketLoggingConfigForm.class.getName(), - getClass().getClassLoader(), - null, - "impl.packetlogging.PACKET_LOGGING_CONFIG", - 1200, - true), - packetLoggingProps); } /** @@ -185,39 +87,14 @@ public class PacketLoggingActivator throws Exception { - if(getPacketLoggingService() != null) - getPacketLoggingService().stop(); + if(packetLoggingService != null) + packetLoggingService.stop(); + if (logger.isInfoEnabled()) logger.info("Packet Logging Service ...[STOPPED]"); } /** - * Reads the configurations and loads them. - */ - private void loadConfig() - { - globalLoggingEnabled = getConfigurationService().getBoolean( - PACKET_LOGGING_ENABLED_PROPERTY_NAME, - globalLoggingEnabled); - - sipLoggingEnabled = getConfigurationService().getBoolean( - PACKET_LOGGING_SIP_ENABLED_PROPERTY_NAME, - sipLoggingEnabled); - - jabberLoggingEnabled = getConfigurationService().getBoolean( - PACKET_LOGGING_JABBER_ENABLED_PROPERTY_NAME, - jabberLoggingEnabled); - - rtpLoggingEnabled = getConfigurationService().getBoolean( - PACKET_LOGGING_RTP_ENABLED_PROPERTY_NAME, - rtpLoggingEnabled); - - ice4jLoggingEnabled = getConfigurationService().getBoolean( - PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME, - ice4jLoggingEnabled); - } - - /** * Returns a reference to a ConfigurationService implementation currently * registered in the bundle context or null if no such implementation was * found. @@ -253,157 +130,4 @@ public class PacketLoggingActivator } return fileAccessService; } - - /** - * Returns the <tt>ResourceManagementService</tt> obtained from the - * bundle context. - * - * @return the <tt>ResourceManagementService</tt> obtained from the - * bundle context - */ - public static ResourceManagementService getResourceService() - { - if (resourceService == null) - { - ServiceReference resourceReference - = bundleContext.getServiceReference( - ResourceManagementService.class.getName()); - - resourceService = - (ResourceManagementService) bundleContext - .getService(resourceReference); - } - - return resourceService; - } - - /** - * Checks whether packet logging is enabled in the configuration. - * @return <tt>true</tt> if packet logging is enabled. - */ - public static boolean isGlobalLoggingEnabled() - { - return globalLoggingEnabled; - } - - /** - * Checks whether packet logging is enabled in the configuration - * for sip protocol. - * @return <tt>true</tt> if packet logging is enabled for sip protocol. - */ - public static boolean isSipLoggingEnabled() - { - return sipLoggingEnabled; - } - - /** - * Checks whether packet logging is enabled in the configuration - * for jabber protocol. - * @return <tt>true</tt> if packet logging is enabled for jabber protocol. - */ - public static boolean isJabberLoggingEnabled() - { - return jabberLoggingEnabled; - } - - /** - * Checks whether packet logging is enabled in the configuration - * for RTP. - * @return <tt>true</tt> if packet logging is enabled for RTP. - */ - public static boolean isRTPLoggingEnabled() - { - return rtpLoggingEnabled; - } - - /** - * Checks whether packet logging is enabled in the configuration - * for Ice4J. - * @return <tt>true</tt> if packet logging is enabled for RTP. - */ - public static boolean isIce4JLoggingEnabled() - { - return ice4jLoggingEnabled; - } - - /** - * Change whether packet logging is enabled and save it in configuration. - * @param enabled <tt>true</tt> if we enable it. - */ - static void setGlobalLoggingEnabled(boolean enabled) - { - getConfigurationService().setProperty( - PACKET_LOGGING_ENABLED_PROPERTY_NAME, enabled); - - if(!enabled) - { - // as we are globally off, set it and to services - sipLoggingEnabled = false; - jabberLoggingEnabled = false; - rtpLoggingEnabled = false; - ice4jLoggingEnabled = false; - } - - globalLoggingEnabled = enabled; - } - - /** - * Change whether packet logging for sip protocol is enabled - * and save it in configuration. - * @param enabled <tt>true</tt> if we enable it. - */ - public static void setSipLoggingEnabled(boolean enabled) - { - getConfigurationService().setProperty( - PACKET_LOGGING_SIP_ENABLED_PROPERTY_NAME, enabled); - - sipLoggingEnabled = enabled; - } - - /** - * Change whether packet logging for jabber protocol is enabled - * and save it in configuration. - * @param enabled <tt>true</tt> if we enable it. - */ - public static void setJabberLoggingEnabled(boolean enabled) - { - getConfigurationService().setProperty( - PACKET_LOGGING_JABBER_ENABLED_PROPERTY_NAME, enabled); - - jabberLoggingEnabled = enabled; - } - - /** - * Change whether packet logging for RTP is enabled - * and save it in configuration. - * @param enabled <tt>true</tt> if we enable it. - */ - public static void setRTPLoggingEnabled(boolean enabled) - { - getConfigurationService().setProperty( - PACKET_LOGGING_RTP_ENABLED_PROPERTY_NAME, enabled); - - rtpLoggingEnabled = true; - } - - /** - * Change whether packet logging for Ice4J is enabled - * and save it in configuration. - * @param enabled <tt>true</tt> if we enable it. - */ - public static void setIce4JLoggingEnabled(boolean enabled) - { - getConfigurationService().setProperty( - PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME, enabled); - - ice4jLoggingEnabled = true; - } - - /** - * Our packet logging service instance. - */ - public static PacketLoggingServiceImpl getPacketLoggingService() - { - return packetLoggingService; - } } diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigForm.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigForm.java deleted file mode 100644 index 342c55f..0000000 --- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigForm.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.packetlogging; - -import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.swing.*; - -import javax.swing.*; -import javax.swing.event.*; -import java.awt.*; -import java.awt.event.*; - -/** - * The Packet Logging Service configuration form. - * @author Damian Minkov - */ -public class PacketLoggingConfigForm - extends TransparentPanel - implements ActionListener, - DocumentListener -{ - /** - * The enable packet logging check box. - */ - private JCheckBox enableCheckBox; - - /** - * Check box to enable/disable packet debug of sip protocol. - */ - private JCheckBox sipProtocolCheckBox; - - /** - * Check box to enable/disable packet debug of jabber protocol. - */ - private JCheckBox jabberProtocolCheckBox; - - /** - * Check box to enable/disable packet debug of media protocol/RTP. - */ - private JCheckBox rtpProtocolCheckBox; - - /** - * Check box to enable/disable packet debug of Ice4J. - */ - private JCheckBox ice4jProtocolCheckBox; - - /** - * The file count label. - */ - private JLabel fileCountLabel; - - /** - * The filed for file count value. - */ - private JTextField fileCountField = new JTextField(); - - /** - * The file size label. - */ - private JLabel fileSizeLabel; - - /** - * The filed for file size value. - */ - private JTextField fileSizeField = new JTextField(); - - - /** - * Creates Packet Logging Config form. - */ - public PacketLoggingConfigForm() - { - super(new BorderLayout()); - - init(); - loadValues(); - } - - /** - * Creating the configuration form - */ - private void init() - { - ResourceManagementService resources = - PacketLoggingActivator.getResourceService(); - - enableCheckBox = new SIPCommCheckBox( - resources.getI18NString("impl.packetlogging.ENABLE_DISABLE")); - enableCheckBox.addActionListener(this); - - sipProtocolCheckBox = new SIPCommCheckBox( - resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME")); - sipProtocolCheckBox.addActionListener(this); - - jabberProtocolCheckBox = new SIPCommCheckBox( - resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME")); - jabberProtocolCheckBox.addActionListener(this); - - String rtpDescription = resources.getI18NString( - "impl.packetlogging.PACKET_LOGGING_RTP_DESCRIPTION"); - rtpProtocolCheckBox = new SIPCommCheckBox( - resources.getI18NString("impl.packetlogging.PACKET_LOGGING_RTP") - + " " + rtpDescription); - rtpProtocolCheckBox.addActionListener(this); - rtpProtocolCheckBox.setToolTipText(rtpDescription); - - ice4jProtocolCheckBox = new SIPCommCheckBox( - resources.getI18NString("impl.packetlogging.PACKET_LOGGING_ICE4J")); - ice4jProtocolCheckBox.addActionListener(this); - - JPanel mainPanel = new TransparentPanel(); - - add(mainPanel, BorderLayout.NORTH); - - mainPanel.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - - enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); - - c.fill = GridBagConstraints.HORIZONTAL; - c.weightx = 1.0; - c.gridx = 0; - c.gridy = 0; - mainPanel.add(enableCheckBox, c); - - String label = resources.getI18NString( - "impl.packetlogging.PACKET_LOGGING_DESCRIPTION"); - JLabel descriptionLabel = new JLabel(label); - descriptionLabel.setToolTipText(label); - enableCheckBox.setToolTipText(label); - descriptionLabel.setForeground(Color.GRAY); - descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8)); - c.gridy = 1; - c.insets = new Insets(0, 25, 10, 0); - mainPanel.add(descriptionLabel, c); - - final JPanel loggersButtonPanel - = new TransparentPanel(new GridLayout(0, 1)); - - loggersButtonPanel.setBorder(BorderFactory.createTitledBorder( - resources.getI18NString("service.gui.PROTOCOL"))); - - loggersButtonPanel.add(sipProtocolCheckBox); - loggersButtonPanel.add(jabberProtocolCheckBox); - loggersButtonPanel.add(rtpProtocolCheckBox); - loggersButtonPanel.add(ice4jProtocolCheckBox); - - c.insets = new Insets(0, 20, 10, 0); - c.gridy = 2; - mainPanel.add(loggersButtonPanel, c); - - final JPanel advancedPanel - = new TransparentPanel(new GridLayout(0, 2)); - - advancedPanel.setBorder(BorderFactory.createTitledBorder( - resources.getI18NString("service.gui.ADVANCED"))); - - fileCountField.getDocument().addDocumentListener(this); - fileSizeField.getDocument().addDocumentListener(this); - - fileCountLabel = new JLabel(resources.getI18NString( - "impl.packetlogging.PACKET_LOGGING_FILE_COUNT")); - advancedPanel.add(fileCountLabel); - advancedPanel.add(fileCountField); - fileSizeLabel = new JLabel(resources.getI18NString( - "impl.packetlogging.PACKET_LOGGING_FILE_SIZE")); - advancedPanel.add(fileSizeLabel); - advancedPanel.add(fileSizeField); - - c.gridy = 3; - mainPanel.add(advancedPanel, c); - - } - - /** - * Loading the values stored into configuration form - */ - private void loadValues() - { - enableCheckBox.setSelected( - PacketLoggingActivator.isGlobalLoggingEnabled()); - sipProtocolCheckBox.setSelected( - PacketLoggingActivator.isSipLoggingEnabled()); - jabberProtocolCheckBox.setSelected( - PacketLoggingActivator.isJabberLoggingEnabled()); - rtpProtocolCheckBox.setSelected( - PacketLoggingActivator.isRTPLoggingEnabled()); - ice4jProtocolCheckBox.setSelected( - PacketLoggingActivator.isIce4JLoggingEnabled()); - fileCountField.setText(String.valueOf(PacketLoggingActivator - .getPacketLoggingService().getLogfileCount())); - fileSizeField.setText(String.valueOf(PacketLoggingActivator - .getPacketLoggingService().getLimit()/1000)); - - updateButtonsState(); - } - - /** - * Update button enable/disable state according enableCheckBox. - */ - private void updateButtonsState() - { - sipProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); - jabberProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); - rtpProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); - ice4jProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); - fileCountField.setEnabled(enableCheckBox.isSelected()); - fileSizeField.setEnabled(enableCheckBox.isSelected()); - fileSizeLabel.setEnabled(enableCheckBox.isSelected()); - fileCountLabel.setEnabled(enableCheckBox.isSelected()); - } - - /** - * Invoked when an action occurs. - */ - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - - if(source.equals(enableCheckBox)) - { - // turn it on/off in activator - PacketLoggingActivator.setGlobalLoggingEnabled( - enableCheckBox.isSelected()); - updateButtonsState(); - } - else if(source.equals(sipProtocolCheckBox)) - { - PacketLoggingActivator.setSipLoggingEnabled( - sipProtocolCheckBox.isSelected()); - } - else if(source.equals(jabberProtocolCheckBox)) - { - PacketLoggingActivator.setJabberLoggingEnabled( - jabberProtocolCheckBox.isSelected()); - } - else if(source.equals(rtpProtocolCheckBox)) - { - PacketLoggingActivator.setRTPLoggingEnabled( - rtpProtocolCheckBox.isSelected()); - } - else if(source.equals(ice4jProtocolCheckBox)) - { - PacketLoggingActivator.setIce4JLoggingEnabled( - ice4jProtocolCheckBox.isSelected()); - } - } - - /** - * Gives notification that there was an insert into the document. The - * range given by the DocumentEvent bounds the freshly inserted region. - * - * @param e the document event - */ - public void insertUpdate(DocumentEvent e) - { - documentChanged(e); - } - - /** - * Gives notification that a portion of the document has been - * removed. The range is given in terms of what the view last - * saw (that is, before updating sticky positions). - * - * @param e the document event - */ - public void removeUpdate(DocumentEvent e) - { - documentChanged(e); - } - - /** - * Not used. - * - * @param e the document event - */ - public void changedUpdate(DocumentEvent e) - {} - - /** - * A change in the text fields. - * @param e the document event. - */ - private void documentChanged(DocumentEvent e) - { - if(e.getDocument().equals(fileCountField.getDocument())) - { - // set file count only if its un integer - try - { - int newFileCount = Integer.valueOf(fileCountField.getText()); - fileCountField.setForeground(Color.black); - PacketLoggingActivator.getPacketLoggingService() - .setLogfileCount(newFileCount); - } - catch(Throwable t) - { - fileCountField.setForeground(Color.red); - } - } - else if(e.getDocument().equals(fileSizeField.getDocument())) - { - // set file size only if its un integer - try - { - int newFileSize = Integer.valueOf(fileSizeField.getText()); - fileSizeField.setForeground(Color.black); - PacketLoggingActivator.getPacketLoggingService() - .setLimit(newFileSize * 1000); - } - catch(Throwable t) - { - fileSizeField.setForeground(Color.red); - } - } - } -} diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java new file mode 100644 index 0000000..be2b2ab --- /dev/null +++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingConfigurationImpl.java @@ -0,0 +1,155 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.impl.packetlogging; + +import net.java.sip.communicator.service.configuration.*; +import net.java.sip.communicator.service.packetlogging.*; + +/** + * Extends PacketLoggingConfiguration by storing and loading values from + * configuration service. + * + * @author Damian Minkov + */ +public class PacketLoggingConfigurationImpl + extends PacketLoggingConfiguration +{ + /** + * Creates new PacketLoggingConfiguration and load values from + * configuration service and if missing uses already defined + * default values. + */ + PacketLoggingConfigurationImpl() + { + // load values from config service + ConfigurationService configService = + PacketLoggingActivator.getConfigurationService(); + + super.setGlobalLoggingEnabled( + configService.getBoolean( + PACKET_LOGGING_ENABLED_PROPERTY_NAME, + isGlobalLoggingEnabled())); + super.setSipLoggingEnabled( + configService.getBoolean( + PACKET_LOGGING_SIP_ENABLED_PROPERTY_NAME, + isSipLoggingEnabled())); + super.setJabberLoggingEnabled( + configService.getBoolean( + PACKET_LOGGING_JABBER_ENABLED_PROPERTY_NAME, + isJabberLoggingEnabled())); + super.setRTPLoggingEnabled( + configService.getBoolean( + PACKET_LOGGING_RTP_ENABLED_PROPERTY_NAME, + isRTPLoggingEnabled())); + super.setIce4JLoggingEnabled( + configService.getBoolean( + PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME, + isIce4JLoggingEnabled())); + super.setLimit( + configService.getLong( + PACKET_LOGGING_FILE_SIZE_PROPERTY_NAME, + getLimit())); + super.setLogfileCount( + configService.getInt( + PACKET_LOGGING_FILE_COUNT_PROPERTY_NAME, + getLogfileCount())); + } + + /** + * Change whether packet logging is enabled and save it in configuration. + * @param enabled <tt>true</tt> if we enable it. + */ + public void setGlobalLoggingEnabled(boolean enabled) + { + super.setGlobalLoggingEnabled(enabled); + + PacketLoggingActivator.getConfigurationService().setProperty( + PACKET_LOGGING_ENABLED_PROPERTY_NAME, enabled); + } + + /** + * Change whether packet logging for sip protocol is enabled + * and save it in configuration. + * @param enabled <tt>true</tt> if we enable it. + */ + public void setSipLoggingEnabled(boolean enabled) + { + super.setSipLoggingEnabled(enabled); + + PacketLoggingActivator.getConfigurationService().setProperty( + PACKET_LOGGING_SIP_ENABLED_PROPERTY_NAME, + enabled); + } + + /** + * Change whether packet logging for jabber protocol is enabled + * and save it in configuration. + * @param enabled <tt>true</tt> if we enable it. + */ + public void setJabberLoggingEnabled(boolean enabled) + { + super.setJabberLoggingEnabled(enabled); + + PacketLoggingActivator.getConfigurationService().setProperty( + PACKET_LOGGING_JABBER_ENABLED_PROPERTY_NAME, + enabled); + } + + /** + * Change whether packet logging for RTP is enabled + * and save it in configuration. + * @param enabled <tt>true</tt> if we enable it. + */ + public void setRTPLoggingEnabled(boolean enabled) + { + super.setRTPLoggingEnabled(enabled); + + PacketLoggingActivator.getConfigurationService().setProperty( + PACKET_LOGGING_RTP_ENABLED_PROPERTY_NAME, + enabled); + } + + /** + * Change whether packet logging for Ice4J is enabled + * and save it in configuration. + * @param enabled <tt>true</tt> if we enable it. + */ + public void setIce4JLoggingEnabled(boolean enabled) + { + super.setIce4JLoggingEnabled(enabled); + + PacketLoggingActivator.getConfigurationService().setProperty( + PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME, + enabled); + } + + /** + * Changes the file size limit. + * @param limit the new limit size. + */ + public void setLimit(long limit) + { + super.setLimit(limit); + + PacketLoggingActivator.getConfigurationService().setProperty( + PACKET_LOGGING_FILE_SIZE_PROPERTY_NAME, + limit); + } + + /** + * Changes file count. + * @param logfileCount the new file count. + */ + public void setLogfileCount(int logfileCount) + { + super.setLogfileCount(logfileCount); + + PacketLoggingActivator.getConfigurationService().setProperty( + PACKET_LOGGING_FILE_COUNT_PROPERTY_NAME, + logfileCount); + } +} diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java index e1905b4..d0615bf 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java +++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java @@ -38,6 +38,11 @@ public class PacketLoggingServiceImpl private SaverThread saverThread = new SaverThread(); /** + * The current configuration. + */ + private PacketLoggingConfiguration packetLoggingConfiguration = null; + + /** * The fake ethernet header we use as template. */ private final static byte[] fakeEthernetHeader = @@ -133,17 +138,6 @@ public class PacketLoggingServiceImpl private long written = 0; /** - * The limit for the file size. - * 0 means no limit. - */ - private long limit = 5000000; - - /** - * The counter for number of files. - */ - private int logfileCount = 3; - - /** * All the files we can use for writing. */ private File[] files; @@ -154,14 +148,6 @@ public class PacketLoggingServiceImpl */ public void start() { - limit = PacketLoggingActivator.getConfigurationService().getLong( - PacketLoggingActivator.PACKET_LOGGING_FILE_SIZE_PROPERTY_NAME, - limit); - - logfileCount = PacketLoggingActivator.getConfigurationService().getInt( - PacketLoggingActivator.PACKET_LOGGING_FILE_COUNT_PROPERTY_NAME, - logfileCount); - saverThread.start(); } @@ -172,11 +158,13 @@ public class PacketLoggingServiceImpl private void getFileNames() throws Exception { - files = new File[getLogfileCount()]; - for(int i = 0; i < getLogfileCount(); i++) + files = new File[getConfiguration().getLogfileCount()]; + for(int i = 0; i < getConfiguration().getLogfileCount(); i++) { files[i] = PacketLoggingActivator.getFileAccessService() - .getPrivatePersistentFile("log/sip-communicator" + i + ".pcap"); + .getPrivatePersistentFile( + PacketLoggingActivator.LOGGING_DIR_NAME + + File.separator + "sip-communicator" + i + ".pcap"); } } @@ -194,7 +182,7 @@ public class PacketLoggingServiceImpl outputStream.close(); } - for (int i = getLogfileCount() -2; i >= 0; i--) + for (int i = getConfiguration().getLogfileCount() -2; i >= 0; i--) { File f1 = files[i]; File f2 = files[i+1]; @@ -288,7 +276,7 @@ public class PacketLoggingServiceImpl */ public boolean isLoggingEnabled() { - return PacketLoggingActivator.isGlobalLoggingEnabled(); + return getConfiguration().isGlobalLoggingEnabled(); } /** @@ -303,17 +291,17 @@ public class PacketLoggingServiceImpl switch(protocol) { case SIP: - return PacketLoggingActivator.isGlobalLoggingEnabled() - && PacketLoggingActivator.isSipLoggingEnabled(); + return getConfiguration().isGlobalLoggingEnabled() + && getConfiguration().isSipLoggingEnabled(); case JABBER: - return PacketLoggingActivator.isGlobalLoggingEnabled() - && PacketLoggingActivator.isJabberLoggingEnabled(); + return getConfiguration().isGlobalLoggingEnabled() + && getConfiguration().isJabberLoggingEnabled(); case RTP: - return PacketLoggingActivator.isGlobalLoggingEnabled() - && PacketLoggingActivator.isRTPLoggingEnabled(); + return getConfiguration().isGlobalLoggingEnabled() + && getConfiguration().isRTPLoggingEnabled(); case ICE4J: - return PacketLoggingActivator.isGlobalLoggingEnabled() - && PacketLoggingActivator.isIce4JLoggingEnabled(); + return getConfiguration().isGlobalLoggingEnabled() + && getConfiguration().isIce4JLoggingEnabled(); default: return false; } @@ -385,6 +373,19 @@ public class PacketLoggingServiceImpl } /** + * Returns the current Packet Logging Configuration. + * + * @return the Packet Logging Configuration. + */ + public PacketLoggingConfiguration getConfiguration() + { + if(packetLoggingConfiguration == null) + packetLoggingConfiguration = new PacketLoggingConfigurationImpl(); + + return packetLoggingConfiguration; + } + + /** * Dump the packet to the output file stream. * * @param packet the packet ot save. @@ -537,7 +538,8 @@ public class PacketLoggingServiceImpl rotateFiles();// this one opens the file for write } - if(getLimit() > 0 && written > getLimit()) + if(getConfiguration().getLimit() > 0 + && written > getConfiguration().getLimit()) rotateFiles(); addInt(tsSec); @@ -628,50 +630,6 @@ public class PacketLoggingServiceImpl } /** - * The limit for the file size. 0 means no limit. - * @return the file size limit. - */ - public long getLimit() - { - return limit; - } - - /** - * Changes the file size limit. - * @param limit the new limit size. - */ - public void setLimit(long limit) - { - this.limit = limit; - - PacketLoggingActivator.getConfigurationService().setProperty( - PacketLoggingActivator.PACKET_LOGGING_FILE_SIZE_PROPERTY_NAME, - limit); - } - - /** - * The counter for number of files. - * @return the number of file counts. - */ - public int getLogfileCount() - { - return logfileCount; - } - - /** - * Changes file count. - * @param logfileCount the new file count. - */ - public void setLogfileCount(int logfileCount) - { - this.logfileCount = logfileCount; - - PacketLoggingActivator.getConfigurationService().setProperty( - PacketLoggingActivator.PACKET_LOGGING_FILE_COUNT_PROPERTY_NAME, - logfileCount); - } - - /** * The data we receive and that we will dump in a file. */ private class Packet diff --git a/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf b/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf index 593c203..7cdd3b7 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf +++ b/src/net/java/sip/communicator/impl/packetlogging/packetlogging.manifest.mf @@ -10,7 +10,6 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.gui, net.java.sip.communicator.service.neomedia, net.java.sip.communicator.service.protocol, - net.java.sip.communicator.service.resources, net.java.sip.communicator.util, net.java.sip.communicator.util.swing, javax.swing, diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/debugger/SmackPacketDebugger.java b/src/net/java/sip/communicator/impl/protocol/jabber/debugger/SmackPacketDebugger.java index 1694cb4..e3747d0 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/debugger/SmackPacketDebugger.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/debugger/SmackPacketDebugger.java @@ -8,6 +8,7 @@ package net.java.sip.communicator.impl.protocol.jabber.debugger; import net.java.sip.communicator.impl.protocol.jabber.*; import net.java.sip.communicator.service.packetlogging.*; +import net.java.sip.communicator.util.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.packet.*; @@ -60,7 +61,21 @@ public class SmackPacketDebugger try { - remoteAddress = InetAddress.getByName(connection.getHost()).getAddress(); + InetSocketAddress inetAddress; + + if(Boolean.getBoolean("java.net.preferIPv6Addresses")) + { + inetAddress = NetworkUtils.getAAAARecord( + connection.getHost(), 0); + } + else + { + inetAddress = NetworkUtils.getARecord( + connection.getHost(), 0); + } + + if(inetAddress != null) + remoteAddress = inetAddress.getAddress().getAddress(); // to create empty ipv6 address default is ipv4 if(remoteAddress.length != localAddress.length) diff --git a/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java b/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java new file mode 100644 index 0000000..6241f36 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java @@ -0,0 +1,616 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. See terms of license at gnu.org. + */ +package net.java.sip.communicator.plugin.loggingutils; + +import com.sun.jndi.toolkit.url.*; +import net.java.sip.communicator.service.certificate.*; +import net.java.sip.communicator.service.notification.*; +import net.java.sip.communicator.service.packetlogging.*; +import net.java.sip.communicator.service.resources.*; +import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.swing.*; + +import javax.net.ssl.*; +import javax.swing.*; +import javax.swing.event.*; +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.net.*; +import java.util.*; + +/** + * The Logging configuration form. + * @author Damian Minkov + */ +public class LoggingConfigForm + extends TransparentPanel + implements ActionListener, + DocumentListener +{ + /** + * Our Logger. + */ + private static final Logger logger + = Logger.getLogger(LoggingConfigForm.class); + + /** + * The enable packet logging check box. + */ + private JCheckBox enableCheckBox; + + /** + * Check box to enable/disable packet debug of sip protocol. + */ + private JCheckBox sipProtocolCheckBox; + + /** + * Check box to enable/disable packet debug of jabber protocol. + */ + private JCheckBox jabberProtocolCheckBox; + + /** + * Check box to enable/disable packet debug of media protocol/RTP. + */ + private JCheckBox rtpProtocolCheckBox; + + /** + * Check box to enable/disable packet debug of Ice4J. + */ + private JCheckBox ice4jProtocolCheckBox; + + /** + * The file count label. + */ + private JLabel fileCountLabel; + + /** + * The filed for file count value. + */ + private JTextField fileCountField = new JTextField(); + + /** + * The file size label. + */ + private JLabel fileSizeLabel; + + /** + * The filed for file size value. + */ + private JTextField fileSizeField = new JTextField(); + + /** + * Notification event. + */ + private static final String LOGFILES_ARCHIVED = "LogFilesArchived"; + + /** + * Archive logs button. + */ + private SIPCommTextButton archiveButton; + + /** + * Archive logs button. + */ + private SIPCommTextButton uploadLogsButton; + + /** + * Creates Packet Logging Config form. + */ + public LoggingConfigForm() + { + super(new BorderLayout()); + + init(); + loadValues(); + + // Register notification for saved calls. + if(LoggingUtilsActivator.getNotificationService() != null) + LoggingUtilsActivator.getNotificationService() + .registerDefaultNotificationForEvent( + LOGFILES_ARCHIVED, + NotificationService.ACTION_POPUP_MESSAGE, + null, + null); + } + + /** + * Creating the configuration form + */ + private void init() + { + ResourceManagementService resources = + LoggingUtilsActivator.getResourceService(); + + enableCheckBox = new SIPCommCheckBox( + resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE")); + enableCheckBox.addActionListener(this); + + sipProtocolCheckBox = new SIPCommCheckBox( + resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME")); + sipProtocolCheckBox.addActionListener(this); + + jabberProtocolCheckBox = new SIPCommCheckBox( + resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME")); + jabberProtocolCheckBox.addActionListener(this); + + String rtpDescription = resources.getI18NString( + "plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION"); + rtpProtocolCheckBox = new SIPCommCheckBox( + resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP") + + " " + rtpDescription); + rtpProtocolCheckBox.addActionListener(this); + rtpProtocolCheckBox.setToolTipText(rtpDescription); + + ice4jProtocolCheckBox = new SIPCommCheckBox( + resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J")); + ice4jProtocolCheckBox.addActionListener(this); + + JPanel mainPanel = new TransparentPanel(); + + add(mainPanel, BorderLayout.NORTH); + + mainPanel.setLayout(new GridBagLayout()); + + GridBagConstraints c = new GridBagConstraints(); + + enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); + + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1.0; + c.gridx = 0; + c.gridy = 0; + mainPanel.add(enableCheckBox, c); + + String label = resources.getI18NString( + "plugin.loggingutils.PACKET_LOGGING_DESCRIPTION"); + JLabel descriptionLabel = new JLabel(label); + descriptionLabel.setToolTipText(label); + enableCheckBox.setToolTipText(label); + descriptionLabel.setForeground(Color.GRAY); + descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8)); + c.gridy = 1; + c.insets = new Insets(0, 25, 10, 0); + mainPanel.add(descriptionLabel, c); + + final JPanel loggersButtonPanel + = new TransparentPanel(new GridLayout(0, 1)); + + loggersButtonPanel.setBorder(BorderFactory.createTitledBorder( + resources.getI18NString("service.gui.PROTOCOL"))); + + loggersButtonPanel.add(sipProtocolCheckBox); + loggersButtonPanel.add(jabberProtocolCheckBox); + loggersButtonPanel.add(rtpProtocolCheckBox); + loggersButtonPanel.add(ice4jProtocolCheckBox); + + c.insets = new Insets(0, 20, 10, 0); + c.gridy = 2; + mainPanel.add(loggersButtonPanel, c); + + final JPanel advancedPanel + = new TransparentPanel(new GridLayout(0, 2)); + + advancedPanel.setBorder(BorderFactory.createTitledBorder( + resources.getI18NString("service.gui.ADVANCED"))); + + fileCountField.getDocument().addDocumentListener(this); + fileSizeField.getDocument().addDocumentListener(this); + + fileCountLabel = new JLabel(resources.getI18NString( + "plugin.loggingutils.PACKET_LOGGING_FILE_COUNT")); + advancedPanel.add(fileCountLabel); + advancedPanel.add(fileCountField); + fileSizeLabel = new JLabel(resources.getI18NString( + "plugin.loggingutils.PACKET_LOGGING_FILE_SIZE")); + advancedPanel.add(fileSizeLabel); + advancedPanel.add(fileSizeField); + + c.gridy = 3; + mainPanel.add(advancedPanel, c); + + archiveButton = new SIPCommTextButton( + resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON")); + archiveButton.addActionListener(this); + + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.LINE_START; + c.weightx = 0; + c.gridx = 0; + c.gridy = 4; + mainPanel.add(archiveButton, c); + + String uploadLocation = + LoggingUtilsActivator.getResourceService() + .getSettingsString("plugin.loggingutils.uploadlocation"); + + if(!StringUtils.isNullOrEmpty(uploadLocation)) + { + uploadLogsButton = new SIPCommTextButton( + resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON")); + uploadLogsButton.addActionListener(this); + + c.insets = new Insets(10, 0, 0, 0); + c.gridy = 5; + mainPanel.add(uploadLogsButton, c); + } + } + + /** + * Loading the values stored into configuration form + */ + private void loadValues() + { + PacketLoggingService packetLogging = + LoggingUtilsActivator.getPacketLoggingService(); + + enableCheckBox.setSelected( + packetLogging.getConfiguration().isGlobalLoggingEnabled()); + + sipProtocolCheckBox.setSelected( + packetLogging.getConfiguration().isSipLoggingEnabled()); + jabberProtocolCheckBox.setSelected( + packetLogging.getConfiguration().isJabberLoggingEnabled()); + rtpProtocolCheckBox.setSelected( + packetLogging.getConfiguration().isRTPLoggingEnabled()); + ice4jProtocolCheckBox.setSelected( + packetLogging.getConfiguration().isIce4JLoggingEnabled()); + fileCountField.setText(String.valueOf( + packetLogging.getConfiguration().getLogfileCount())); + fileSizeField.setText(String.valueOf( + packetLogging.getConfiguration().getLimit()/1000)); + + updateButtonsState(); + } + + /** + * Update button enable/disable state according enableCheckBox. + */ + private void updateButtonsState() + { + sipProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); + jabberProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); + rtpProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); + ice4jProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); + fileCountField.setEnabled(enableCheckBox.isSelected()); + fileSizeField.setEnabled(enableCheckBox.isSelected()); + fileSizeLabel.setEnabled(enableCheckBox.isSelected()); + fileCountLabel.setEnabled(enableCheckBox.isSelected()); + } + + /** + * Invoked when an action occurs. + */ + public void actionPerformed(ActionEvent e) + { + Object source = e.getSource(); + + PacketLoggingService packetLogging = + LoggingUtilsActivator.getPacketLoggingService(); + + if(source.equals(enableCheckBox)) + { + // turn it on/off in activator + packetLogging.getConfiguration().setGlobalLoggingEnabled( + enableCheckBox.isSelected()); + updateButtonsState(); + } + else if(source.equals(sipProtocolCheckBox)) + { + packetLogging.getConfiguration().setSipLoggingEnabled( + sipProtocolCheckBox.isSelected()); + } + else if(source.equals(jabberProtocolCheckBox)) + { + packetLogging.getConfiguration().setJabberLoggingEnabled( + jabberProtocolCheckBox.isSelected()); + } + else if(source.equals(rtpProtocolCheckBox)) + { + packetLogging.getConfiguration().setRTPLoggingEnabled( + rtpProtocolCheckBox.isSelected()); + } + else if(source.equals(ice4jProtocolCheckBox)) + { + packetLogging.getConfiguration().setIce4JLoggingEnabled( + ice4jProtocolCheckBox.isSelected()); + } + else if(source.equals(archiveButton)) + { + collectLogs(); + } + else if(source.equals(uploadLogsButton)) + { + new Thread(new Runnable() + { + public void run() + { + uploadLogs(); + } + }).start(); + + } + } + + /** + * Gives notification that there was an insert into the document. The + * range given by the DocumentEvent bounds the freshly inserted region. + * + * @param e the document event + */ + public void insertUpdate(DocumentEvent e) + { + documentChanged(e); + } + + /** + * Gives notification that a portion of the document has been + * removed. The range is given in terms of what the view last + * saw (that is, before updating sticky positions). + * + * @param e the document event + */ + public void removeUpdate(DocumentEvent e) + { + documentChanged(e); + } + + /** + * Not used. + * + * @param e the document event + */ + public void changedUpdate(DocumentEvent e) + {} + + /** + * A change in the text fields. + * @param e the document event. + */ + private void documentChanged(DocumentEvent e) + { + if(e.getDocument().equals(fileCountField.getDocument())) + { + // set file count only if its un integer + try + { + int newFileCount = Integer.valueOf(fileCountField.getText()); + fileCountField.setForeground(Color.black); + LoggingUtilsActivator.getPacketLoggingService() + .getConfiguration().setLogfileCount(newFileCount); + } + catch(Throwable t) + { + fileCountField.setForeground(Color.red); + } + } + else if(e.getDocument().equals(fileSizeField.getDocument())) + { + // set file size only if its un integer + try + { + int newFileSize = Integer.valueOf(fileSizeField.getText()); + fileSizeField.setForeground(Color.black); + LoggingUtilsActivator.getPacketLoggingService() + .getConfiguration().setLimit(newFileSize * 1000); + } + catch(Throwable t) + { + fileSizeField.setForeground(Color.red); + } + } + } + + /** + * Asks user for a location to save logs by poping up a file chooser. + * and archiving logs and saving them on the specified location. + */ + private void collectLogs() + { + ResourceManagementService resources = + LoggingUtilsActivator.getResourceService(); + + SipCommFileChooser fileChooser = GenericFileDialog.create( + null, + resources.getI18NString( + "plugin.callrecordingconfig.CHOOSE_DIR"), + SipCommFileChooser.LOAD_FILE_OPERATION); + fileChooser.setSelectionMode( + SipCommFileChooser.SAVE_FILE_OPERATION); + + String defaultDir = ""; + try + { + defaultDir = LoggingUtilsActivator.getFileAccessService() + .getDefaultDownloadDirectory().getAbsolutePath() + + File.separator; + } + catch(IOException ex){} + fileChooser.setStartPath( + defaultDir + LogsCollector.getDefaultFileName()); + + File dest = fileChooser.getFileFromDialog(); + + if(dest == null) + return; + + dest = LogsCollector.collectLogs(dest); + + NotificationService notificationService + = LoggingUtilsActivator.getNotificationService(); + + if(notificationService != null) + { + String bodyMsgKey = null; + + if(dest != null) + bodyMsgKey = "plugin.loggingutils.ARCHIVE_MESSAGE_OK"; + else + bodyMsgKey = "plugin.loggingutils.ARCHIVE_MESSAGE_NOTOK"; + + notificationService.fireNotification( + LOGFILES_ARCHIVED, + resources.getI18NString( + "plugin.loggingutils.ARCHIVE_BUTTON"), + resources.getI18NString( + bodyMsgKey, + new String[]{dest.getAbsolutePath()}), + null, + null); + } + } + + /** + * Upload files to pre-configured url. + */ + private void uploadLogs() + { + try + { + File tempDir = LoggingUtilsActivator.getFileAccessService() + .getTemporaryDirectory(); + File newDest = new File( + tempDir, LogsCollector.getDefaultFileName()); + + newDest = LogsCollector.collectLogs(newDest); + + String uploadLocation = + LoggingUtilsActivator.getResourceService() + .getSettingsString("plugin.loggingutils.uploadlocation"); + + if(uploadLocation == null) + return; + + URL url = new URL(uploadLocation); + URLConnection urlConn = url.openConnection(); + + if (!(urlConn instanceof HttpURLConnection)) + return; + + HttpURLConnection conn = (HttpURLConnection)urlConn; + + if(urlConn instanceof HttpsURLConnection) + { + CertificateVerificationService vs = + LoggingUtilsActivator.getCertificateVerificationService(); + + int port = url.getPort(); + + /* if we do not specify port in the URL + * (http://domain.org:port) we have to set up the default + * port of HTTP (80) or + * HTTPS (443). + */ + if(port == -1) + { + if(url.getProtocol().equals("http")) + { + port = 80; + } + else if(url.getProtocol().equals("https")) + { + port = 443; + } + } + + ((HttpsURLConnection)urlConn).setSSLSocketFactory( + vs.getSSLContext( + url.getHost(), port).getSocketFactory()); + } + + Random random = new Random(); + + String boundary = "---------------------------" + + Long.toString(random.nextLong(), 36) + + Long.toString(random.nextLong(), 36) + + Long.toString(random.nextLong(), 36); + conn.setDoOutput(true); + conn.setRequestProperty("Content-Type", + "multipart/form-data; boundary=" + boundary); + + OutputStream out = conn.getOutputStream(); + + out.write("--".getBytes()); + out.write(boundary.getBytes()); + + out.write("\r\n".getBytes()); + out.write("Content-Disposition: form-data; name=\"".getBytes()); + out.write("logs".getBytes()); + out.write('"'); + + out.write("; filename=\"".getBytes()); + out.write(newDest.getPath().getBytes()); + out.write('"'); + + out.write("\r\n".getBytes()); + out.write("Content-Type: ".getBytes()); + String type = conn.guessContentTypeFromName(newDest.getPath()); + if (type == null) + type = "application/octet-stream"; + out.write(type.getBytes()); + out.write("\r\n".getBytes()); + out.write("\r\n".getBytes()); + + byte[] buf = new byte[4096]; + int nread; + FileInputStream in = new FileInputStream(newDest); + while((nread = in.read(buf, 0, buf.length)) >= 0) + { + out.write(buf, 0, nread); + } + out.flush(); + buf = null; + out.write("\r\n".getBytes()); + + out.write("--".getBytes()); + out.write(boundary.getBytes()); + out.write("--".getBytes()); + out.write("\r\n".getBytes()); + out.close(); + InputStream serverInput = conn.getInputStream(); + + // Get response data. + BufferedReader input = + new BufferedReader(new InputStreamReader(serverInput)); + + if(logger.isDebugEnabled()) + { + logger.debug("Log files uploaded result:"); + String str; + while((str = input.readLine()) != null) + { + logger.debug(str); + } + } + input.close (); + + NotificationService notificationService + = LoggingUtilsActivator.getNotificationService(); + + if(notificationService != null) + { + String bodyMsgKey = "plugin.loggingutils.ARCHIVE_MESSAGE_OK"; + + ResourceManagementService resources = + LoggingUtilsActivator.getResourceService(); + + notificationService.fireNotification( + LOGFILES_ARCHIVED, + resources.getI18NString( + "plugin.loggingutils.ARCHIVE_BUTTON"), + resources.getI18NString( + bodyMsgKey, + new String[]{uploadLocation}), + null, + null); + } + } + catch(Throwable e) + { + logger.error("Cannot upload file", e); + } + } +} diff --git a/src/net/java/sip/communicator/plugin/loggingutils/LoggingUtilsActivator.java b/src/net/java/sip/communicator/plugin/loggingutils/LoggingUtilsActivator.java new file mode 100644 index 0000000..f7e0ef5 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/loggingutils/LoggingUtilsActivator.java @@ -0,0 +1,228 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.plugin.loggingutils; + +import net.java.sip.communicator.service.certificate.*; +import net.java.sip.communicator.service.configuration.*; +import net.java.sip.communicator.service.fileaccess.*; +import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.notification.*; +import net.java.sip.communicator.service.packetlogging.*; +import net.java.sip.communicator.service.resources.*; +import net.java.sip.communicator.util.*; +import org.osgi.framework.*; + +import java.util.*; + +/** + * Creates and registers logging config form. + * @author Damian Minkov + */ +public class LoggingUtilsActivator + implements BundleActivator +{ + /** + * Our logging. + */ + private static Logger logger = + Logger.getLogger(LoggingUtilsActivator.class); + + /** + * The OSGI bundle context. + */ + private static BundleContext bundleContext = null; + + /** + * The resource service. + */ + private static ResourceManagementService resourceService; + + /** + * The configuration service. + */ + private static ConfigurationService configurationService = null; + + /** + * The packet logging service. + */ + private static PacketLoggingService packetLoggingService = null; + + /** + * The service giving access to files. + */ + private static FileAccessService fileAccessService; + + /** + * Notification service. + */ + private static NotificationService notificationService; + + /** + * Reference to the <tt>CertificateVerificationService</tt>. + */ + private static CertificateVerificationService certificateService = null; + + /** + * Creates and register logging configuration. + * + * @param bundleContext OSGI bundle context + * @throws Exception if error creating configuration. + */ + public void start(BundleContext bundleContext) + throws + Exception + { + LoggingUtilsActivator.bundleContext = bundleContext; + + // Config Form + Dictionary<String, String> packetLoggingProps + = new Hashtable<String, String>(); + packetLoggingProps.put( + ConfigurationForm.FORM_TYPE, + ConfigurationForm.ADVANCED_TYPE); + bundleContext.registerService( + ConfigurationForm.class.getName(), + new LazyConfigurationForm( + LoggingConfigForm.class.getName(), + getClass().getClassLoader(), + null, + "plugin.loggingutils.PACKET_LOGGING_CONFIG", + 1200, + true), + packetLoggingProps); + } + + /** + * Stops the Logging utils bundle + * + * @param bundleContext the OSGI bundle context + */ + public void stop(BundleContext bundleContext) + throws + Exception + { + } + + /** + * Returns the <tt>ResourceManagementService</tt> obtained from the + * bundle context. + * + * @return the <tt>ResourceManagementService</tt> obtained from the + * bundle context + */ + public static ResourceManagementService getResourceService() + { + if (resourceService == null) + { + ServiceReference resourceReference + = bundleContext.getServiceReference( + ResourceManagementService.class.getName()); + + resourceService = + (ResourceManagementService) bundleContext + .getService(resourceReference); + } + + return resourceService; + } + + /** + * Returns a reference to a ConfigurationService implementation currently + * registered in the bundle context or null if no such implementation was + * found. + * + * @return a currently valid implementation of the ConfigurationService. + */ + public static ConfigurationService getConfigurationService() + { + if (configurationService == null) + { + ServiceReference confReference + = bundleContext.getServiceReference( + ConfigurationService.class.getName()); + configurationService + = (ConfigurationService) bundleContext.getService(confReference); + } + return configurationService; + } + + /** + * Returns a reference to a PacketLoggingService implementation currently + * registered in the bundle context or null if no such implementation was + * found. + * + * @return a currently valid implementation of the PacketLoggingService. + */ + public static PacketLoggingService getPacketLoggingService() + { + if (packetLoggingService == null) + { + ServiceReference confReference + = bundleContext.getServiceReference( + PacketLoggingService.class.getName()); + packetLoggingService + = (PacketLoggingService) bundleContext.getService(confReference); + } + return packetLoggingService; + } + + /** + * Returns the <tt>FileAccessService</tt> obtained from the bundle context. + * + * @return the <tt>FileAccessService</tt> obtained from the bundle context + */ + public static FileAccessService getFileAccessService() + { + if (fileAccessService == null) + { + fileAccessService + = ServiceUtils.getService( + bundleContext, + FileAccessService.class); + } + return fileAccessService; + } + + /** + * Returns the <tt>NotificationService</tt> obtained from the bundle context. + * + * @return the <tt>NotificationService</tt> obtained from the bundle context + */ + public static NotificationService getNotificationService() + { + if (notificationService == null) + { + notificationService + = ServiceUtils.getService( + bundleContext, + NotificationService.class); + } + return notificationService; + } + + /** + * Return the certificate verification service impl. + * @return the CertificateVerification service. + */ + public static CertificateVerificationService + getCertificateVerificationService() + { + if(certificateService == null) + { + ServiceReference certVerifyReference + = bundleContext.getServiceReference( + CertificateVerificationService.class.getName()); + if(certVerifyReference != null) + certificateService + = (CertificateVerificationService)bundleContext.getService( + certVerifyReference); + } + + return certificateService; + } + +} diff --git a/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java b/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java new file mode 100644 index 0000000..3e052d9 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/loggingutils/LogsCollector.java @@ -0,0 +1,265 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. See terms of license at gnu.org. + */ +package net.java.sip.communicator.plugin.loggingutils; + +import net.java.sip.communicator.util.*; + +import java.io.*; +import java.text.*; +import java.util.*; +import java.util.regex.*; +import java.util.zip.*; + +/** + * Collects logs and save them in compressed zip file. + * @author Damian Minkov + */ +public class LogsCollector +{ + /** + * Our Logger. + */ + private static final Logger logger + = Logger.getLogger(LogsCollector.class); + + /** + * The name of the log dir. + */ + final static String LOGGING_DIR_NAME = "log"; + + /** + * The prefix name of standard java crash log file. + */ + private static final String JAVA_ERROR_LOG_PREFIX = "hs_err_pid"; + + /** + * The date format used in file names. + */ + private static final SimpleDateFormat FORMAT + = new SimpleDateFormat("yyyy-MM-dd@HH.mm.ss"); + + /** + * The pattern we use to match crash logs. + */ + private static Pattern JAVA_ERROR_LOG_PATTERN = + Pattern.compile( + Pattern.quote("sip.communicator"), + Pattern.CASE_INSENSITIVE); + + /** + * Save the log files in archived file. If destination is a folder + * we generate filename with current date and time. If the destination + * is null we do nothing and if its a file we use at, as we check + * does it end with zip extension, is missing we add it. + * @param destination + */ + static File collectLogs(File destination) + { + if(destination == null) + return null; + + if(!destination.isDirectory()) + { + if(!destination.getName().endsWith("zip")) + destination = new File(destination.getParentFile(), + destination.getName() + ".zip"); + } + else + { + destination = new File(destination, getDefaultFileName()); + } + + try + { + ZipOutputStream out = new ZipOutputStream( + new FileOutputStream(destination)); + + collectHomeFolderLogs(out); + collectJavaCrashLogs(out); + + out.close(); + + return destination; + } + catch(FileNotFoundException ex) + { + logger.error("Error creating logs file archive", ex); + } + catch(IOException ex) + { + logger.error("Error closing archive file", ex); + } + + return null; + } + + /** + * The default filename to use. + * @return the default filename to use. + */ + public static String getDefaultFileName() + { + return FORMAT.format(new Date()) + "-logs.zip"; + } + + /** + * Collects all files from log folder except the lock file. + * And put them in the zip file as zip entries. + * @param out the output zip file. + */ + private static void collectHomeFolderLogs(ZipOutputStream out) + { + try + { + File[] fs = LoggingUtilsActivator.getFileAccessService() + .getPrivatePersistentDirectory(LOGGING_DIR_NAME).listFiles(); + + for(File f : fs) + { + if(f.getName().endsWith(".lck")) + continue; + + addFileToZip(f, out); + } + } + catch(Exception e) + { + logger.error("Error obtaining logs folder", e); + } + } + + /** + * Copies a file to the given archive. + * @param file the file to copy. + * @param out the output archive stream. + */ + private static void addFileToZip(File file, ZipOutputStream out) + { + byte[] buf = new byte[1024]; + + try + { + FileInputStream in = new FileInputStream(file); + + // new ZIP entry + out.putNextEntry(new ZipEntry( + LOGGING_DIR_NAME + File.separator + file.getName())); + + // transfer bytes + int len; + while ((len = in.read(buf)) > 0) + { + out.write(buf, 0, len); + } + + out.closeEntry(); + in.close(); + } + catch(FileNotFoundException ex) + { + logger.error("Error obtaining file to archive", ex); + } + catch(IOException ex) + { + logger.error("Error saving file to archive", ex); + } + } + + /** + * Searches for java crash logs belonging to us and add them to + * the log archive. + * + * @param out the output archive stream. + */ + private static void collectJavaCrashLogs(ZipOutputStream out) + { + // First check in working dir + addCrashFilesToArchive( + new File(".").listFiles(), + JAVA_ERROR_LOG_PREFIX, + out); + + // If we don't have permissions to write to working directory + // the crash logs maybe in the temp directory, + // or on the Desktop if its windows + if(OSUtils.IS_WINDOWS) + { + // check Desktop + File[] desktopFiles = new File(System.getProperty( + "user.home") + File.separator + "Desktop").listFiles(); + addCrashFilesToArchive(desktopFiles, JAVA_ERROR_LOG_PREFIX, out); + } + + if(OSUtils.IS_MAC) + { + // ~/Library/Logs/CrashReporter + addCrashFilesToArchive( + new File("./Library/Logs/CrashReporter").listFiles(),null, out); + // /Library/Logs/CrashReporter + addCrashFilesToArchive( + new File("/Library/Logs/CrashReporter").listFiles(), null, out); + } + else + { + // search in /tmp folder + // Solaris OS and Linux the temporary directory is /tmp + // windows TMP or TEMP environment variable is the temporary folder + + //java.io.tmpdir + File[] tempFiles = + new File(System.getProperty("java.io.tmpdir")).listFiles(); + addCrashFilesToArchive(tempFiles, JAVA_ERROR_LOG_PREFIX, out); + } + } + + /** + * Checks if file is a crash log file and does it belongs to us. + * @param files files to check. + * @param filterStartsWith a prefix for the files, can be null if no + * prefix check should be made. + * @param out the output archive stream. + */ + private static void addCrashFilesToArchive( + File files[], String filterStartsWith, ZipOutputStream out) + { + byte[] buf = new byte[1024]; + // First check in working dir + for(File f: files) + { + if(filterStartsWith != null + && !f.getName().startsWith(JAVA_ERROR_LOG_PREFIX)) + { + continue; + } + + if(isOurCrashLog(f)) + { + addFileToZip(f, out); + } + } + } + + /** + * Checks whether the crash log file is for our application. + * @param file the crash log file. + * @return <tt>true</tt> if error log is ours. + */ + private static boolean isOurCrashLog(File file) + { + try + { + BufferedReader reader = new BufferedReader(new FileReader(file)); + String line = null; + while((line = reader.readLine()) != null) + if(JAVA_ERROR_LOG_PATTERN.matcher(line).find()) + return true; + } + catch(Throwable e) + {} + + return false; + } +} diff --git a/src/net/java/sip/communicator/plugin/loggingutils/loggingutils.manifest.mf b/src/net/java/sip/communicator/plugin/loggingutils/loggingutils.manifest.mf new file mode 100644 index 0000000..d9f3a1a --- /dev/null +++ b/src/net/java/sip/communicator/plugin/loggingutils/loggingutils.manifest.mf @@ -0,0 +1,21 @@ +Bundle-Activator: net.java.sip.communicator.plugin.loggingutils.LoggingUtilsActivator +Bundle-Name: Logging utils +Bundle-Description: A bundle that provides packet logging utils as config and saving archived logs +Bundle-Vendor: sip-communicator.org +Bundle-Version: 0.0.1 +System-Bundle: yes +Import-Package: org.osgi.framework, + net.java.sip.communicator.service.certificate, + net.java.sip.communicator.service.configuration, + net.java.sip.communicator.service.fileaccess, + net.java.sip.communicator.service.gui, + net.java.sip.communicator.service.notification, + net.java.sip.communicator.service.packetlogging, + net.java.sip.communicator.service.resources, + net.java.sip.communicator.util, + net.java.sip.communicator.util.swing, + javax.net.ssl, + javax.swing, + javax.swing.border, + javax.swing.event, + javax.swing.text diff --git a/src/net/java/sip/communicator/service/packetlogging/PacketLoggingConfiguration.java b/src/net/java/sip/communicator/service/packetlogging/PacketLoggingConfiguration.java new file mode 100644 index 0000000..aa58d29 --- /dev/null +++ b/src/net/java/sip/communicator/service/packetlogging/PacketLoggingConfiguration.java @@ -0,0 +1,237 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.packetlogging; + +/** + * Stores the configuration used by Packet Logging Service. + * + * @author Damian Minkov + */ +public class PacketLoggingConfiguration +{ + /** + * Configuration property for packet logging enabled/disabled. + */ + public final static String PACKET_LOGGING_ENABLED_PROPERTY_NAME + = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_ENABLED"; + + /** + * Configuration property for packet logging for + * sip protocol enabled/disabled. + */ + public final static String PACKET_LOGGING_SIP_ENABLED_PROPERTY_NAME + = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_SIP_ENABLED"; + + /** + * Configuration property for packet logging for + * jabber protocol enabled/disabled. + */ + public final static String PACKET_LOGGING_JABBER_ENABLED_PROPERTY_NAME + = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_JABBER_ENABLED"; + + /** + * Configuration property for packet logging for + * RTP enabled/disabled. + */ + public final static String PACKET_LOGGING_RTP_ENABLED_PROPERTY_NAME + = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_RTP_ENABLED"; + + /** + * Configuration property for packet logging for + * ICE4J enabled/disabled. + */ + public final static String PACKET_LOGGING_ICE4J_ENABLED_PROPERTY_NAME + = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_ICE4J_ENABLED"; + + /** + * Configuration property for packet logging file count. + */ + public final static String PACKET_LOGGING_FILE_COUNT_PROPERTY_NAME + = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_FILE_COUNT"; + + /** + * Configuration property for packet logging file size. + */ + public final static String PACKET_LOGGING_FILE_SIZE_PROPERTY_NAME + = "net.java.sip.communicator.packetlogging.PACKET_LOGGING_FILE_SIZE"; + + /** + * Is Packet Logging Service enabled. + */ + private boolean globalLoggingEnabled = true; + + /** + * Is Packet Logging Service enabled for sip protocol. + */ + private boolean sipLoggingEnabled = true; + + /** + * Is Packet Logging Service enabled for jabber protocol. + */ + private boolean jabberLoggingEnabled = true; + + /** + * Is Packet Logging Service enabled for rtp. + */ + private boolean rtpLoggingEnabled = true; + + /** + * Is Packet Logging Service enabled for ice4j. + */ + private boolean ice4jLoggingEnabled = true; + + /** + * The limit for the file size. + * 0 means no limit. + */ + private long limit = 5000000; + + /** + * The counter for number of files. + */ + private int logfileCount = 3; + + /** + * Checks whether packet logging is enabled in the configuration. + * @return <tt>true</tt> if packet logging is enabled. + */ + public boolean isGlobalLoggingEnabled() + { + return this.globalLoggingEnabled; + } + + /** + * Checks whether packet logging is enabled in the configuration + * for sip protocol. + * @return <tt>true</tt> if packet logging is enabled for sip protocol. + */ + public boolean isSipLoggingEnabled() + { + return this.sipLoggingEnabled; + } + + /** + * Checks whether packet logging is enabled in the configuration + * for jabber protocol. + * @return <tt>true</tt> if packet logging is enabled for jabber protocol. + */ + public boolean isJabberLoggingEnabled() + { + return this.jabberLoggingEnabled; + } + + /** + * Checks whether packet logging is enabled in the configuration + * for RTP. + * @return <tt>true</tt> if packet logging is enabled for RTP. + */ + public boolean isRTPLoggingEnabled() + { + return this.rtpLoggingEnabled; + } + + /** + * Checks whether packet logging is enabled in the configuration + * for Ice4J. + * @return <tt>true</tt> if packet logging is enabled for RTP. + */ + public boolean isIce4JLoggingEnabled() + { + return this.ice4jLoggingEnabled; + } + + /** + * The limit for the file size. 0 means no limit. + * @return the file size limit. + */ + public long getLimit() + { + return this.limit; + } + + /** + * The counter for number of files. + * @return the number of file counts. + */ + public int getLogfileCount() + { + return this.logfileCount; + } + + /** + * Change whether packet logging is enabled. + * @param enabled <tt>true</tt> if we enable it. + */ + public void setGlobalLoggingEnabled(boolean enabled) + { + if(!enabled) + { + // as we are globally off, set it and to services + this.sipLoggingEnabled = false; + this.jabberLoggingEnabled = false; + this.rtpLoggingEnabled = false; + this.ice4jLoggingEnabled = false; + } + + this.globalLoggingEnabled = enabled; + } + + /** + * Change whether packet logging for sip protocol is enabled. + * @param enabled <tt>true</tt> if we enable it. + */ + public void setSipLoggingEnabled(boolean enabled) + { + this.sipLoggingEnabled = enabled; + } + + /** + * Change whether packet logging for jabber protocol is enabled. + * @param enabled <tt>true</tt> if we enable it. + */ + public void setJabberLoggingEnabled(boolean enabled) + { + this.jabberLoggingEnabled = enabled; + } + + /** + * Change whether packet logging for RTP is enabled. + * @param enabled <tt>true</tt> if we enable it. + */ + public void setRTPLoggingEnabled(boolean enabled) + { + this.rtpLoggingEnabled = true; + } + + /** + * Change whether packet logging for Ice4J is enabled. + * @param enabled <tt>true</tt> if we enable it. + */ + public void setIce4JLoggingEnabled(boolean enabled) + { + this.ice4jLoggingEnabled = true; + } + + /** + * Changes the file size limit. + * @param limit the new limit size. + */ + public void setLimit(long limit) + { + this.limit = limit; + } + + /** + * Changes file count. + * @param logfileCount the new file count. + */ + public void setLogfileCount(int logfileCount) + { + this.logfileCount = logfileCount; + } + +} diff --git a/src/net/java/sip/communicator/service/packetlogging/PacketLoggingService.java b/src/net/java/sip/communicator/service/packetlogging/PacketLoggingService.java index bdf4103..3ee454f 100644 --- a/src/net/java/sip/communicator/service/packetlogging/PacketLoggingService.java +++ b/src/net/java/sip/communicator/service/packetlogging/PacketLoggingService.java @@ -98,4 +98,11 @@ public interface PacketLoggingService byte[] packetContent, int packetOffset, int packetLength); + + /** + * Returns the current Packet Logging Configuration. + * + * @return the Packet Logging Configuration. + */ + public PacketLoggingConfiguration getConfiguration(); } |