Move the custom draw notifications into the Draw.*Item functions.
[wine] / dlls / rpcrt4 / cstub.c
1 /*
2  * COM stub (CStdStubBuffer) implementation
3  *
4  * Copyright 2001 Ove Kåven, TransGaming Technologies
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "windef.h"
22 #include "winbase.h"
23 #include "winerror.h"
24
25 #include "wine/obj_base.h"
26 #include "wine/obj_channel.h"
27
28 #include "rpcproxy.h"
29
30 #include "wine/debug.h"
31
32 #include "cpsf.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(ole);
35
36 #define STUB_HEADER(This) (((CInterfaceStubHeader*)((This)->lpVtbl))[-1])
37
38 HRESULT WINAPI CStdStubBuffer_Construct(REFIID riid,
39                                        LPUNKNOWN pUnkServer,
40                                        CInterfaceStubVtbl *vtbl,
41                                        LPPSFACTORYBUFFER pPSFactory,
42                                        LPRPCSTUBBUFFER *ppStub)
43 {
44   CStdStubBuffer *This;
45
46   TRACE("(%p,%p,%p,%p)\n", pUnkServer, vtbl, pPSFactory, ppStub);
47   TRACE("iid=%s\n", debugstr_guid(vtbl->header.piid));
48   TRACE("vtbl=%p\n", &vtbl->Vtbl);
49
50   if (!IsEqualGUID(vtbl->header.piid, riid)) {
51     ERR("IID mismatch during stub creation\n");
52     return RPC_E_UNEXPECTED;
53   }
54
55   This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CStdStubBuffer));
56   if (!This) return E_OUTOFMEMORY;
57
58   This->lpVtbl = &vtbl->Vtbl;
59   This->RefCount = 1;
60   This->pvServerObject = pUnkServer;
61   This->pPSFactory = pPSFactory;
62   *ppStub = (LPRPCSTUBBUFFER)This;
63
64   IPSFactoryBuffer_AddRef(pPSFactory);
65   return S_OK;
66 }
67
68 HRESULT WINAPI CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface,
69                                             REFIID riid,
70                                             LPVOID *obj)
71 {
72   ICOM_THIS(CStdStubBuffer,iface);
73   TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(riid),obj);
74
75   if (IsEqualGUID(&IID_IUnknown,riid) ||
76       IsEqualGUID(&IID_IRpcStubBuffer,riid)) {
77     *obj = This;
78     This->RefCount++;
79     return S_OK;
80   }
81   return E_NOINTERFACE;
82 }
83
84 ULONG WINAPI CStdStubBuffer_AddRef(LPRPCSTUBBUFFER iface)
85 {
86   ICOM_THIS(CStdStubBuffer,iface);
87   TRACE("(%p)->AddRef()\n",This);
88   return ++(This->RefCount);
89 }
90
91 ULONG WINAPI NdrCStdStubBuffer_Release(LPRPCSTUBBUFFER iface,
92                                       LPPSFACTORYBUFFER pPSF)
93 {
94   ICOM_THIS(CStdStubBuffer,iface);
95   TRACE("(%p)->Release()\n",This);
96
97   if (!--(This->RefCount)) {
98     IUnknown_Release(This->pvServerObject);
99     IPSFactoryBuffer_Release(This->pPSFactory);
100     HeapFree(GetProcessHeap(),0,This);
101     return 0;
102   }
103   return This->RefCount;
104 }
105
106 HRESULT WINAPI CStdStubBuffer_Connect(LPRPCSTUBBUFFER iface,
107                                      LPUNKNOWN lpUnkServer)
108 {
109   ICOM_THIS(CStdStubBuffer,iface);
110   TRACE("(%p)->Connect(%p)\n",This,lpUnkServer);
111   This->pvServerObject = lpUnkServer;
112   return S_OK;
113 }
114
115 void WINAPI CStdStubBuffer_Disconnect(LPRPCSTUBBUFFER iface)
116 {
117   ICOM_THIS(CStdStubBuffer,iface);
118   TRACE("(%p)->Disconnect()\n",This);
119   This->pvServerObject = NULL;
120 }
121
122 HRESULT WINAPI CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface,
123                                     PRPCOLEMESSAGE pMsg,
124                                     LPRPCCHANNELBUFFER pChannel)
125 {
126   ICOM_THIS(CStdStubBuffer,iface);
127   DWORD dwPhase = STUB_UNMARSHAL;
128   TRACE("(%p)->Invoke(%p,%p)\n",This,pMsg,pChannel);
129
130   STUB_HEADER(This).pDispatchTable[pMsg->iMethod](iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
131   return S_OK;
132 }
133
134 LPRPCSTUBBUFFER WINAPI CStdStubBuffer_IsIIDSupported(LPRPCSTUBBUFFER iface,
135                                                     REFIID riid)
136 {
137   ICOM_THIS(CStdStubBuffer,iface);
138   TRACE("(%p)->IsIIDSupported(%s)\n",This,debugstr_guid(riid));
139   return IsEqualGUID(STUB_HEADER(This).piid, riid) ? iface : NULL;
140 }
141
142 ULONG WINAPI CStdStubBuffer_CountRefs(LPRPCSTUBBUFFER iface)
143 {
144   ICOM_THIS(CStdStubBuffer,iface);
145   TRACE("(%p)->CountRefs()\n",This);
146   return This->RefCount;
147 }
148
149 HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(LPRPCSTUBBUFFER iface,
150                                                        LPVOID *ppv)
151 {
152   ICOM_THIS(CStdStubBuffer,iface);
153   TRACE("(%p)->DebugServerQueryInterface(%p)\n",This,ppv);
154   return S_OK;
155 }
156
157 void WINAPI CStdStubBuffer_DebugServerRelease(LPRPCSTUBBUFFER iface,
158                                              LPVOID pv)
159 {
160   ICOM_THIS(CStdStubBuffer,iface);
161   TRACE("(%p)->DebugServerRelease(%p)\n",This,pv);
162 }