diff options
author | Vincent Lucas <chenzo@jitsi.org> | 2013-08-17 03:59:06 +0200 |
---|---|---|
committer | Vincent Lucas <chenzo@jitsi.org> | 2013-08-17 03:59:06 +0200 |
commit | c3e4622091a1509dbdb6f8e11c0bc421758d8d22 (patch) | |
tree | 5dc2164d6a6256b36309e4660c64bc005fc22bc3 /src/native/addrbook/msoutlook | |
parent | e80acc496396fa46903e98a335843ec64cfcba54 (diff) | |
download | jitsi-c3e4622091a1509dbdb6f8e11c0bc421758d8d22.zip jitsi-c3e4622091a1509dbdb6f8e11c0bc421758d8d22.tar.gz jitsi-c3e4622091a1509dbdb6f8e11c0bc421758d8d22.tar.bz2 |
Corrects UTF strings modification for Outlook contacts.
Diffstat (limited to 'src/native/addrbook/msoutlook')
4 files changed, 8 insertions, 23 deletions
diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx index 0228a6c..17920dd 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx @@ -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) diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h index 5cb333f..cdc36d5 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h @@ -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); diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx index 288ef47..1d3d362 100644 --- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx @@ -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; } diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx index 0d43d67..fa81c62 100644 --- a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx +++ b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx @@ -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; } |