diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2012-10-01 06:10:21 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2012-10-01 06:10:21 +0000 |
commit | 1ee98bdf07c702123efd5ded704bc32ac71a0859 (patch) | |
tree | 7289c9f8f571702a588a824d69f272af03b450c3 | |
parent | b75a83f406c9eafec0f81a43cb5bda6a87bb9d58 (diff) | |
download | jitsi-1ee98bdf07c702123efd5ded704bc32ac71a0859.zip jitsi-1ee98bdf07c702123efd5ded704bc32ac71a0859.tar.gz jitsi-1ee98bdf07c702123efd5ded704bc32ac71a0859.tar.bz2 |
Commits work in progress on improving, stabalising audio and video telephony conferencing.
18 files changed, 292 insertions, 234 deletions
diff --git a/lib/installer-exclude/libjitsi.jar b/lib/installer-exclude/libjitsi.jar Binary files differindex 28946d7..aff8795 100644 --- a/lib/installer-exclude/libjitsi.jar +++ b/lib/installer-exclude/libjitsi.jar diff --git a/src/net/java/sip/communicator/impl/gui/main/SingleWindowContainer.java b/src/net/java/sip/communicator/impl/gui/main/SingleWindowContainer.java index a1e0472..3a99c45 100644 --- a/src/net/java/sip/communicator/impl/gui/main/SingleWindowContainer.java +++ b/src/net/java/sip/communicator/impl/gui/main/SingleWindowContainer.java @@ -9,6 +9,7 @@ package net.java.sip.communicator.impl.gui.main; import java.awt.*; import java.awt.event.*; import java.util.*; +import java.util.List; import javax.swing.*; import javax.swing.Timer; @@ -29,20 +30,20 @@ import net.java.sip.communicator.util.swing.*; */ public class SingleWindowContainer extends TransparentPanel - implements ChatContainer, - CallContainer, - CallTitleListener, - ChangeListener + implements ChatContainer, + CallContainer, + CallTitleListener, + ChangeListener { /** - * The logger for this class. + * The <tt>Logger</tt> used by this instance for logging output. */ private final Logger logger = Logger.getLogger(SingleWindowContainer.class); /** * The tabbed pane, containing all conversations. */ - private ConversationTabbedPane tabbedPane = null; + private final ConversationTabbedPane tabbedPane; /** * The count of current conversations. @@ -52,8 +53,8 @@ public class SingleWindowContainer /** * Chat change listeners. */ - private final java.util.List<ChatChangeListener> chatChangeListeners = - new Vector<ChatChangeListener>(); + private final List<ChatChangeListener> chatChangeListeners + = new Vector<ChatChangeListener>(); /** * The contact photo panel. @@ -377,19 +378,15 @@ public class SingleWindowContainer { Component currentConversation = getCurrentConversation(); - tabbedPane.addTab( - name, - icon, - conversation); - + tabbedPane.addTab(name, icon, conversation); tabbedPane.getParent().validate(); - // If not specified explicitly, when added to the tabbed pane, - // the first chat panel should rest the selected component. - if (currentConversation != null && !isSelected) - tabbedPane.setSelectedComponent(currentConversation); - else - tabbedPane.setSelectedComponent(conversation); + // If not specified explicitly, when added to the tabbed pane, the first + // chat panel should rest the selected component. + tabbedPane.setSelectedComponent( + (currentConversation != null && !isSelected) + ? currentConversation + : conversation); } /** @@ -408,22 +405,19 @@ public class SingleWindowContainer private Component createToolbar() { - JPanel northPanel = new TransparentPanel(new BorderLayout()); - mainToolBar = new MainToolBar(this); // The toolbar would be only visible when a chat is opened. mainToolBar.setVisible(false); - boolean chatToolbarVisible = ConfigurationManager.isChatToolbarVisible(); - northPanel.setVisible(chatToolbarVisible); + JPanel northPanel = new TransparentPanel(new BorderLayout()); northPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0)); + northPanel.setPreferredSize(new Dimension(500, 35)); + northPanel.setVisible(ConfigurationManager.isChatToolbarVisible()); northPanel.add(mainToolBar, BorderLayout.EAST); northPanel.add(contactPhotoPanel, BorderLayout.WEST); - northPanel.setPreferredSize(new Dimension(500, 35)); - return northPanel; } diff --git a/src/net/java/sip/communicator/impl/gui/main/call/AbstractCallToggleButton.java b/src/net/java/sip/communicator/impl/gui/main/call/AbstractCallToggleButton.java index 0c67e0b..3915004 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/AbstractCallToggleButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/AbstractCallToggleButton.java @@ -181,14 +181,10 @@ public abstract class AbstractCallToggleButton implements ActionListener, Runnable { - private final Call call; - private Thread runner; public CallToggleButtonModel(Call call) { - this.call = call; - addActionListener(this); } diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java index 4715805..1aef677 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java @@ -53,13 +53,13 @@ public class CallDialog public Dimension getMinimumSize()
{
Dimension minSize = super.getMinimumSize();
+
if(callPanel != null)
{
int minButtonWidth = callPanel.getMinimumButtonWidth();
+
if(minButtonWidth > minSize.getWidth())
- {
- return new Dimension(minButtonWidth, 300);
- }
+ minSize = new Dimension(minButtonWidth, 300);
}
return minSize;
@@ -108,19 +108,19 @@ public class CallDialog public void closeWait(CallPanel callPanel)
{
if (this.callPanel.equals(callPanel))
- {
disposeWait();
- }
}
/**
- * Hang ups the current call on close.
- * @param isEscaped indicates if the window was close by pressing the escape
- * button
+ * {@inheritDoc}
+ *
+ * Hang ups the call/telephony conference depicted by this
+ * <tt>CallDialog</tt> on close.
*/
- protected void close(boolean isEscaped)
+ @Override
+ protected void close(boolean escape)
{
- callPanel.actionPerformedOnHangupButton(isEscaped);
+ callPanel.actionPerformedOnHangupButton(escape);
}
/**
@@ -132,10 +132,7 @@ public class CallDialog */
public boolean isCallVisible(CallPanel callPanel)
{
- if (this.callPanel.equals(callPanel))
- return isVisible();
-
- return false;
+ return this.callPanel.equals(callPanel) ? isVisible() : false;
}
/**
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/InputVolumeControlButton.java b/src/net/java/sip/communicator/impl/gui/main/call/InputVolumeControlButton.java index d161548..6d8a5ef 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/InputVolumeControlButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/InputVolumeControlButton.java @@ -37,11 +37,6 @@ public class InputVolumeControlButton Runnable { /** - * The <tt>Call</tt> that this button controls. - */ - private final Call call; - - /** * Mutes the call in other thread. */ private Thread muteRunner; @@ -134,7 +129,6 @@ public class InputVolumeControlButton pressedIconImageID, "service.gui.MUTE_BUTTON_TOOL_TIP"); - this.call = call; this.fullScreen = fullScreen; this.mute = selected; diff --git a/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java index 8fda985..3498dee 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java @@ -29,8 +29,8 @@ import com.explodingpixels.macwidgets.*; * @author Yana Stamcheva */ public abstract class PreCallDialog - implements ActionListener, - Skinnable + implements ActionListener, + Skinnable { /** * The call button name. @@ -101,20 +101,20 @@ public abstract class PreCallDialog /** * The window handling received calls. */ - private Window preCallWindow; + private final Window preCallWindow; /** * If it is a video call. */ - private boolean video = false; + private final boolean video; /** * If the call should be answered in an existing call. */ - private boolean mergeCall = false; + private final boolean mergeCall; /** - * Creates an instanceof <tt>PreCallDialog</tt> by specifying the dialog + * Creates an instance of <tt>PreCallDialog</tt> by specifying the dialog * title. * * @param title the title of the dialog @@ -127,7 +127,7 @@ public abstract class PreCallDialog } /** - * Creates an instanceof <tt>PreCallDialog</tt> by specifying the dialog + * Creates an instance of <tt>PreCallDialog</tt> by specifying the dialog * title and the text to show. * * @param title the title of the dialog @@ -140,7 +140,7 @@ public abstract class PreCallDialog } /** - * Creates an instanceof <tt>PreCallDialog</tt> by specifying the dialog + * Creates an instance of <tt>PreCallDialog</tt> by specifying the dialog * title and the text to show. * * @param title the title of the dialog @@ -154,18 +154,24 @@ public abstract class PreCallDialog { preCallWindow = createPreCallWindow(title, text, accounts); + if (video) + { + // Make sure there is a VIDEO MediaDevice and it is capable of + // capture/sending + MediaDevice mediaDevice + = GuiActivator.getMediaService().getDefaultDevice( + MediaType.VIDEO, + MediaUseCase.CALL); + + if ((mediaDevice == null) + || !mediaDevice.getDirection().allowsSending()) + video = false; + } + this.video = video; this.mergeCall = existingCall; - MediaDevice mediaDevice - = GuiActivator.getMediaService().getDefaultDevice( - MediaType.VIDEO, MediaUseCase.CALL); - - // check whether we have device enabled for capturing(sending) - if (mediaDevice != null) - this.video = video && mediaDevice.getDirection().allowsSending(); - - this.initComponents(); + initComponents(); } /** @@ -199,8 +205,9 @@ public abstract class PreCallDialog if (accounts != null) { - accountsCombo = HudWidgetFactory - .createHudComboBox(new DefaultComboBoxModel(accounts)); + accountsCombo + = HudWidgetFactory.createHudComboBox( + new DefaultComboBoxModel(accounts)); } } else @@ -216,9 +223,7 @@ public abstract class PreCallDialog callLabelImage = new JLabel(); if (accounts != null) - { accountsCombo = new JComboBox(accounts); - } } if (text != null) diff --git a/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java index 071acd9..06f329d 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java @@ -29,9 +29,9 @@ import org.jitsi.util.*; */ public class ReceivedCallDialog extends PreCallDialog - implements ActionListener, - CallListener, - Skinnable + implements ActionListener, + CallListener, + Skinnable { /** * The incoming call to render. @@ -57,11 +57,11 @@ public class ReceivedCallDialog this.incomingCall = call; - OperationSetBasicTelephony<?> telephonyOpSet - = call.getProtocolProvider() - .getOperationSet(OperationSetBasicTelephony.class); + OperationSetBasicTelephony<?> basicTelephony + = call.getProtocolProvider().getOperationSet( + OperationSetBasicTelephony.class); - telephonyOpSet.addCallListener(this); + basicTelephony.addCallListener(this); initCallLabel(getCallLabels()); } @@ -150,16 +150,34 @@ public class ReceivedCallDialog } /** - * When call is remotely ended we close this dialog. - * @param event the <tt>CallEvent</tt> that has been triggered + * {@inheritDoc} + * + * When the <tt>Call</tt> depicted by this dialog is (remotely) ended, + * close/dispose of this dialog. + * + * @param event a <tt>CallEvent</tt> which specifies the <tt>Call</tt> that + * has ended */ public void callEnded(CallEvent event) { - Call sourceCall = event.getSourceCall(); + if (event.getSourceCall().equals(incomingCall)) + dispose(); + } - if (sourceCall.equals(incomingCall)) + @Override + public void dispose() + { + try { - dispose(); + OperationSetBasicTelephony<?> basicTelephony + = incomingCall.getProtocolProvider().getOperationSet( + OperationSetBasicTelephony.class); + + basicTelephony.removeCallListener(this); + } + finally + { + super.dispose(); } } @@ -227,12 +245,11 @@ public class ReceivedCallDialog private String getPeerDisplayName(CallPeer peer) { String displayName = peer.getDisplayName(); - String peerAddress = peer.getAddress(); - - if(StringUtils.isNullOrEmpty(displayName, true)) - return peerAddress; - return displayName; + return + StringUtils.isNullOrEmpty(displayName, true) + ? peer.getAddress() + : displayName; } /** @@ -243,15 +260,16 @@ public class ReceivedCallDialog */ private String getPeerDisplayAddress(CallPeer peer) { - String displayName = peer.getDisplayName(); String peerAddress = peer.getAddress(); if(StringUtils.isNullOrEmpty(peerAddress, true)) return null; - - if(peerAddress.equalsIgnoreCase(displayName)) - return null; - - return peerAddress; + else + { + return + peerAddress.equalsIgnoreCase(peer.getDisplayName()) + ? null + : peerAddress; + } } } 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 12289ce..e0b7ac1 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 @@ -94,13 +94,14 @@ public class RecordButton */ public RecordButton(Call call, boolean fullScreen, boolean selected) { - super( call, - fullScreen, - true, - selected, - ImageLoader.RECORD_BUTTON, - ImageLoader.RECORD_BUTTON_PRESSED, - null); + super( + call, + fullScreen, + true, + selected, + ImageLoader.RECORD_BUTTON, + ImageLoader.RECORD_BUTTON_PRESSED, + null); String toolTip = resources.getI18NString("service.gui.RECORD_BUTTON_TOOL_TIP"); diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceCallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceCallPanel.java index f2f30ff..f886558 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceCallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceCallPanel.java @@ -47,7 +47,7 @@ public class ConferenceCallPanel /** * The conference call. */ - private final Call call; + protected final Call call; /** * The scroll pane. diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java index 0b19e7a..071905b 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java @@ -24,15 +24,11 @@ public class VideoConferenceCallPanel extends ConferenceCallPanel { /** - * The contained call. - */ - private final Call call; - - /** * Maps a <tt>CallPeer</tt> to its renderer. */ protected final Hashtable<CallPeer, ConferenceCallPeerRenderer> - callPeerPanels = new Hashtable<CallPeer, ConferenceCallPeerRenderer>(); + callPeerPanels + = new Hashtable<CallPeer, ConferenceCallPeerRenderer>(); /** * A mapping of a member and its renderer. @@ -41,8 +37,7 @@ public class VideoConferenceCallPanel conferenceMembersPanels = new Hashtable<ConferenceMember, ConferenceMemberPanel>(); - public VideoConferenceCallPanel(CallPanel callPanel, - Call call) + public VideoConferenceCallPanel(CallPanel callPanel, Call call) { this(callPanel, call, null); } @@ -59,8 +54,6 @@ public class VideoConferenceCallPanel { super(callPanel, call, videoHandler, true); - this.call = call; - addVideoContainer(); getVideoHandler().setLocalVideoToolbar(createLocalVideoToolBar()); @@ -103,13 +96,13 @@ public class VideoConferenceCallPanel public void conferenceMemberAdded( CallPeer callPeer, ConferenceMember member) { - // It's already there. - if (conferenceMembersPanels.containsKey(member)) - return; - - conferenceMemberAdded(callPeer, member, false); + // Only if it isn't there yet. + if (!conferenceMembersPanels.containsKey(member)) + { + conferenceMemberAdded(callPeer, member, false); - getVideoHandler().handleVideoEvent(call, null); + getVideoHandler().handleVideoEvent(call, null); + } } /** @@ -124,7 +117,7 @@ public class VideoConferenceCallPanel return; if (CallManager.addressesAreEqual( - member.getAddress(), callPeer.getAddress())) + member.getAddress(), callPeer.getAddress())) { return; } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java index 7acf869..922c939 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java @@ -1830,7 +1830,6 @@ public class ChatConversationPanel document.getLength()); String msgDivString = msgDivWriter.toString(); - String newMsgDivString = msgDivString.replaceFirst( ChatHtmlUtils.MESSAGE_DIV_ID + lastMessageUID, @@ -1855,10 +1854,9 @@ public class ChatConversationPanel else msgEndIndex = newMsgDivString.lastIndexOf("</div>"); - document.setOuterHTML(messageDivElement, - newMsgDivString.substring( - msgStartIndex, - msgEndIndex + 6)); + document.setOuterHTML( + messageDivElement, + newMsgDivString.substring(msgStartIndex, msgEndIndex + 6)); } catch (IOException e) { diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ProtocolContactSourceServiceImpl.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ProtocolContactSourceServiceImpl.java index eed8906..77624d0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ProtocolContactSourceServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ProtocolContactSourceServiceImpl.java @@ -106,7 +106,7 @@ public class ProtocolContactSourceServiceImpl { private int contactCount; - private String queryString; + private final String queryString; public ProtocolCQuery(String queryString, int contactCount) { @@ -118,11 +118,12 @@ public class ProtocolContactSourceServiceImpl this.contactCount = contactCount; } - protected String normalizePhoneNumber(String phoneNumber) - { - return phoneNumber; - } - + /** + * {@inheritDoc} + * + * Always returns <tt>false</tt>. + */ + @Override protected boolean phoneNumberMatches(String phoneNumber) { return false; @@ -130,8 +131,9 @@ public class ProtocolContactSourceServiceImpl public void run() { - Iterator<MetaContact> contactListIter = metaContactListService - .findAllMetaContactsForProvider(protocolProvider); + Iterator<MetaContact> contactListIter + = metaContactListService.findAllMetaContactsForProvider( + protocolProvider); while (contactListIter.hasNext()) { @@ -166,39 +168,40 @@ public class ProtocolContactSourceServiceImpl break; Contact contact = contacts.next(); + String contactAddress = contact.getAddress(); + String contactDisplayName = contact.getDisplayName(); if (queryString == null || queryString.length() <= 0 || metaContact.getDisplayName().startsWith(queryString) - || contact.getAddress().startsWith(queryString) - || contact.getDisplayName().startsWith(queryString)) + || contactAddress.startsWith(queryString) + || contactDisplayName.startsWith(queryString)) { - ArrayList<ContactDetail> contactDetails - = new ArrayList<ContactDetail>(); - ContactDetail contactDetail - = new ContactDetail(contact.getAddress()); - - ArrayList<Class<? extends OperationSet>> - supportedOpSets + = new ContactDetail(contactAddress); + List<Class<? extends OperationSet>> supportedOpSets = new ArrayList<Class<? extends OperationSet>>(); + supportedOpSets.add(opSetClass); contactDetail.setSupportedOpSets(supportedOpSets); + List<ContactDetail> contactDetails + = new ArrayList<ContactDetail>(); + contactDetails.add(contactDetail); GenericSourceContact sourceContact = new GenericSourceContact( - ProtocolContactSourceServiceImpl.this, - contact.getDisplayName(), - contactDetails); + ProtocolContactSourceServiceImpl.this, + contactDisplayName, + contactDetails); - if (!contact.getAddress().equals(contact.getDisplayName())) - sourceContact.setDisplayDetails(contact.getAddress()); + if (!contactAddress.equals(contactDisplayName)) + sourceContact.setDisplayDetails(contactAddress); sourceContact.setImage(metaContact.getAvatar()); - sourceContact - .setPresenceStatus(contact.getPresenceStatus()); + sourceContact.setPresenceStatus( + contact.getPresenceStatus()); addQueryResult(sourceContact); } diff --git a/src/net/java/sip/communicator/impl/libjitsi/LibJitsiActivator.java b/src/net/java/sip/communicator/impl/libjitsi/LibJitsiActivator.java index bccc135..a2b21cf 100644 --- a/src/net/java/sip/communicator/impl/libjitsi/LibJitsiActivator.java +++ b/src/net/java/sip/communicator/impl/libjitsi/LibJitsiActivator.java @@ -6,6 +6,8 @@ */ package net.java.sip.communicator.impl.libjitsi; +import java.lang.reflect.*; + import org.jitsi.service.libjitsi.*; import org.osgi.framework.*; @@ -15,7 +17,39 @@ public class LibJitsiActivator public void start(BundleContext bundleContext) throws Exception { - LibJitsi.start(); + /* + * XXX To start/initialize the libjitsi library, simply call + * LibJitsi#start(). The following is a temporary workaround for the + * benefit of the Jitsi VideoBridge project (which uses Jitsi's libjitsi + * bundle and runs on an incomplete OSGi implementation) and not the + * Jitsi project. + */ + Method start; + + try + { + start = LibJitsi.class.getDeclaredMethod("start", Object.class); + if (Modifier.isStatic(start.getModifiers())) + { + start.setAccessible(true); + if (!start.isAccessible()) + start = null; + } + else + start = null; + } + catch (NoSuchMethodException nsme) + { + start = null; + } + catch (SecurityException se) + { + start = null; + } + if (start == null) + LibJitsi.start(); + else + start.invoke(null, bundleContext); } public void stop(BundleContext bundleContext) diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java index 3f65c57..f025a2d 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java +++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingActivator.java @@ -26,8 +26,8 @@ public class PacketLoggingActivator /** * Our logging. */ - private static Logger logger = - Logger.getLogger(PacketLoggingActivator.class); + private static Logger logger + = Logger.getLogger(PacketLoggingActivator.class); /** * The OSGI bundle context. @@ -62,20 +62,32 @@ public class PacketLoggingActivator * @throws Exception if starting the PacketLoggingServiceImpl. */ public void start(BundleContext bundleContext) - throws - Exception + throws Exception { - PacketLoggingActivator.bundleContext = bundleContext; - - packetLoggingService = new PacketLoggingServiceImpl(); + /* + * PacketLoggingServiceImpl requires a FileAccessService implementation. + * Ideally, we'd be listening to the bundleContext and will be making + * the PacketLoggingService implementation available in accord with the + * availability of a FileAccessService implementation. Unfortunately, + * the real world is far from ideal. + */ + fileAccessService + = ServiceUtils.getService(bundleContext, FileAccessService.class); + if (fileAccessService != null) + { + PacketLoggingActivator.bundleContext = bundleContext; - packetLoggingService.start(); + packetLoggingService = new PacketLoggingServiceImpl(); + packetLoggingService.start(); - bundleContext.registerService(PacketLoggingService.class.getName(), - packetLoggingService, null); + bundleContext.registerService( + PacketLoggingService.class.getName(), + packetLoggingService, + null); - if (logger.isInfoEnabled()) - logger.info("Packet Logging Service ...[REGISTERED]"); + if (logger.isInfoEnabled()) + logger.info("Packet Logging Service ...[REGISTERED]"); + } } /** @@ -84,12 +96,15 @@ public class PacketLoggingActivator * @param bundleContext the OSGI bundle context */ public void stop(BundleContext bundleContext) - throws - Exception + throws Exception { if(packetLoggingService != null) packetLoggingService.stop(); + configurationService = null; + fileAccessService = null; + packetLoggingService = null; + if (logger.isInfoEnabled()) logger.info("Packet Logging Service ...[STOPPED]"); } @@ -121,13 +136,6 @@ public class PacketLoggingActivator */ public static FileAccessService getFileAccessService() { - if (fileAccessService == null) - { - fileAccessService - = ServiceUtils.getService( - bundleContext, - FileAccessService.class); - } return fileAccessService; } } diff --git a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java index d063d8c..9529ac4 100644 --- a/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java +++ b/src/net/java/sip/communicator/impl/packetlogging/PacketLoggingServiceImpl.java @@ -159,13 +159,18 @@ public class PacketLoggingServiceImpl private void getFileNames() throws Exception { - files = new File[getConfiguration().getLogfileCount()]; - for(int i = 0; i < getConfiguration().getLogfileCount(); i++) + int fileCount = getConfiguration().getLogfileCount(); + + files = new File[fileCount]; + for(int i = 0; i < fileCount; i++) { - files[i] = PacketLoggingActivator.getFileAccessService() - .getPrivatePersistentFile( - PacketLoggingActivator.LOGGING_DIR_NAME - + File.separator + "jitsi" + i + ".pcap"); + files[i] + = PacketLoggingActivator.getFileAccessService().getPrivatePersistentFile( + PacketLoggingActivator.LOGGING_DIR_NAME + + File.separator + + "jitsi" + + i + + ".pcap"); } } @@ -183,16 +188,15 @@ public class PacketLoggingServiceImpl outputStream.close(); } - for (int i = getConfiguration().getLogfileCount() -2; i >= 0; i--) + for (int i = getConfiguration().getLogfileCount() - 2; i >= 0; i--) { File f1 = files[i]; File f2 = files[i+1]; + if (f1.exists()) { if (f2.exists()) - { f2.delete(); - } f1.renameTo(f2); } } @@ -220,7 +224,10 @@ public class PacketLoggingServiceImpl { e.printStackTrace(); } - outputStream = null; + finally + { + outputStream = null; + } } } @@ -281,31 +288,40 @@ public class PacketLoggingServiceImpl } /** - * Checks is logging globally enabled for and is it currently - * available fo the given service. + * Checks is logging globally enabled for and is it currently available for + * the given service. * * @param protocol that is checked. * @return is logging enabled. */ public boolean isLoggingEnabled(ProtocolName protocol) { - switch(protocol) + PacketLoggingConfiguration cfg = getConfiguration(); + + if (cfg.isGlobalLoggingEnabled()) { - case SIP: - return getConfiguration().isGlobalLoggingEnabled() - && getConfiguration().isSipLoggingEnabled(); - case JABBER: - return getConfiguration().isGlobalLoggingEnabled() - && getConfiguration().isJabberLoggingEnabled(); - case RTP: - return getConfiguration().isGlobalLoggingEnabled() - && getConfiguration().isRTPLoggingEnabled(); - case ICE4J: - return getConfiguration().isGlobalLoggingEnabled() - && getConfiguration().isIce4JLoggingEnabled(); - default: - return false; + switch(protocol) + { + case SIP: + return cfg.isSipLoggingEnabled(); + case JABBER: + return cfg.isJabberLoggingEnabled(); + case RTP: + return cfg.isRTPLoggingEnabled(); + case ICE4J: + return cfg.isIce4JLoggingEnabled(); + default: + /* + * It may seem like it was unnecessary to invoke + * getConfiguration and isGlobalLoggingEnabled prior to + * checking that the specified protocol is supported but, + * actually, there are no other ProtocolName values. + */ + return false; + } } + else + return false; } /** @@ -539,8 +555,9 @@ public class PacketLoggingServiceImpl rotateFiles();// this one opens the file for write } - if(getConfiguration().getLimit() > 0 - && written > getConfiguration().getLimit()) + long limit = getConfiguration().getLimit(); + + if((limit > 0) && (written > limit)) rotateFiles(); addInt(tsSec); @@ -739,7 +756,7 @@ public class PacketLoggingServiceImpl /** * List of packets queued to be written in the file. */ - private List<Packet> packetsToDump = new ArrayList<Packet>(); + private final List<Packet> pktsToSave = new ArrayList<Packet>(); /** * Sends instant messages in separate thread so we don't block @@ -748,14 +765,13 @@ public class PacketLoggingServiceImpl public void run() { stopped = false; - while(!stopped) { - Packet pktToSave = null; + Packet pktToSave; synchronized(this) { - if(packetsToDump.isEmpty()) + if(pktsToSave.isEmpty()) { try { @@ -764,10 +780,10 @@ public class PacketLoggingServiceImpl catch (InterruptedException iex) { } + continue; } - if(!packetsToDump.isEmpty()) - pktToSave = packetsToDump.remove(0); + pktToSave = pktsToSave.remove(0); } if(pktToSave != null) @@ -778,7 +794,14 @@ public class PacketLoggingServiceImpl } catch(Throwable t) { - logger.error("Error writing packet to file", t); + /* + * XXX ThreadDeath must be rethrown; otherwise, the + * related Thread will not die. + */ + if (t instanceof ThreadDeath) + throw (ThreadDeath) t; + else + logger.error("Error writing packet to file", t); } } } @@ -799,7 +822,7 @@ public class PacketLoggingServiceImpl */ public synchronized void queuePacket(Packet packet) { - packetsToDump.add(packet); + pktsToSave.add(packet); notifyAll(); } } diff --git a/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java b/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java index dfa19ec..847a13a 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java @@ -250,16 +250,16 @@ public class ConfigurationManager "impl.gui.NORMALIZE_PHONE_NUMBER"; isNormalizePhoneNumber - = GeneralConfigPluginActivator.getConfigurationService() - .getBoolean(normalizePhoneNumberProperty, true); + = configService.getBoolean(normalizePhoneNumberProperty, true); // Load the "ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS" property. String acceptPhoneNumberWithAlphaCharsProperty = "impl.gui.ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS"; acceptPhoneNumberWithAlphaChars - = GeneralConfigPluginActivator.getConfigurationService() - .getBoolean(acceptPhoneNumberWithAlphaCharsProperty, true); + = configService.getBoolean( + acceptPhoneNumberWithAlphaCharsProperty, + true); } /** diff --git a/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java b/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java index 8f22216..e5db2e6 100644 --- a/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java +++ b/src/net/java/sip/communicator/plugin/loggingutils/LoggingConfigForm.java @@ -273,24 +273,18 @@ public class LoggingConfigForm */ 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)); + PacketLoggingService packetLogging + = LoggingUtilsActivator.getPacketLoggingService(); + PacketLoggingConfiguration cfg = packetLogging.getConfiguration(); + + enableCheckBox.setSelected(cfg.isGlobalLoggingEnabled()); + + sipProtocolCheckBox.setSelected(cfg.isSipLoggingEnabled()); + jabberProtocolCheckBox.setSelected(cfg.isJabberLoggingEnabled()); + rtpProtocolCheckBox.setSelected(cfg.isRTPLoggingEnabled()); + ice4jProtocolCheckBox.setSelected(cfg.isIce4JLoggingEnabled()); + fileCountField.setText(String.valueOf(cfg.getLogfileCount())); + fileSizeField.setText(String.valueOf(cfg.getLimit() / 1000)); updateButtonsState(); } diff --git a/src/net/java/sip/communicator/util/swing/SIPCommFrame.java b/src/net/java/sip/communicator/util/swing/SIPCommFrame.java index 158760e..0d68b39 100644 --- a/src/net/java/sip/communicator/util/swing/SIPCommFrame.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommFrame.java @@ -811,13 +811,13 @@ public class SIPCommFrame } /** - * All functions implemented in this method will be invoked when user - * presses the Escape key. - * @param isEscaped indicates if this frame has been closed by pressing the - * Esc key + * Notifies this instance that it has been requested to close. The default + * <tt>SIPCommFrame</tt> implementation does nothing. + * + * @param escape <tt>true</tt> if the request to close this instance is in + * response of a press on the Escape key; otherwise, <tt>false</tt> */ - protected void close(boolean isEscaped) + protected void close(boolean escape) { - } } |