Adds 'Instant Messaging' ContactDetail category and uses it in the Mac OS X Address Book ContactSourceService.

cusax-fix
Lyubomir Marinov 15 years ago
parent b980e383e2
commit 614c9d5ca5

@ -248,18 +248,25 @@ private ContactDetail createContactDetail(
String contactAddress,
Object label)
{
String p, l;
String c, l;
switch (property)
{
case kABEmailProperty:
p = ContactDetail.CATEGORY_EMAIL;
c = ContactDetail.CATEGORY_EMAIL;
break;
case kABPhoneProperty:
p = ContactDetail.CATEGORY_PHONE;
c = ContactDetail.CATEGORY_PHONE;
break;
case kABAIMInstantProperty:
case kABICQInstantProperty:
case kABJabberInstantProperty:
case kABMSNInstantProperty:
case kABYahooInstantProperty:
c = ContactDetail.CATEGORY_INSTANT_MESSAGING;
break;
default:
p = null;
c = null;
break;
}
@ -272,7 +279,7 @@ private ContactDetail createContactDetail(
l = null;
}
return new ContactDetail(contactAddress, new String[] { p, l });
return new ContactDetail(contactAddress, c, new String[] { l });
}
/**
@ -732,14 +739,14 @@ private ContactDetail setCapabilities(
switch (property)
{
case kABEmailProperty:
break;
case kABAIMInstantProperty:
supportedOpSets.add(OperationSetBasicInstantMessaging.class);
preferredProtocols.put(
OperationSetBasicInstantMessaging.class,
ProtocolNames.AIM);
break;
case kABEmailProperty:
break;
case kABICQInstantProperty:
supportedOpSets.add(OperationSetBasicInstantMessaging.class);
preferredProtocols.put(
@ -756,6 +763,9 @@ private ContactDetail setCapabilities(
OperationSetBasicTelephony.class,
ProtocolNames.JABBER);
break;
case kABPhoneProperty:
supportedOpSets.add(OperationSetBasicTelephony.class);
break;
case kABMSNInstantProperty:
supportedOpSets.add(OperationSetBasicInstantMessaging.class);
preferredProtocols.put(
@ -768,9 +778,6 @@ private ContactDetail setCapabilities(
OperationSetBasicInstantMessaging.class,
ProtocolNames.YAHOO);
break;
case kABPhoneProperty:
supportedOpSets.add(OperationSetBasicTelephony.class);
break;
default:
break;
}

@ -42,8 +42,14 @@ public class ContactDetail
public static final String CATEGORY_EMAIL = "Email";
/**
* The standard/well-known label of a <tt>ContactDetail</tt> representing a
* phone number.
* The standard/well-known category of a <tt>ContactDetail</tt> representing
* a contact address for instant messaging.
*/
public static final String CATEGORY_INSTANT_MESSAGING = "Instant Messaging";
/**
* The standard/well-known category of a <tt>ContactDetail</tt> representing
* a phone number.
*/
public static final String CATEGORY_PHONE = "Phone";
@ -127,7 +133,11 @@ public ContactDetail(String contactAddress)
* convenience, <tt>null</tt> and duplicate values in the specified
* <tt>String[]</tt> <tt>labels</tt> will be ignored i.e. will not appear in
* the set of labels reported by the new <tt>ContactDetail</tt> instance
* later on.
* later on. Additionally, the <tt>category</tt> of the new
* <tt>ContactDetail</tt> instance will be implied from the specified
* <tt>labels</tt> by looking for the standard/well-known categories defined
* by the <tt>CATEGORY_XXX</tt> constants of the <tt>ContactDetail</tt>
* class
*/
public ContactDetail(String contactAddress, String[] labels)
{
@ -144,6 +154,7 @@ public ContactDetail(String contactAddress, String[] labels)
if ((label != null) && !this.labels.contains(label))
{
if (label.equals(CATEGORY_EMAIL)
|| label.equals(CATEGORY_INSTANT_MESSAGING)
|| label.equals(CATEGORY_PHONE))
category = label;
else
@ -154,6 +165,44 @@ public ContactDetail(String contactAddress, String[] labels)
this.category = category;
}
/**
* Initializes a new <tt>ContactDetail</tt> instance which is to represent a
* specific contact address and which is to be optionally labeled with a
* specific category and a specific set of labels.
*
* @param contactAddress the contact address to be represented by the new
* <tt>ContactDetail</tt> instance
* @param category the category (such as one of the <tt>CATEGORY_XXX</tt>
* constants defined by the <tt>ContactDetail</tt> class, for example) to be
* assigned to the new <tt>ContactDetail</tt> instance
* @param labels the set of labels with which the new <tt>ContactDetail</tt>
* instance is to be labeled. The labels may be arbitrary and may include
* any of the standard/well-known labels defined by the <tt>LABEL_XXX</tt>
* constants of the <tt>ContactDetail</tt> class. For the sake of
* convenience, <tt>null</tt> and duplicate values in the specified
* <tt>String[]</tt> <tt>labels</tt> will be ignored i.e. will not appear in
* the set of labels reported by the new <tt>ContactDetail</tt> instance
* later on.
*/
public ContactDetail(
String contactAddress,
String category, String[] labels)
{
// contactAddress
this.contactAddress = contactAddress;
// category
this.category = category;
// labels
if (labels != null)
{
for (String label : labels)
{
if ((label != null) && !this.labels.contains(label))
this.labels.add(label);
}
}
}
/**
* Sets a mapping of preferred <tt>ProtocolProviderServices</tt> for
* a specific <tt>OperationSet</tt>.

Loading…
Cancel
Save