Include objbase.h for CoTaskMem* prototypes (or we get WINAPI
[wine] / ole / oleobj.c
1 /*
2  *      OLE2 COM objects
3  *
4  *      Copyright 1998 Eric Kohl
5  */
6
7
8 #include "ole.h"
9 #include "ole2.h"
10 #include "winerror.h"
11 #include "windows.h"
12 #include "wine/obj_base.h"
13 #include "wine/obj_storage.h"
14 #include "wine/obj_moniker.h"
15 #include "wine/obj_dataobject.h"
16 #include "oleobj.h"
17 #include "debug.h"
18
19
20 #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
21 #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
22 #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
23
24
25 /**************************************************************************
26  *  IOleAdviseHolder Implementation
27  */
28 static HRESULT WINAPI IOleAdviseHolder_QueryInterface(LPOLEADVISEHOLDER,REFIID,LPVOID*);
29 static ULONG WINAPI   IOleAdviseHolder_AddRef(LPOLEADVISEHOLDER);
30 static ULONG WINAPI   IOleAdviseHolder_Release(LPOLEADVISEHOLDER);
31 static HRESULT WINAPI IOleAdviseHolder_Advise(LPOLEADVISEHOLDER, IAdviseSink*, DWORD*);
32 static HRESULT WINAPI IOleAdviseHolder_Unadvise (LPOLEADVISEHOLDER, DWORD);
33 static HRESULT WINAPI IOleAdviseHolder_EnumAdvise (LPOLEADVISEHOLDER, IEnumSTATDATA **);
34 static HRESULT WINAPI IOleAdviseHolder_SendOnRename (LPOLEADVISEHOLDER, IMoniker *);
35 static HRESULT WINAPI IOleAdviseHolder_SendOnSave (LPOLEADVISEHOLDER this);
36 static HRESULT WINAPI IOleAdviseHolder_SendOnClose (LPOLEADVISEHOLDER this);
37
38
39 /**************************************************************************
40  *  IOleAdviseHolder_VTable
41  */
42 static IOleAdviseHolder_VTable oahvt =
43 {
44     IOleAdviseHolder_QueryInterface,
45     IOleAdviseHolder_AddRef,
46     IOleAdviseHolder_Release,
47     IOleAdviseHolder_Advise,
48     IOleAdviseHolder_Unadvise,
49     IOleAdviseHolder_EnumAdvise,
50     IOleAdviseHolder_SendOnRename,
51     IOleAdviseHolder_SendOnSave,
52     IOleAdviseHolder_SendOnClose
53 };
54
55 /**************************************************************************
56  *  IOleAdviseHolder_Constructor
57  */
58
59 LPOLEADVISEHOLDER IOleAdviseHolder_Constructor()
60 {
61     LPOLEADVISEHOLDER lpoah;
62
63     lpoah= (LPOLEADVISEHOLDER)HeapAlloc(GetProcessHeap(),0,sizeof(IOleAdviseHolder));
64     lpoah->ref = 1;
65     lpoah->lpvtbl = &oahvt;
66     FIXME (ole, "(%p)->()\n", lpoah);
67
68     return lpoah;
69 }
70
71 /**************************************************************************
72  *  IOleAdviseHolder_QueryInterface
73  */
74 static HRESULT WINAPI
75 IOleAdviseHolder_QueryInterface (LPOLEADVISEHOLDER this, REFIID riid, LPVOID *ppvObj)
76 {
77     char xriid[50];
78     WINE_StringFromCLSID((LPCLSID)riid,xriid);
79     FIXME (ole, "(%p)->(\n\tIID:\t%s)\n", this, xriid);
80
81     *ppvObj = NULL;
82
83     if(IsEqualIID(riid, &IID_IUnknown)) {
84         /* IUnknown */
85         *ppvObj = this; 
86     }
87     else if(IsEqualIID(riid, &IID_IOleAdviseHolder)) {
88         /* IOleAdviseHolder */
89         *ppvObj = (IOleAdviseHolder*) this;
90     }
91
92     if(*ppvObj) {
93         (*(LPOLEADVISEHOLDER*)ppvObj)->lpvtbl->fnAddRef(this);          
94         FIXME (ole, "-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
95         return S_OK;
96     }
97
98     FIXME (ole, "-- Interface: E_NOINTERFACE\n");
99     return E_NOINTERFACE;
100 }
101
102 /******************************************************************************
103  * IOleAdviseHolder_AddRef
104  */
105 static ULONG WINAPI
106 IOleAdviseHolder_AddRef (LPOLEADVISEHOLDER this)
107 {
108     FIXME (ole, "(%p)->(count=%lu)\n", this, this->ref);
109     return ++(this->ref);
110 }
111
112 /******************************************************************************
113  * IOleAdviseHolder_Release
114  */
115 static ULONG WINAPI
116 IOleAdviseHolder_Release (LPOLEADVISEHOLDER this)
117 {
118     FIXME (ole, "(%p)->(count=%lu)\n", this, this->ref);
119     if (!--(this->ref)) {
120         FIXME (ole, "-- destroying IOleAdviseHolder(%p)\n", this);
121         HeapFree(GetProcessHeap(),0,this);
122         return 0;
123     }
124     return this->ref;
125 }
126
127 /******************************************************************************
128  * IOleAdviseHolder_Advise
129  */
130 static HRESULT WINAPI
131 IOleAdviseHolder_Advise (LPOLEADVISEHOLDER this,
132                          IAdviseSink *pAdvise, DWORD *pdwConnection)
133 {
134     FIXME (ole, "(%p)->(%p %p)\n", this, pAdvise, pdwConnection);
135
136     *pdwConnection = 0;
137
138    return S_OK;
139 }
140
141 /******************************************************************************
142  * IOleAdviseHolder_Unadvise
143  */
144 static HRESULT WINAPI
145 IOleAdviseHolder_Unadvise (LPOLEADVISEHOLDER this, DWORD dwConnection)
146 {
147     FIXME (ole, "(%p)->(%lu)\n", this, dwConnection);
148
149     return S_OK;
150 }
151
152 /******************************************************************************
153  * IOleAdviseHolder_EnumAdvise
154  */
155 static HRESULT WINAPI
156 IOleAdviseHolder_EnumAdvise (LPOLEADVISEHOLDER this, IEnumSTATDATA **ppenumAdvise)
157 {
158     FIXME (ole, "(%p)->(%p)\n", this, ppenumAdvise);
159
160     *ppenumAdvise = NULL;
161
162     return S_OK;
163 }
164
165 /******************************************************************************
166  * IOleAdviseHolder_SendOnRename
167  */
168 static HRESULT WINAPI
169 IOleAdviseHolder_SendOnRename (LPOLEADVISEHOLDER this, IMoniker *pmk)
170 {
171     FIXME (ole, "(%p)->(%p)\n", this, pmk);
172
173
174     return S_OK;
175 }
176
177 /******************************************************************************
178  * IOleAdviseHolder_SendOnSave
179  */
180 static HRESULT WINAPI
181 IOleAdviseHolder_SendOnSave (LPOLEADVISEHOLDER this)
182 {
183     FIXME (ole, "(%p)\n", this);
184
185
186     return S_OK;
187 }
188
189 /******************************************************************************
190  * IOleAdviseHolder_SendOnClose
191  */
192 static HRESULT WINAPI
193 IOleAdviseHolder_SendOnClose (LPOLEADVISEHOLDER this)
194 {
195     FIXME (ole, "(%p)\n", this);
196
197
198     return S_OK;
199 }
200
201 /***********************************************************************
202  * API functions
203  */
204
205 /***********************************************************************
206  * CreateOleAdviseHolder [OLE32.59]
207  */
208 HRESULT WINAPI CreateOleAdviseHolder32 (LPOLEADVISEHOLDER *ppOAHolder)
209 {
210     FIXME(ole,"(%p): stub!\n", ppOAHolder);
211
212     *ppOAHolder = IOleAdviseHolder_Constructor ();
213     if (*ppOAHolder)
214         return S_OK;
215
216     *ppOAHolder = 0;
217     return E_OUTOFMEMORY;
218 }
219