Commits the patch of Sebastien Vincent provided on the dev mailing list in an e-mail with the subject "[Patch] Warnings" which fixes multiple warnings about unnecessary casts, missing or incorrect javadocs.

cusax-fix
Lyubomir Marinov 16 years ago
parent d10540987f
commit dfb0c91c94

@ -106,10 +106,11 @@ public Collection<CallRecord> findByStartDate(Date startDate)
History history = this.getHistory(null, null); History history = this.getHistory(null, null);
HistoryReader reader = history.getReader(); HistoryReader reader = history.getReader();
addHistorySearchProgressListeners(reader, 1); addHistorySearchProgressListeners(reader, 1);
QueryResultSet rs = reader.findByStartDate(startDate); QueryResultSet<HistoryRecord> rs
= reader.findByStartDate(startDate);
while (rs.hasNext()) while (rs.hasNext())
{ {
HistoryRecord hr = (HistoryRecord) rs.next(); HistoryRecord hr = rs.next();
result.add(convertHistoryRecordToCallRecord(hr)); result.add(convertHistoryRecordToCallRecord(hr));
} }
removeHistorySearchProgressListeners(reader); removeHistorySearchProgressListeners(reader);
@ -154,10 +155,10 @@ public Collection<CallRecord> findByEndDate(Date endDate) throws RuntimeExceptio
History history = this.getHistory(null, null); History history = this.getHistory(null, null);
HistoryReader reader = history.getReader(); HistoryReader reader = history.getReader();
addHistorySearchProgressListeners(reader, 1); addHistorySearchProgressListeners(reader, 1);
QueryResultSet rs = reader.findByEndDate(endDate); QueryResultSet<HistoryRecord> rs = reader.findByEndDate(endDate);
while (rs.hasNext()) while (rs.hasNext())
{ {
HistoryRecord hr = (HistoryRecord) rs.next(); HistoryRecord hr = rs.next();
result.add(convertHistoryRecordToCallRecord(hr)); result.add(convertHistoryRecordToCallRecord(hr));
} }
removeHistorySearchProgressListeners(reader); removeHistorySearchProgressListeners(reader);
@ -204,10 +205,11 @@ public Collection<CallRecord> findByPeriod(Date startDate, Date endDate) throws
History history = this.getHistory(null, null); History history = this.getHistory(null, null);
HistoryReader reader = history.getReader(); HistoryReader reader = history.getReader();
addHistorySearchProgressListeners(reader, 1); addHistorySearchProgressListeners(reader, 1);
QueryResultSet rs = reader.findByPeriod(startDate, endDate); QueryResultSet<HistoryRecord> rs
= reader.findByPeriod(startDate, endDate);
while (rs.hasNext()) while (rs.hasNext())
{ {
HistoryRecord hr = (HistoryRecord) rs.next(); HistoryRecord hr = rs.next();
result.add(convertHistoryRecordToCallRecord(hr)); result.add(convertHistoryRecordToCallRecord(hr));
} }
removeHistorySearchProgressListeners(reader); removeHistorySearchProgressListeners(reader);
@ -250,10 +252,11 @@ public Collection<CallRecord> findLast(int count) throws RuntimeException
{ {
// the default ones // the default ones
History history = this.getHistory(null, null); History history = this.getHistory(null, null);
QueryResultSet rs = history.getReader().findLast(count); QueryResultSet<HistoryRecord> rs
= history.getReader().findLast(count);
while (rs.hasNext()) while (rs.hasNext())
{ {
HistoryRecord hr = (HistoryRecord) rs.next(); HistoryRecord hr = rs.next();
result.add(convertHistoryRecordToCallRecord(hr)); result.add(convertHistoryRecordToCallRecord(hr));
} }
} }
@ -281,11 +284,11 @@ public Collection<CallRecord> findByPeer(String address)
History history = this.getHistory(null, null); History history = this.getHistory(null, null);
HistoryReader reader = history.getReader(); HistoryReader reader = history.getReader();
addHistorySearchProgressListeners(reader, 1); addHistorySearchProgressListeners(reader, 1);
QueryResultSet rs = QueryResultSet<HistoryRecord> rs
reader.findByKeyword(address, "callParticipantIDs"); = reader.findByKeyword(address, "callParticipantIDs");
while (rs.hasNext()) while (rs.hasNext())
{ {
HistoryRecord hr = (HistoryRecord) rs.next(); HistoryRecord hr = rs.next();
result.add(convertHistoryRecordToCallRecord(hr)); result.add(convertHistoryRecordToCallRecord(hr));
} }
removeHistorySearchProgressListeners(reader); removeHistorySearchProgressListeners(reader);
@ -679,9 +682,8 @@ private void handleProviderAdded(ProtocolProviderService provider)
logger.debug("Adding protocol provider " + provider.getProtocolName()); logger.debug("Adding protocol provider " + provider.getProtocolName());
// check whether the provider has a basic telephony operation set // check whether the provider has a basic telephony operation set
OperationSetBasicTelephony opSetTelephony = OperationSetBasicTelephony opSetTelephony
(OperationSetBasicTelephony) provider = provider.getOperationSet(OperationSetBasicTelephony.class);
.getOperationSet(OperationSetBasicTelephony.class);
if (opSetTelephony != null) if (opSetTelephony != null)
{ {
@ -701,9 +703,8 @@ private void handleProviderAdded(ProtocolProviderService provider)
*/ */
private void handleProviderRemoved(ProtocolProviderService provider) private void handleProviderRemoved(ProtocolProviderService provider)
{ {
OperationSetBasicTelephony opSetTelephony = OperationSetBasicTelephony opSetTelephony
(OperationSetBasicTelephony) provider = provider.getOperationSet(OperationSetBasicTelephony.class);
.getOperationSet(OperationSetBasicTelephony.class);
if (opSetTelephony != null) if (opSetTelephony != null)
{ {

@ -210,9 +210,8 @@ public void stop(BundleContext bc)
//stop listening to all currently installed providers //stop listening to all currently installed providers
for (ProtocolProviderService pp : currentlyInstalledProviders.values()) for (ProtocolProviderService pp : currentlyInstalledProviders.values())
{ {
OperationSetPersistentPresence opSetPersPresence OperationSetPersistentPresence opSetPersPresence =
= (OperationSetPersistentPresence)pp pp.getOperationSet(OperationSetPersistentPresence.class);
.getOperationSet(OperationSetPersistentPresence.class);
if(opSetPersPresence !=null) if(opSetPersPresence !=null)
{ {
@ -226,8 +225,8 @@ public void stop(BundleContext bc)
else else
{ {
//check if a non persistent presence operation set exists. //check if a non persistent presence operation set exists.
OperationSetPresence opSetPresence = (OperationSetPresence)pp OperationSetPresence opSetPresence =
.getOperationSet(OperationSetPresence.class); pp.getOperationSet(OperationSetPresence.class);
if(opSetPresence != null) if(opSetPresence != null)
{ {
@ -357,8 +356,7 @@ private void addNewContactToMetaContact( ProtocolProviderService provider,
throws MetaContactListException throws MetaContactListException
{ {
OperationSetPersistentPresence opSetPersPresence = OperationSetPersistentPresence opSetPersPresence =
(OperationSetPersistentPresence) provider provider.getOperationSet(OperationSetPersistentPresence.class);
.getOperationSet(OperationSetPersistentPresence.class);
if (opSetPersPresence == null) if (opSetPersPresence == null)
{ {
/** @todo handle non-persistent presence operation sets as well */ /** @todo handle non-persistent presence operation sets as well */
@ -507,8 +505,7 @@ private ContactGroup resolveProtoPath(ProtocolProviderService protoProvider,
} }
OperationSetPersistentPresence opSetPersPresence = OperationSetPersistentPresence opSetPersPresence =
(OperationSetPersistentPresence) protoProvider protoProvider.getOperationSet(OperationSetPersistentPresence.class);
.getOperationSet(OperationSetPersistentPresence.class);
//if persistent presence is not supported - just bail //if persistent presence is not supported - just bail
//we should have verified this earlier anyway //we should have verified this earlier anyway
@ -884,9 +881,10 @@ public void moveContact(Contact contact,
currentParentMetaContact.removeProtoContact(contact); currentParentMetaContact.removeProtoContact(contact);
//get a persistent presence operation set //get a persistent presence operation set
OperationSetPersistentPresence opSetPresence = OperationSetPersistentPresence opSetPresence
(OperationSetPersistentPresence) contact.getProtocolProvider() = contact
.getOperationSet(OperationSetPersistentPresence.class); .getProtocolProvider()
.getOperationSet(OperationSetPersistentPresence.class);
if (opSetPresence == null) if (opSetPresence == null)
{ {
@ -985,10 +983,11 @@ public void moveMetaContact(MetaContact metaContact,
.getProtocolProvider(), (MetaContactGroupImpl) newMetaGroup); .getProtocolProvider(), (MetaContactGroupImpl) newMetaGroup);
//get a persistent or non persistent presence operation set //get a persistent or non persistent presence operation set
OperationSetPersistentPresence opSetPresence = OperationSetPersistentPresence opSetPresence
(OperationSetPersistentPresence) protoContact = protoContact
.getProtocolProvider().getOperationSet( .getProtocolProvider()
OperationSetPersistentPresence.class); .getOperationSet(
OperationSetPersistentPresence.class);
if (opSetPresence == null) if (opSetPresence == null)
{ {
@ -1034,9 +1033,10 @@ public void removeContact(Contact contact) throws MetaContactListException
//updating and/or removing the corresponding meta contact would happen //updating and/or removing the corresponding meta contact would happen
//once a confirmation event is received from the underlying protocol //once a confirmation event is received from the underlying protocol
//provider //provider
OperationSetPresence opSetPresence = OperationSetPresence opSetPresence
(OperationSetPresence) contact.getProtocolProvider() = contact
.getOperationSet(OperationSetPresence.class); .getProtocolProvider()
.getOperationSet(OperationSetPresence.class);
//in case the provider only has a persistent operation set: //in case the provider only has a persistent operation set:
if (opSetPresence == null) if (opSetPresence == null)
@ -1139,10 +1139,11 @@ public void removeMetaContactGroup(
{ {
ContactGroup protoGroup = protoGroups.next(); ContactGroup protoGroup = protoGroups.next();
OperationSetPersistentPresence opSetPersPresence = OperationSetPersistentPresence opSetPersPresence
(OperationSetPersistentPresence) protoGroup = protoGroup
.getProtocolProvider().getOperationSet( .getProtocolProvider()
OperationSetPersistentPresence.class); .getOperationSet(
OperationSetPersistentPresence.class);
if (opSetPersPresence == null) if (opSetPersPresence == null)
{ {
@ -1614,8 +1615,7 @@ private synchronized void handleProviderAdded(
// check whether the provider has a persistent presence op set // check whether the provider has a persistent presence op set
OperationSetPersistentPresence opSetPersPresence = OperationSetPersistentPresence opSetPersPresence =
(OperationSetPersistentPresence) provider provider.getOperationSet(OperationSetPersistentPresence.class);
.getOperationSet(OperationSetPersistentPresence.class);
this.currentlyInstalledProviders.put( this.currentlyInstalledProviders.put(
provider.getAccountID().getAccountUniqueID(), provider.getAccountID().getAccountUniqueID(),
@ -1673,9 +1673,8 @@ private void handleProviderRemoved(
remove(provider.getAccountID().getAccountUniqueID()); remove(provider.getAccountID().getAccountUniqueID());
//get the root group for the provider so that we could remove it. //get the root group for the provider so that we could remove it.
OperationSetPersistentPresence persPresOpSet OperationSetPersistentPresence persPresOpSet =
= (OperationSetPersistentPresence)provider provider.getOperationSet(OperationSetPersistentPresence.class);
.getOperationSet(OperationSetPersistentPresence.class);
//ignore if persistent presence is not supported. //ignore if persistent presence is not supported.
if(persPresOpSet == null) if(persPresOpSet == null)
@ -2708,8 +2707,8 @@ ContactGroup loadStoredContactGroup(MetaContactGroupImpl containingMetaGroup,
//get the presence op set //get the presence op set
ProtocolProviderService sourceProvider = ProtocolProviderService sourceProvider =
currentlyInstalledProviders.get(accountID); currentlyInstalledProviders.get(accountID);
OperationSetPersistentPresence presenceOpSet = OperationSetPersistentPresence presenceOpSet
(OperationSetPersistentPresence) sourceProvider = sourceProvider
.getOperationSet(OperationSetPersistentPresence.class); .getOperationSet(OperationSetPersistentPresence.class);
ContactGroup newProtoGroup = presenceOpSet.createUnresolvedContactGroup( ContactGroup newProtoGroup = presenceOpSet.createUnresolvedContactGroup(
@ -2758,8 +2757,8 @@ void loadStoredMetaContact(
//mc //mc
ProtocolProviderService sourceProvider = ProtocolProviderService sourceProvider =
currentlyInstalledProviders.get(accountID); currentlyInstalledProviders.get(accountID);
OperationSetPersistentPresence presenceOpSet = OperationSetPersistentPresence presenceOpSet
(OperationSetPersistentPresence) sourceProvider = sourceProvider
.getOperationSet(OperationSetPersistentPresence.class); .getOperationSet(OperationSetPersistentPresence.class);
for (MclStorageManager.StoredProtoContactDescriptor contactDescriptor for (MclStorageManager.StoredProtoContactDescriptor contactDescriptor

@ -387,8 +387,8 @@ public void addProtocolSupportedOperationSets(
} }
// Obtain the ad-hoc multi user chat operation set. // Obtain the ad-hoc multi user chat operation set.
OperationSetAdHocMultiUserChat adHocMultiChatOpSet = OperationSetAdHocMultiUserChat adHocMultiChatOpSet
(OperationSetAdHocMultiUserChat) protocolProvider = protocolProvider
.getOperationSet(OperationSetAdHocMultiUserChat.class); .getOperationSet(OperationSetAdHocMultiUserChat.class);
if (adHocMultiChatOpSet != null) if (adHocMultiChatOpSet != null)
@ -403,13 +403,11 @@ public void addProtocolSupportedOperationSets(
// Obtain file transfer operation set. // Obtain file transfer operation set.
OperationSetFileTransfer fileTransferOpSet OperationSetFileTransfer fileTransferOpSet
= (OperationSetFileTransfer) protocolProvider = protocolProvider.getOperationSet(OperationSetFileTransfer.class);
.getOperationSet(OperationSetFileTransfer.class);
if (fileTransferOpSet != null) if (fileTransferOpSet != null)
{ {
fileTransferOpSet.addFileTransferListener( fileTransferOpSet.addFileTransferListener(getContactListPanel());
getContactListPanel());
} }
} }

@ -82,18 +82,15 @@ public void addAccount(ProtocolProviderService pps)
} }
else else
{ {
OperationSetPresence presence = OperationSetPresence presence
(OperationSetPresence) pps = pps.getOperationSet(OperationSetPresence.class);
.getOperationSet(OperationSetPresence.class); OperationSetPresence selectedPresence
= selectedProvider.getOperationSet(OperationSetPresence.class);
OperationSetPresence selectedPresence =
(OperationSetPresence) selectedProvider
.getOperationSet(OperationSetPresence.class);
if (presence != null if (presence != null
&& selectedPresence != null && selectedPresence != null
&& (selectedPresence.getPresenceStatus().getStatus() < presence && (selectedPresence.getPresenceStatus().getStatus()
.getPresenceStatus().getStatus())) < presence.getPresenceStatus().getStatus()))
{ {
setSelected(pps); setSelected(pps);
} }

@ -260,7 +260,7 @@ public CreateCallThread(ProtocolProviderService protocolProvider,
public void run() public void run()
{ {
OperationSetBasicTelephony telephonyOpSet OperationSetBasicTelephony telephonyOpSet
= (OperationSetBasicTelephony) protocolProvider = protocolProvider
.getOperationSet(OperationSetBasicTelephony.class); .getOperationSet(OperationSetBasicTelephony.class);
/* /*
@ -326,8 +326,7 @@ public void run()
{ {
CallPeer peer = peers.next(); CallPeer peer = peers.next();
OperationSetBasicTelephony telephony = OperationSetBasicTelephony telephony =
(OperationSetBasicTelephony) pps pps.getOperationSet(OperationSetBasicTelephony.class);
.getOperationSet(OperationSetBasicTelephony.class);
try try
{ {
@ -363,8 +362,7 @@ public CreateConferenceCallThread(
public void run() public void run()
{ {
OperationSetTelephonyConferencing confOpSet OperationSetTelephonyConferencing confOpSet
= (OperationSetTelephonyConferencing) protocolProvider = protocolProvider.getOperationSet(OperationSetTelephonyConferencing.class);
.getOperationSet(OperationSetTelephonyConferencing.class);
/* /*
* XXX If we are here and we just discover that * XXX If we are here and we just discover that

@ -419,16 +419,13 @@ private void sendDtmfTone(DTMFTone dtmfTone)
while (callPeers.hasNext()) while (callPeers.hasNext())
{ {
CallPeer peer = callPeers.next(); CallPeer peer = callPeers.next();
OperationSetDTMF dtmfOpSet
if (peer.getProtocolProvider() = peer
.getOperationSet(OperationSetDTMF.class) != null) .getProtocolProvider()
{
OperationSetDTMF dtmfOpSet
= (OperationSetDTMF) peer.getProtocolProvider()
.getOperationSet(OperationSetDTMF.class); .getOperationSet(OperationSetDTMF.class);
if (dtmfOpSet != null)
dtmfOpSet.sendDTMF(peer, dtmfTone); dtmfOpSet.sendDTMF(peer, dtmfTone);
}
} }
} }
catch (NullPointerException e1) catch (NullPointerException e1)

@ -122,7 +122,7 @@ public void actionPerformed(ActionEvent evt)
if (call != null) if (call != null)
{ {
OperationSetBasicTelephony telephony = OperationSetBasicTelephony telephony =
(OperationSetBasicTelephony) call.getProtocolProvider() call.getProtocolProvider()
.getOperationSet(OperationSetBasicTelephony.class); .getOperationSet(OperationSetBasicTelephony.class);
Iterator<? extends CallPeer> peers = call.getCallPeers(); Iterator<? extends CallPeer> peers = call.getCallPeers();

@ -1,117 +1,117 @@
/* /*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
* *
* Distributable under LGPL license. * Distributable under LGPL license.
* See terms of license at gnu.org. * See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.impl.gui.main.call; package net.java.sip.communicator.impl.gui.main.call;
import java.awt.event.*; import java.awt.event.*;
import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.*;
/** /**
* @author Lubomir Marinov * @author Lubomir Marinov
*/ */
public class LocalVideoButton public class LocalVideoButton
extends SIPCommToggleButton extends SIPCommToggleButton
{ {
private static final Logger logger private static final Logger logger
= Logger.getLogger(LocalVideoButton.class); = Logger.getLogger(LocalVideoButton.class);
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;
/** /**
* Creates a <tt>LocalVideoButton</tt> by specifying the corresponding * Creates a <tt>LocalVideoButton</tt> by specifying the corresponding
* <tt>call</tt>. * <tt>call</tt>.
* @param call the corresponding to this button call * @param call the corresponding to this button call
*/ */
public LocalVideoButton(Call call) public LocalVideoButton(Call call)
{ {
setBgImage(ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG)); setBgImage(ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG));
setBgRolloverImage( setBgRolloverImage(
ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG)); ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG));
setIconImage(ImageLoader.getImage(ImageLoader.LOCAL_VIDEO_BUTTON)); setIconImage(ImageLoader.getImage(ImageLoader.LOCAL_VIDEO_BUTTON));
setPressedImage( setPressedImage(
ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_PRESSED_BG)); ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_PRESSED_BG));
setModel(new LocalVideoButtonModel(call)); setModel(new LocalVideoButtonModel(call));
setToolTipText(GuiActivator.getResources().getI18NString( setToolTipText(GuiActivator.getResources().getI18NString(
"service.gui.LOCAL_VIDEO_BUTTON_TOOL_TIP")); "service.gui.LOCAL_VIDEO_BUTTON_TOOL_TIP"));
} }
private static class LocalVideoButtonModel private static class LocalVideoButtonModel
extends ToggleButtonModel extends ToggleButtonModel
implements ActionListener, implements ActionListener,
Runnable Runnable
{ {
private final Call call; private final Call call;
private Thread runner; private Thread runner;
public LocalVideoButtonModel(Call call) public LocalVideoButtonModel(Call call)
{ {
this.call = call; this.call = call;
addActionListener(this); addActionListener(this);
} }
public synchronized void actionPerformed(ActionEvent event) public synchronized void actionPerformed(ActionEvent event)
{ {
if (runner == null) if (runner == null)
{ {
runner = new Thread(this, LocalVideoButton.class.getName()); runner = new Thread(this, LocalVideoButton.class.getName());
runner.setDaemon(true); runner.setDaemon(true);
setEnabled(false); setEnabled(false);
runner.start(); runner.start();
} }
} }
public void run() public void run()
{ {
try try
{ {
doRun(); doRun();
} }
finally finally
{ {
synchronized (this) synchronized (this)
{ {
if (Thread.currentThread().equals(runner)) if (Thread.currentThread().equals(runner))
{ {
runner = null; runner = null;
setEnabled(true); setEnabled(true);
} }
} }
} }
} }
private void doRun() private void doRun()
{ {
OperationSetVideoTelephony telephony = (OperationSetVideoTelephony) OperationSetVideoTelephony telephony =
call.getProtocolProvider() call.getProtocolProvider()
.getOperationSet(OperationSetVideoTelephony.class); .getOperationSet(OperationSetVideoTelephony.class);
if (telephony != null) if (telephony != null)
{ {
try try
{ {
telephony.setLocalVideoAllowed( telephony.setLocalVideoAllowed(
call, call,
!telephony.isLocalVideoAllowed(call)); !telephony.isLocalVideoAllowed(call));
} }
catch (OperationFailedException ex) catch (OperationFailedException ex)
{ {
logger.error( logger.error(
"Failed to toggle the streaming of local video.", "Failed to toggle the streaming of local video.",
ex); ex);
} }
} }
} }
} }
} }

@ -290,7 +290,7 @@ private OperationSetVideoTelephony addVideoListener()
return null; return null;
final OperationSetVideoTelephony telephony = final OperationSetVideoTelephony telephony =
(OperationSetVideoTelephony) call.getProtocolProvider() call.getProtocolProvider()
.getOperationSet(OperationSetVideoTelephony.class); .getOperationSet(OperationSetVideoTelephony.class);
if (telephony == null) if (telephony == null)
return null; return null;

@ -505,7 +505,7 @@ private void createSecurityPanel(CallPeerSecurityOnEvent event)
if (callPeer != null) if (callPeer != null)
{ {
OperationSetSecureTelephony secure OperationSetSecureTelephony secure
= (OperationSetSecureTelephony) callPeer = callPeer
.getProtocolProvider().getOperationSet( .getProtocolProvider().getOperationSet(
OperationSetSecureTelephony.class); OperationSetSecureTelephony.class);
@ -548,7 +548,7 @@ protected Component createTransferCallButton()
if (callPeer != null) if (callPeer != null)
{ {
OperationSetAdvancedTelephony telephony = OperationSetAdvancedTelephony telephony =
(OperationSetAdvancedTelephony) callPeer.getProtocolProvider() callPeer.getProtocolProvider()
.getOperationSet(OperationSetAdvancedTelephony.class); .getOperationSet(OperationSetAdvancedTelephony.class);
if (telephony != null) if (telephony != null)

@ -53,7 +53,7 @@ public ReceivedCallDialog(Call call)
this.initComponents(); this.initComponents();
OperationSetBasicTelephony telephonyOpSet OperationSetBasicTelephony telephonyOpSet
= (OperationSetBasicTelephony) call.getProtocolProvider() = call.getProtocolProvider()
.getOperationSet(OperationSetBasicTelephony.class); .getOperationSet(OperationSetBasicTelephony.class);
telephonyOpSet.addCallListener(this); telephonyOpSet.addCallListener(this);

@ -65,8 +65,9 @@ public void actionPerformed(ActionEvent e)
if (call != null) if (call != null)
{ {
OperationSetSecureTelephony secure OperationSetSecureTelephony secure
= (OperationSetSecureTelephony) call = call
.getProtocolProvider().getOperationSet( .getProtocolProvider()
.getOperationSet(
OperationSetSecureTelephony.class); OperationSetSecureTelephony.class);
if (secure != null) if (secure != null)

@ -89,7 +89,7 @@ private void actionPerformed(ActionListener listener, ActionEvent evt)
if (call != null) if (call != null)
{ {
OperationSetAdvancedTelephony telephony = OperationSetAdvancedTelephony telephony =
(OperationSetAdvancedTelephony) call.getProtocolProvider() call.getProtocolProvider()
.getOperationSet(OperationSetAdvancedTelephony.class); .getOperationSet(OperationSetAdvancedTelephony.class);
if (telephony != null) if (telephony != null)
@ -222,7 +222,7 @@ private CallPeer findCallPeer(String address)
{ {
ProtocolProviderService service = (ProtocolProviderService) ProtocolProviderService service = (ProtocolProviderService)
bundleContext.getService(serviceReference); bundleContext.getService(serviceReference);
OperationSetBasicTelephony telephony = (OperationSetBasicTelephony) OperationSetBasicTelephony telephony =
service.getOperationSet(telephonyClass); service.getOperationSet(telephonyClass);
if (telephony != null) if (telephony != null)

@ -650,8 +650,7 @@ public ChatRoomWrapper createChatRoom(
ChatRoomWrapper chatRoomWrapper = null; ChatRoomWrapper chatRoomWrapper = null;
OperationSetMultiUserChat groupChatOpSet OperationSetMultiUserChat groupChatOpSet
= (OperationSetMultiUserChat) protocolProvider = protocolProvider.getOperationSet(OperationSetMultiUserChat.class);
.getOperationSet(OperationSetMultiUserChat.class);
// If there's no group chat operation set we have nothing to do here. // If there's no group chat operation set we have nothing to do here.
if (groupChatOpSet == null) if (groupChatOpSet == null)
@ -661,10 +660,9 @@ public ChatRoomWrapper createChatRoom(
try try
{ {
Map<String, Object> members = new Hashtable<String, Object>(); Map<String, Object> members = new Hashtable<String, Object>();
OperationSetPersistentPresence opSet = OperationSetPersistentPresence opSet
(OperationSetPersistentPresence) = protocolProvider
protocolProvider.getOperationSet( .getOperationSet(OperationSetPersistentPresence.class);
OperationSetPersistentPresence.class);
for(String contact : contacts) for(String contact : contacts)
{ {
@ -733,7 +731,7 @@ public AdHocChatRoomWrapper createAdHocChatRoom(
AdHocChatRoomWrapper chatRoomWrapper = null; AdHocChatRoomWrapper chatRoomWrapper = null;
OperationSetAdHocMultiUserChat groupChatOpSet OperationSetAdHocMultiUserChat groupChatOpSet
= (OperationSetAdHocMultiUserChat) protocolProvider = protocolProvider
.getOperationSet(OperationSetAdHocMultiUserChat.class); .getOperationSet(OperationSetAdHocMultiUserChat.class);
// If there's no group chat operation set we have nothing to do here. // If there's no group chat operation set we have nothing to do here.
@ -746,7 +744,6 @@ public AdHocChatRoomWrapper createAdHocChatRoom(
{ {
List<Contact> members = new LinkedList<Contact>(); List<Contact> members = new LinkedList<Contact>();
OperationSetPersistentPresence opSet = OperationSetPersistentPresence opSet =
(OperationSetPersistentPresence)
protocolProvider.getOperationSet( protocolProvider.getOperationSet(
OperationSetPersistentPresence.class); OperationSetPersistentPresence.class);
@ -1645,8 +1642,8 @@ private static class FindRoomTask
public ChatRoom doInBackground() public ChatRoom doInBackground()
{ {
OperationSetMultiUserChat groupChatOpSet OperationSetMultiUserChat groupChatOpSet
= (OperationSetMultiUserChat) chatRoomProvider = chatRoomProvider
.getProtocolProvider().getOperationSet( .getProtocolProvider().getOperationSet(
OperationSetMultiUserChat.class); OperationSetMultiUserChat.class);
ChatRoom chatRoom = null; ChatRoom chatRoom = null;
@ -1687,7 +1684,7 @@ public List<String> doInBackground()
return null; return null;
OperationSetMultiUserChat groupChatOpSet OperationSetMultiUserChat groupChatOpSet
= (OperationSetMultiUserChat) protocolProvider = protocolProvider
.getOperationSet(OperationSetMultiUserChat.class); .getOperationSet(OperationSetMultiUserChat.class);
if (groupChatOpSet == null) if (groupChatOpSet == null)

@ -149,11 +149,10 @@ public HistoryWindow(Object historyContact)
Contact protoContact = protoContacts.next(); Contact protoContact = protoContacts.next();
OperationSetBasicInstantMessaging basicInstantMessaging OperationSetBasicInstantMessaging basicInstantMessaging
= (OperationSetBasicInstantMessaging) = protoContact
protoContact .getProtocolProvider()
.getProtocolProvider() .getOperationSet(
.getOperationSet( OperationSetBasicInstantMessaging.class);
OperationSetBasicInstantMessaging.class);
if (basicInstantMessaging != null) if (basicInstantMessaging != null)
{ {

@ -155,9 +155,8 @@ public void contactClicked(ContactListEvent evt)
= defaultContact.getProtocolProvider(); = defaultContact.getProtocolProvider();
OperationSetBasicInstantMessaging OperationSetBasicInstantMessaging
defaultIM = (OperationSetBasicInstantMessaging) defaultIM = defaultProvider.getOperationSet(
defaultProvider.getOperationSet( OperationSetBasicInstantMessaging.class);
OperationSetBasicInstantMessaging.class);
ProtocolProviderService protoContactProvider; ProtocolProviderService protoContactProvider;
OperationSetBasicInstantMessaging protoContactIM; OperationSetBasicInstantMessaging protoContactIM;
@ -177,9 +176,8 @@ public void contactClicked(ContactListEvent evt)
protoContactProvider = contact.getProtocolProvider(); protoContactProvider = contact.getProtocolProvider();
protoContactIM = (OperationSetBasicInstantMessaging) protoContactIM = protoContactProvider.getOperationSet(
protoContactProvider.getOperationSet( OperationSetBasicInstantMessaging.class);
OperationSetBasicInstantMessaging.class);
if(protoContactIM != null if(protoContactIM != null
&& protoContactIM.isOfflineMessagingSupported() && protoContactIM.isOfflineMessagingSupported()

@ -46,7 +46,7 @@ public ContactListTransferHandler(DefaultContactList contactList)
* @param t the data to import * @param t the data to import
* @return <tt>true</tt> if the data was inserted into the component; * @return <tt>true</tt> if the data was inserted into the component;
* <tt>false</tt>, otherwise * <tt>false</tt>, otherwise
* @see TransferHandler#importData(JComponent. Transferable) * @see TransferHandler#importData(JComponent, Transferable)
*/ */
@SuppressWarnings("unchecked") //taken care of @SuppressWarnings("unchecked") //taken care of
public boolean importData(JComponent comp, Transferable t) public boolean importData(JComponent comp, Transferable t)

@ -162,10 +162,8 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
* to do anything useful can be prevented. * to do anything useful can be prevented.
*/ */
final OperationSetServerStoredAccountInfo accountInfoOpSet final OperationSetServerStoredAccountInfo accountInfoOpSet
= (OperationSetServerStoredAccountInfo) = protocolProvider.getOperationSet(
protocolProvider OperationSetServerStoredAccountInfo.class);
.getOperationSet(
OperationSetServerStoredAccountInfo.class);
if (accountInfoOpSet != null) if (accountInfoOpSet != null)

@ -68,8 +68,7 @@ public PresenceStatusMenu(ProtocolProviderService protocolProvider)
this.protocolProvider = protocolProvider; this.protocolProvider = protocolProvider;
this.presence this.presence
= (OperationSetPresence) protocolProvider = protocolProvider.getOperationSet(OperationSetPresence.class);
.getOperationSet(OperationSetPresence.class);
this.statusIterator = this.presence.getSupportedStatusSet(); this.statusIterator = this.presence.getSupportedStatusSet();

@ -1341,8 +1341,7 @@ public static ImageIcon getAccountStatusImage(ProtocolProviderService pps)
ImageIcon statusIcon; ImageIcon statusIcon;
OperationSetPresence presence OperationSetPresence presence
= (OperationSetPresence) pps = pps.getOperationSet(OperationSetPresence.class);
.getOperationSet(OperationSetPresence.class);
Image statusImage; Image statusImage;
if (presence != null) if (presence != null)

@ -138,7 +138,7 @@ public void mouseClicked(MouseEvent e)
if (e.getClickCount() > 1) if (e.getClickCount() > 1)
{ {
Object[] metaContacts Object[] metaContacts
= (Object[]) selectedContactList.getSelectedValues(); = selectedContactList.getSelectedValues();
moveContactsFromRightToLeft(metaContacts); moveContactsFromRightToLeft(metaContacts);
} }
@ -189,8 +189,7 @@ public void mouseClicked(MouseEvent e)
{ {
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
Object[] metaContacts Object[] metaContacts = contactList.getSelectedValues();
= (Object[]) contactList.getSelectedValues();
if (metaContacts != null && metaContacts.length > 0) if (metaContacts != null && metaContacts.length > 0)
moveContactsFromLeftToRight(metaContacts); moveContactsFromLeftToRight(metaContacts);
@ -201,8 +200,7 @@ public void actionPerformed(ActionEvent e)
{ {
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
Object[] metaContacts Object[] metaContacts = selectedContactList.getSelectedValues();
= (Object[]) selectedContactList.getSelectedValues();
if (metaContacts != null && metaContacts.length > 0) if (metaContacts != null && metaContacts.length > 0)
moveContactsFromRightToLeft(metaContacts); moveContactsFromRightToLeft(metaContacts);

@ -484,7 +484,7 @@ public void cleanup()
* The data output stream calls this method to transform outgoing * The data output stream calls this method to transform outgoing
* packets. * packets.
* *
* @see PacketTransformer#transform(net.java.sip.communicator.impl.media.transform.RawPacket) * @see PacketTransformer#transform(RawPacket)
*/ */
public RawPacket transform(RawPacket pkt) public RawPacket transform(RawPacket pkt)
{ {
@ -521,7 +521,7 @@ public RawPacket transform(RawPacket pkt)
* The input data stream calls this method to transform * The input data stream calls this method to transform
* incoming packets. * incoming packets.
* *
* @see PacketTransformer#reverseTransform(net.java.sip.communicator.impl.media.transform.RawPacket) * @see PacketTransformer#reverseTransform(RawPacket)
*/ */
public RawPacket reverseTransform(RawPacket pkt) public RawPacket reverseTransform(RawPacket pkt)
{ {

@ -1064,8 +1064,7 @@ private void handleProviderAdded(ProtocolProviderService provider)
// check whether the provider has a basic im operation set // check whether the provider has a basic im operation set
OperationSetBasicInstantMessaging opSetIm = OperationSetBasicInstantMessaging opSetIm =
(OperationSetBasicInstantMessaging) provider provider.getOperationSet(OperationSetBasicInstantMessaging.class);
.getOperationSet(OperationSetBasicInstantMessaging.class);
if (opSetIm != null) if (opSetIm != null)
{ {
@ -1077,8 +1076,7 @@ private void handleProviderAdded(ProtocolProviderService provider)
} }
OperationSetMultiUserChat opSetMultiUChat = OperationSetMultiUserChat opSetMultiUChat =
(OperationSetMultiUserChat) provider provider.getOperationSet(OperationSetMultiUserChat.class);
.getOperationSet(OperationSetMultiUserChat.class);
if (opSetMultiUChat != null) if (opSetMultiUChat != null)
{ {
@ -1108,8 +1106,7 @@ private void handleProviderAdded(ProtocolProviderService provider)
private void handleProviderRemoved(ProtocolProviderService provider) private void handleProviderRemoved(ProtocolProviderService provider)
{ {
OperationSetBasicInstantMessaging opSetIm = OperationSetBasicInstantMessaging opSetIm =
(OperationSetBasicInstantMessaging) provider provider.getOperationSet(OperationSetBasicInstantMessaging.class);
.getOperationSet(OperationSetBasicInstantMessaging.class);
if (opSetIm != null) if (opSetIm != null)
{ {
@ -1117,8 +1114,7 @@ private void handleProviderRemoved(ProtocolProviderService provider)
} }
OperationSetMultiUserChat opSetMultiUChat = OperationSetMultiUserChat opSetMultiUChat =
(OperationSetMultiUserChat) provider provider.getOperationSet(OperationSetMultiUserChat.class);
.getOperationSet(OperationSetMultiUserChat.class);
if (opSetMultiUChat != null) if (opSetMultiUChat != null)
{ {

@ -93,8 +93,8 @@ public Object getMenu()
private void addAccount(ProtocolProviderService protocolProvider) private void addAccount(ProtocolProviderService protocolProvider)
{ {
OperationSetPresence presence OperationSetPresence presence
= (OperationSetPresence) = protocolProvider.getOperationSet(OperationSetPresence.class);
protocolProvider.getOperationSet(OperationSetPresence.class);
boolean swing = (menu instanceof JComponent); boolean swing = (menu instanceof JComponent);
if (presence == null) if (presence == null)
@ -157,8 +157,8 @@ private void removeAccount(ProtocolProviderService protocolProvider)
* addAccount(ProtocolProviderService). * addAccount(ProtocolProviderService).
*/ */
OperationSetPresence presence OperationSetPresence presence
= (OperationSetPresence) = protocolProvider.getOperationSet(OperationSetPresence.class);
protocolProvider.getOperationSet(OperationSetPresence.class);
if (presence != null) if (presence != null)
presence.removeProviderPresenceStatusListener(this); presence.removeProviderPresenceStatusListener(this);
else else

@ -1,416 +1,416 @@
/* /*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
* *
* Distributable under LGPL license. * Distributable under LGPL license.
* See terms of license at gnu.org. * See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.impl.protocol; package net.java.sip.communicator.impl.protocol;
import java.util.*; import java.util.*;
import org.osgi.framework.*; import org.osgi.framework.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
/** /**
* Imposes the policy to have one call in progress i.e. to put existing calls on * Imposes the policy to have one call in progress i.e. to put existing calls on
* hold when a new call enters in progress. * hold when a new call enters in progress.
* *
* @author Lubomir Marinov * @author Lubomir Marinov
*/ */
public class SingleCallInProgressPolicy public class SingleCallInProgressPolicy
{ {
/** /**
* The name of the configuration property which specifies whether * The name of the configuration property which specifies whether
* <code>SingleCallInProgressPolicy</code> is enabled i.e. whether it should * <code>SingleCallInProgressPolicy</code> is enabled i.e. whether it should
* put existing calls on hold when a new call enters in progress. * put existing calls on hold when a new call enters in progress.
*/ */
private static final String PNAME_SINGLE_CALL_IN_PROGRESS_POLICY_ENABLED private static final String PNAME_SINGLE_CALL_IN_PROGRESS_POLICY_ENABLED
= "net.java.sip.communicator.impl.protocol.SingleCallInProgressPolicy.enabled"; = "net.java.sip.communicator.impl.protocol.SingleCallInProgressPolicy.enabled";
/** /**
* Implements the listeners interfaces used by this policy. * Implements the listeners interfaces used by this policy.
*/ */
private class SingleCallInProgressPolicyListener private class SingleCallInProgressPolicyListener
implements CallChangeListener, implements CallChangeListener,
CallListener, CallListener,
ServiceListener ServiceListener
{ {
/** /**
* Stops tracking the state of a specific <code>Call</code> and no * Stops tracking the state of a specific <code>Call</code> and no
* longer tries to put it on hold when it ends. * longer tries to put it on hold when it ends.
* *
* @see CallListener#callEnded(CallEvent) * @see CallListener#callEnded(CallEvent)
*/ */
public void callEnded(CallEvent callEvent) public void callEnded(CallEvent callEvent)
{ {
SingleCallInProgressPolicy.this.handleCallEvent( SingleCallInProgressPolicy.this.handleCallEvent(
CallEvent.CALL_ENDED, callEvent); CallEvent.CALL_ENDED, callEvent);
} }
/** /**
* Does nothing because adding <code>CallPeer<code>s to * Does nothing because adding <code>CallPeer<code>s to
* <code>Call</code>s isn't related to the policy to put existing calls * <code>Call</code>s isn't related to the policy to put existing calls
* on hold when a new call becomes in-progress and just implements * on hold when a new call becomes in-progress and just implements
* <code>CallChangeListener</code>. * <code>CallChangeListener</code>.
* *
* @see CallChangeListener#callPeerAdded(CallPeerEvent) * @see CallChangeListener#callPeerAdded(CallPeerEvent)
*/ */
public void callPeerAdded( CallPeerEvent callPeerEvent) public void callPeerAdded( CallPeerEvent callPeerEvent)
{ {
/* /*
* Not of interest, just implementing CallChangeListener in which * Not of interest, just implementing CallChangeListener in which
* only #callStateChanged(CallChangeEvent) is of interest. * only #callStateChanged(CallChangeEvent) is of interest.
*/ */
} }
/** /**
* Does nothing because removing <code>CallPeer<code>s to * Does nothing because removing <code>CallPeer<code>s to
* <code>Call</code>s isn't related to the policy to put existing calls * <code>Call</code>s isn't related to the policy to put existing calls
* on hold when a new call becomes in-progress and just implements * on hold when a new call becomes in-progress and just implements
* <code>CallChangeListener</code>. * <code>CallChangeListener</code>.
* *
* @see CallChangeListener#callPeerRemoved(CallPeerEvent) * @see CallChangeListener#callPeerRemoved(CallPeerEvent)
*/ */
public void callPeerRemoved( CallPeerEvent callPeerEvent) public void callPeerRemoved( CallPeerEvent callPeerEvent)
{ {
/* /*
* Not of interest, just implementing CallChangeListener in which * Not of interest, just implementing CallChangeListener in which
* only #callStateChanged(CallChangeEvent) is of interest. * only #callStateChanged(CallChangeEvent) is of interest.
*/ */
} }
/** /**
* Upon a <code>Call</code> changing its state to * Upon a <code>Call</code> changing its state to
* <code>CallState.CALL_IN_PROGRESS</code>, puts the other existing * <code>CallState.CALL_IN_PROGRESS</code>, puts the other existing
* <code>Call</code>s on hold. * <code>Call</code>s on hold.
* *
* @param callChangeEvent the <tt>CallChangeEvent</tt> that we are to * @param callChangeEvent the <tt>CallChangeEvent</tt> that we are to
* deliver. * deliver.
* *
* @see CallChangeListener#callStateChanged(CallChangeEvent) * @see CallChangeListener#callStateChanged(CallChangeEvent)
*/ */
public void callStateChanged(CallChangeEvent callChangeEvent) public void callStateChanged(CallChangeEvent callChangeEvent)
{ {
SingleCallInProgressPolicy.this.callStateChanged(callChangeEvent); SingleCallInProgressPolicy.this.callStateChanged(callChangeEvent);
} }
/** /**
* Remembers an incoming <code>Call</code> so that it can put the other * Remembers an incoming <code>Call</code> so that it can put the other
* existing <code>Call</code>s on hold when it changes its state to * existing <code>Call</code>s on hold when it changes its state to
* <code>CallState.CALL_IN_PROGRESS</code>. * <code>CallState.CALL_IN_PROGRESS</code>.
* *
* @see CallListener#incomingCallReceived(CallEvent) * @see CallListener#incomingCallReceived(CallEvent)
*/ */
public void incomingCallReceived(CallEvent callEvent) public void incomingCallReceived(CallEvent callEvent)
{ {
SingleCallInProgressPolicy.this.handleCallEvent( SingleCallInProgressPolicy.this.handleCallEvent(
CallEvent.CALL_RECEIVED, callEvent); CallEvent.CALL_RECEIVED, callEvent);
} }
/** /**
* Remembers an outgoing <code>Call</code> so that it can put the other * Remembers an outgoing <code>Call</code> so that it can put the other
* existing <code>Call</code>s on hold when it changes its state to * existing <code>Call</code>s on hold when it changes its state to
* <code>CallState.CALL_IN_PROGRESS</code>. * <code>CallState.CALL_IN_PROGRESS</code>.
* *
* @see CallListener#outgoingCallCreated(CallEvent) * @see CallListener#outgoingCallCreated(CallEvent)
*/ */
public void outgoingCallCreated(CallEvent callEvent) public void outgoingCallCreated(CallEvent callEvent)
{ {
SingleCallInProgressPolicy.this.handleCallEvent( SingleCallInProgressPolicy.this.handleCallEvent(
CallEvent.CALL_INITIATED, callEvent); CallEvent.CALL_INITIATED, callEvent);
} }
/** /**
* Starts/stops tracking the new <code>Call</code>s originating from a * Starts/stops tracking the new <code>Call</code>s originating from a
* specific <code>ProtocolProviderService</code> when it * specific <code>ProtocolProviderService</code> when it
* registers/unregisters in order to take them into account when putting * registers/unregisters in order to take them into account when putting
* existing calls on hold upon a new call entering its in-progress * existing calls on hold upon a new call entering its in-progress
* state. * state.
* *
* @param serviceEvent * @param serviceEvent
* the <code>ServiceEvent</code> event describing a change in * the <code>ServiceEvent</code> event describing a change in
* the state of a service registration which may be a * the state of a service registration which may be a
* <code>ProtocolProviderService</code> supporting * <code>ProtocolProviderService</code> supporting
* <code>OperationSetBasicTelephony</code> and thus being * <code>OperationSetBasicTelephony</code> and thus being
* able to create new <code>Call</code>s * able to create new <code>Call</code>s
*/ */
public void serviceChanged(ServiceEvent serviceEvent) public void serviceChanged(ServiceEvent serviceEvent)
{ {
SingleCallInProgressPolicy.this.serviceChanged(serviceEvent); SingleCallInProgressPolicy.this.serviceChanged(serviceEvent);
} }
} }
/** /**
* Our class logger * Our class logger
*/ */
private static final Logger logger = private static final Logger logger =
Logger.getLogger(SingleCallInProgressPolicy.class); Logger.getLogger(SingleCallInProgressPolicy.class);
/** /**
* The <code>BundleContext</code> to the Calls of which this policy applies. * The <code>BundleContext</code> to the Calls of which this policy applies.
*/ */
private final BundleContext bundleContext; private final BundleContext bundleContext;
/** /**
* The <code>Call</code>s this policy manages i.e. put on hold when one of * The <code>Call</code>s this policy manages i.e. put on hold when one of
* them enters in progress. * them enters in progress.
*/ */
private final List<Call> calls = new ArrayList<Call>(); private final List<Call> calls = new ArrayList<Call>();
/** /**
* The listener utilized by this policy to discover new <code>Call</code> * The listener utilized by this policy to discover new <code>Call</code>
* and track their in-progress state. * and track their in-progress state.
*/ */
private final SingleCallInProgressPolicyListener listener = private final SingleCallInProgressPolicyListener listener =
new SingleCallInProgressPolicyListener(); new SingleCallInProgressPolicyListener();
/** /**
* Initializes a new <code>SingleCallInProgressPolicy</code> instance which * Initializes a new <code>SingleCallInProgressPolicy</code> instance which
* will apply to the <code>Call</code>s of a specific * will apply to the <code>Call</code>s of a specific
* <code>BundleContext</code>. * <code>BundleContext</code>.
* *
* @param bundleContext * @param bundleContext
* the <code>BundleContext</code> to the * the <code>BundleContext</code> to the
* <code>Call<code>s of which the new policy should apply * <code>Call<code>s of which the new policy should apply
*/ */
public SingleCallInProgressPolicy(BundleContext bundleContext) public SingleCallInProgressPolicy(BundleContext bundleContext)
{ {
this.bundleContext = bundleContext; this.bundleContext = bundleContext;
this.bundleContext.addServiceListener(listener); this.bundleContext.addServiceListener(listener);
} }
/** /**
* Registers a specific <code>Call</code> with this policy in order to have * Registers a specific <code>Call</code> with this policy in order to have
* the rules of the latter apply to the former. * the rules of the latter apply to the former.
* *
* @param call * @param call
* the <code>Call</code> to register with this policy in order to * the <code>Call</code> to register with this policy in order to
* have the rules of the latter apply to the former * have the rules of the latter apply to the former
*/ */
private void addCallListener(Call call) private void addCallListener(Call call)
{ {
synchronized (calls) synchronized (calls)
{ {
if (!calls.contains(call)) if (!calls.contains(call))
{ {
CallState callState = call.getCallState(); CallState callState = call.getCallState();
if ((callState != null) if ((callState != null)
&& !callState.equals(CallState.CALL_ENDED)) && !callState.equals(CallState.CALL_ENDED))
{ {
calls.add(call); calls.add(call);
} }
} }
} }
call.addCallChangeListener(listener); call.addCallChangeListener(listener);
} }
/** /**
* Registers a specific <code>OperationSetBasicTelephony</code> with this * Registers a specific <code>OperationSetBasicTelephony</code> with this
* policy in order to have the rules of the latter apply to the * policy in order to have the rules of the latter apply to the
* <code>Call</code>s created by the former. * <code>Call</code>s created by the former.
* *
* @param telephony * @param telephony
* the <code>OperationSetBasicTelephony</code> to register with * the <code>OperationSetBasicTelephony</code> to register with
* this policy in order to have the rules of the latter apply to * this policy in order to have the rules of the latter apply to
* the <code>Call</code>s created by the former * the <code>Call</code>s created by the former
*/ */
private void addOperationSetBasicTelephonyListener( private void addOperationSetBasicTelephonyListener(
OperationSetBasicTelephony telephony) OperationSetBasicTelephony telephony)
{ {
telephony.addCallListener(listener); telephony.addCallListener(listener);
} }
/** /**
* Handles changes in the state of a <code>Call</code> this policy applies * Handles changes in the state of a <code>Call</code> this policy applies
* to in order to detect when new calls become in-progress and when the * to in order to detect when new calls become in-progress and when the
* other calls should be put on hold. * other calls should be put on hold.
* *
* @param callChangeEvent * @param callChangeEvent
* a <code>CallChangeEvent</code> value which describes the * a <code>CallChangeEvent</code> value which describes the
* <code>Call</code> and the change in its state * <code>Call</code> and the change in its state
*/ */
private void callStateChanged(CallChangeEvent callChangeEvent) private void callStateChanged(CallChangeEvent callChangeEvent)
{ {
Call call = callChangeEvent.getSourceCall(); Call call = callChangeEvent.getSourceCall();
if (CallState.CALL_INITIALIZATION.equals(callChangeEvent.getOldValue()) if (CallState.CALL_INITIALIZATION.equals(callChangeEvent.getOldValue())
&& CallState.CALL_IN_PROGRESS.equals(call.getCallState()) && CallState.CALL_IN_PROGRESS.equals(call.getCallState())
&& ProtocolProviderActivator && ProtocolProviderActivator
.getConfigurationService() .getConfigurationService()
.getBoolean( .getBoolean(
PNAME_SINGLE_CALL_IN_PROGRESS_POLICY_ENABLED, PNAME_SINGLE_CALL_IN_PROGRESS_POLICY_ENABLED,
true)) true))
{ {
synchronized (calls) synchronized (calls)
{ {
for (Call otherCall : calls) for (Call otherCall : calls)
if (!call.equals(otherCall) if (!call.equals(otherCall)
&& CallState.CALL_IN_PROGRESS && CallState.CALL_IN_PROGRESS
.equals(otherCall.getCallState())) .equals(otherCall.getCallState()))
putOnHold(otherCall); putOnHold(otherCall);
} }
} }
} }
/** /**
* Performs end-of-life cleanup associated with this instance e.g. removes * Performs end-of-life cleanup associated with this instance e.g. removes
* added listeners. * added listeners.
*/ */
public void dispose() public void dispose()
{ {
bundleContext.removeServiceListener(listener); bundleContext.removeServiceListener(listener);
} }
/** /**
* Handles the start and end of the <code>Call</code>s this policy applies * Handles the start and end of the <code>Call</code>s this policy applies
* to in order to have them or stop having them put the other existing calls * to in order to have them or stop having them put the other existing calls
* on hold when the former change their states to * on hold when the former change their states to
* <code>CallState.CALL_IN_PROGRESS</code>. * <code>CallState.CALL_IN_PROGRESS</code>.
* *
* @param type * @param type
* one of {@link CallEvent#CALL_ENDED}, * one of {@link CallEvent#CALL_ENDED},
* {@link CallEvent#CALL_INITIATED} and * {@link CallEvent#CALL_INITIATED} and
* {@link CallEvent#CALL_RECEIVED} which described the type of * {@link CallEvent#CALL_RECEIVED} which described the type of
* the event to be handled * the event to be handled
* @param callEvent * @param callEvent
* a <code>CallEvent</code> value which describes the change and * a <code>CallEvent</code> value which describes the change and
* the <code>Call</code> associated with it * the <code>Call</code> associated with it
*/ */
private void handleCallEvent(int type, CallEvent callEvent) private void handleCallEvent(int type, CallEvent callEvent)
{ {
Call call = callEvent.getSourceCall(); Call call = callEvent.getSourceCall();
switch (type) switch (type)
{ {
case CallEvent.CALL_ENDED: case CallEvent.CALL_ENDED:
removeCallListener(call); removeCallListener(call);
break; break;
case CallEvent.CALL_INITIATED: case CallEvent.CALL_INITIATED:
case CallEvent.CALL_RECEIVED: case CallEvent.CALL_RECEIVED:
addCallListener(call); addCallListener(call);
break; break;
} }
} }
/** /**
* Puts the <code>CallPeer</code>s of a specific <code>Call</code> on * Puts the <code>CallPeer</code>s of a specific <code>Call</code> on
* hold. * hold.
* *
* @param call * @param call
* the <code>Call</code> the <code>CallPeer</code>s of * the <code>Call</code> the <code>CallPeer</code>s of
* which are to be put on hold * which are to be put on hold
*/ */
private void putOnHold(Call call) private void putOnHold(Call call)
{ {
OperationSetBasicTelephony telephony = OperationSetBasicTelephony telephony =
(OperationSetBasicTelephony) call.getProtocolProvider() call.getProtocolProvider()
.getOperationSet(OperationSetBasicTelephony.class); .getOperationSet(OperationSetBasicTelephony.class);
if (telephony != null) if (telephony != null)
{ {
for (Iterator<? extends CallPeer> peerIter = for (Iterator<? extends CallPeer> peerIter =
call.getCallPeers(); peerIter.hasNext();) call.getCallPeers(); peerIter.hasNext();)
{ {
CallPeer peer = peerIter.next(); CallPeer peer = peerIter.next();
CallPeerState peerState = peer.getState(); CallPeerState peerState = peer.getState();
if (!CallPeerState.DISCONNECTED.equals(peerState) if (!CallPeerState.DISCONNECTED.equals(peerState)
&& !CallPeerState.FAILED.equals(peerState) && !CallPeerState.FAILED.equals(peerState)
&& !CallPeerState.isOnHold(peerState)) && !CallPeerState.isOnHold(peerState))
{ {
try try
{ {
telephony.putOnHold(peer); telephony.putOnHold(peer);
} }
catch (OperationFailedException ex) catch (OperationFailedException ex)
{ {
logger.error("Failed to put " + peer logger.error("Failed to put " + peer
+ " on hold.", ex); + " on hold.", ex);
} }
} }
} }
} }
} }
/** /**
* Unregisters a specific <code>Call</code> from this policy in order to * Unregisters a specific <code>Call</code> from this policy in order to
* have the rules of the latter no longer applied to the former. * have the rules of the latter no longer applied to the former.
* *
* @param call * @param call
* the <code>Call</code> to unregister from this policy in order * the <code>Call</code> to unregister from this policy in order
* to have the rules of the latter no longer apply to the former * to have the rules of the latter no longer apply to the former
*/ */
private void removeCallListener(Call call) private void removeCallListener(Call call)
{ {
call.removeCallChangeListener(listener); call.removeCallChangeListener(listener);
synchronized (calls) synchronized (calls)
{ {
calls.remove(call); calls.remove(call);
} }
} }
/** /**
* Unregisters a specific <code>OperationSetBasicTelephony</code> from this * Unregisters a specific <code>OperationSetBasicTelephony</code> from this
* policy in order to have the rules of the latter no longer apply to the * policy in order to have the rules of the latter no longer apply to the
* <code>Call</code>s created by the former. * <code>Call</code>s created by the former.
* *
* @param telephony * @param telephony
* the <code>OperationSetBasicTelephony</code> to unregister from * the <code>OperationSetBasicTelephony</code> to unregister from
* this policy in order to have the rules of the latter apply to * this policy in order to have the rules of the latter apply to
* the <code>Call</code>s created by the former * the <code>Call</code>s created by the former
*/ */
private void removeOperationSetBasicTelephonyListener( private void removeOperationSetBasicTelephonyListener(
OperationSetBasicTelephony telephony) OperationSetBasicTelephony telephony)
{ {
telephony.removeCallListener(listener); telephony.removeCallListener(listener);
} }
/** /**
* Handles the registering and unregistering of * Handles the registering and unregistering of
* <code>OperationSetBasicTelephony</code> instances in order to apply or * <code>OperationSetBasicTelephony</code> instances in order to apply or
* unapply the rules of this policy to the <code>Call</code>s originating * unapply the rules of this policy to the <code>Call</code>s originating
* from them. * from them.
* *
* @param serviceEvent * @param serviceEvent
* a <code>ServiceEvent</code> value which described a change in * a <code>ServiceEvent</code> value which described a change in
* a OSGi service and which is to be examined for the registering * a OSGi service and which is to be examined for the registering
* or unregistering of a <code>ProtocolProviderService</code> and * or unregistering of a <code>ProtocolProviderService</code> and
* thus a <code>OperationSetBasicTelephony</code> * thus a <code>OperationSetBasicTelephony</code>
*/ */
private void serviceChanged(ServiceEvent serviceEvent) private void serviceChanged(ServiceEvent serviceEvent)
{ {
Object service = Object service =
bundleContext.getService(serviceEvent.getServiceReference()); bundleContext.getService(serviceEvent.getServiceReference());
if (service instanceof ProtocolProviderService) if (service instanceof ProtocolProviderService)
{ {
OperationSetBasicTelephony telephony = OperationSetBasicTelephony telephony =
(OperationSetBasicTelephony) ((ProtocolProviderService) service) ((ProtocolProviderService) service)
.getOperationSet(OperationSetBasicTelephony.class); .getOperationSet(OperationSetBasicTelephony.class);
if (telephony != null) if (telephony != null)
{ {
switch (serviceEvent.getType()) switch (serviceEvent.getType())
{ {
case ServiceEvent.REGISTERED: case ServiceEvent.REGISTERED:
addOperationSetBasicTelephonyListener(telephony); addOperationSetBasicTelephonyListener(telephony);
break; break;
case ServiceEvent.UNREGISTERING: case ServiceEvent.UNREGISTERING:
removeOperationSetBasicTelephonyListener(telephony); removeOperationSetBasicTelephonyListener(telephony);
break; break;
} }
} }
} }
} }
} }

@ -1,396 +1,395 @@
/* /*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
* *
* Distributable under LGPL license. See terms of license at gnu.org. * Distributable under LGPL license. See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.impl.protocol.facebook; package net.java.sip.communicator.impl.protocol.facebook;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import org.apache.http.*; import org.apache.http.*;
import org.json.*; import org.json.*;
/** /**
* Adapter for the Facebook protocol. This class works as a bridge between the * Adapter for the Facebook protocol. This class works as a bridge between the
* Facebook specific classes and the sip communication interfaces. It manages * Facebook specific classes and the sip communication interfaces. It manages
* the lifecycle of the classes responsible of accessing Facebook servers and * the lifecycle of the classes responsible of accessing Facebook servers and
* also manage the necessary {@link Thread threads} used to update the state * also manage the necessary {@link Thread threads} used to update the state
* with the latest server changes. * with the latest server changes.
* *
* @author Dai Zhiwei * @author Dai Zhiwei
* @author Lubomir Marinov * @author Lubomir Marinov
* @author Edgar Poce * @author Edgar Poce
*/ */
public class FacebookAdapter public class FacebookAdapter
implements FacebookSessionListener implements FacebookSessionListener
{ {
private static Logger logger = Logger.getLogger(FacebookAdapter.class); private static Logger logger = Logger.getLogger(FacebookAdapter.class);
private final OperationSetBasicInstantMessagingFacebookImpl private final OperationSetBasicInstantMessagingFacebookImpl
basicInstantMessaging; basicInstantMessaging;
/** /**
* Parent service provider * Parent service provider
*/ */
private final ProtocolProviderServiceFacebookImpl parentProvider; private final ProtocolProviderServiceFacebookImpl parentProvider;
private final OperationSetPersistentPresenceFacebookImpl persistentPresence; private final OperationSetPersistentPresenceFacebookImpl persistentPresence;
/** /**
* The Facebook session * The Facebook session
*/ */
private FacebookSession session; private FacebookSession session;
private final OperationSetTypingNotificationsFacebookImpl private final OperationSetTypingNotificationsFacebookImpl
typingNotifications; typingNotifications;
/** /**
* Cache of typing notifications * Cache of typing notifications
*/ */
private final Map<String, TypingNotificationRecord> typingNotificationRecord private final Map<String, TypingNotificationRecord> typingNotificationRecord
= new HashMap<String, TypingNotificationRecord>(); = new HashMap<String, TypingNotificationRecord>();
/** /**
* Adapter for each Facebook Chat account. * Adapter for each Facebook Chat account.
* *
* @param parentProvider the parent service provider * @param parentProvider the parent service provider
* @param persistentPresence * @param persistentPresence
* @param basicInstantMessaging * @param basicInstantMessaging
* @param typingNotifications * @param typingNotifications
*/ */
public FacebookAdapter( public FacebookAdapter(
ProtocolProviderServiceFacebookImpl parentProvider, ProtocolProviderServiceFacebookImpl parentProvider,
OperationSetPersistentPresenceFacebookImpl persistentPresence, OperationSetPersistentPresenceFacebookImpl persistentPresence,
OperationSetBasicInstantMessagingFacebookImpl basicInstantMessaging, OperationSetBasicInstantMessagingFacebookImpl basicInstantMessaging,
OperationSetTypingNotificationsFacebookImpl typingNotifications) OperationSetTypingNotificationsFacebookImpl typingNotifications)
{ {
this.parentProvider = parentProvider; this.parentProvider = parentProvider;
this.persistentPresence = persistentPresence; this.persistentPresence = persistentPresence;
this.basicInstantMessaging = basicInstantMessaging; this.basicInstantMessaging = basicInstantMessaging;
this.typingNotifications = typingNotifications; this.typingNotifications = typingNotifications;
} }
/** /**
* Get the facebook id of this account * Get the facebook id of this account
* *
* @return the facebook id of this account * @return the facebook id of this account
*/ */
public String getUID() public String getUID()
{ {
return this.session.getUid(); return this.session.getUid();
} }
/** /**
* Get the parent service provider * Get the parent service provider
* *
* @return parent service provider * @return parent service provider
*/ */
public ProtocolProviderServiceFacebookImpl getParentProvider() public ProtocolProviderServiceFacebookImpl getParentProvider()
{ {
return parentProvider; return parentProvider;
} }
/** /**
* Initializes the {@link FacebookSession},<br> * Initializes the {@link FacebookSession},<br>
* Initializes the {@link Thread}s to update the buddy list and to poll * Initializes the {@link Thread}s to update the buddy list and to poll
* messages * messages
* *
* @param email * @param email
* @param password * @param password
* @return true if the user is logged in * @return true if the user is logged in
* @throws IOException * @throws IOException
* @throws BrokenFacebookProtocolException * @throws BrokenFacebookProtocolException
*/ */
public synchronized boolean initialize( public synchronized boolean initialize(
final String email, final String email,
final String password) final String password)
throws OperationFailedException throws OperationFailedException
{ {
if (this.session != null && this.session.isLoggedIn()) if (this.session != null && this.session.isLoggedIn())
return true; return true;
logger.info("initializing facebook adapter. account"); logger.info("initializing facebook adapter. account");
try try
{ {
this.session = new FacebookSession(); this.session = new FacebookSession();
boolean loggedIn = session.login(email, password); boolean loggedIn = session.login(email, password);
if (loggedIn) if (loggedIn)
session.addListener(this); session.addListener(this);
return loggedIn; return loggedIn;
} }
catch (Exception e) catch (Exception e)
{ {
throw throw
new OperationFailedException( new OperationFailedException(
"unable to initialize adapter", "unable to initialize adapter",
FacebookErrorException.kError_Login_GenericError, FacebookErrorException.kError_Login_GenericError,
e); e);
} }
} }
/** /**
* Post typing notification to the given contact. * Post typing notification to the given contact.
* *
* @param notifiedContact * @param notifiedContact
* the contact we want to notify * the contact we want to notify
* @param typingState * @param typingState
* our current typing state(SC) * our current typing state(SC)
* @throws HttpException * @throws HttpException
* the http exception * the http exception
* @throws IOException * @throws IOException
* IO exception * IO exception
* @throws JSONException * @throws JSONException
* JSON parsing exception * JSON parsing exception
* @throws Exception * @throws Exception
* the general exception * the general exception
*/ */
public void postTypingNotification(Contact notifiedContact, int typingState) public void postTypingNotification(Contact notifiedContact, int typingState)
throws HttpException, throws HttpException,
IOException, IOException,
JSONException, JSONException,
Exception Exception
{ {
TypingNotificationRecord record TypingNotificationRecord record
= typingNotificationRecord.get(notifiedContact.getAddress()); = typingNotificationRecord.get(notifiedContact.getAddress());
if (record == null) if (record == null)
{ {
record = new TypingNotificationRecord(-1l, -1); record = new TypingNotificationRecord(-1l, -1);
synchronized (typingNotificationRecord) synchronized (typingNotificationRecord)
{ {
typingNotificationRecord typingNotificationRecord
.put(notifiedContact.getAddress(), record); .put(notifiedContact.getAddress(), record);
} }
} }
if (record.getTime() < System.currentTimeMillis() - 1000) if (record.getTime() < System.currentTimeMillis() - 1000)
{ {
FacebookOutgoingTypingNotification msg FacebookOutgoingTypingNotification msg
= new FacebookOutgoingTypingNotification(session); = new FacebookOutgoingTypingNotification(session);
msg.setAddress(notifiedContact.getAddress()); msg.setAddress(notifiedContact.getAddress());
msg.setTypingState(typingState); msg.setTypingState(typingState);
msg.send(); msg.send();
record.setTime(System.currentTimeMillis()); record.setTime(System.currentTimeMillis());
record.setType(typingState); record.setType(typingState);
} }
} }
public void setStatusMessage(String statusMessage) public void setStatusMessage(String statusMessage)
throws OperationFailedException throws OperationFailedException
{ {
try try
{ {
this.session.setStatusMessage(statusMessage); this.session.setStatusMessage(statusMessage);
} }
catch (IOException e) catch (IOException e)
{ {
throw throw
new OperationFailedException( new OperationFailedException(
"unable to change facebook status message", "unable to change facebook status message",
-1, -1,
e); e);
} }
} }
public synchronized void shutdown() public synchronized void shutdown()
{ {
if (session != null) if (session != null)
{ {
logger.info("shutting down facebook adapter"); logger.info("shutting down facebook adapter");
session.logout(); session.logout();
} }
} }
/** /**
* *
* @param message * @param message
* @param to * @param to
* @return * @return
*/ */
public synchronized MessageDeliveryFailedEvent postMessage( public synchronized MessageDeliveryFailedEvent postMessage(
Message message, Message message,
Contact to) Contact to)
{ {
FacebookOutgoingMailboxMessage msg FacebookOutgoingMailboxMessage msg
= new FacebookOutgoingMailboxMessage(session); = new FacebookOutgoingMailboxMessage(session);
msg.setAddress(to.getAddress()); msg.setAddress(to.getAddress());
msg.setContent(message.getContent()); msg.setContent(message.getContent());
msg.setSubject(message.getSubject()); msg.setSubject(message.getSubject());
msg.setUid(message.getMessageUID()); msg.setUid(message.getMessageUID());
try try
{ {
msg.send(); msg.send();
return null; return null;
} }
catch (BrokenFacebookProtocolException e) catch (BrokenFacebookProtocolException e)
{ {
logger.error(e); logger.error(e);
return new MessageDeliveryFailedEvent(message, to, -1, System return new MessageDeliveryFailedEvent(message, to, -1, System
.currentTimeMillis(), e.getMessage()); .currentTimeMillis(), e.getMessage());
} }
catch (IOException e) catch (IOException e)
{ {
logger.warn(e); logger.warn(e);
return new MessageDeliveryFailedEvent(message, to, -1, System return new MessageDeliveryFailedEvent(message, to, -1, System
.currentTimeMillis(), e.getMessage()); .currentTimeMillis(), e.getMessage());
} }
catch (FacebookErrorException e) catch (FacebookErrorException e)
{ {
return new MessageDeliveryFailedEvent(message, to, e.getCode()); return new MessageDeliveryFailedEvent(message, to, e.getCode());
} }
} }
public MessageDeliveryFailedEvent postFacebookChatMessage( public MessageDeliveryFailedEvent postFacebookChatMessage(
Message message, Message message,
Contact to) Contact to)
{ {
FacebookOutgoingChatMessage msg FacebookOutgoingChatMessage msg
= new FacebookOutgoingChatMessage(session); = new FacebookOutgoingChatMessage(session);
msg.setAddress(to.getAddress()); msg.setAddress(to.getAddress());
msg.setContent(message.getContent()); msg.setContent(message.getContent());
msg.setMessageUid(message.getMessageUID()); msg.setMessageUid(message.getMessageUID());
try try
{ {
msg.send(); msg.send();
return null; return null;
} }
catch (BrokenFacebookProtocolException e) catch (BrokenFacebookProtocolException e)
{ {
logger.error(e); logger.error(e);
return new MessageDeliveryFailedEvent(message, to, -1, System return new MessageDeliveryFailedEvent(message, to, -1, System
.currentTimeMillis(), e.getMessage()); .currentTimeMillis(), e.getMessage());
} }
catch (IOException e) catch (IOException e)
{ {
logger.warn(e); logger.warn(e);
return new MessageDeliveryFailedEvent(message, to, -1, System return new MessageDeliveryFailedEvent(message, to, -1, System
.currentTimeMillis(), e.getMessage()); .currentTimeMillis(), e.getMessage());
} }
catch (FacebookErrorException e) catch (FacebookErrorException e)
{ {
return new MessageDeliveryFailedEvent(message, to, e.getCode()); return new MessageDeliveryFailedEvent(message, to, e.getCode());
} }
} }
/** /**
* Promotes the incoming message to the GUI * Promotes the incoming message to the GUI
* *
* @see FacebookIncomingMessageListener#onIncomingChatMessage(FacebookMessage) * @see FacebookSessionListener#onIncomingChatMessage(FacebookMessage)
*/ */
public void onIncomingChatMessage(FacebookMessage msg) public void onIncomingChatMessage(FacebookMessage msg)
{ {
if (!msg.getFrom().equals(this.session.getUid())) if (!msg.getFrom().equals(this.session.getUid()))
basicInstantMessaging.receivedInstantMessage(msg); basicInstantMessaging.receivedInstantMessage(msg);
} }
/** /**
* Promotes the incoming notification to the GUI * Promotes the incoming notification to the GUI
* *
* @see FacebookIncomingMessageListener#onIncomingTypingNotification(String, * @see FacebookSessionListener#onIncomingTypingNotification(String, int)
* int) */
*/ public void onIncomingTypingNotification(String buddyUid, int state)
public void onIncomingTypingNotification(String buddyUid, int state) {
{ if (!buddyUid.equals(this.session.getUid()))
if (!buddyUid.equals(this.session.getUid())) {
{ Contact fromContact = persistentPresence.findContactByID(buddyUid);
Contact fromContact = persistentPresence.findContactByID(buddyUid); if (fromContact == null)
if (fromContact == null) fromContact
fromContact = persistentPresence.createVolatileContact(buddyUid);
= persistentPresence.createVolatileContact(buddyUid);
int typingState = OperationSetTypingNotifications.STATE_UNKNOWN;
int typingState = OperationSetTypingNotifications.STATE_UNKNOWN; switch (state)
switch (state) {
{ case 1:
case 1: typingState = OperationSetTypingNotifications.STATE_TYPING;
typingState = OperationSetTypingNotifications.STATE_TYPING; break;
break; case 0:
case 0: typingState = OperationSetTypingNotifications.STATE_STOPPED;
typingState = OperationSetTypingNotifications.STATE_STOPPED; break;
break; default:
default: typingState = OperationSetTypingNotifications.STATE_UNKNOWN;
typingState = OperationSetTypingNotifications.STATE_UNKNOWN; }
}
typingNotifications
typingNotifications .receivedTypingNotification(fromContact, typingState);
.receivedTypingNotification(fromContact, typingState); }
} }
}
/**
/** * notifies SC that the connection is lost
* notifies SC that the connection is lost */
*/ public void onFacebookConnectionLost() {
public void onFacebookConnectionLost() { if (parentProvider.isRegistered())
if (parentProvider.isRegistered()) {
{ try
try {
{ parentProvider.unregister();
parentProvider.unregister(); }
} catch (OperationFailedException e)
catch (OperationFailedException e) {
{ logger.error("unable to unregister", e);
logger.error("unable to unregister", e); }
} }
}
// tag all the buddies as offline
// tag all the buddies as offline persistentPresence
persistentPresence .setPresenceStatusForAllContacts(FacebookStatusEnum.OFFLINE);
.setPresenceStatusForAllContacts(FacebookStatusEnum.OFFLINE); }
}
public void onBuddyListUpdated()
public void onBuddyListUpdated() {
{ for (FacebookUser user : this.session.getBuddyList().getBuddies())
for (FacebookUser user : this.session.getBuddyList().getBuddies()) {
{ PresenceStatus newStatus;
PresenceStatus newStatus; if (user.isOnline && user.isIdle)
if (user.isOnline && user.isIdle) newStatus = FacebookStatusEnum.IDLE;
newStatus = FacebookStatusEnum.IDLE; else if (user.isOnline)
else if (user.isOnline) newStatus = FacebookStatusEnum.ONLINE;
newStatus = FacebookStatusEnum.ONLINE; else
else newStatus = FacebookStatusEnum.OFFLINE;
newStatus = FacebookStatusEnum.OFFLINE;
persistentPresence.setPresenceStatusForContact(user.uid, newStatus);
persistentPresence.setPresenceStatusForContact(user.uid, newStatus); }
} }
}
public FacebookSession getSession()
public FacebookSession getSession() {
{ return session;
return session; }
}
private static class TypingNotificationRecord
private static class TypingNotificationRecord {
{ private long time;
private long time; private int type;
private int type;
public TypingNotificationRecord(long time, int type)
public TypingNotificationRecord(long time, int type) {
{ this.time = time;
this.time = time; this.type = type;
this.type = type; }
}
public long getTime()
public long getTime() {
{ return time;
return time; }
}
public int getType()
public int getType() {
{ return type;
return type; }
}
public void setTime(long time)
public void setTime(long time) {
{ this.time = time;
this.time = time; }
}
public void setType(int type)
public void setType(int type) {
{ this.type = type;
this.type = type; }
} }
} }
}

@ -1,288 +1,287 @@
/* /*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
* *
* Distributable under LGPL license. See terms of license at gnu.org. * Distributable under LGPL license. See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.impl.protocol.facebook; package net.java.sip.communicator.impl.protocol.facebook;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import org.apache.http.*; import org.apache.http.*;
import org.apache.http.client.entity.*; import org.apache.http.client.entity.*;
import org.apache.http.client.methods.*; import org.apache.http.client.methods.*;
import org.apache.http.message.*; import org.apache.http.message.*;
import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HTTP;
import org.apache.http.util.*; import org.apache.http.util.*;
import org.json.*; import org.json.*;
/** /**
* Facebook buddy list that store the online buddies information we got from the * Facebook buddy list that store the online buddies information we got from the
* server since we logged in. Some information of ourselves also included. <br> * server since we logged in. Some information of ourselves also included. <br>
* This class is responsible of establishing the http connections and updating * This class is responsible of establishing the http connections and updating
* its state when requested. * its state when requested.
* *
* @author Dai Zhiwei * @author Dai Zhiwei
* @author Edgar Poce * @author Edgar Poce
*/ */
public class FacebookBuddyList public class FacebookBuddyList
{ {
private static Logger logger = Logger.getLogger(FacebookBuddyList.class); private static Logger logger = Logger.getLogger(FacebookBuddyList.class);
/** /**
* The url of the update * The url of the update
*/ */
private static final String BUDDYLIST_URL private static final String BUDDYLIST_URL
= "http://www.facebook.com/ajax/chat/buddy_list.php"; = "http://www.facebook.com/ajax/chat/buddy_list.php";
/** /**
* The Facebook Session * The Facebook Session
*/ */
private final FacebookSession session; private final FacebookSession session;
/** /**
* Our (online) buddies' information cache * Our (online) buddies' information cache
*/ */
private transient Map<String, FacebookUser> cache private transient Map<String, FacebookUser> cache
= new LinkedHashMap<String, FacebookUser>(); = new LinkedHashMap<String, FacebookUser>();
/** /**
* Some information of ourselves/myself. * Some information of ourselves/myself.
*/ */
private transient FacebookUser me; private transient FacebookUser me;
/** /**
* Listener of this buddy list * Listener of this buddy list
*/ */
private List<FacebookSessionListener> listeners private List<FacebookSessionListener> listeners
= new ArrayList<FacebookSessionListener>(); = new ArrayList<FacebookSessionListener>();
/** /**
* Init the cache and the parent adapter. * Init the cache and the parent adapter.
* *
* @param adapter * @param session the Facebook session
*/ */
public FacebookBuddyList(FacebookSession session) public FacebookBuddyList(FacebookSession session)
{ {
this.session = session; this.session = session;
} }
public void update() public void update()
throws BrokenFacebookProtocolException, throws BrokenFacebookProtocolException,
IOException, IOException,
FacebookErrorException FacebookErrorException
{ {
// reconnecting // reconnecting
this.session.reconnect(); this.session.reconnect();
logger.info("Updating buddy list..."); logger.info("Updating buddy list...");
// perform POST request // perform POST request
List<NameValuePair> nvps = new ArrayList<NameValuePair>(); List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("buddy_list", "1")); nvps.add(new BasicNameValuePair("buddy_list", "1"));
nvps.add(new BasicNameValuePair("notifications", "1")); nvps.add(new BasicNameValuePair("notifications", "1"));
nvps.add(new BasicNameValuePair("force_render", "true")); nvps.add(new BasicNameValuePair("force_render", "true"));
nvps.add(new BasicNameValuePair("post_form_id", session.getFormId())); nvps.add(new BasicNameValuePair("post_form_id", session.getFormId()));
nvps.add(new BasicNameValuePair("user", session.getUid())); nvps.add(new BasicNameValuePair("user", session.getUid()));
HttpPost post = new HttpPost(BUDDYLIST_URL); HttpPost post = new HttpPost(BUDDYLIST_URL);
post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
HttpResponse response = this.session.getHttpClient().execute(post); HttpResponse response = this.session.getHttpClient().execute(post);
String body = EntityUtils.toString(response.getEntity()); String body = EntityUtils.toString(response.getEntity());
if (response.getStatusLine().getStatusCode() != 200) if (response.getStatusLine().getStatusCode() != 200)
{ {
throw new BrokenFacebookProtocolException("Code " throw new BrokenFacebookProtocolException("Code "
+ response.getStatusLine().getStatusCode() + response.getStatusLine().getStatusCode()
+ ". Unable to update Facebook buddy list."); + ". Unable to update Facebook buddy list.");
} }
this.update(body); this.update(body);
} }
/** /**
* Get meta info of this account * Get meta info of this account
* *
* @return meta info of this account * @return meta info of this account
*/ */
public FacebookUser getMyMetaInfo() public FacebookUser getMyMetaInfo()
{ {
return me; return me;
} }
/** /**
* Get our buddy who has the given id from the cache. * Get our buddy who has the given id from the cache.
* *
* @param contactID * @param uid the id we want to look up
* the id we wanna look up * @return the buddy who has the given id
* @return the buddy who has the given id * @throws FacebookErrorException
* @throws FacebookErrorException * @throws IOException
* @throws IOException * @throws BrokenFacebookProtocolException
* @throws BrokenFacebookProtocolException */
*/ public FacebookUser getBuddyByUID(String uid)
public FacebookUser getBuddyByUID(String uid) throws BrokenFacebookProtocolException,
throws BrokenFacebookProtocolException, IOException,
IOException, FacebookErrorException
FacebookErrorException {
{ FacebookUser buddy = this.cache.get(uid);
FacebookUser buddy = this.cache.get(uid); if (buddy == null && this.me != null && this.me.uid.equals(uid))
if (buddy == null && this.me != null && this.me.uid.equals(uid)) {
{ buddy = me;
buddy = me; }
} return buddy;
return buddy; }
}
/**
/** * @return the users in the cache
* @return the users in the cache */
*/ public Collection<FacebookUser> getBuddies()
public Collection<FacebookUser> getBuddies() {
{ return Collections.unmodifiableCollection(this.cache.values());
return Collections.unmodifiableCollection(this.cache.values()); }
}
/**
/** * Release the resource
* Release the resource */
*/ public void clear()
public void clear() {
{ for (FacebookUser u : this.cache.values())
for (FacebookUser u : this.cache.values()) {
{ u.isOnline = false;
u.isOnline = false; }
} }
}
/**
/** * Updates the buddy list<br>
* Updates the buddy list<br> * If the {@link FacebookSession} is logged out then this method returns
* If the {@link FacebookSession} is logged out then this method returns * without modifying the state of the buddy list.
* without modifying the state of the buddy list. *
* * @param body
* @param body * @throws BrokenFacebookProtocolException
* @throws BrokenFacebookProtocolException * @throws FacebookErrorException
* @throws FacebookErrorException */
*/ @SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") public void update(String body)
public void update(String body) throws BrokenFacebookProtocolException,
throws BrokenFacebookProtocolException, FacebookErrorException
FacebookErrorException {
{ // the session might be getting closed by another thread
// the session might be getting closed by another thread // do nothing if it's logged out
// do nothing if it's logged out synchronized (session)
synchronized (session) {
{ if (!session.isLoggedIn())
if (!session.isLoggedIn()) {
{ return;
return; }
} }
}
JSONObject jsonBuddyList = parseBody(body);
JSONObject jsonBuddyList = parseBody(body); try {
try { /*
/* * If listChanged, then we can get the buddies available via looking
* If listChanged, then we can get the buddies available via looking * at the nowAvailableList else. we can only get the buddies' info,
* at the nowAvailableList else. we can only get the buddies' info, * and the nowAvailableList is empty.
* and the nowAvailableList is empty. */
*/ JSONObject userInfos = (JSONObject) jsonBuddyList.get("userInfos");
JSONObject userInfos = (JSONObject) jsonBuddyList.get("userInfos"); if (userInfos != null)
if (userInfos != null) {
{ // Then add the new buddies and set them as online(constructor)
// Then add the new buddies and set them as online(constructor) Iterator<String> it = userInfos.keys();
Iterator<String> it = userInfos.keys(); while (it.hasNext())
while (it.hasNext()) {
{ String key = it.next();
String key = it.next(); JSONObject jsonUser = (JSONObject) userInfos.get(key);
JSONObject jsonUser = (JSONObject) userInfos.get(key); if (jsonUser == null)
if (jsonUser == null) {
{ throw new BrokenFacebookProtocolException(
throw new BrokenFacebookProtocolException( "unable to get user info. " + userInfos);
"unable to get user info. " + userInfos); }
} FacebookUser buddy = new FacebookUser(key, jsonUser);
FacebookUser buddy = new FacebookUser(key, jsonUser); if (buddy.uid.equals(this.session.getUid()))
if (buddy.uid.equals(this.session.getUid())) {
{ this.me = buddy;
this.me = buddy; }
} else
else {
{ this.cache.put(key, buddy);
this.cache.put(key, buddy); }
} }
} }
}
JSONObject nowAvailableList = jsonBuddyList
JSONObject nowAvailableList = jsonBuddyList .getJSONObject("nowAvailableList");
.getJSONObject("nowAvailableList");
if (nowAvailableList == null)
if (nowAvailableList == null) {
{ throw new BrokenFacebookProtocolException(
throw new BrokenFacebookProtocolException( "Unable to read Facebook now available list");
"Unable to read Facebook now available list"); }
}
for (FacebookUser user : this.cache.values())
for (FacebookUser user : this.cache.values()) {
{ if (nowAvailableList.has(user.uid))
if (nowAvailableList.has(user.uid)) {
{ user.isOnline = true;
user.isOnline = true; user.lastSeen = Calendar.getInstance().getTimeInMillis();
user.lastSeen = Calendar.getInstance().getTimeInMillis(); user.isIdle = nowAvailableList.getJSONObject(user.uid)
user.isIdle = nowAvailableList.getJSONObject(user.uid) .getBoolean("i");
.getBoolean("i"); }
} else
else {
{ user.isOnline = false;
user.isOnline = false; }
} }
} // notify listeners
// notify listeners for (FacebookSessionListener l : this.listeners)
for (FacebookSessionListener l : this.listeners) l.onBuddyListUpdated();
l.onBuddyListUpdated(); }
} catch (JSONException e)
catch (JSONException e) {
{ throw new BrokenFacebookProtocolException(e);
throw new BrokenFacebookProtocolException(e); }
} }
}
private JSONObject parseBody(String body)
private JSONObject parseBody(String body) throws BrokenFacebookProtocolException,
throws BrokenFacebookProtocolException, FacebookErrorException
FacebookErrorException {
{ FacebookJsonResponse jsonResponse = new FacebookJsonResponse(session,
FacebookJsonResponse jsonResponse = new FacebookJsonResponse(session, body);
body); try
try {
{ JSONObject json = jsonResponse.getJson();
JSONObject json = jsonResponse.getJson(); JSONObject payload = (JSONObject) json.get("payload");
JSONObject payload = (JSONObject) json.get("payload"); if (payload == null)
if (payload == null) {
{ throw new BrokenFacebookProtocolException(
throw new BrokenFacebookProtocolException( "unable to parse buddy list. there's no payload field. "
"unable to parse buddy list. there's no payload field. " + jsonResponse);
+ jsonResponse); }
} JSONObject jsonBuddyList = (JSONObject) payload.get("buddy_list");
JSONObject jsonBuddyList = (JSONObject) payload.get("buddy_list"); if (jsonBuddyList == null)
if (jsonBuddyList == null) {
{ throw new BrokenFacebookProtocolException(
throw new BrokenFacebookProtocolException( "unable to parse buddy list. there's no buddy list field. "
"unable to parse buddy list. there's no buddy list field. " + jsonResponse);
+ jsonResponse); }
} return jsonBuddyList;
return jsonBuddyList; }
} catch (JSONException e)
catch (JSONException e) {
{ throw new BrokenFacebookProtocolException(
throw new BrokenFacebookProtocolException( "unable to parse json response");
"unable to parse json response"); }
} }
}
public int getSize()
public int getSize() {
{ return this.cache.size();
return this.cache.size(); }
}
/**
/** * Adds a listener which is notified when the buddy list state changes
* Adds a listener which is notified when the buddy list state changes *
* * @param listener
* @param listener */
*/ public void addListener(FacebookSessionListener listener)
public void addListener(FacebookSessionListener listener) {
{ this.listeners.add(listener);
this.listeners.add(listener); }
} }
}

@ -17,12 +17,12 @@
/** /**
* This poller checks for new messages in Facebook servers and notifies to the * This poller checks for new messages in Facebook servers and notifies to the
* registered {@link FacebookIncomingMessageListener listeners} if a new * registered {@link FacebookSessionListener listeners} if a new
* {@link FacebookMessage} is found.<br> * {@link FacebookMessage} is found.<br>
* Registered {@link FacebookIncomingMessageListener listeners} are notified * Registered {@link FacebookSessionListener listeners} are notified upon
* upon arrival of both messages from other buddies and own messages.<br> * arrival of both messages from other buddies and own messages.<br>
* It's responsibility of the {@link FacebookIncomingMessageListener listeners} * It's the responsibility of the {@link FacebookSessionListener listeners} to
* to discard undesired notifications, e.g. own messages. * discard undesired notifications, e.g. own messages.
* *
* @author Edgar Poce * @author Edgar Poce
*/ */

@ -45,7 +45,6 @@ public FacebookOutgoingChatMessage(FacebookSession session)
* Only one message can be sent at a time for a given * Only one message can be sent at a time for a given
* {@link FacebookSession} * {@link FacebookSession}
* *
* @return true if the message was sent successfully
* @throws BrokenFacebookProtocolException * @throws BrokenFacebookProtocolException
* @throws IOException * @throws IOException
*/ */

@ -1,266 +1,265 @@
/* /*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
* *
* Distributable under LGPL license. See terms of license at gnu.org. * Distributable under LGPL license. See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.impl.protocol.facebook; package net.java.sip.communicator.impl.protocol.facebook;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
/** /**
* Instant messaging functionality for the Facebook protocol. * Instant messaging functionality for the Facebook protocol.
* *
* @author Dai Zhiwei * @author Dai Zhiwei
* @author Lubomir Marinov * @author Lubomir Marinov
*/ */
public class OperationSetBasicInstantMessagingFacebookImpl public class OperationSetBasicInstantMessagingFacebookImpl
extends AbstractOperationSetBasicInstantMessaging extends AbstractOperationSetBasicInstantMessaging
{ {
private static final Logger logger private static final Logger logger
= Logger.getLogger(OperationSetBasicInstantMessagingFacebookImpl.class); = Logger.getLogger(OperationSetBasicInstantMessagingFacebookImpl.class);
/** /**
* The currently valid persistent presence operation set.. * The currently valid persistent presence operation set..
*/ */
private OperationSetPersistentPresenceFacebookImpl opSetPersPresence = null; private OperationSetPersistentPresenceFacebookImpl opSetPersPresence = null;
/** /**
* The protocol provider that created us. * The protocol provider that created us.
*/ */
private ProtocolProviderServiceFacebookImpl parentProvider = null; private ProtocolProviderServiceFacebookImpl parentProvider = null;
/** /**
* Creates an instance of this operation set keeping a reference to the * Creates an instance of this operation set keeping a reference to the
* parent protocol provider and presence operation set. * parent protocol provider and presence operation set.
* *
* @param provider The provider instance that creates us. * @param provider The provider instance that creates us.
* @param opSetPersPresence the currently valid * @param opSetPersPresence the currently valid
* <tt>OperationSetPersistentPresenceFacebookImpl</tt> * <tt>OperationSetPersistentPresenceFacebookImpl</tt>
* instance. * instance.
*/ */
public OperationSetBasicInstantMessagingFacebookImpl( public OperationSetBasicInstantMessagingFacebookImpl(
ProtocolProviderServiceFacebookImpl provider, ProtocolProviderServiceFacebookImpl provider,
OperationSetPersistentPresenceFacebookImpl opSetPersPresence) OperationSetPersistentPresenceFacebookImpl opSetPersPresence)
{ {
this.opSetPersPresence = opSetPersPresence; this.opSetPersPresence = opSetPersPresence;
this.parentProvider = provider; this.parentProvider = provider;
} }
/* /*
* Implements * Implements
* AbstractOperationSetBasicInstantMessaging#createMessage(String, String, * AbstractOperationSetBasicInstantMessaging#createMessage(String, String,
* String, String). Creates a new MessageFacebookImpl instance with the * String, String). Creates a new MessageFacebookImpl instance with the
* specified properties. * specified properties.
*/ */
public Message createMessage( public Message createMessage(
String content, String contentType, String encoding, String subject) String content, String contentType, String encoding, String subject)
{ {
return return
new MessageFacebookImpl(content, contentType, encoding, subject); new MessageFacebookImpl(content, contentType, encoding, subject);
} }
/** /**
* Sends the <tt>message</tt> to the destination indicated by the * Sends the <tt>message</tt> to the destination indicated by the
* <tt>to</tt> contact. * <tt>to</tt> contact.
* *
* @param to the <tt>Contact</tt> to send <tt>message</tt> to * @param to the <tt>Contact</tt> to send <tt>message</tt> to
* @param message the <tt>Message</tt> to send. * @param message the <tt>Message</tt> to send.
* @throws IllegalStateException if the underlying ICQ stack is not * @throws IllegalStateException if the underlying ICQ stack is not
* registered and initialized. * registered and initialized.
* @throws IllegalArgumentException if <tt>to</tt> is not an instance * @throws IllegalArgumentException if <tt>to</tt> is not an instance
* belonging to the underlying implementation. * belonging to the underlying implementation.
*/ */
public void sendInstantMessage(final Contact to, final Message message) public void sendInstantMessage(final Contact to, final Message message)
throws IllegalStateException, throws IllegalStateException,
IllegalArgumentException IllegalArgumentException
{ {
if (!(to instanceof ContactFacebookImpl)) if (!(to instanceof ContactFacebookImpl))
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The specified contact is not a Facebook contact." + to); "The specified contact is not a Facebook contact." + to);
Thread sender = new Thread(new Runnable() Thread sender = new Thread(new Runnable()
{ {
public void run() public void run()
{ {
// deliver the facebook chat Message // deliver the facebook chat Message
MessageDeliveryFailedEvent errorEvent = null; MessageDeliveryFailedEvent errorEvent = null;
errorEvent = errorEvent =
OperationSetBasicInstantMessagingFacebookImpl.this.parentProvider OperationSetBasicInstantMessagingFacebookImpl.this.parentProvider
.getAdapter().postFacebookChatMessage(message, to); .getAdapter().postFacebookChatMessage(message, to);
if (errorEvent == null) if (errorEvent == null)
{ {
fireMessageDelivered(message, to); fireMessageDelivered(message, to);
return; return;
} }
if(errorEvent.getErrorCode() == FacebookErrorException.kError_Async_NotLoggedIn if(errorEvent.getErrorCode() == FacebookErrorException.kError_Async_NotLoggedIn
|| errorEvent.getErrorCode() == FacebookErrorException.kError_Async_LoginChanged) || errorEvent.getErrorCode() == FacebookErrorException.kError_Async_LoginChanged)
{ {
try try
{ {
parentProvider.unregister(RegistrationStateChangeEvent.REASON_MULTIPLE_LOGINS); parentProvider.unregister(RegistrationStateChangeEvent.REASON_MULTIPLE_LOGINS);
} }
catch (OperationFailedException e1) catch (OperationFailedException e1)
{ {
logger.error( logger.error(
"Unable to unregister the protocol provider: " "Unable to unregister the protocol provider: "
+ this + this
+ " due to the following exception: " + e1); + " due to the following exception: " + e1);
} }
fireMessageDeliveryFailed( fireMessageDeliveryFailed(
message, message,
to, to,
MessageDeliveryFailedEvent.PROVIDER_NOT_REGISTERED); MessageDeliveryFailedEvent.PROVIDER_NOT_REGISTERED);
return; return;
} }
// if the above delivery failed, we try again! // if the above delivery failed, we try again!
try try
{ {
// wait a moment // wait a moment
Thread.sleep(1000); Thread.sleep(1000);
errorEvent = errorEvent =
OperationSetBasicInstantMessagingFacebookImpl.this.parentProvider OperationSetBasicInstantMessagingFacebookImpl.this.parentProvider
.getAdapter().postFacebookChatMessage(message, to); .getAdapter().postFacebookChatMessage(message, to);
if (errorEvent == null) if (errorEvent == null)
{ {
fireMessageDelivered(message, to); fireMessageDelivered(message, to);
return; return;
} }
if(errorEvent.getErrorCode() == FacebookErrorException.kError_Async_NotLoggedIn if(errorEvent.getErrorCode() == FacebookErrorException.kError_Async_NotLoggedIn
|| errorEvent.getErrorCode() == FacebookErrorException.kError_Async_LoginChanged) || errorEvent.getErrorCode() == FacebookErrorException.kError_Async_LoginChanged)
{ {
try try
{ {
parentProvider.unregister(RegistrationStateChangeEvent.REASON_MULTIPLE_LOGINS); parentProvider.unregister(RegistrationStateChangeEvent.REASON_MULTIPLE_LOGINS);
} }
catch (OperationFailedException e1) catch (OperationFailedException e1)
{ {
logger.error( logger.error(
"Unable to unregister the protocol provider: " "Unable to unregister the protocol provider: "
+ this + this
+ " due to the following exception: " + e1); + " due to the following exception: " + e1);
} }
} }
} }
catch (InterruptedException e) catch (InterruptedException e)
{ {
logger.warn(e.getMessage()); logger.warn(e.getMessage());
} }
// if we get here, we have failed to deliver this message, // if we get here, we have failed to deliver this message,
// twice. // twice.
fireMessageDeliveryFailed( fireMessageDeliveryFailed(
message, message,
to, to,
MessageDeliveryFailedEvent.UNKNOWN_ERROR); MessageDeliveryFailedEvent.UNKNOWN_ERROR);
// now do message delivery.----what's this? // now do message delivery.----what's this?
// in case that the "to" we deliver this message to is // in case that the "to" we deliver this message to is
// ourselves? // ourselves?
// deliverMessageToMyself(message, (ContactFacebookImpl)to); // deliverMessageToMyself(message, (ContactFacebookImpl)to);
} }
}); });
sender.start(); sender.start();
} }
/** /**
* Invoked by the facebook adapter when we got messages from the server. * Invoked by the facebook adapter when we got messages from the server.
* *
* @param message * @param fbmsg the received Facebook instant message
* @param from */
*/ public void receivedInstantMessage(FacebookMessage fbmsg)
public void receivedInstantMessage(FacebookMessage fbmsg) {
{ Message message = this.createMessage(fbmsg.getText());
Message message = this.createMessage(fbmsg.getText()); String fromID = fbmsg.getFrom();
String fromID = fbmsg.getFrom();
// TODO handle the msgID.
// TODO handle the msgID. // it's generated when we createMessage() by now.
// it's generated when we createMessage() by now. // We should set the message id according to the fbmsg.msgID.
// We should set the message id according to the fbmsg.msgID. // But it's not important.
// But it's not important.
Contact fromContact = opSetPersPresence.findContactByID(fromID);
Contact fromContact = opSetPersPresence.findContactByID(fromID); if (fromContact == null)
if (fromContact == null) {
{ // from facebook user who are not on our contact list
// from facebook user who are not on our contact list // TODO creat volatile contact, fire event.
// TODO creat volatile contact, fire event. fromContact = opSetPersPresence.createVolatileContact(fromID);
fromContact = opSetPersPresence.createVolatileContact(fromID); // opSetPersPresence.subscribe(fromID);
// opSetPersPresence.subscribe(fromID); }
} fireMessageReceived(message, fromContact);
fireMessageReceived(message, fromContact); }
}
/**
/** * Notifies all registered message listeners that a message has been
* Notifies all registered message listeners that a message has been * delivered successfully to its addressee..
* delivered successfully to its addressee.. *
* * @param message
* @param message * the <tt>Message</tt> that has been delivered.
* the <tt>Message</tt> that has been delivered. * @param to
* @param to * the <tt>Contact</tt> that <tt>message</tt> was delivered to.
* the <tt>Contact</tt> that <tt>message</tt> was delivered to. */
*/ protected void fireMessageDelivered(Message message, Contact to)
protected void fireMessageDelivered(Message message, Contact to) {
{ // we succeeded in sending a message to contact "to",
// we succeeded in sending a message to contact "to", // so we know he is online
// so we know he is online // but -- if we support the "invisible" status,
// but -- if we support the "invisible" status, // this line could be commented
// this line could be commented opSetPersPresence
opSetPersPresence .setPresenceStatusForContact(
.setPresenceStatusForContact( (ContactFacebookImpl) to,
(ContactFacebookImpl) to, FacebookStatusEnum.ONLINE);
FacebookStatusEnum.ONLINE);
super.fireMessageDelivered(message, to);
super.fireMessageDelivered(message, to); }
}
/**
/** * Notifies all registered message listeners that a message has been
* Notifies all registered message listeners that a message has been * received.
* received. *
* * @param message the <tt>Message</tt> that has been received.
* @param message the <tt>Message</tt> that has been received. * @param from the <tt>Contact</tt> that <tt>message</tt> was received
* @param from the <tt>Contact</tt> that <tt>message</tt> was received * from.
* from. */
*/ protected void fireMessageReceived(Message message, Contact from)
protected void fireMessageReceived(Message message, Contact from) {
{ // we got a message from contact "from", so we know he is online
// we got a message from contact "from", so we know he is online opSetPersPresence
opSetPersPresence .setPresenceStatusForContact(
.setPresenceStatusForContact( (ContactFacebookImpl) from,
(ContactFacebookImpl) from, FacebookStatusEnum.ONLINE);
FacebookStatusEnum.ONLINE);
super.fireMessageReceived(message, from);
super.fireMessageReceived(message, from); }
}
/**
/** * Determines whether the protocol provider (or the protocol itself) support
* Determines whether the protocol provider (or the protocol itself) support * sending and receiving offline messages. Most often this method would
* sending and receiving offline messages. Most often this method would * return true for protocols that support offline messages and false for
* return true for protocols that support offline messages and false for * those that don't. It is however possible for a protocol to support these
* those that don't. It is however possible for a protocol to support these * messages and yet have a particular account that does not (i.e. feature
* messages and yet have a particular account that does not (i.e. feature * not enabled on the protocol server). In cases like this it is possible
* not enabled on the protocol server). In cases like this it is possible * for this method to return true even when offline messaging is not
* for this method to return true even when offline messaging is not * supported, and then have the sendMessage method throw an
* supported, and then have the sendMessage method throw an * OperationFailedException with code - OFFLINE_MESSAGES_NOT_SUPPORTED.
* OperationFailedException with code - OFFLINE_MESSAGES_NOT_SUPPORTED. *
* * @return <tt>true</tt> if the protocol supports offline messages and
* @return <tt>true</tt> if the protocol supports offline messages and * <tt>false</tt> otherwise.
* <tt>false</tt> otherwise. */
*/ public boolean isOfflineMessagingSupported()
public boolean isOfflineMessagingSupported() {
{ return false;
return false; }
}
/**
/** * Determines wheter the protocol supports the supplied content type
* Determines wheter the protocol supports the supplied content type *
* * @param contentType the type we want to check
* @param contentType the type we want to check * @return <tt>true</tt> if the protocol supports it and <tt>false</tt>
* @return <tt>true</tt> if the protocol supports it and <tt>false</tt> * otherwise.
* otherwise. */
*/ public boolean isContentTypeSupported(String contentType)
public boolean isContentTypeSupported(String contentType) {
{ return contentType.equals(DEFAULT_MIME_TYPE);
return contentType.equals(DEFAULT_MIME_TYPE); }
} }
}

@ -377,7 +377,7 @@ public void leave()
{ {
Map.Entry<String, Contact> memberEntry = membersSet.next(); Map.Entry<String, Contact> memberEntry = membersSet.next();
Contact participant = (Contact) memberEntry.getValue(); Contact participant = memberEntry.getValue();
fireParticipantPresenceEvent(participant, fireParticipantPresenceEvent(participant,
AdHocChatRoomParticipantPresenceChangeEvent.CONTACT_LEFT, AdHocChatRoomParticipantPresenceChangeEvent.CONTACT_LEFT,

@ -107,8 +107,8 @@ public String getDisplayName()
if (call != null) if (call != null)
{ {
ProtocolProviderService pps = call.getProtocolProvider(); ProtocolProviderService pps = call.getProtocolProvider();
OperationSetPresence opSetPresence = (OperationSetPresence) pps OperationSetPresence opSetPresence
.getOperationSet(OperationSetPresence.class); = pps.getOperationSet(OperationSetPresence.class);
Contact cont = opSetPresence.findContactByID(getAddress()); Contact cont = opSetPresence.findContactByID(getAddress());
if (cont != null) if (cont != null)
@ -243,8 +243,8 @@ public ProtocolProviderService getProtocolProvider()
public Contact getContact() public Contact getContact()
{ {
ProtocolProviderService pps = call.getProtocolProvider(); ProtocolProviderService pps = call.getProtocolProvider();
OperationSetPresence opSetPresence = (OperationSetPresence) pps OperationSetPresence opSetPresence
.getOperationSet(OperationSetPresence.class); = pps.getOperationSet(OperationSetPresence.class);
return opSetPresence.findContactByID(getAddress()); return opSetPresence.findContactByID(getAddress());
} }

@ -63,8 +63,9 @@ public OperationSetGeolocationJabberImpl(
{ {
this.jabberProvider = provider; this.jabberProvider = provider;
this.opsetprez = (OperationSetPersistentPresence) this.opsetprez
provider.getOperationSet(OperationSetPersistentPresence.class); = provider
.getOperationSet(OperationSetPersistentPresence.class);
this.jabberProvider.addRegistrationStateChangeListener( this.jabberProvider.addRegistrationStateChangeListener(
new RegistrationStateListener()); new RegistrationStateListener());

@ -63,7 +63,7 @@ public class OperationSetMultiUserChatJabberImpl
jabberProvider.addRegistrationStateChangeListener(providerRegListener); jabberProvider.addRegistrationStateChangeListener(providerRegListener);
OperationSetPersistentPresence presenceOpSet OperationSetPersistentPresence presenceOpSet
= (OperationSetPersistentPresence) jabberProvider = jabberProvider
.getOperationSet(OperationSetPersistentPresence.class); .getOperationSet(OperationSetPersistentPresence.class);
presenceOpSet.addSubscriptionListener(this); presenceOpSet.addSubscriptionListener(this);

@ -151,8 +151,7 @@ public void handleUri(String uri)
} }
OperationSetPresence presenceOpSet OperationSetPresence presenceOpSet
= (OperationSetPresence) provider = provider.getOperationSet(OperationSetPresence.class);
.getOperationSet(OperationSetPresence.class);
try try
{ {

@ -710,7 +710,8 @@ public boolean equals(Object obj)
public OperationSetPersistentPresence public OperationSetPersistentPresence
getParentPresenceOperationSet() getParentPresenceOperationSet()
{ {
return (OperationSetPersistentPresence)parentProvider return
parentProvider
.getOperationSet(OperationSetPersistentPresence.class); .getOperationSet(OperationSetPersistentPresence.class);
} }
@ -724,7 +725,8 @@ public boolean equals(Object obj)
public OperationSetBasicInstantMessaging public OperationSetBasicInstantMessaging
getParentBasicInstantMessagingOperationSet() getParentBasicInstantMessagingOperationSet()
{ {
return (OperationSetBasicInstantMessaging)parentProvider return
parentProvider
.getOperationSet(OperationSetBasicInstantMessaging.class); .getOperationSet(OperationSetBasicInstantMessaging.class);
} }
@ -738,8 +740,7 @@ public boolean equals(Object obj)
public OperationSetFileTransfer public OperationSetFileTransfer
getFileTransferOperationSet() getFileTransferOperationSet()
{ {
return (OperationSetFileTransfer)parentProvider return parentProvider.getOperationSet(OperationSetFileTransfer.class);
.getOperationSet(OperationSetFileTransfer.class);
} }

@ -369,7 +369,6 @@ public void rejectInvitation(AdHocChatRoomInvitation invitation,
* @param targetChatRoom the room that invitation refers to * @param targetChatRoom the room that invitation refers to
* @param inviter the inviter that sent the invitation * @param inviter the inviter that sent the invitation
* @param reason the reason why the inviter sent the invitation * @param reason the reason why the inviter sent the invitation
* @param password the password to use when joining the room
*/ */
public void fireInvitationEvent(AdHocChatRoom targetChatRoom, public void fireInvitationEvent(AdHocChatRoom targetChatRoom,
String inviter, String reason) String inviter, String reason)

@ -1,194 +1,192 @@
/* /*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
* *
* Distributable under LGPL license. * Distributable under LGPL license.
* See terms of license at gnu.org. * See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.plugin.autoaway; package net.java.sip.communicator.plugin.autoaway;
import java.awt.*; import java.awt.*;
import java.util.*; import java.util.*;
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
/** /**
* A Runnable, which permanently looks at the mouse position. If the mouse is * A Runnable, which permanently looks at the mouse position. If the mouse is
* not moved, all accounts are set to "Away" or similar states. * not moved, all accounts are set to "Away" or similar states.
* *
* @author Thomas Hofer * @author Thomas Hofer
*/ */
public class StatusUpdateThread public class StatusUpdateThread
implements Runnable implements Runnable
{ {
private boolean run = false; private boolean run = false;
private Point lastPosition = null; private Point lastPosition = null;
private final Map<ProtocolProviderService, PresenceStatus> lastStates private final Map<ProtocolProviderService, PresenceStatus> lastStates
= new HashMap<ProtocolProviderService, PresenceStatus>(); = new HashMap<ProtocolProviderService, PresenceStatus>();
private static final int IDLE_TIMER = 3000; private static final int IDLE_TIMER = 3000;
private static final int AWAY_DEFAULT_STATUS = 40; private static final int AWAY_DEFAULT_STATUS = 40;
public void run() public void run()
{ {
run = true; run = true;
int timer = 0; int timer = 0;
do do
{ {
try try
{ {
if (MouseInfo.getPointerInfo() != null) if (MouseInfo.getPointerInfo() != null)
{ {
PointerInfo info = MouseInfo.getPointerInfo(); PointerInfo info = MouseInfo.getPointerInfo();
Point currentPosition Point currentPosition
= (info != null) ? info.getLocation() : new Point(0, 0); = (info != null) ? info.getLocation() : new Point(0, 0);
if (!isNear(lastPosition, currentPosition)) if (!isNear(lastPosition, currentPosition))
{ {
// position has changed // position has changed
// check, if a minor state has been automatically set // check, if a minor state has been automatically set
// and // and
// reset this state to the former state. // reset this state to the former state.
for (ProtocolProviderService protocolProviderService for (ProtocolProviderService protocolProviderService
: AutoAwayActivator.getProtocolProviders()) : AutoAwayActivator.getProtocolProviders())
{ {
if (lastStates.get(protocolProviderService) != null) if (lastStates.get(protocolProviderService) != null)
{ {
PresenceStatus lastState PresenceStatus lastState
= lastStates.get(protocolProviderService); = lastStates.get(protocolProviderService);
OperationSetPresence presence OperationSetPresence presence
= (OperationSetPresence) = protocolProviderService
protocolProviderService .getOperationSet(
.getOperationSet( OperationSetPresence.class);
OperationSetPresence.class); try
try {
{ presence
presence .publishPresenceStatus(lastState, "");
.publishPresenceStatus(lastState, ""); } catch (IllegalArgumentException e)
} catch (IllegalArgumentException e) {
{ } catch (IllegalStateException e)
} catch (IllegalStateException e) {
{ } catch (OperationFailedException e)
} catch (OperationFailedException e) {
{ }
} lastStates.remove(protocolProviderService);
lastStates.remove(protocolProviderService); }
} }
} timer = getTimer() * 1000 * 60;
timer = getTimer() * 1000 * 60; } else
} else {
{ // position has not changed!
// position has not changed! // get all protocols and set them to away
// get all protocols and set them to away for (ProtocolProviderService protocolProviderService
for (ProtocolProviderService protocolProviderService : AutoAwayActivator.getProtocolProviders())
: AutoAwayActivator.getProtocolProviders()) {
{ OperationSetPresence presence
OperationSetPresence presence = protocolProviderService
= (OperationSetPresence) .getOperationSet(
protocolProviderService OperationSetPresence.class);
.getOperationSet(
OperationSetPresence.class); PresenceStatus status = presence
.getPresenceStatus();
PresenceStatus status = presence
.getPresenceStatus(); if (status.getStatus()
< PresenceStatus.AVAILABLE_THRESHOLD)
if (status.getStatus() {
< PresenceStatus.AVAILABLE_THRESHOLD) // already (manually) set to away or lower
{ continue;
// already (manually) set to away or lower }
continue;
} lastStates.put(protocolProviderService, status);
lastStates.put(protocolProviderService, status); PresenceStatus newStatus = findAwayStatus(presence);
PresenceStatus newStatus = findAwayStatus(presence); try
{
try if (newStatus != null)
{ presence
if (newStatus != null) .publishPresenceStatus(
presence newStatus,
.publishPresenceStatus( newStatus.getStatusName());
newStatus, } catch (IllegalArgumentException e)
newStatus.getStatusName()); {
} catch (IllegalArgumentException e) } catch (IllegalStateException e)
{ {
} catch (IllegalStateException e) } catch (OperationFailedException e)
{ {
} catch (OperationFailedException e) }
{ }
}
} timer = IDLE_TIMER;
}
timer = IDLE_TIMER; lastPosition = currentPosition;
} }
lastPosition = currentPosition; Thread.sleep(timer);
} } catch (InterruptedException e)
Thread.sleep(timer); {
} catch (InterruptedException e) }
{ } while (run && timer > 0);
} }
} while (run && timer > 0);
} public void stop()
{
public void stop() run = false;
{ }
run = false;
} /**
* Finds the Away-Status of the protocols
/** *
* Finds the Away-Status of the protocols * @param presence
* * @return
* @param presence */
* @return private PresenceStatus findAwayStatus(OperationSetPresence presence)
*/ {
private PresenceStatus findAwayStatus(OperationSetPresence presence) Iterator<PresenceStatus> statusSet = presence.getSupportedStatusSet();
{ PresenceStatus status = null;
Iterator<PresenceStatus> statusSet = presence.getSupportedStatusSet();
PresenceStatus status = null; while (statusSet.hasNext())
{
while (statusSet.hasNext()) PresenceStatus possibleState = statusSet.next();
{ int possibleStatus = possibleState.getStatus();
PresenceStatus possibleState = statusSet.next();
int possibleStatus = possibleState.getStatus(); if ((possibleStatus < PresenceStatus.AVAILABLE_THRESHOLD)
&& (possibleStatus >= PresenceStatus.ONLINE_THRESHOLD))
if ((possibleStatus < PresenceStatus.AVAILABLE_THRESHOLD) {
&& (possibleStatus >= PresenceStatus.ONLINE_THRESHOLD)) if (status == null
{ || (Math.abs(possibleStatus - AWAY_DEFAULT_STATUS)
if (status == null < Math.abs(
|| (Math.abs(possibleStatus - AWAY_DEFAULT_STATUS) status.getStatus()
< Math.abs( - AWAY_DEFAULT_STATUS)))
status.getStatus() {
- AWAY_DEFAULT_STATUS))) status = possibleState;
{ }
status = possibleState; }
} }
} return status;
} }
return status;
} private int getTimer()
{
private int getTimer() ConfigurationService configService
{ = AutoAwayActivator.getConfigService();
ConfigurationService configService
= AutoAwayActivator.getConfigService(); return
configService.getBoolean(Preferences.ENABLE, false)
return ? configService.getInt(Preferences.TIMER, 0)
configService.getBoolean(Preferences.ENABLE, false) : 0;
? configService.getInt(Preferences.TIMER, 0) }
: 0;
} public boolean isRunning()
{
public boolean isRunning() return run;
{ }
return run;
} private boolean isNear(Point p1, Point p2)
{
private boolean isNear(Point p1, Point p2) return
{ (p1 != null)
return && (p2 != null)
(p1 != null) && (Math.abs(p1.x - p2.x) <= 10)
&& (p2 != null) && (Math.abs(p1.y - p2.y) <= 10);
&& (Math.abs(p1.x - p2.x) <= 10) }
&& (Math.abs(p1.y - p2.y) <= 10); }
}
}

@ -1,344 +1,340 @@
/* /*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
* *
* Distributable under LGPL license. * Distributable under LGPL license.
* See terms of license at gnu.org. * See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.plugin.chatalerter; package net.java.sip.communicator.plugin.chatalerter;
import javax.swing.*; import javax.swing.*;
import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import org.jdesktop.jdic.misc.*; import org.jdesktop.jdic.misc.*;
import org.osgi.framework.*; import org.osgi.framework.*;
/** /**
* Chat Alerter plugin. * Chat Alerter plugin.
* *
* Sends alerts to the user when new message arrives and the application is not * Sends alerts to the user when new message arrives and the application is not
* in the foreground. On Mac OS X this will bounce the dock icon until the user * in the foreground. On Mac OS X this will bounce the dock icon until the user
* selects the chat windows. On Windows, Gnome and KDE this will flash the * selects the chat windows. On Windows, Gnome and KDE this will flash the
* taskbar button/icon until the user selects the chat window. * taskbar button/icon until the user selects the chat window.
* *
* @author Damian Minkov * @author Damian Minkov
*/ */
public class ChatAlerterActivator public class ChatAlerterActivator
implements BundleActivator, implements BundleActivator,
ServiceListener, ServiceListener,
MessageListener, MessageListener,
ChatRoomMessageListener, ChatRoomMessageListener,
AdHocChatRoomMessageListener, AdHocChatRoomMessageListener,
LocalUserChatRoomPresenceListener, LocalUserChatRoomPresenceListener,
LocalUserAdHocChatRoomPresenceListener LocalUserAdHocChatRoomPresenceListener
{ {
/** /**
* The logger for this class. * The logger for this class.
*/ */
private static Logger logger = Logger.getLogger(ChatAlerterActivator.class); private static Logger logger = Logger.getLogger(ChatAlerterActivator.class);
/** /**
* The BundleContext that we got from the OSGI bus. * The BundleContext that we got from the OSGI bus.
*/ */
private BundleContext bundleContext = null; private BundleContext bundleContext = null;
/** /**
* UIService reference. * UIService reference.
*/ */
private UIService uiService; private UIService uiService;
/** /**
* Starts this bundle. * Starts this bundle.
*/ */
public void start(BundleContext bc) throws Exception public void start(BundleContext bc) throws Exception
{ {
try try
{ {
// try to load native libs, if it fails don't do anything // try to load native libs, if it fails don't do anything
Alerter.newInstance(); Alerter.newInstance();
} }
catch (Exception exception) catch (Exception exception)
{ {
logger.info("The Alerter not supported or problem loading it!", logger.info("The Alerter not supported or problem loading it!",
exception); exception);
return; return;
} }
ServiceReference uiServiceRef
= bc.getServiceReference(UIService.class.getName());
uiService = (UIService) bc.getService(uiServiceRef);
this.bundleContext = bc;
// start listening for newly register or removed protocol providers
bc.addServiceListener(this);
ServiceReference[] protocolProviderRefs;
try
{
protocolProviderRefs = bc.getServiceReferences(
ProtocolProviderService.class.getName(),
null);
}
catch (InvalidSyntaxException ex)
{
// this shouldn't happen since we're providing no parameter string
// but let's log just in case.
logger.error(
"Error while retrieving service refs", ex);
return;
}
// in case we found any
if (protocolProviderRefs != null)
{
logger.debug("Found "
+ protocolProviderRefs.length
+ " already installed providers.");
for (ServiceReference protocolProviderRef : protocolProviderRefs)
{
ProtocolProviderService provider
= (ProtocolProviderService)
bc.getService(protocolProviderRef);
this.handleProviderAdded(provider);
}
}
} ServiceReference uiServiceRef
= bc.getServiceReference(UIService.class.getName());
public void stop(BundleContext bc) throws Exception
{ uiService = (UIService) bc.getService(uiServiceRef);
// start listening for newly register or removed protocol providers
bc.removeServiceListener(this); this.bundleContext = bc;
ServiceReference[] protocolProviderRefs; // start listening for newly register or removed protocol providers
try bc.addServiceListener(this);
{
protocolProviderRefs = bc.getServiceReferences( ServiceReference[] protocolProviderRefs;
ProtocolProviderService.class.getName(), try
null); {
} protocolProviderRefs = bc.getServiceReferences(
catch (InvalidSyntaxException ex) ProtocolProviderService.class.getName(),
{ null);
// this shouldn't happen since we're providing no parameter string }
// but let's log just in case. catch (InvalidSyntaxException ex)
logger.error( {
"Error while retrieving service refs", ex); // this shouldn't happen since we're providing no parameter string
return; // but let's log just in case.
} logger.error(
"Error while retrieving service refs", ex);
// in case we found any return;
if (protocolProviderRefs != null) }
{
for (ServiceReference protocolProviderRef : protocolProviderRefs) // in case we found any
{ if (protocolProviderRefs != null)
ProtocolProviderService provider {
= (ProtocolProviderService) logger.debug("Found "
bc.getService(protocolProviderRef); + protocolProviderRefs.length
+ " already installed providers.");
this.handleProviderRemoved(provider); for (ServiceReference protocolProviderRef : protocolProviderRefs)
} {
} ProtocolProviderService provider
} = (ProtocolProviderService)
bc.getService(protocolProviderRef);
/**
* Used to attach the Alerter plugin to existing or this.handleProviderAdded(provider);
* just registered protocol provider. Checks if the provider has implementation }
* of OperationSetBasicInstantMessaging }
*
* @param provider ProtocolProviderService }
*/
private void handleProviderAdded(ProtocolProviderService provider) public void stop(BundleContext bc) throws Exception
{ {
logger.debug("Adding protocol provider " + provider.getProtocolName()); // start listening for newly register or removed protocol providers
bc.removeServiceListener(this);
// check whether the provider has a basic im operation set
OperationSetBasicInstantMessaging opSetIm = ServiceReference[] protocolProviderRefs;
(OperationSetBasicInstantMessaging) provider try
.getOperationSet(OperationSetBasicInstantMessaging.class); {
protocolProviderRefs = bc.getServiceReferences(
if (opSetIm != null) ProtocolProviderService.class.getName(),
{ null);
opSetIm.addMessageListener(this); }
} catch (InvalidSyntaxException ex)
else {
{ // this shouldn't happen since we're providing no parameter string
logger.trace("Service did not have a im op. set."); // but let's log just in case.
} logger.error(
"Error while retrieving service refs", ex);
// check whether the provider has a sms operation set return;
OperationSetSmsMessaging opSetSms = }
(OperationSetSmsMessaging) provider
.getOperationSet(OperationSetSmsMessaging.class); // in case we found any
if (protocolProviderRefs != null)
if (opSetSms != null) {
{ for (ServiceReference protocolProviderRef : protocolProviderRefs)
opSetSms.addMessageListener(this); {
} ProtocolProviderService provider
else = (ProtocolProviderService)
{ bc.getService(protocolProviderRef);
logger.trace("Service did not have a sms op. set.");
} this.handleProviderRemoved(provider);
}
OperationSetMultiUserChat opSetMultiUChat = }
(OperationSetMultiUserChat) provider }
.getOperationSet(OperationSetMultiUserChat.class);
/**
if (opSetMultiUChat != null) * Used to attach the Alerter plugin to existing or
{ * just registered protocol provider. Checks if the provider has implementation
for (ChatRoom room : opSetMultiUChat.getCurrentlyJoinedChatRooms()) * of OperationSetBasicInstantMessaging
room.addMessageListener(this); *
* @param provider ProtocolProviderService
opSetMultiUChat.addPresenceListener(this); */
} private void handleProviderAdded(ProtocolProviderService provider)
else {
{ logger.debug("Adding protocol provider " + provider.getProtocolName());
logger.trace("Service did not have a multi im op. set.");
} // check whether the provider has a basic im operation set
} OperationSetBasicInstantMessaging opSetIm
= provider
/** .getOperationSet(OperationSetBasicInstantMessaging.class);
* Removes the specified provider from the list of currently known providers
* and ignores all the messages exchanged by it if (opSetIm != null)
* {
* @param provider the ProtocolProviderService that has been unregistered. opSetIm.addMessageListener(this);
*/ }
private void handleProviderRemoved(ProtocolProviderService provider) else
{ {
OperationSetBasicInstantMessaging opSetIm = logger.trace("Service did not have a im op. set.");
(OperationSetBasicInstantMessaging) provider }
.getOperationSet(OperationSetBasicInstantMessaging.class);
// check whether the provider has a sms operation set
if (opSetIm != null) OperationSetSmsMessaging opSetSms
{ = provider.getOperationSet(OperationSetSmsMessaging.class);
opSetIm.removeMessageListener(this);
} if (opSetSms != null)
{
OperationSetMultiUserChat opSetMultiUChat = opSetSms.addMessageListener(this);
(OperationSetMultiUserChat) provider }
.getOperationSet(OperationSetMultiUserChat.class); else
{
if (opSetMultiUChat != null) logger.trace("Service did not have a sms op. set.");
{ }
for (ChatRoom room : opSetMultiUChat.getCurrentlyJoinedChatRooms())
room.removeMessageListener(this); OperationSetMultiUserChat opSetMultiUChat
} = provider.getOperationSet(OperationSetMultiUserChat.class);
}
if (opSetMultiUChat != null)
/** {
* Called to notify interested parties that a change in our presence in for (ChatRoom room : opSetMultiUChat.getCurrentlyJoinedChatRooms())
* a chat room has occurred. Changes may include us being kicked, join, room.addMessageListener(this);
* left.
* @param evt the <tt>LocalUserChatRoomPresenceChangeEvent</tt> instance opSetMultiUChat.addPresenceListener(this);
* containing the chat room and the type, and reason of the change }
*/ else
public void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt) {
{ logger.trace("Service did not have a multi im op. set.");
if(evt.getEventType() == }
LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED) }
{
if (!evt.getChatRoom().isSystem()) /**
evt.getChatRoom().addMessageListener(this); * Removes the specified provider from the list of currently known providers
} * and ignores all the messages exchanged by it
else *
{ * @param provider the ProtocolProviderService that has been unregistered.
evt.getChatRoom().removeMessageListener(this); */
} private void handleProviderRemoved(ProtocolProviderService provider)
} {
OperationSetBasicInstantMessaging opSetIm
public void messageReceived(MessageReceivedEvent evt) = provider.getOperationSet(OperationSetBasicInstantMessaging.class);
{
alertChatWindow(); if (opSetIm != null)
} {
opSetIm.removeMessageListener(this);
public void messageDelivered(MessageDeliveredEvent evt) }
{
// do nothing OperationSetMultiUserChat opSetMultiUChat
} = provider.getOperationSet(OperationSetMultiUserChat.class);
public void messageDeliveryFailed(MessageDeliveryFailedEvent evt) if (opSetMultiUChat != null)
{ {
// do nothing for (ChatRoom room : opSetMultiUChat.getCurrentlyJoinedChatRooms())
} room.removeMessageListener(this);
}
public void messageReceived(ChatRoomMessageReceivedEvent evt) }
{
alertChatWindow(); /**
} * Called to notify interested parties that a change in our presence in
* a chat room has occurred. Changes may include us being kicked, join,
public void messageDelivered(ChatRoomMessageDeliveredEvent evt) * left.
{ * @param evt the <tt>LocalUserChatRoomPresenceChangeEvent</tt> instance
// do nothing * containing the chat room and the type, and reason of the change
} */
public void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt)
public void messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt) {
{ if(evt.getEventType() ==
// do nothing LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED)
} {
if (!evt.getChatRoom().isSystem())
/** evt.getChatRoom().addMessageListener(this);
* Alerts that a message has been received in }
* <code>ExportedWindow.CHAT_WINDOW</code> by using a platform-dependent else
* visual clue such as flashing it in the task bar on Windows and Linux. {
*/ evt.getChatRoom().removeMessageListener(this);
private void alertChatWindow() }
{ }
try
{ public void messageReceived(MessageReceivedEvent evt)
ExportedWindow win {
= uiService.getExportedWindow(ExportedWindow.CHAT_WINDOW); alertChatWindow();
if (win == null) }
return;
public void messageDelivered(MessageDeliveredEvent evt)
Object winSource = win.getSource(); {
if (!(winSource instanceof JFrame)) // do nothing
return; }
JFrame fr = (JFrame) winSource; public void messageDeliveryFailed(MessageDeliveryFailedEvent evt)
{
Alerter.newInstance().alert(fr); // do nothing
} }
catch (Exception ex)
{ public void messageReceived(ChatRoomMessageReceivedEvent evt)
logger.error("Cannot alert chat window!"); {
} alertChatWindow();
} }
/** public void messageDelivered(ChatRoomMessageDeliveredEvent evt)
* When new protocol provider is registered we check {
* does it supports needed Op. Sets and if so add a listener to it // do nothing
* }
* @param serviceEvent ServiceEvent
*/ public void messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt)
public void serviceChanged(ServiceEvent serviceEvent) {
{ // do nothing
Object sService }
= bundleContext.getService(serviceEvent.getServiceReference());
/**
logger.trace("Received a service event for: " + * Alerts that a message has been received in
sService.getClass().getName()); * <code>ExportedWindow.CHAT_WINDOW</code> by using a platform-dependent
* visual clue such as flashing it in the task bar on Windows and Linux.
// we don't care if the source service is not a protocol provider */
if (!(sService instanceof ProtocolProviderService)) private void alertChatWindow()
return; {
try
logger.debug("Service is a protocol provider."); {
switch (serviceEvent.getType()) ExportedWindow win
{ = uiService.getExportedWindow(ExportedWindow.CHAT_WINDOW);
case ServiceEvent.REGISTERED: if (win == null)
this.handleProviderAdded((ProtocolProviderService)sService); return;
break;
Object winSource = win.getSource();
case ServiceEvent.UNREGISTERING: if (!(winSource instanceof JFrame))
this.handleProviderRemoved( (ProtocolProviderService) sService); return;
break;
} JFrame fr = (JFrame) winSource;
}
Alerter.newInstance().alert(fr);
}
catch (Exception ex)
{
logger.error("Cannot alert chat window!");
}
}
/**
* When new protocol provider is registered we check
* does it supports needed Op. Sets and if so add a listener to it
*
* @param serviceEvent ServiceEvent
*/
public void serviceChanged(ServiceEvent serviceEvent)
{
Object sService
= bundleContext.getService(serviceEvent.getServiceReference());
logger.trace("Received a service event for: " +
sService.getClass().getName());
// we don't care if the source service is not a protocol provider
if (!(sService instanceof ProtocolProviderService))
return;
logger.debug("Service is a protocol provider.");
switch (serviceEvent.getType())
{
case ServiceEvent.REGISTERED:
this.handleProviderAdded((ProtocolProviderService)sService);
break;
case ServiceEvent.UNREGISTERING:
this.handleProviderRemoved( (ProtocolProviderService) sService);
break;
}
}
public void messageDelivered(AdHocChatRoomMessageDeliveredEvent evt) public void messageDelivered(AdHocChatRoomMessageDeliveredEvent evt)
{ {
@ -377,4 +373,4 @@ public void localUserAdHocPresenceChanged(
evt.getAdHocChatRoom().removeMessageListener(this); evt.getAdHocChatRoom().removeMessageListener(this);
} }
} }
} }

@ -349,8 +349,7 @@ public void handleProviderAdded(ProtocolProviderService provider)
// check whether the provider has a basic telephony operation set // check whether the provider has a basic telephony operation set
OperationSetBasicTelephony opSetTelephony = OperationSetBasicTelephony opSetTelephony =
(OperationSetBasicTelephony) provider provider.getOperationSet(OperationSetBasicTelephony.class);
.getOperationSet(OperationSetBasicTelephony.class);
if (opSetTelephony != null) if (opSetTelephony != null)
{ {
@ -360,7 +359,6 @@ public void handleProviderAdded(ProtocolProviderService provider)
{ {
logger.trace("Service did not have a basic telephony op. set."); logger.trace("Service did not have a basic telephony op. set.");
} }
} }
/** /**
@ -372,8 +370,7 @@ public void handleProviderAdded(ProtocolProviderService provider)
private void handleProviderRemoved(ProtocolProviderService provider) private void handleProviderRemoved(ProtocolProviderService provider)
{ {
OperationSetBasicTelephony opSetTelephony = OperationSetBasicTelephony opSetTelephony =
(OperationSetBasicTelephony) provider provider.getOperationSet(OperationSetBasicTelephony.class);
.getOperationSet(OperationSetBasicTelephony.class);
if (opSetTelephony != null) if (opSetTelephony != null)
{ {
@ -574,9 +571,9 @@ private void waitForCallEnd(Call call)
private void answerCall(Call call) private void answerCall(Call call)
{ {
OperationSetBasicTelephony telephony OperationSetBasicTelephony telephony
= (OperationSetBasicTelephony)call = call
.getProtocolProvider().getOperationSet( .getProtocolProvider()
OperationSetBasicTelephony.class); .getOperationSet(OperationSetBasicTelephony.class);
Iterator peers = call.getCallPeers(); Iterator peers = call.getCallPeers();
while(peers.hasNext()) while(peers.hasNext())
@ -607,9 +604,9 @@ private void answerCall(Call call)
private void hangupCall(Call call) private void hangupCall(Call call)
{ {
OperationSetBasicTelephony telephony OperationSetBasicTelephony telephony
= (OperationSetBasicTelephony)call = call
.getProtocolProvider().getOperationSet( .getProtocolProvider()
OperationSetBasicTelephony.class); .getOperationSet(OperationSetBasicTelephony.class);
logger.info("Max Message Length Reached, Mailbox is" logger.info("Max Message Length Reached, Mailbox is"
+" disconnecting the call"); +" disconnecting the call");
Iterator<? extends CallPeer> callPeers = call.getCallPeers(); Iterator<? extends CallPeer> callPeers = call.getCallPeers();

@ -176,8 +176,8 @@ public void start(BundleContext bc) throws Exception
private void handleProviderAdded(ProtocolProviderService provider) private void handleProviderAdded(ProtocolProviderService provider)
{ {
OperationSetInstantMessageTransform opSetMessageTransform = OperationSetInstantMessageTransform opSetMessageTransform
(OperationSetInstantMessageTransform) provider = provider
.getOperationSet(OperationSetInstantMessageTransform.class); .getOperationSet(OperationSetInstantMessageTransform.class);
if (opSetMessageTransform != null) if (opSetMessageTransform != null)
@ -244,8 +244,8 @@ public void stop(BundleContext bc) throws Exception
private void handleProviderRemoved(ProtocolProviderService provider) private void handleProviderRemoved(ProtocolProviderService provider)
{ {
// check whether the provider has a basic im operation set // check whether the provider has a basic im operation set
OperationSetInstantMessageTransform opSetMessageTransform = OperationSetInstantMessageTransform opSetMessageTransform
(OperationSetInstantMessageTransform) provider = provider
.getOperationSet(OperationSetInstantMessageTransform.class); .getOperationSet(OperationSetInstantMessageTransform.class);
if (opSetMessageTransform != null) if (opSetMessageTransform != null)

@ -109,8 +109,7 @@ public static List<OperationSetWhiteboarding> getWhiteboardOperationSets()
= (ProtocolProviderService) bundleContext.getService(serRef); = (ProtocolProviderService) bundleContext.getService(serRef);
OperationSetWhiteboarding opSet OperationSetWhiteboarding opSet
= (OperationSetWhiteboarding) = protocolProvider
protocolProvider
.getOperationSet(OperationSetWhiteboarding.class); .getOperationSet(OperationSetWhiteboarding.class);
if(opSet != null) if(opSet != null)

@ -59,9 +59,10 @@ public WhiteboardSessionManager()
*/ */
public void initWhiteboard (final Contact contact) public void initWhiteboard (final Contact contact)
{ {
opSetWb = (OperationSetWhiteboarding) opSetWb
contact.getProtocolProvider(). = contact
getOperationSet(OperationSetWhiteboarding.class); .getProtocolProvider()
.getOperationSet(OperationSetWhiteboarding.class);
if (opSetWb == null) if (opSetWb == null)
{ {

@ -46,7 +46,7 @@ protected void setUp() throws Exception
fixture.setUp(); fixture.setUp();
OperationSetPersistentPresence opSetPresence = OperationSetPersistentPresence opSetPresence =
(OperationSetPersistentPresence) fixture.mockProvider fixture.mockProvider
.getOperationSet(OperationSetPersistentPresence.class); .getOperationSet(OperationSetPersistentPresence.class);
mockGroup = (MockContactGroup)opSetPresence mockGroup = (MockContactGroup)opSetPresence

@ -190,8 +190,8 @@ public void testPartialContactListRestauration()
//verify that contents of the meta contact list matches contents of //verify that contents of the meta contact list matches contents of
//the mock provider we removed. //the mock provider we removed.
ContactGroup oldProtoRoot = ContactGroup oldProtoRoot =
((OperationSetPersistentPresence) fixture.mockProvider fixture.mockProvider
.getOperationSet(OperationSetPersistentPresence.class)) .getOperationSet(OperationSetPersistentPresence.class)
.getServerStoredContactListRoot(); .getServerStoredContactListRoot();
fixture.assertGroupEquals( fixture.assertGroupEquals(
@ -203,8 +203,8 @@ public void testPartialContactListRestauration()
//verify that the new mock provider has created unresolved contacts //verify that the new mock provider has created unresolved contacts
//for all contacts in the meta cl. //for all contacts in the meta cl.
ContactGroup newProtoRoot = ContactGroup newProtoRoot =
((OperationSetPersistentPresence) fixture.replacementMockPr fixture.replacementMockPr
.getOperationSet(OperationSetPersistentPresence.class)) .getOperationSet(OperationSetPersistentPresence.class)
.getServerStoredContactListRoot(); .getServerStoredContactListRoot();
assertEquals("Newly loaded provider does not match the old one." assertEquals("Newly loaded provider does not match the old one."
@ -240,21 +240,21 @@ public void testCompleteContactListRestauration()
//Get references to the root groups of the 2 providers we removed //Get references to the root groups of the 2 providers we removed
ContactGroup oldProtoMockP1Root = ContactGroup oldProtoMockP1Root =
((OperationSetPersistentPresence) fixture.mockP1 fixture.mockP1
.getOperationSet(OperationSetPersistentPresence.class)) .getOperationSet(OperationSetPersistentPresence.class)
.getServerStoredContactListRoot(); .getServerStoredContactListRoot();
ContactGroup oldProtoMockP2Root = ContactGroup oldProtoMockP2Root =
((OperationSetPersistentPresence) fixture.mockP2 fixture.mockP2
.getOperationSet(OperationSetPersistentPresence.class)) .getOperationSet(OperationSetPersistentPresence.class)
.getServerStoredContactListRoot(); .getServerStoredContactListRoot();
//verify that contacts tnat unresolved contacts that have been created //verify that contacts tnat unresolved contacts that have been created
//inside that the replacement mock providers match those in the //inside that the replacement mock providers match those in the
//providers we removed. //providers we removed.
ContactGroup newProtoMockP1Root = ContactGroup newProtoMockP1Root =
((OperationSetPersistentPresence) fixture.replacementMockP1 fixture.replacementMockP1
.getOperationSet(OperationSetPersistentPresence.class)) .getOperationSet(OperationSetPersistentPresence.class)
.getServerStoredContactListRoot(); .getServerStoredContactListRoot();
assertEquals("Newly loaded provider does not match the old one." assertEquals("Newly loaded provider does not match the old one."
@ -262,8 +262,8 @@ public void testCompleteContactListRestauration()
, newProtoMockP1Root); , newProtoMockP1Root);
ContactGroup newProtoMockP2Root = ContactGroup newProtoMockP2Root =
((OperationSetPersistentPresence) fixture.replacementMockP2 fixture.replacementMockP2
.getOperationSet(OperationSetPersistentPresence.class)) .getOperationSet(OperationSetPersistentPresence.class)
.getServerStoredContactListRoot(); .getServerStoredContactListRoot();
assertEquals("Newly loaded provider does not match the old one." assertEquals("Newly loaded provider does not match the old one."

@ -74,7 +74,7 @@ private Message createMessage(Contact contact, Message message,
String action) String action)
{ {
OperationSetBasicInstantMessaging imOpSet = OperationSetBasicInstantMessaging imOpSet =
(OperationSetBasicInstantMessaging) contact.getProtocolProvider() contact.getProtocolProvider()
.getOperationSet(OperationSetBasicInstantMessaging.class); .getOperationSet(OperationSetBasicInstantMessaging.class);
return imOpSet.createMessage("__" + action + "__" return imOpSet.createMessage("__" + action + "__"
+ message.getContent()); + message.getContent());

@ -147,8 +147,7 @@ public void testRegister()
// This message is supposed to be offline message and as one is tested // This message is supposed to be offline message and as one is tested
// in TestOperationSetBasicInstantMessaging.testReceiveOfflineMessages() // in TestOperationSetBasicInstantMessaging.testReceiveOfflineMessages()
OperationSetBasicInstantMessaging opSetBasicIM = OperationSetBasicInstantMessaging opSetBasicIM =
(OperationSetBasicInstantMessaging) fixture.provider fixture.provider.getOperationSet(OperationSetBasicInstantMessaging.class);
.getOperationSet(OperationSetBasicInstantMessaging.class);
fixture.offlineMsgCollector.register(opSetBasicIM); fixture.offlineMsgCollector.register(opSetBasicIM);
//give time for the AIM server to notify everyone of our arrival //give time for the AIM server to notify everyone of our arrival

@ -70,10 +70,10 @@ public void testCreateCancelCall()
throws ParseException, OperationFailedException throws ParseException, OperationFailedException
{ {
OperationSetBasicTelephony basicTelephonyP1 OperationSetBasicTelephony basicTelephonyP1
= (OperationSetBasicTelephony)fixture.provider1.getOperationSet( = fixture.provider1.getOperationSet(
OperationSetBasicTelephony.class); OperationSetBasicTelephony.class);
OperationSetBasicTelephony basicTelephonyP2 OperationSetBasicTelephony basicTelephonyP2
= (OperationSetBasicTelephony)fixture.provider2.getOperationSet( = fixture.provider2.getOperationSet(
OperationSetBasicTelephony.class); OperationSetBasicTelephony.class);
CallEventCollector call1Listener CallEventCollector call1Listener
@ -300,10 +300,10 @@ public void testCreateRejectCall()
throws ParseException, OperationFailedException throws ParseException, OperationFailedException
{ {
OperationSetBasicTelephony basicTelephonyP1 OperationSetBasicTelephony basicTelephonyP1
= (OperationSetBasicTelephony)fixture.provider1.getOperationSet( = fixture.provider1.getOperationSet(
OperationSetBasicTelephony.class); OperationSetBasicTelephony.class);
OperationSetBasicTelephony basicTelephonyP2 OperationSetBasicTelephony basicTelephonyP2
= (OperationSetBasicTelephony)fixture.provider2.getOperationSet( = fixture.provider2.getOperationSet(
OperationSetBasicTelephony.class); OperationSetBasicTelephony.class);
CallEventCollector call1Listener CallEventCollector call1Listener
@ -537,10 +537,10 @@ public void aTestCreateAnswerHangupCall()
throws ParseException, OperationFailedException throws ParseException, OperationFailedException
{ {
OperationSetBasicTelephony basicTelephonyP1 OperationSetBasicTelephony basicTelephonyP1
= (OperationSetBasicTelephony)fixture.provider1.getOperationSet( = fixture.provider1.getOperationSet(
OperationSetBasicTelephony.class); OperationSetBasicTelephony.class);
OperationSetBasicTelephony basicTelephonyP2 OperationSetBasicTelephony basicTelephonyP2
= (OperationSetBasicTelephony)fixture.provider2.getOperationSet( = fixture.provider2.getOperationSet(
OperationSetBasicTelephony.class); OperationSetBasicTelephony.class);
CallEventCollector call1Listener CallEventCollector call1Listener

Loading…
Cancel
Save