File: helpers.i

package info (click to toggle)
kopanocore 8.7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 15,400 kB
  • sloc: cpp: 175,422; python: 24,623; perl: 7,319; php: 6,056; sh: 2,172; makefile: 1,294; xml: 45; ansic: 1
file content (55 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* SPDX-License-Identifier: AGPL-3.0-only */
%{
#include <kopano/ECTags.h>
%}

// Pull in the language-specific helpers
#if SWIGPYTHON
%include "python/helpers_python.i"
#endif

%typemap(in) (IMAPIProp *lpWrapped, LPCIID USE_IID_FOR_OUTPUT) (int res)
{
	res = SWIG_ConvertPtr($input, (void**)&$1, $1_descriptor, 0 |  0 );
    if (!SWIG_IsOK(res)) {
      SWIG_exception_fail(SWIG_ArgError(res1), "BUG"); 
    }

	$2 = IIDFromType(TypeFromObject($input));
}

%typemap(in,numinputs=0) LPUNKNOWN *OUTPUT_USE_IID (LPUNKNOWN temp) {
  $1 = ($1_type)&temp;
}


/* Unwrap a MAPI object */
%inline %{
HRESULT UnwrapObject(IMAPIProp *lpWrapped, LPCIID USE_IID_FOR_OUTPUT, LPUNKNOWN* OUTPUT_USE_IID) {
	HRESULT hr = hrSuccess;
	IUnknown *lpUnwrapped = NULL;
	LPSPropValue lpPropValue = NULL;

	if (lpWrapped == NULL || OUTPUT_USE_IID == NULL) {
		hr = MAPI_E_INVALID_PARAMETER;
		goto exit;
	}

	if (HrGetOneProp(lpWrapped, PR_EC_OBJECT, &lpPropValue) == hrSuccess) {
		lpUnwrapped = reinterpret_cast<IUnknown *>(lpPropValue->Value.lpszA);
		if (lpUnwrapped == NULL) {
			hr = MAPI_E_INVALID_PARAMETER;
			goto exit;
		}

		hr = lpUnwrapped->QueryInterface(*USE_IID_FOR_OUTPUT, (void**)OUTPUT_USE_IID);
	} else {
		// Possible object already wrapped, gives the original object back
		hr = lpWrapped->QueryInterface(*USE_IID_FOR_OUTPUT, (void**)OUTPUT_USE_IID);
	}

exit:
	MAPIFreeBuffer(lpPropValue);
	return hr;
}
%}