comctl32: Remove TOOLTIPS_WindowFromPoint, putting its functionality into its sole...
[wine] / dlls / qedit / main.c
1 /*              DirectShow Editing Services (qedit.dll)
2  *
3  * Copyright 2008 Google (Lei Zhang)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #include "qedit_private.h"
21 #include "wine/debug.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(qedit);
24
25 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
26 {
27     switch(fdwReason) {
28         case DLL_PROCESS_ATTACH:
29             DisableThreadLibraryCalls(hInstDLL);
30             break;
31         case DLL_PROCESS_DETACH:
32             break;
33     }
34     return TRUE;
35 }
36
37 /******************************************************************************
38  * DirectShow ClassFactory
39  */
40 typedef struct {
41     IClassFactory ITF_IClassFactory;
42
43     LONG ref;
44     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
45 } IClassFactoryImpl;
46
47 struct object_creation_info
48 {
49     const CLSID *clsid;
50     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
51 };
52
53 static const struct object_creation_info object_creation[] =
54 {
55     { &CLSID_MediaDet, MediaDet_create },
56     { &CLSID_SampleGrabber, SampleGrabber_create },
57 };
58
59 static HRESULT WINAPI
60 DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
61 {
62     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
63
64     if (IsEqualGUID(riid, &IID_IUnknown)
65         || IsEqualGUID(riid, &IID_IClassFactory))
66     {
67         IClassFactory_AddRef(iface);
68         *ppobj = This;
69         return S_OK;
70     }
71
72     *ppobj = NULL;
73     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
74     return E_NOINTERFACE;
75 }
76
77 static ULONG WINAPI DSCF_AddRef(LPCLASSFACTORY iface)
78 {
79     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
80     return InterlockedIncrement(&This->ref);
81 }
82
83 static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface)
84 {
85     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
86
87     ULONG ref = InterlockedDecrement(&This->ref);
88
89     if (ref == 0)
90         CoTaskMemFree(This);
91
92     return ref;
93 }
94
95 static HRESULT WINAPI DSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
96 {
97     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
98     HRESULT hres;
99     LPUNKNOWN punk;
100
101     TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
102
103     *ppobj = NULL;
104     hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
105     if (SUCCEEDED(hres)) {
106         hres = IUnknown_QueryInterface(punk, riid, ppobj);
107         IUnknown_Release(punk);
108     }
109     return hres;
110 }
111
112 static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
113 {
114     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
115     FIXME("(%p)->(%d),stub!\n",This,dolock);
116     return S_OK;
117 }
118
119 static const IClassFactoryVtbl DSCF_Vtbl =
120 {
121     DSCF_QueryInterface,
122     DSCF_AddRef,
123     DSCF_Release,
124     DSCF_CreateInstance,
125     DSCF_LockServer
126 };
127
128
129 /***********************************************************************
130  *              DllCanUnloadNow (QEDIT.@)
131  */
132 HRESULT WINAPI DllCanUnloadNow(void)
133 {
134     return S_OK;
135 }
136
137 /*******************************************************************************
138  * DllGetClassObject [QEDIT.@]
139  * Retrieves class object from a DLL object
140  *
141  * PARAMS
142  *    rclsid [I] CLSID for the class object
143  *    riid   [I] Reference to identifier of interface for class object
144  *    ppv    [O] Address of variable to receive interface pointer for riid
145  *
146  * RETURNS
147  *    Success: S_OK
148  *    Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
149  *             E_UNEXPECTED, E_NOINTERFACE
150  */
151
152 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
153 {
154     unsigned int i;
155     IClassFactoryImpl *factory;
156
157     TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
158
159     if ( !IsEqualGUID( &IID_IClassFactory, riid )
160          && ! IsEqualGUID( &IID_IUnknown, riid) )
161         return E_NOINTERFACE;
162
163     for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
164     {
165         if (IsEqualGUID(object_creation[i].clsid, rclsid))
166             break;
167     }
168
169     if (i == sizeof(object_creation)/sizeof(object_creation[0]))
170     {
171         FIXME("%s: no class found.\n", debugstr_guid(rclsid));
172         return CLASS_E_CLASSNOTAVAILABLE;
173     }
174
175     factory = CoTaskMemAlloc(sizeof(*factory));
176     if (factory == NULL) return E_OUTOFMEMORY;
177
178     factory->ITF_IClassFactory.lpVtbl = &DSCF_Vtbl;
179     factory->ref = 1;
180
181     factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
182
183     *ppv = &(factory->ITF_IClassFactory);
184     return S_OK;
185 }