diff --git a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java index 1cf19dbf1..280dc3350 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java +++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java @@ -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; } diff --git a/src/net/java/sip/communicator/service/contactsource/ContactDetail.java b/src/net/java/sip/communicator/service/contactsource/ContactDetail.java index 33f996c4e..56c1ef1af 100644 --- a/src/net/java/sip/communicator/service/contactsource/ContactDetail.java +++ b/src/net/java/sip/communicator/service/contactsource/ContactDetail.java @@ -42,8 +42,14 @@ public class ContactDetail public static final String CATEGORY_EMAIL = "Email"; /** - * The standard/well-known label of a ContactDetail representing a - * phone number. + * The standard/well-known category of a ContactDetail representing + * a contact address for instant messaging. + */ + public static final String CATEGORY_INSTANT_MESSAGING = "Instant Messaging"; + + /** + * The standard/well-known category of a ContactDetail representing + * a phone number. */ public static final String CATEGORY_PHONE = "Phone"; @@ -127,7 +133,11 @@ public ContactDetail(String contactAddress) * convenience, null and duplicate values in the specified * String[] labels will be ignored i.e. will not appear in * the set of labels reported by the new ContactDetail instance - * later on. + * later on. Additionally, the category of the new + * ContactDetail instance will be implied from the specified + * labels by looking for the standard/well-known categories defined + * by the CATEGORY_XXX constants of the ContactDetail + * 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 ContactDetail 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 + * ContactDetail instance + * @param category the category (such as one of the CATEGORY_XXX + * constants defined by the ContactDetail class, for example) to be + * assigned to the new ContactDetail instance + * @param labels the set of labels with which the new ContactDetail + * instance is to be labeled. The labels may be arbitrary and may include + * any of the standard/well-known labels defined by the LABEL_XXX + * constants of the ContactDetail class. For the sake of + * convenience, null and duplicate values in the specified + * String[] labels will be ignored i.e. will not appear in + * the set of labels reported by the new ContactDetail 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 ProtocolProviderServices for * a specific OperationSet.