Reflect contact capabilities in call history.

cusax-fix
Sebastien Vincent 15 years ago
parent e70de6b46d
commit ea2ba53bed

@ -71,9 +71,9 @@ public class CallHistorySourceContact implements SourceContact
private final String displayDetails;
/**
* Creates an instance of <tt>CallHistorySourceContact</tt>
* @param contactSource
* @param callRecord
* Creates an instance of <tt>CallHistorySourceContact</tt>
* @param contactSource the contact source
* @param callRecord the call record
*/
public CallHistorySourceContact(CallHistoryContactSource contactSource,
CallRecord callRecord)
@ -129,8 +129,31 @@ private void initPeerDetails()
= new Hashtable<Class<? extends OperationSet>,
ProtocolProviderService>();
preferredProviders.put( OperationSetBasicTelephony.class,
OperationSetContactCapabilities opSetCaps =
preferredProvider.getOperationSet(
OperationSetContactCapabilities.class);
OperationSetPresence opSetPres =
preferredProvider.getOperationSet(
OperationSetPresence.class);
if(opSetCaps != null && opSetPres != null)
{
Contact contact = opSetPres.findContactByID(
peerAddress);
if(contact != null && opSetCaps.getOperationSet(
contact,
OperationSetBasicTelephony.class) != null)
{
preferredProviders.put(
OperationSetBasicTelephony.class,
preferredProvider);
}
}
else
{
preferredProviders.put(OperationSetBasicTelephony.class,
preferredProvider);
}
contactDetail.setPreferredProviders(preferredProviders);
}
@ -150,11 +173,18 @@ private void initPeerDetails()
contactDetail.setPreferredProtocols(preferredProtocols);
}
// Set supported operation sets.
LinkedList<Class<? extends OperationSet>> supportedOpSets
= new LinkedList<Class<? extends OperationSet>>();
supportedOpSets.add(OperationSetBasicTelephony.class);
// if the contat supports call
if((preferredProviders != null &&
preferredProviders.containsKey(
OperationSetBasicTelephony.class)) ||
(preferredProtocols != null))
{
supportedOpSets.add(OperationSetBasicTelephony.class);
}
contactDetail.setSupportedOpSets(supportedOpSets);
contactDetails.add(contactDetail);
@ -267,7 +297,7 @@ public ContactDetail getPreferredContactDetail(
/**
* Returns the date string to show for the given date.
*
*
* @param date the date to format
* @return the date string to show for the given date
*/

@ -19,6 +19,7 @@
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.main.call.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.contactsource.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.neomedia.*;
import net.java.sip.communicator.service.neomedia.device.*;
@ -43,7 +44,13 @@ public class ContactListTreeCellRenderer
Icon,
Skinnable
{
/**
* Serial version UID.
*/
private static final long serialVersionUID = 0L;
private static final Color glowOuterHigh = new Color(223, 238, 249, 100);
private static final Color glowOuterLow = new Color(219, 233, 243, 100);
/**
@ -133,6 +140,9 @@ public class ContactListTreeCellRenderer
*/
protected final JLabel rightLabel = new JLabel();
/**
* The message received image.
*/
private Image msgReceivedImage;
/**
@ -400,9 +410,9 @@ else if (value instanceof GroupNode)
// We have no photo icon for groups.
this.rightLabel.setIcon(null);
if (groupItem.countChildContacts() >= 0)
this.rightLabel.setText( groupItem.countOnlineChildContacts()
this.rightLabel.setText( groupItem.countOnlineChildContacts()
+ "/" + groupItem.countChildContacts());
this.setToolTipText(groupItem.getDescriptor().toString());
@ -614,7 +624,10 @@ private void initButtonsPanel(UIContact uiContact)
= uiContact.getDefaultContactDetail(
OperationSetBasicTelephony.class);
if (telephonyContact != null)
// for SourceContact in history that do not support telephony, we
// show the button but disabled
if (telephonyContact != null ||
uiContact.getDescriptor() instanceof SourceContact)
{
constraints.anchor = GridBagConstraints.WEST;
constraints.fill = GridBagConstraints.NONE;
@ -634,6 +647,7 @@ private void initButtonsPanel(UIContact uiContact)
callButton.setBounds(x,
nameLabel.getHeight() + statusMessageLabelHeight, 28, 28);
callButton.setEnabled(telephonyContact != null);
}
UIContactDetail videoContact
@ -727,7 +741,7 @@ public void paintIcon(Component c, Graphics g, int x, int y)
getIconWidth() - 1, getIconHeight() - 1,
10, 10);
// Indent component content from the border.
// Indent component content from the border.
g2.translate(x + 5, y + 5);
super.paint(g2);

@ -25,7 +25,7 @@
/**
* The right button menu for external contact sources.
* @see ExternalContactSource
*
*
* @author Yana Stamcheva
* @author Adam Netocny
*/
@ -33,6 +33,14 @@ public class SourceContactRightButtonMenu
extends JPopupMenu
implements Skinnable
{
/**
* Serial version UID.
*/
private static final long serialVersionUID = 0L;
/**
* The source contact.
*/
private final SourceContact sourceContact;
/**
@ -112,6 +120,8 @@ public void actionPerformed(ActionEvent e)
CallManager.createCall(detail.getContactAddress());
}
});
callContactItem.setEnabled(detail.getSupportedOperationSets().
contains(OperationSetBasicTelephony.class));
callContactMenu.add(callContactItem);
}
return callContactMenu;

@ -122,6 +122,7 @@ public String getPreferredProtocol(Class<? extends OperationSet> opSetClass)
{
return preferredProtocol;
}
/**
* Returns the <tt>PresenceStatus</tt> of this <tt>ContactDetail</tt> or
* null if the detail doesn't support presence.

@ -24,6 +24,9 @@ public class ExternalContactSource
*/
private final SourceUIGroup sourceUIGroup;
/**
* The contact source.
*/
private final ContactSourceService contactSource;
/**

@ -9,7 +9,6 @@
import java.util.*;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.packet.*;
import net.java.sip.communicator.service.protocol.*;
@ -142,7 +141,6 @@ public class ContactGroupJabberImpl
this.ssclCallback = ssclCallback;
}
/**
* Returns the number of <tt>Contact</tt> members of this
* <tt>ContactGroup</tt>

@ -51,8 +51,8 @@ public class OperationSetPersistentPresenceJabberImpl
private PresenceStatus currentStatus;
/**
* A map containing bindings between SIP Communicator's jabber presence status
* instances and Jabber status codes
* A map containing bindings between SIP Communicator's jabber presence
* status instances and Jabber status codes
*/
private static Map<String, Presence.Mode> scToJabberModesMappings
= new Hashtable<String, Presence.Mode>();
@ -316,7 +316,8 @@ public void moveContactToGroup(Contact contactToMove,
if( !(contactToMove instanceof ContactJabberImpl) )
throw new IllegalArgumentException(
"The specified contact is not an jabber contact." + contactToMove);
"The specified contact is not an jabber contact." +
contactToMove);
if( !(newParent instanceof ContactGroupJabberImpl) )
throw new IllegalArgumentException(
"The specified group is not an jabber contact group."
@ -529,9 +530,9 @@ public void setAuthorizationHandler(AuthorizationHandler handler)
* subscribing fails due to errors experienced during network
* communication
*/
public void subscribe(ContactGroup parent, String contactIdentifier) throws
IllegalArgumentException, IllegalStateException,
OperationFailedException
public void subscribe(ContactGroup parent, String contactIdentifier)
throws IllegalArgumentException, IllegalStateException,
OperationFailedException
{
assertConnected();
@ -647,7 +648,8 @@ else if(mode.equals(Presence.Mode.xa))
* @param status the jabberStatus
* @return a PresenceStatus instance
*/
public static Presence.Mode presenceStatusToJabberMode(PresenceStatus status)
public static Presence.Mode presenceStatusToJabberMode(
PresenceStatus status)
{
return scToJabberModesMappings.get(status
.getStatusName());
@ -906,7 +908,8 @@ void firePresenceStatusChanged(Presence presence)
TreeSet<Presence> userStats = statuses.get(userID);
if(userStats == null)
{
userStats = new TreeSet<Presence>(new Comparator<Presence>(){
userStats = new TreeSet<Presence>(new Comparator<Presence>()
{
public int compare(Presence o1, Presence o2)
{
int res = o1.getPriority() - o2.getPriority();
@ -934,10 +937,12 @@ public int compare(Presence o1, Presence o2)
}
else
{
String resource = StringUtils.parseResource(presence.getFrom());
String resource = StringUtils.parseResource(
presence.getFrom());
// remove the status for this resource
// if we are online we will update its value with the new status
// if we are online we will update its value with the new
// status
for (Iterator<Presence> iter = userStats.iterator();
iter.hasNext();)
{
@ -1114,7 +1119,8 @@ else if (presenceType == Presence.Type.unsubscribed)
}
catch(OperationFailedException e)
{
logger.error("Cannot remove contact that unsubscribed.");
logger.error(
"Cannot remove contact that unsubscribed.");
}
}
}

@ -13,6 +13,7 @@
import net.java.sip.communicator.util.*;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smackx.packet.*;
@ -354,21 +355,21 @@ public ContactJabberImpl findContactById(String id)
{
Iterator<ContactGroup> contactGroups = rootGroup.subgroups();
ContactJabberImpl result = null;
String userId = StringUtils.parseBareAddress(id);
while(contactGroups.hasNext())
{
ContactGroupJabberImpl contactGroup
= (ContactGroupJabberImpl)contactGroups.next();
result = contactGroup.findContact(id);
result = contactGroup.findContact(userId);
if (result != null)
return result;
}
//try the root group now
return rootGroup.findContact(id);
return rootGroup.findContact(userId);
}
/**

@ -55,7 +55,7 @@ public class ContactDetail
private Map<Class<? extends OperationSet>, String> preferredProtocols;
/**
* A list of all supported <tt>OperatioSet</tt> classes.
* A list of all supported <tt>OperationSet</tt> classes.
*/
private List<Class<? extends OperationSet>> supportedOpSets = null;

Loading…
Cancel
Save