1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS BDA Proxy
4  * FILE:            dll/directx/msvidctl/enumtuningspaces.cpp
5  * PURPOSE:         ITuningSpace interface
6  *
7  * PROGRAMMERS:     Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 #include "precomp.h"
10 
11 class CEnumTuningSpaces : public IEnumTuningSpaces
12 {
13 public:
14     STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
15 
AddRef()16     STDMETHODIMP_(ULONG) AddRef()
17     {
18         InterlockedIncrement(&m_Ref);
19         return m_Ref;
20     }
Release()21     STDMETHODIMP_(ULONG) Release()
22     {
23         InterlockedDecrement(&m_Ref);
24         if (!m_Ref)
25         {
26             //delete this;
27             return 0;
28         }
29         return m_Ref;
30     }
31 
32     // IEnumTuningSpaces methods
33     HRESULT STDMETHODCALLTYPE Next(ULONG celt, ITuningSpace **rgelt, ULONG *pceltFetched);
34     HRESULT STDMETHODCALLTYPE Skip(ULONG celt);
35     HRESULT STDMETHODCALLTYPE Reset();
36     HRESULT STDMETHODCALLTYPE Clone(IEnumTuningSpaces **ppEnum);
37 
CEnumTuningSpaces()38     CEnumTuningSpaces() : m_Ref(0){};
39 
~CEnumTuningSpaces()40     virtual ~CEnumTuningSpaces(){};
41 
42 protected:
43     LONG m_Ref;
44 };
45 
46 HRESULT
47 STDMETHODCALLTYPE
QueryInterface(IN REFIID refiid,OUT PVOID * Output)48 CEnumTuningSpaces::QueryInterface(
49     IN  REFIID refiid,
50     OUT PVOID* Output)
51 {
52     if (IsEqualGUID(refiid, IID_IUnknown))
53     {
54         *Output = PVOID(this);
55         reinterpret_cast<IUnknown*>(*Output)->AddRef();
56         return NOERROR;
57     }
58 
59     if (IsEqualGUID(refiid, IID_IEnumTuningSpaces))
60     {
61         *Output = (IEnumTuningSpaces*)this;
62         reinterpret_cast<IEnumTuningSpaces*>(*Output)->AddRef();
63         return NOERROR;
64     }
65 
66     WCHAR Buffer[MAX_PATH];
67     LPOLESTR lpstr;
68     StringFromCLSID(refiid, &lpstr);
69     swprintf(Buffer, L"CEnumTuningSpaces::QueryInterface: NoInterface for %s\n", lpstr);
70     OutputDebugStringW(Buffer);
71     CoTaskMemFree(lpstr);
72 
73     return E_NOINTERFACE;
74 }
75 
76 //-------------------------------------------------------------------
77 // IEnumTuningSpaces
78 //
79 HRESULT
80 STDMETHODCALLTYPE
Next(ULONG celt,ITuningSpace ** rgelt,ULONG * pceltFetched)81 CEnumTuningSpaces::Next(ULONG celt, ITuningSpace **rgelt, ULONG *pceltFetched)
82 {
83     OutputDebugStringW(L"CEnumTuningSpaces::Next : stub\n");
84     return CTuningSpace_fnConstructor(NULL, IID_ITuningSpace, (void**)rgelt);
85 
86 }
87 
88 HRESULT
89 STDMETHODCALLTYPE
Skip(ULONG celt)90 CEnumTuningSpaces::Skip(ULONG celt)
91 {
92     OutputDebugStringW(L"CEnumTuningSpaces::Skip : NotImplemented\n");
93     return E_NOTIMPL;
94 }
95 
96 HRESULT
97 STDMETHODCALLTYPE
Reset()98 CEnumTuningSpaces::Reset()
99 {
100     OutputDebugStringW(L"CEnumTuningSpaces::Reset : NotImplemented\n");
101     return E_NOTIMPL;
102 }
103 
104 HRESULT
105 STDMETHODCALLTYPE
Clone(IEnumTuningSpaces ** ppEnum)106 CEnumTuningSpaces::Clone(IEnumTuningSpaces **ppEnum)
107 {
108     OutputDebugStringW(L"CEnumTuningSpaces::Clone : NotImplemented\n");
109     return E_NOTIMPL;
110 }
111 
112 HRESULT
113 WINAPI
CEnumTuningSpaces_fnConstructor(IUnknown * pUnknown,REFIID riid,LPVOID * ppv)114 CEnumTuningSpaces_fnConstructor(
115     IUnknown *pUnknown,
116     REFIID riid,
117     LPVOID * ppv)
118 {
119     // construct device control
120     CEnumTuningSpaces * tuningspaces = new CEnumTuningSpaces();
121 
122 #ifdef MSVIDCTL_TRACE
123     WCHAR Buffer[MAX_PATH];
124     LPOLESTR lpstr;
125     StringFromCLSID(riid, &lpstr);
126     swprintf(Buffer, L"CEnumTuningSpaces_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown);
127     OutputDebugStringW(Buffer);
128 #endif
129 
130     if (!tuningspaces)
131         return E_OUTOFMEMORY;
132 
133     if (FAILED(tuningspaces->QueryInterface(riid, ppv)))
134     {
135         /* not supported */
136         delete tuningspaces;
137         return E_NOINTERFACE;
138     }
139 
140     return NOERROR;
141 }
142 
143