helpers.i 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. %{
  2. #include <kopano/ECTags.h>
  3. #include <kopano/IECUnknown.h>
  4. %}
  5. // Pull in the language-specific helpers
  6. #if SWIGPYTHON
  7. %include "python/helpers_python.i"
  8. #endif
  9. %typemap(in) (IMAPIProp *lpWrapped, LPCIID USE_IID_FOR_OUTPUT) (int res)
  10. {
  11. res = SWIG_ConvertPtr($input, (void**)&$1, $1_descriptor, 0 | 0 );
  12. if (!SWIG_IsOK(res)) {
  13. SWIG_exception_fail(SWIG_ArgError(res1), "BUG");
  14. }
  15. $2 = IIDFromType(TypeFromObject($input));
  16. }
  17. %typemap(in,numinputs=0) LPUNKNOWN *OUTPUT_USE_IID (LPUNKNOWN temp) {
  18. $1 = ($1_type)&temp;
  19. }
  20. /* Unwrap a MAPI object */
  21. %inline %{
  22. HRESULT UnwrapObject(IMAPIProp *lpWrapped, LPCIID USE_IID_FOR_OUTPUT, LPUNKNOWN* OUTPUT_USE_IID) {
  23. HRESULT hr = hrSuccess;
  24. IECUnknown* lpUnwrapped = NULL;
  25. LPSPropValue lpPropValue = NULL;
  26. if (lpWrapped == NULL || OUTPUT_USE_IID == NULL) {
  27. hr = MAPI_E_INVALID_PARAMETER;
  28. goto exit;
  29. }
  30. if (HrGetOneProp(lpWrapped, PR_EC_OBJECT, &lpPropValue) == hrSuccess) {
  31. lpUnwrapped = (IECUnknown *)lpPropValue->Value.lpszA;
  32. if (lpUnwrapped == NULL) {
  33. hr = MAPI_E_INVALID_PARAMETER;
  34. goto exit;
  35. }
  36. hr = lpUnwrapped->QueryInterface(*USE_IID_FOR_OUTPUT, (void**)OUTPUT_USE_IID);
  37. } else {
  38. // Possible object already wrapped, gives the original object back
  39. hr = lpWrapped->QueryInterface(*USE_IID_FOR_OUTPUT, (void**)OUTPUT_USE_IID);
  40. }
  41. exit:
  42. MAPIFreeBuffer(lpPropValue);
  43. return hr;
  44. }
  45. %}