diff options
author | Vincent Lucas <lucas@Vincents-MacBook-Pro.local> | 2013-05-07 10:53:43 +0200 |
---|---|---|
committer | Vincent Lucas <lucas@Vincents-MacBook-Pro.local> | 2013-05-07 10:53:43 +0200 |
commit | bd11acf2b29a04dd59f287249748ac369c5caf7e (patch) | |
tree | c9dfd4126e825295d27d08aecf27368b5437f247 /src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx | |
parent | 30d591762bd8c52cb2154ff74035b5aef857780b (diff) | |
download | jitsi-bd11acf2b29a04dd59f287249748ac369c5caf7e.zip jitsi-bd11acf2b29a04dd59f287249748ac369c5caf7e.tar.gz jitsi-bd11acf2b29a04dd59f287249748ac369c5caf7e.tar.bz2 |
Creates a COM service to able Jitsi 32 bits to communicate with MAPI 64 bits (Outlook). And vice-versa.
Diffstat (limited to 'src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx')
-rw-r--r-- | src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx new file mode 100644 index 0000000..e34b0ce --- /dev/null +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx @@ -0,0 +1,169 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +#include "MsOutlookAddrBookClient.h" + +#include <stdio.h> +#include <wchar.h> + +#include "../MAPINotification.h" +#include "../net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h" +#include "../StringUtils.h" + +/** + * Instanciates a new MsOutlookAddrBookClient. + */ +MsOutlookAddrBookClient::MsOutlookAddrBookClient(): + _refCount(1) +{ +} + +/** + * Deletes this MsOutlookAddrBookClient. + */ +MsOutlookAddrBookClient::~MsOutlookAddrBookClient() +{ + Release(); +} + +/** + * Returns an instance of the interface requested, if available. + * + * @param iid The identifier of the interface requested. + * @param obj A pointer use to return an object instance implementing the + * interface requested. + * + * @return S_OK if the corresponding interface has been found. E_POINTER, or + * E_NOINTERFACE otherwise. + */ +STDMETHODIMP MsOutlookAddrBookClient::QueryInterface(REFIID iid, PVOID *obj) +{ + OLECHAR* strGuid; + StringFromCLSID(iid, &strGuid); + ::CoTaskMemFree(strGuid); + + HRESULT hr; + + if (!obj) + { + hr = E_POINTER; + } + else if (IID_IUnknown == iid) + { + AddRef(); + *obj = static_cast<IUnknown *>( + static_cast<IMsOutlookAddrBookClient *>(this)); + hr = S_OK; + } + else if (IID_IMsOutlookAddrBookClient == iid) + { + AddRef(); + *obj = static_cast<IMsOutlookAddrBookClient *>(this); + hr = S_OK; + } + else + { + hr = E_NOINTERFACE; + } + + return hr; +} + +/** + * Increment the number of reference. + * + * @return The number of reference. + */ +STDMETHODIMP_(ULONG) MsOutlookAddrBookClient::AddRef() +{ + return ++_refCount; +} + +/** + * Decrement the number of reference. + * + * @return The number of reference. + */ +STDMETHODIMP_(ULONG) MsOutlookAddrBookClient::Release() +{ + ULONG refCount = --_refCount; + + if(!refCount) + { + delete this; + } + + return refCount; +} + +/** + * Callback which receives each time the COM server found a contact when making + * a search via the foreachMailUser function. + * + * @param id The contact identifier. + * + * @return S_OK. + */ +HRESULT STDMETHODCALLTYPE MsOutlookAddrBookClient::foreachMailUserCallback( + BSTR id) +{ + char * charId = StringUtils::WideCharToMultiByte(id); + MAPINotification_callCallbackMethod(charId, NULL); + free(charId); + + return S_OK; +} + +/** + * Callback called each time the COM server forward a contact deleted notify + * event from MAPI. + * + * @param id The contact identifier. + * + * @return S_OK. + */ +HRESULT STDMETHODCALLTYPE MsOutlookAddrBookClient::deleted(BSTR id) +{ + char * charId = StringUtils::WideCharToMultiByte(id); + MAPINotification_jniCallDeletedMethod(charId); + free(charId); + + return S_OK; +} + +/** + * Callback called each time the COM server forward a contact inserted notify + * event from MAPI. + * + * @param id The contact identifier. + * + * @return S_OK. + */ +HRESULT STDMETHODCALLTYPE MsOutlookAddrBookClient::inserted(BSTR id) +{ + char * charId = StringUtils::WideCharToMultiByte(id); + MAPINotification_jniCallInsertedMethod(charId); + free(charId); + + return S_OK; +} + +/** + * Callback called each time the COM server forward a contact updated notify + * event from MAPI. + * + * @param id The contact identifier. + * + * @return S_OK. + */ +HRESULT STDMETHODCALLTYPE MsOutlookAddrBookClient::updated(BSTR id) +{ + char * charId = StringUtils::WideCharToMultiByte(id); + MAPINotification_jniCallUpdatedMethod(charId); + free(charId); + + return S_OK; +} |