1 #ifdef _WIN32
2 
3 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
4 //
5 // File: MAPISink.cpp
6 // Description: MAPI Advise Sink Wrapper
7 //
8 // Copyright (C) 2005-2011, Noel Dillabough
9 //
10 // This source code is free to use and modify provided this notice remains intact and that any enhancements
11 // or bug fixes are posted to the CodeProject page hosting this class for the community to benefit.
12 //
13 // Usage: see the CodeProject article at http://www.codeproject.com/internet/CMapiEx.asp
14 //
15 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 
17 // Ported to U++ Framework by Koldo. See License.txt file
18 
19 #include "MAPIEx.h"
20 #include "MAPISink.h"
21 
22 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
23 // MAPISink
24 
MAPISink(LPNOTIFCALLBACK lpfnCallback,LPVOID lpvContext)25 MAPISink::MAPISink(LPNOTIFCALLBACK lpfnCallback, LPVOID lpvContext) {
26 	m_lpfnCallback = lpfnCallback;
27 	m_lpvContext = lpvContext;
28 	m_nRef = 0;
29 }
30 
QueryInterface(REFIID riid,LPVOID FAR * ppvObj)31 HRESULT MAPISink::QueryInterface(REFIID riid, LPVOID FAR* ppvObj) {
32 	if(riid == IID_IUnknown) {
33 		*ppvObj = this;
34 		AddRef();
35 		return S_OK;
36 	}
37 	return E_NOINTERFACE;
38 }
39 
AddRef()40 ULONG MAPISink::AddRef() {
41 	return InterlockedIncrement(&m_nRef);
42 }
43 
Release()44 ULONG MAPISink::Release() {
45 	ULONG ul = InterlockedDecrement(&m_nRef);
46 	if(!ul)
47 		delete this;
48 	return ul;
49 }
50 
OnNotify(ULONG cNotification,LPNOTIFICATION lpNotifications)51 ULONG MAPISink::OnNotify(ULONG cNotification, LPNOTIFICATION lpNotifications) {
52 	if(m_lpfnCallback)
53 		m_lpfnCallback(m_lpvContext, cNotification, lpNotifications);
54 	return 0;
55 }
56 
57 #endif