|
|
|
|
@ -221,6 +221,7 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac
|
|
|
|
|
|
|
|
|
|
if((props = (void**) malloc(propIdCount * sizeof(void*))) != NULL)
|
|
|
|
|
{
|
|
|
|
|
memset(props, 0, propIdCount * sizeof(void*));
|
|
|
|
|
if((propsLength = (unsigned long*) malloc(
|
|
|
|
|
propIdCount * sizeof(unsigned long))) != NULL)
|
|
|
|
|
{
|
|
|
|
|
@ -253,149 +254,153 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac
|
|
|
|
|
&comPropsLength,
|
|
|
|
|
&comPropsType);
|
|
|
|
|
|
|
|
|
|
SafeArrayLock(comPropsType);
|
|
|
|
|
memcpy(
|
|
|
|
|
propsType,
|
|
|
|
|
comPropsType->pvData,
|
|
|
|
|
propIdCount * sizeof(char));
|
|
|
|
|
SafeArrayUnlock(comPropsType);
|
|
|
|
|
SafeArrayDestroy(comPropsType);
|
|
|
|
|
|
|
|
|
|
SafeArrayLock(comPropsLength);
|
|
|
|
|
memcpy(
|
|
|
|
|
propsLength,
|
|
|
|
|
comPropsLength->pvData,
|
|
|
|
|
propIdCount * sizeof(unsigned long));
|
|
|
|
|
SafeArrayUnlock(comPropsLength);
|
|
|
|
|
SafeArrayDestroy(comPropsLength);
|
|
|
|
|
|
|
|
|
|
SafeArrayLock(comProps);
|
|
|
|
|
byte * data = (byte*) comProps->pvData;
|
|
|
|
|
for(int j = 0; j < propIdCount; ++j)
|
|
|
|
|
if(HR_SUCCEEDED(hr))
|
|
|
|
|
{
|
|
|
|
|
if((props[j] = malloc(propsLength[j])) != NULL)
|
|
|
|
|
SafeArrayLock(comPropsType);
|
|
|
|
|
memcpy(
|
|
|
|
|
propsType,
|
|
|
|
|
comPropsType->pvData,
|
|
|
|
|
propIdCount * sizeof(char));
|
|
|
|
|
SafeArrayUnlock(comPropsType);
|
|
|
|
|
|
|
|
|
|
SafeArrayLock(comPropsLength);
|
|
|
|
|
memcpy(
|
|
|
|
|
propsLength,
|
|
|
|
|
comPropsLength->pvData,
|
|
|
|
|
propIdCount * sizeof(unsigned long));
|
|
|
|
|
SafeArrayUnlock(comPropsLength);
|
|
|
|
|
|
|
|
|
|
SafeArrayLock(comProps);
|
|
|
|
|
byte * data = (byte*) comProps->pvData;
|
|
|
|
|
for(int j = 0; j < propIdCount; ++j)
|
|
|
|
|
{
|
|
|
|
|
memcpy(props[j], data, propsLength[j]);
|
|
|
|
|
data += propsLength[j];
|
|
|
|
|
if((props[j] = malloc(propsLength[j])) != NULL)
|
|
|
|
|
{
|
|
|
|
|
memcpy(props[j], data, propsLength[j]);
|
|
|
|
|
data += propsLength[j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SafeArrayUnlock(comProps);
|
|
|
|
|
SafeArrayDestroy(comProps);
|
|
|
|
|
SafeArrayUnlock(comProps);
|
|
|
|
|
|
|
|
|
|
SafeArrayDestroy(comPropIds);
|
|
|
|
|
SysFreeString(comEntryId);
|
|
|
|
|
free(unicodeEntryId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(HR_SUCCEEDED(hr))
|
|
|
|
|
{
|
|
|
|
|
// Decode properties to java
|
|
|
|
|
jclass objectClass = jniEnv->FindClass("java/lang/Object");
|
|
|
|
|
if (objectClass)
|
|
|
|
|
{
|
|
|
|
|
javaProps = jniEnv->NewObjectArray(
|
|
|
|
|
propIdCount,
|
|
|
|
|
objectClass,
|
|
|
|
|
NULL);
|
|
|
|
|
for(int j = 0; j < propIdCount; ++j)
|
|
|
|
|
// Decode properties to java
|
|
|
|
|
jclass objectClass
|
|
|
|
|
= jniEnv->FindClass("java/lang/Object");
|
|
|
|
|
if (objectClass)
|
|
|
|
|
{
|
|
|
|
|
// byte array
|
|
|
|
|
if(propsType[j] == 'b' && props[j] != NULL)
|
|
|
|
|
javaProps = jniEnv->NewObjectArray(
|
|
|
|
|
propIdCount,
|
|
|
|
|
objectClass,
|
|
|
|
|
NULL);
|
|
|
|
|
for(int j = 0; j < propIdCount; ++j)
|
|
|
|
|
{
|
|
|
|
|
jbyteArray value = jniEnv->NewByteArray(
|
|
|
|
|
(jsize) propsLength[j]);
|
|
|
|
|
if(value)
|
|
|
|
|
// byte array
|
|
|
|
|
if(propsType[j] == 'b' && props[j] != NULL)
|
|
|
|
|
{
|
|
|
|
|
jbyte *bytes
|
|
|
|
|
= jniEnv->GetByteArrayElements(
|
|
|
|
|
value, NULL);
|
|
|
|
|
|
|
|
|
|
if (bytes)
|
|
|
|
|
jbyteArray value = jniEnv->NewByteArray(
|
|
|
|
|
(jsize) propsLength[j]);
|
|
|
|
|
if(value)
|
|
|
|
|
{
|
|
|
|
|
memcpy(bytes, props[j], propsLength[j]);
|
|
|
|
|
jniEnv->ReleaseByteArrayElements(
|
|
|
|
|
value,
|
|
|
|
|
bytes,
|
|
|
|
|
0);
|
|
|
|
|
jniEnv->SetObjectArrayElement(
|
|
|
|
|
javaProps,
|
|
|
|
|
j,
|
|
|
|
|
value);
|
|
|
|
|
jbyte *bytes
|
|
|
|
|
= jniEnv->GetByteArrayElements(
|
|
|
|
|
value, NULL);
|
|
|
|
|
|
|
|
|
|
if (bytes)
|
|
|
|
|
{
|
|
|
|
|
memcpy(
|
|
|
|
|
bytes,
|
|
|
|
|
props[j],
|
|
|
|
|
propsLength[j]);
|
|
|
|
|
jniEnv->ReleaseByteArrayElements(
|
|
|
|
|
value,
|
|
|
|
|
bytes,
|
|
|
|
|
0);
|
|
|
|
|
jniEnv->SetObjectArrayElement(
|
|
|
|
|
javaProps,
|
|
|
|
|
j,
|
|
|
|
|
value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// long
|
|
|
|
|
else if(propsType[j] == 'l' && props[j] != NULL)
|
|
|
|
|
{
|
|
|
|
|
jclass longClass
|
|
|
|
|
= jniEnv->FindClass("java/lang/Long");
|
|
|
|
|
if (longClass)
|
|
|
|
|
// long
|
|
|
|
|
else if(propsType[j] == 'l' && props[j] != NULL)
|
|
|
|
|
{
|
|
|
|
|
jmethodID longMethodID
|
|
|
|
|
= jniEnv->GetMethodID(
|
|
|
|
|
longClass,
|
|
|
|
|
"<init>",
|
|
|
|
|
"(J)V");
|
|
|
|
|
|
|
|
|
|
if (longMethodID)
|
|
|
|
|
jclass longClass
|
|
|
|
|
= jniEnv->FindClass("java/lang/Long");
|
|
|
|
|
if (longClass)
|
|
|
|
|
{
|
|
|
|
|
jlong l;
|
|
|
|
|
memcpy(&l, props[j], propsLength[j]);
|
|
|
|
|
jobject value = jniEnv->NewObject(
|
|
|
|
|
jmethodID longMethodID
|
|
|
|
|
= jniEnv->GetMethodID(
|
|
|
|
|
longClass,
|
|
|
|
|
longMethodID,
|
|
|
|
|
l);
|
|
|
|
|
"<init>",
|
|
|
|
|
"(J)V");
|
|
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
|
if (longMethodID)
|
|
|
|
|
{
|
|
|
|
|
jniEnv->SetObjectArrayElement(
|
|
|
|
|
javaProps,
|
|
|
|
|
j,
|
|
|
|
|
value);
|
|
|
|
|
jlong l;
|
|
|
|
|
memcpy(&l, props[j], propsLength[j]);
|
|
|
|
|
jobject value = jniEnv->NewObject(
|
|
|
|
|
longClass,
|
|
|
|
|
longMethodID,
|
|
|
|
|
l);
|
|
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
jniEnv->SetObjectArrayElement(
|
|
|
|
|
javaProps,
|
|
|
|
|
j,
|
|
|
|
|
value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 8 bits string
|
|
|
|
|
else if(propsType[j] == 's' && props[j] != NULL)
|
|
|
|
|
{
|
|
|
|
|
jstring value = jniEnv->NewStringUTF(
|
|
|
|
|
(const char*) props[j]);
|
|
|
|
|
if (value)
|
|
|
|
|
// 8 bits string
|
|
|
|
|
else if(propsType[j] == 's' && props[j] != NULL)
|
|
|
|
|
{
|
|
|
|
|
jniEnv->SetObjectArrayElement(
|
|
|
|
|
javaProps,
|
|
|
|
|
j,
|
|
|
|
|
value);
|
|
|
|
|
jstring value = jniEnv->NewStringUTF(
|
|
|
|
|
(const char*) props[j]);
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
jniEnv->SetObjectArrayElement(
|
|
|
|
|
javaProps,
|
|
|
|
|
j,
|
|
|
|
|
value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 16 bits string
|
|
|
|
|
else if(propsType[j] == 'u' && props[j] != NULL)
|
|
|
|
|
{
|
|
|
|
|
jstring value
|
|
|
|
|
= jniEnv->NewString(
|
|
|
|
|
(const jchar *) props[j],
|
|
|
|
|
wcslen((const wchar_t *) props[j]));
|
|
|
|
|
if (value)
|
|
|
|
|
// 16 bits string
|
|
|
|
|
else if(propsType[j] == 'u' && props[j] != NULL)
|
|
|
|
|
{
|
|
|
|
|
jniEnv->SetObjectArrayElement(
|
|
|
|
|
javaProps,
|
|
|
|
|
j,
|
|
|
|
|
value);
|
|
|
|
|
jstring value
|
|
|
|
|
= jniEnv->NewString(
|
|
|
|
|
(const jchar *) props[j],
|
|
|
|
|
wcslen((const wchar_t *) props[j]));
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
jniEnv->SetObjectArrayElement(
|
|
|
|
|
javaProps,
|
|
|
|
|
j,
|
|
|
|
|
value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(jniEnv->ExceptionCheck())
|
|
|
|
|
javaProps = NULL;
|
|
|
|
|
if(jniEnv->ExceptionCheck())
|
|
|
|
|
javaProps = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MsOutlookMAPIHResultException_throwNew(
|
|
|
|
|
jniEnv,
|
|
|
|
|
hr,
|
|
|
|
|
__FILE__, __LINE__);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MsOutlookMAPIHResultException_throwNew(
|
|
|
|
|
jniEnv,
|
|
|
|
|
hr,
|
|
|
|
|
__FILE__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SafeArrayDestroy(comPropsType);
|
|
|
|
|
SafeArrayDestroy(comPropsLength);
|
|
|
|
|
SafeArrayDestroy(comProps);
|
|
|
|
|
SafeArrayDestroy(comPropIds);
|
|
|
|
|
SysFreeString(comEntryId);
|
|
|
|
|
free(unicodeEntryId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|