Corrects UTF strings modification for Outlook contacts.

cusax-fix 4797
Vincent Lucas 12 years ago
parent e80acc4963
commit c3e4622091

@ -1353,7 +1353,7 @@ HRESULT MsOutlookAddrBookContactQuery_IMAPIProp_1GetProps(
* @return 1 if the modification succeded. 0 otherwise.
*/
int MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString
(long propId, const char* nativeValue, const char* nativeEntryId)
(long propId, const wchar_t* nativeValue, const char* nativeEntryId)
{
HRESULT hResult;
@ -1364,20 +1364,9 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString
return 0;
}
size_t valueLength = strlen(nativeValue);
size_t valueLength = wcslen(nativeValue);
LPWSTR wCharValue = (LPWSTR)::malloc((valueLength + 1) * sizeof(wchar_t));
if(mbstowcs(wCharValue, nativeValue, valueLength + 1)
!= valueLength)
{
fprintf(stderr,
"setPropUnicode (addrbook/MsOutlookAddrBookContactQuery.c): \
\n\tmbstowcs\n");
fflush(stderr);
((LPMAPIPROP) mapiProp)->Release();
::free(wCharValue);
wCharValue = NULL;
return 0;
}
memcpy(wCharValue, nativeValue, (valueLength + 1) * sizeof(wchar_t));
ULONG baseGroupEntryIdProp = 0;
switch(propId)

@ -22,7 +22,7 @@ long MsOutlookAddrBookContactQuery_IMAPIProp_1GetProps(
char * propsType);
int MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString
(long propId, const char* nativeValue, const char* nativeEntryId);
(long propId, const wchar_t* nativeValue, const char* nativeEntryId);
char* MsOutlookAddrBookContactQuery_createContact(void);

@ -348,17 +348,15 @@ HRESULT STDMETHODCALLTYPE MsOutlookAddrBookServer::IMAPIProp_SetPropString(
HRESULT hr = E_FAIL;
if(value != NULL && entryId != NULL)
{
LPSTR nativeValue = StringUtils::WideCharToMultiByte(value);
LPSTR nativeId = StringUtils::WideCharToMultiByte(entryId);
if(MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString(
propId,
nativeValue,
value,
nativeId) == 1)
{
hr = S_OK;
}
free(nativeId);
free(nativeValue);
}
return hr;
}

@ -161,13 +161,12 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac
{
jboolean res = JNI_FALSE;
const char *nativeEntryId = jniEnv->GetStringUTFChars(entryId, NULL);
const char *nativeValue = jniEnv->GetStringUTFChars(value, NULL);
IMsOutlookAddrBookServer * iServer = ComClient_getIServer();
if(iServer)
{
LPWSTR unicodeValue
= StringUtils::MultiByteToWideChar(nativeValue);
const LPWSTR unicodeValue
= (const LPWSTR) jniEnv->GetStringChars(value, NULL);
BSTR comValue = SysAllocString(unicodeValue);
LPWSTR unicodeId = StringUtils::MultiByteToWideChar(nativeEntryId);
BSTR comId = SysAllocString(unicodeId);
@ -178,11 +177,10 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac
SysFreeString(comId);
free(unicodeId);
SysFreeString(comValue);
free(unicodeValue);
jniEnv->ReleaseStringChars(value, (const jchar*) unicodeValue);
}
jniEnv->ReleaseStringUTFChars(entryId, nativeEntryId);
jniEnv->ReleaseStringUTFChars(value, nativeValue);
return res;
}

Loading…
Cancel
Save