Adds support for a boolean ConfigurationService property with name net.java.sip.communicator.plugin.msofficecomm.CREATE_CALL_BY_PHONE_NUMBER which instructs the Microsoft Outlook VoIP integration functionality to resolve a sign-in name to a vCard phone number in case it fails to resolve to a Contact with support for OperationSetBasicTelephony. The sort order of the phone number types is controlled through a String ConfigurationService property with name net.java.sip.communicator.plugin.msofficecomm.MPHONE_TYPE_SORT_ORDER which defaults to a value that prefers a work phone number, if available.

cusax-fix
Lyubomir Marinov 14 years ago
parent a802dab29a
commit 26491feccc

@ -21,6 +21,7 @@
import net.java.sip.communicator.service.protocol.yahooconstants.*;
import net.java.sip.communicator.util.*;
import org.jitsi.service.configuration.*;
import org.jitsi.util.xml.*;
import org.osgi.framework.*;
import org.w3c.dom.*;
@ -84,6 +85,28 @@ public class Messenger
*/
static final int MPHONE_TYPE_WORK = 1;
/**
* The name of the boolean <tt>ConfigurationService</tt> property which
* indicates whether {@link #startConversation(int, String[], String)} is
* to invoke {@link UIService#createCall(String[])} with a phone number
* associated with a specific <tt>IMessengerContact</tt> instead of the
* <tt>Contact</tt> address.
*/
private static final String PNAME_CREATE_CALL_BY_PHONE_NUMBER
= "net.java.sip.communicator.plugin.msofficecomm."
+ "CREATE_CALL_BY_PHONE_NUMBER";
/**
* The name of the <tt>String</tt> <tt>ConfigurationService</tt> property
* which specifies the sort order of the <tt>MPHONE_TYPE_*</tt> enumerated
* type values. The default value orders them as follows:
* {@link #MPHONE_TYPE_WORK}, {@link #MPHONE_TYPE_HOME},
* {@link #MPHONE_TYPE_MOBILE}, {@link #MPHONE_TYPE_CUSTOM}.
*/
private static final String PNAME_MPHONE_TYPE_SORT_ORDER
= "net.java.sip.communicator.plugin.msofficecomm."
+ "MPHONE_TYPE_SORT_ORDER";
/**
* The <tt>BundleContext</tt> in which the <tt>msofficecomm</tt> bundle has
* been started.
@ -97,6 +120,19 @@ public class Messenger
*/
private static MetaContactListService metaContactListService;
/**
* The <tt>MPHONE_TYPE_*</tt> enumerated type values indexed by their sort
* order position.
*/
private static final int[] MPHONE_TYPE_SORT_ORDER
= new int[]
{
MPHONE_TYPE_WORK,
MPHONE_TYPE_HOME,
MPHONE_TYPE_MOBILE,
MPHONE_TYPE_CUSTOM
};
/**
* The list of (local) accounts by sign-in name which correspond to
* <tt>IMessengerContact</tt> implementations having <tt>true</tt> as the
@ -338,17 +374,10 @@ else if (phoneNumber instanceof WorkPhoneDetail)
*/
private static int getMPHONE_TYPESortOrder(int mphonetype)
{
switch (mphonetype)
{
case MPHONE_TYPE_HOME:
return 1;
case MPHONE_TYPE_MOBILE:
return 2;
case MPHONE_TYPE_WORK:
return 0;
default:
return 3;
}
for (int i = 0; i < MPHONE_TYPE_SORT_ORDER.length; i++)
if (MPHONE_TYPE_SORT_ORDER[i] == mphonetype)
return i;
return MPHONE_TYPE_SORT_ORDER.length;
}
/**
@ -783,6 +812,13 @@ public void startConversation(
}
List<String> contactList = new ArrayList<String>();
ConfigurationService cfg
= ServiceUtils.getService(
bundleContext,
ConfigurationService.class);
boolean createCallByPhoneNumber
= (cfg != null)
&& cfg.getBoolean(PNAME_CREATE_CALL_BY_PHONE_NUMBER, false);
for (String participant : participants)
{
@ -796,35 +832,49 @@ public void startConversation(
}
else if (opSetClass.equals(OperationSetBasicTelephony.class))
{
// Set<PhoneNumberDetail> participantPhoneNumbers
// = findPhoneNumbersBySigninName(participant, 1);
//
// if (participantPhoneNumbers.size() > 0)
// {
// contactList.add(
// participantPhoneNumbers.iterator().next()
// .getNumber());
// }
/*
* There is no Contact for the specified participant which
* supports OperationSetBasicTelephony. Try without the support
* restriction.
* The boolean ConfigurationService property
* PNAME_CREATE_CALL_BY_PHONE_NUMBER enables instructing whether
* a sign-in name which does not resolve to a Contact with
* support for OperationSetBasicTelephony is to be resolved to
* a phone number (via an associated vCard).
*/
participantContacts
= findContactsBySigninName(participant, null, 1);
if (participantContacts.size() > 0)
if (createCallByPhoneNumber)
{
contactList.add(
getSigninName(participantContacts.get(0), null));
Set<PhoneNumberDetail> participantPhoneNumbers
= findPhoneNumbersBySigninName(participant, 1);
if (participantPhoneNumbers.size() > 0)
{
contactList.add(
participantPhoneNumbers.iterator().next()
.getNumber());
}
}
else
{
/*
* Well, just try to start a conversation with the
* unresolved contact.
* There is no Contact for the specified participant which
* supports OperationSetBasicTelephony. Try without the
* support restriction.
*/
contactList.add(participant);
participantContacts
= findContactsBySigninName(participant, null, 1);
if (participantContacts.size() > 0)
{
contactList.add(
getSigninName(
participantContacts.get(0),
null));
}
else
{
/*
* Well, just try to start a conversation with the
* unresolved contact.
*/
contactList.add(participant);
}
}
}
}

@ -12,5 +12,6 @@ Import-Package: javax.swing,
net.java.sip.communicator.service.protocol.msnconstants,
net.java.sip.communicator.service.protocol.yahooconstants,
net.java.sip.communicator.util,
org.jitsi.service.configuration,
org.jitsi.util,
org.osgi.framework

Loading…
Cancel
Save