aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2011-02-16 03:42:47 +0000
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2011-02-16 03:42:47 +0000
commit0e1659e7a0f8e7ee25ad2c35e0fee8f3a1ece59d (patch)
treeb5683396d87f6cbc362bac2ed6ebd3d4897c2986 /src/net/java
parent4ff9fde938839588467cc532370a3aa682f0bdca (diff)
downloadjitsi-0e1659e7a0f8e7ee25ad2c35e0fee8f3a1ece59d.zip
jitsi-0e1659e7a0f8e7ee25ad2c35e0fee8f3a1ece59d.tar.gz
jitsi-0e1659e7a0f8e7ee25ad2c35e0fee8f3a1ece59d.tar.bz2
Reports contact specifiers such as Home, Work, Mobile for the SourceContact ContactDetails returned by the Microsoft Outlook ContactSourceService.
Diffstat (limited to 'src/net/java')
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java44
-rw-r--r--src/net/java/sip/communicator/service/contactsource/ContactDetail.java99
2 files changed, 142 insertions, 1 deletions
diff --git a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java
index 6b75262..389c252 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java
@@ -189,6 +189,46 @@ public class MsOutlookAddrBookContactQuery
String query,
PtrCallback callback);
+ /**
+ * Gets the set of <tt>ContactDetail</tt> labels to be assigned to a
+ * property specified by its index in {@link #MAPI_MAILUSER_PROP_IDS}.
+ *
+ * @param propIndex the index in <tt>MAPI_MAILUSER_PROP_IDS</tt> of the
+ * property to get the <tt>ContactDetail</tt> labels of
+ * @return the set of <tt>ContactDetail</tt> labels to be assigned to the
+ * property specified by its index in <tt>MAPI_MAILUSER_PROP_IDS</tt>
+ */
+ private String[] getLabels(int propIndex)
+ {
+ switch (propIndex)
+ {
+ case dispidEmail1EmailAddress:
+ case dispidEmail2EmailAddress:
+ case dispidEmail3EmailAddress:
+ case PR_EMAIL_ADDRESS:
+ return new String[] { ContactDetail.LABEL_EMAIL };
+ case PR_BUSINESS2_TELEPHONE_NUMBER:
+ case PR_BUSINESS_TELEPHONE_NUMBER:
+ return
+ new String[]
+ { ContactDetail.LABEL_PHONE, ContactDetail.LABEL_WORK };
+ case PR_HOME2_TELEPHONE_NUMBER:
+ case PR_HOME_TELEPHONE_NUMBER:
+ return
+ new String[]
+ { ContactDetail.LABEL_PHONE, ContactDetail.LABEL_HOME };
+ case PR_MOBILE_TELEPHONE_NUMBER:
+ return
+ new String[]
+ {
+ ContactDetail.LABEL_PHONE,
+ ContactDetail.LABEL_MOBILE
+ };
+ default:
+ return null;
+ }
+ }
+
private static native Object[] IMAPIProp_GetProps(
long mapiProp,
long[] propIds, long flags)
@@ -305,7 +345,9 @@ public class MsOutlookAddrBookContactQuery
stringProp = normalizePhoneNumber(stringProp);
ContactDetail contactDetail
- = new ContactDetail(stringProp);
+ = new ContactDetail(
+ stringProp,
+ getLabels(propIndex));
contactDetail.setSupportedOpSets(supportedOpSets);
contactDetails.add(contactDetail);
diff --git a/src/net/java/sip/communicator/service/contactsource/ContactDetail.java b/src/net/java/sip/communicator/service/contactsource/ContactDetail.java
index 4ac73c5..1dcaa38 100644
--- a/src/net/java/sip/communicator/service/contactsource/ContactDetail.java
+++ b/src/net/java/sip/communicator/service/contactsource/ContactDetail.java
@@ -31,10 +31,41 @@ import net.java.sip.communicator.service.protocol.*;
* their choice.
*
* @author Yana Stamcheva
+ * @author Lyubomir Marinov
*/
public class ContactDetail
{
/**
+ * The standard/well-known label of a <tt>ContactDetail</tt> representing an
+ * e-mail address.
+ */
+ public static final String LABEL_EMAIL = "Email";
+
+ /**
+ * The standard/well-known label of a <tt>ContactDetail</tt> representing an
+ * address of a contact at their home.
+ */
+ public static final String LABEL_HOME = "Home";
+
+ /**
+ * The standard/well-known label of a <tt>ContactDetail</tt> representing a
+ * mobile contact address (e.g. a cell phone number).
+ */
+ public static final String LABEL_MOBILE = "Mobile";
+
+ /**
+ * The standard/well-known label of a <tt>ContactDetail</tt> representing a
+ * phone number.
+ */
+ public static final String LABEL_PHONE = "Phone";
+
+ /**
+ * The standard/well-known label of a <tt>ContactDetail</tt> representing an
+ * address of a contact at their work.
+ */
+ public static final String LABEL_WORK = "Work";
+
+ /**
* The address of this contact detail. This should be the address through
* which the contact could be reached by one of the supported
* <tt>OperationSet</tt>s (e.g. by IM, call).
@@ -42,6 +73,13 @@ public class ContactDetail
private final String contactAddress;
/**
+ * The set of labels of this <tt>ContactDetail</tt>. 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.
+ */
+ private final Collection<String> labels = new LinkedList<String>();
+
+ /**
* A mapping of <tt>OperationSet</tt> classes and preferred protocol
* providers for them.
*/
@@ -66,7 +104,38 @@ public class ContactDetail
*/
public ContactDetail(String contactAddress)
{
+ this(contactAddress, null);
+ }
+
+ /**
+ * 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 set of labels.
+ *
+ * @param contactAddress the contact address to be represented by 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.
+ */
+ public ContactDetail(String contactAddress, String[] labels)
+ {
+ // contactAddress
this.contactAddress = contactAddress;
+ // labels
+ if (labels != null)
+ {
+ System.err.println(this.contactAddress);
+ for (String label : labels)
+ {
+ if (!this.labels.contains(label))
+ {
+ this.labels.add(label);
+ System.err.println("\t" + label);
+ }
+ }
+ }
}
/**
@@ -175,4 +244,34 @@ public class ContactDetail
{
return supportedOpSets;
}
+
+ /**
+ * Determines whether the set of labels of this <tt>ContactDetail</tt>
+ * contains a specific label. 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.
+ *
+ * @param label the label to be determined whether it is contained in the
+ * set of labels of this <tt>ContactDetail</tt>
+ * @return <tt>true</tt> if the specified <tt>label</tt> is contained in the
+ * set of labels of this <tt>ContactDetail</tt>
+ */
+ public boolean containsLabel(String label)
+ {
+ return labels.contains(label);
+ }
+
+ /**
+ * Gets the set of labels of this <tt>ContactDetail</tt>. 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.
+ *
+ * @return the set of labels of this <tt>ContactDetail</tt>. If this
+ * <tt>ContactDetail</tt> has no labels, the returned <tt>Collection</tt> is
+ * empty.
+ */
+ public Collection<String> getLabels()
+ {
+ return Collections.unmodifiableCollection(labels);
+ }
}