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