aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2011-01-06 22:53:43 +0000
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2011-01-06 22:53:43 +0000
commit95e6a467b31a01ab8d457332c325218a7cc6368e (patch)
tree4d62ac921db6e9f8d9199c215abf17b39ba42713 /src
parent3e35215a9e520303e58701b4c10c09954ad5c33b (diff)
downloadjitsi-95e6a467b31a01ab8d457332c325218a7cc6368e.zip
jitsi-95e6a467b31a01ab8d457332c325218a7cc6368e.tar.gz
jitsi-95e6a467b31a01ab8d457332c325218a7cc6368e.tar.bz2
Searches through more properties of the Microsoft Outlook contacts.
Diffstat (limited to 'src')
-rw-r--r--src/native/addrbook/msoutlook/MsOutlookMAPI.h1
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/AddrBookSourceContact.java18
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/AsyncContactQuery.java15
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java2
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java101
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java2
6 files changed, 116 insertions, 23 deletions
diff --git a/src/native/addrbook/msoutlook/MsOutlookMAPI.h b/src/native/addrbook/msoutlook/MsOutlookMAPI.h
index 09d28bc..8bacf6b 100644
--- a/src/native/addrbook/msoutlook/MsOutlookMAPI.h
+++ b/src/native/addrbook/msoutlook/MsOutlookMAPI.h
@@ -11,6 +11,7 @@
#ifndef __in_opt
#define __in_opt
#endif /* #ifndef __in_opt */
+
#include <mapitags.h>
#include <mapix.h>
diff --git a/src/net/java/sip/communicator/plugin/addrbook/AddrBookSourceContact.java b/src/net/java/sip/communicator/plugin/addrbook/AddrBookSourceContact.java
index 8808d7d..73fbe0e 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/AddrBookSourceContact.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/AddrBookSourceContact.java
@@ -37,6 +37,11 @@ public class AddrBookSourceContact
private final String displayName;
/**
+ * The image/avatar of this <tt>SourceContact</tt>
+ */
+ private byte[] image;
+
+ /**
* Initializes a new <tt>AddrBookSourceContact</tt> instance.
*
* @param contactSource the <tt>ContactSourceService</tt> which is creating
@@ -136,8 +141,7 @@ public class AddrBookSourceContact
*/
public byte[] getImage()
{
- // TODO Auto-generated method stub
- return null;
+ return image;
}
/**
@@ -157,4 +161,14 @@ public class AddrBookSourceContact
return contactDetails.isEmpty() ? null : contactDetails.get(0);
}
+
+ /**
+ * Sets the image/avatar of this <tt>SourceContact</tt>.
+ *
+ * @param image the image/avatar to be set on this <tt>SourceContact</tt>
+ */
+ public void setImage(byte[] image)
+ {
+ this.image = image;
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/addrbook/AsyncContactQuery.java b/src/net/java/sip/communicator/plugin/addrbook/AsyncContactQuery.java
index d03742c..3faa77b 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/AsyncContactQuery.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/AsyncContactQuery.java
@@ -80,6 +80,21 @@ public abstract class AsyncContactQuery<T extends ContactSourceService>
}
/**
+ * Gets the number of <tt>SourceContact</tt>s which match this
+ * <tt>ContactQuery</tt>.
+ *
+ * @return the number of <tt>SourceContact</tt> which match this
+ * <tt>ContactQuery</tt>
+ */
+ public int getQueryResultCount()
+ {
+ synchronized (queryResults)
+ {
+ return queryResults.size();
+ }
+ }
+
+ /**
* Gets the <tt>List</tt> of <tt>SourceContact</tt>s which match this
* <tt>ContactQuery</tt>.
*
diff --git a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java
index 2c0c08f..65354f0 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java
@@ -44,7 +44,7 @@ public class MacOSXAddrBookContactSourceService
*/
public String getDisplayName()
{
- return "Mac OS X Address Book";
+ return "Address Book";
}
/**
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 6ef8a55..6f6fe7b 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java
@@ -19,6 +19,13 @@ import net.java.sip.communicator.service.contactsource.*;
public class MsOutlookAddrBookContactQuery
extends AsyncContactQuery<MsOutlookAddrBookContactSourceService>
{
+ private static final int dispidEmail1EmailAddress = 11;
+
+ private static final int dispidEmail2EmailAddress = 12;
+
+ private static final int dispidEmail3EmailAddress = 13;
+
+ private static final long MAPI_MAILUSER = 0x00000006;
/**
* The IDs of the properties of <tt>MAPI_MAILUSER</tt> which are to be
@@ -36,9 +43,15 @@ public class MsOutlookAddrBookContactQuery
0x3A1B /* PR_BUSINESS2_TELEPHONE_NUMBER */,
0x3A09 /* PR_HOME_TELEPHONE_NUMBER */,
0x3A2F /* PR_HOME2_TELEPHONE_NUMBER */,
- 0x3A1C /* PR_MOBILE_TELEPHONE_NUMBER */
+ 0x3A1C /* PR_MOBILE_TELEPHONE_NUMBER */,
+ 0x0FFE /* PR_OBJECT_TYPE */,
+ 0x00008083 /* dispidEmail1EmailAddress */,
+ 0x00008093 /* dispidEmail2EmailAddress */,
+ 0x000080A3 /* dispidEmail3EmailAddress */
};
+ private static final long MAPI_MESSAGE = 0x00000005;
+
/**
* The flag which signals that MAPI strings should be returned in the
* Unicode character set.
@@ -46,64 +59,75 @@ public class MsOutlookAddrBookContactQuery
private static final long MAPI_UNICODE = 0x80000000;
/**
+ * The id of the <tt>PR_ATTACHMENT_CONTACTPHOTO</tt> MAPI property.
+ */
+ private static final long PR_ATTACHMENT_CONTACTPHOTO = 0x7FFF;
+
+ /**
* The index of the id of the <tt>PR_BUSINESS_TELEPHONE_NUMBER</tt> property
* in {@link #MAPI_MAILUSER_PROP_IDS}.
*/
- private static final int PR_BUSINESS_TELEPHONE_NUMBER_INDEX = 5;
+ private static final int PR_BUSINESS_TELEPHONE_NUMBER = 5;
/**
* The index of the id of the <tt>PR_BUSINESS2_TELEPHONE_NUMBER</tt>
* property in {@link #MAPI_MAILUSER_PROP_IDS}.
*/
- private static final int PR_BUSINESS2_TELEPHONE_NUMBER_INDEX = 6;
+ private static final int PR_BUSINESS2_TELEPHONE_NUMBER = 6;
/**
* The index of the id of the <tt>PR_DISPLAY_NAME</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
- private static final int PR_DISPLAY_NAME_INDEX = 0;
+ private static final int PR_DISPLAY_NAME = 0;
/**
* The index of the id of the <tt>PR_EMAIL_ADDRESS</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
- private static final int PR_EMAIL_ADDRESS_INDEX = 1;
+ private static final int PR_EMAIL_ADDRESS = 1;
/**
* The index of the id of the <tt>PR_GIVEN_NAME</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
- private static final int PR_GIVEN_NAME_INDEX = 2;
+ private static final int PR_GIVEN_NAME = 2;
/**
* The index of the id of the <tt>PR_HOME_TELEPHONE_NUMBER</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
- private static final int PR_HOME_TELEPHONE_NUMBER_INDEX = 7;
+ private static final int PR_HOME_TELEPHONE_NUMBER = 7;
/**
* The index of the id of the <tt>PR_HOME2_TELEPHONE_NUMBER</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
- private static final int PR_HOME2_TELEPHONE_NUMBER_INDEX = 8;
+ private static final int PR_HOME2_TELEPHONE_NUMBER = 8;
/**
* The index of the id of the <tt>PR_MIDDLE_NAME</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
- private static final int PR_MIDDLE_NAME_INDEX = 3;
+ private static final int PR_MIDDLE_NAME = 3;
/**
* The index of the id of the <tt>PR_MOBILE_TELEPHONE_NUMBER</tt> property
* in {@link #MAPI_MAILUSER_PROP_IDS}.
*/
- private static final int PR_MOBILE_TELEPHONE_NUMBER_INDEX = 9;
+ private static final int PR_MOBILE_TELEPHONE_NUMBER = 9;
+
+ /**
+ * The index of the id of the <tt>PR_OBJECT_TYPE</tt> property in
+ * {@link #MAPI_MAILUSER_PROP_IDS}.
+ */
+ private static final int PR_OBJECT_TYPE = 10;
/**
* The index of the id of the <tt>PR_SURNAME</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
- private static final int PR_SURNAME_INDEX = 4;
+ private static final int PR_SURNAME = 4;
/**
* The indexes in {@link #MAPI_MAILUSER_PROP_IDS} of the property IDs which
@@ -113,12 +137,15 @@ public class MsOutlookAddrBookContactQuery
private static final int[] CONTACT_DETAIL_PROP_INDEXES
= new int[]
{
- PR_EMAIL_ADDRESS_INDEX,
- PR_BUSINESS_TELEPHONE_NUMBER_INDEX,
- PR_BUSINESS2_TELEPHONE_NUMBER_INDEX,
- PR_HOME_TELEPHONE_NUMBER_INDEX,
- PR_HOME2_TELEPHONE_NUMBER_INDEX,
- PR_MOBILE_TELEPHONE_NUMBER_INDEX
+ PR_EMAIL_ADDRESS,
+ PR_BUSINESS_TELEPHONE_NUMBER,
+ PR_BUSINESS2_TELEPHONE_NUMBER,
+ PR_HOME_TELEPHONE_NUMBER,
+ PR_HOME2_TELEPHONE_NUMBER,
+ PR_MOBILE_TELEPHONE_NUMBER,
+ dispidEmail1EmailAddress,
+ dispidEmail2EmailAddress,
+ dispidEmail3EmailAddress
};
static
@@ -126,6 +153,8 @@ public class MsOutlookAddrBookContactQuery
System.loadLibrary("jmsoutlookaddrbook");
}
+ private int mapiMessageCount;
+
/**
* Initializes a new <tt>MsOutlookAddrBookContactQuery</tt> instance to
* be performed by a specific
@@ -182,6 +211,18 @@ public class MsOutlookAddrBookContactQuery
iUnknown,
MAPI_MAILUSER_PROP_IDS,
MAPI_UNICODE);
+ long objType
+ = (props[PR_OBJECT_TYPE] instanceof Long)
+ ? ((Long) props[PR_OBJECT_TYPE]).longValue()
+ : 0;
+
+ /*
+ * If we have results from the Contacts folder(s), don't read from the
+ * Address Book because there may be duplicates.
+ */
+ if ((MAPI_MAILUSER == objType) && (mapiMessageCount != 0))
+ return false;
+
boolean matches = false;
for (Object prop : props)
@@ -211,12 +252,34 @@ public class MsOutlookAddrBookContactQuery
}
}
- SourceContact sourceContact
+ AddrBookSourceContact sourceContact
= new AddrBookSourceContact(
getContactSource(),
- (String) props[PR_DISPLAY_NAME_INDEX],
+ (String) props[PR_DISPLAY_NAME],
contactDetails);
+ if (MAPI_MESSAGE == objType)
+ {
+ ++mapiMessageCount;
+
+ try
+ {
+ Object[] images
+ = IMAPIProp_GetProps(
+ iUnknown,
+ new long[] { PR_ATTACHMENT_CONTACTPHOTO },
+ 0);
+ Object image = images[0];
+
+ if (image instanceof byte[])
+ sourceContact.setImage((byte[]) image);
+ }
+ catch (MsOutlookMAPIHResultException ex)
+ {
+ // Ignore it, the image isn't as vital as the SourceContact.
+ }
+ }
+
addQueryResult(sourceContact);
}
return (getStatus() == QUERY_IN_PROGRESS);
diff --git a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java
index fca8320..2a1acc9 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java
@@ -60,7 +60,7 @@ public class MsOutlookAddrBookContactSourceService
*/
public String getDisplayName()
{
- return "Microsoft Outlook Address Book";
+ return "Microsoft Outlook";
}
/**