aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/native/windows/msofficecomm/MessengerContact.cxx105
-rw-r--r--src/native/windows/msofficecomm/MessengerContact.h1
-rw-r--r--src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java41
3 files changed, 124 insertions, 23 deletions
diff --git a/src/native/windows/msofficecomm/MessengerContact.cxx b/src/native/windows/msofficecomm/MessengerContact.cxx
index edc0c74..ce0e9d8 100644
--- a/src/native/windows/msofficecomm/MessengerContact.cxx
+++ b/src/native/windows/msofficecomm/MessengerContact.cxx
@@ -14,6 +14,7 @@ EXTERN_C const GUID DECLSPEC_SELECTANY IID_IMessengerContactAdvanced
jclass MessengerContact::_jclass = NULL;
jmethodID MessengerContact::_jctorMethodID = NULL;
+jmethodID MessengerContact::_jgetPhoneNumberMethodID = NULL;
jmethodID MessengerContact::_jgetStatusMethodID = NULL;
jmethodID MessengerContact::_jisSelfMethodID = NULL;
@@ -165,7 +166,67 @@ STDMETHODIMP MessengerContact::get_IsTagged(VARIANT_BOOL *pBoolIsTagged)
STDMETHODIMP_E_NOTIMPL_STUB
STDMETHODIMP MessengerContact::get_PhoneNumber(MPHONE_TYPE PhoneType, BSTR *bstrNumber)
- STDMETHODIMP_E_NOTIMPL_STUB
+{
+ HRESULT hr;
+
+ if (bstrNumber)
+ {
+ if (_jobject)
+ {
+ JavaVM *vm = OutOfProcessServer::getJavaVM();
+ JNIEnv *env;
+
+ if (vm && !(vm->AttachCurrentThreadAsDaemon((void **) &env, NULL)))
+ {
+ jobject jobj
+ = env->CallObjectMethod(
+ _jobject,
+ _jgetPhoneNumberMethodID,
+ (jint) PhoneType);
+
+ if (env->ExceptionCheck())
+ {
+ env->ExceptionClear();
+ *bstrNumber = NULL;
+ hr = E_FAIL;
+ }
+ else
+ {
+ jstring jstr = (jstring) jobj;
+ const jchar *jchars
+ = jstr ? env->GetStringChars(jstr, NULL) : NULL;
+
+ if (jchars)
+ {
+ *bstrNumber = ::SysAllocString((LPOLESTR) jchars);
+ env->ReleaseStringChars(jstr, jchars);
+ hr = *bstrNumber ? S_OK : E_OUTOFMEMORY;
+ }
+ else
+ {
+ *bstrNumber = NULL;
+ hr = E_FAIL;
+ }
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+ }
+ }
+ else
+ {
+ *bstrNumber = NULL;
+ hr = E_UNEXPECTED;
+ }
+ }
+ else
+ {
+ *bstrNumber = NULL;
+ hr = E_FAIL;
+ }
+ }
+ else
+ hr = RPC_X_NULL_REF_POINTER;
+ return hr;
+}
STDMETHODIMP
MessengerContact::get_PresenceProperties(VARIANT *pvPresenceProperties)
@@ -410,27 +471,40 @@ HRESULT MessengerContact::start(JNIEnv *env)
if (ctorMethodID)
{
- jmethodID getStatusMethodID
- = env->GetMethodID(clazz, "getStatus", "()I");
+ jmethodID getPhoneNumberMethodID
+ = env->GetMethodID(
+ clazz,
+ "getPhoneNumber",
+ "(I)Ljava/lang/String;");
- if (getStatusMethodID)
+ if (getPhoneNumberMethodID)
{
- jmethodID isSelfMethodID
- = env->GetMethodID(clazz, "isSelf", "()Z");
+ jmethodID getStatusMethodID
+ = env->GetMethodID(clazz, "getStatus", "()I");
- if (isSelfMethodID)
+ if (getStatusMethodID)
{
- clazz = (jclass) env->NewGlobalRef(clazz);
- if (clazz)
+ jmethodID isSelfMethodID
+ = env->GetMethodID(clazz, "isSelf", "()Z");
+
+ if (isSelfMethodID)
{
- _jclass = clazz;
- _jctorMethodID = ctorMethodID;
- _jgetStatusMethodID = getStatusMethodID;
- _jisSelfMethodID = isSelfMethodID;
- hr = S_OK;
+ clazz = (jclass) env->NewGlobalRef(clazz);
+ if (clazz)
+ {
+ _jclass = clazz;
+ _jctorMethodID = ctorMethodID;
+ _jgetPhoneNumberMethodID
+ = getPhoneNumberMethodID;
+ _jgetStatusMethodID = getStatusMethodID;
+ _jisSelfMethodID = isSelfMethodID;
+ hr = S_OK;
+ }
+ else
+ hr = E_OUTOFMEMORY;
}
else
- hr = E_OUTOFMEMORY;
+ hr = E_FAIL;
}
else
hr = E_FAIL;
@@ -455,6 +529,7 @@ HRESULT MessengerContact::stop(JNIEnv *env)
_jclass = NULL;
_jctorMethodID = NULL;
+ _jgetPhoneNumberMethodID = NULL;
_jgetStatusMethodID = NULL;
_jisSelfMethodID = NULL;
if (clazz)
diff --git a/src/native/windows/msofficecomm/MessengerContact.h b/src/native/windows/msofficecomm/MessengerContact.h
index 3415bde..00f1584 100644
--- a/src/native/windows/msofficecomm/MessengerContact.h
+++ b/src/native/windows/msofficecomm/MessengerContact.h
@@ -57,6 +57,7 @@ protected:
private:
static jclass _jclass;
static jmethodID _jctorMethodID;
+ static jmethodID _jgetPhoneNumberMethodID;
static jmethodID _jgetStatusMethodID;
static jmethodID _jisSelfMethodID;
diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java b/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java
index 18020a7..21319d1 100644
--- a/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java
+++ b/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java
@@ -692,14 +692,35 @@ public class Messenger
}
else if (opSetClass.equals(OperationSetBasicTelephony.class))
{
- Set<PhoneNumberDetail> participantPhoneNumbers
- = findPhoneNumbersBySigninName(participant, 1);
+// Set<PhoneNumberDetail> participantPhoneNumbers
+// = findPhoneNumbersBySigninName(participant, 1);
+//
+// if (participantPhoneNumbers.size() > 0)
+// {
+// contactList.add(
+// participantPhoneNumbers.iterator().next()
+// .getNumber());
+// }
- if (participantPhoneNumbers.size() > 0)
+ /*
+ * There is no Contact for the specified participant which
+ * supports OperationSetBasicTelephony. Try without the support
+ * restriction.
+ */
+ participantContacts
+ = findContactsBySigninName(participant, null, 1);
+ if (participantContacts.size() > 0)
{
contactList.add(
- participantPhoneNumbers.iterator().next()
- .getNumber());
+ getSigninName(participantContacts.get(0), null));
+ }
+ else
+ {
+ /*
+ * Well, just try to start a conversation with the
+ * unresolved contact.
+ */
+ contactList.add(participant);
}
}
}
@@ -1039,7 +1060,9 @@ public class Messenger
* @param signinName the <tt>IMessengerContact</tt> sign-in name for
* which the associated <tt>Contact</tt> instances are to be found
* @param opSetClass the <tt>OperationSet</tt> class to be supported by
- * the possibly found <tt>Contact</tt> instances
+ * the possibly found <tt>Contact</tt> instances or <tt>null</tt> if no
+ * specific <tt>OperationSet</tt> class is required of the possibly
+ * found <tt>Contact</tt> instances
* @param limit the maximum number of found <tt>Contact</tt>s at which
* the search should stop or {@link Integer#MAX_VALUE} if the search is
* to be unbound with respect to the number of found <tt>Contact</tt>s
@@ -1057,8 +1080,10 @@ public class Messenger
{
ProtocolProviderService pps = e.getKey();
OperationSetContactCapabilities contactCapabilitiesOpSet
- = pps.getOperationSet(
- OperationSetContactCapabilities.class);
+ = (opSetClass == null)
+ ? null
+ : pps.getOperationSet(
+ OperationSetContactCapabilities.class);
for (Contact contact
: Messenger.findContactsBySigninName(