atl80: Added AtlComModuleRegisterServer implementation (based on AtlModuleRegisterSer...
[wine] / dlls / wiaservc / wiadevmgr.c
1 /*
2  * WiaDevMgr functions
3  *
4  * Copyright 2009 Damjan Jovanovic
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #define COBJMACROS
22
23 #include "objbase.h"
24 #include "wia_lh.h"
25
26 #include "wiaservc_private.h"
27
28 #include "wine/debug.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(wia);
31
32 static inline wiadevmgr *impl_from_IWiaDevMgr(IWiaDevMgr *iface)
33 {
34     return CONTAINING_RECORD(iface, wiadevmgr, IWiaDevMgr_iface);
35 }
36
37 static HRESULT WINAPI wiadevmgr_QueryInterface(IWiaDevMgr *iface, REFIID riid, void **ppvObject)
38 {
39     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
40
41     TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject);
42
43     if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IWiaDevMgr))
44         *ppvObject = iface;
45     else
46     {
47         FIXME("interface %s not implemented\n", debugstr_guid(riid));
48         *ppvObject = NULL;
49         return E_NOINTERFACE;
50     }
51     IUnknown_AddRef((IUnknown*) *ppvObject);
52     return S_OK;
53 }
54
55 static ULONG WINAPI wiadevmgr_AddRef(IWiaDevMgr *iface)
56 {
57     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
58     return InterlockedIncrement(&This->ref);
59 }
60
61 static ULONG WINAPI wiadevmgr_Release(IWiaDevMgr *iface)
62 {
63     ULONG ref;
64     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
65
66     ref = InterlockedDecrement(&This->ref);
67     if (ref == 0)
68         HeapFree(GetProcessHeap(), 0, This);
69     return ref;
70 }
71
72 static HRESULT WINAPI wiadevmgr_EnumDeviceInfo(IWiaDevMgr *iface, LONG lFlag, IEnumWIA_DEV_INFO **ppIEnum)
73 {
74     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
75     FIXME("(%p, %d, %p): stub\n", This, lFlag, ppIEnum);
76     return E_NOTIMPL;
77 }
78
79 static HRESULT WINAPI wiadevmgr_CreateDevice(IWiaDevMgr *iface, BSTR bstrDeviceID, IWiaItem **ppWiaItemRoot)
80 {
81     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
82     FIXME("(%p, %s, %p): stub\n", This, debugstr_w(bstrDeviceID), ppWiaItemRoot);
83     return E_NOTIMPL;
84 }
85
86 static HRESULT WINAPI wiadevmgr_SelectDeviceDlg(IWiaDevMgr *iface, HWND hwndParent, LONG lDeviceType,
87                                                 LONG lFlags, BSTR *pbstrDeviceID, IWiaItem **ppItemRoot)
88 {
89     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
90     FIXME("(%p, %p, %d, 0x%x, %p, %p): stub\n", This, hwndParent, lDeviceType, lFlags, pbstrDeviceID, ppItemRoot);
91     return E_NOTIMPL;
92 }
93
94 static HRESULT WINAPI wiadevmgr_SelectDeviceDlgID(IWiaDevMgr *iface, HWND hwndParent, LONG lDeviceType,
95                                                   LONG lFlags, BSTR *pbstrDeviceID)
96 {
97     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
98     FIXME("(%p, %p, %d, 0x%x, %p): stub\n", This, hwndParent, lDeviceType, lFlags, pbstrDeviceID);
99     return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI wiadevmgr_GetImageDlg(IWiaDevMgr *iface, HWND hwndParent, LONG lDeviceType,
103                                             LONG lFlags, LONG lIntent, IWiaItem *pItemRoot,
104                                             BSTR bstrFilename, GUID *pguidFormat)
105 {
106     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
107     FIXME("(%p, %p, %d, 0x%x, %d, %p, %s, %s): stub\n", This, hwndParent, lDeviceType, lFlags,
108         lIntent, pItemRoot, debugstr_w(bstrFilename), debugstr_guid(pguidFormat));
109     return E_NOTIMPL;
110 }
111
112 static HRESULT WINAPI wiadevmgr_RegisterEventCallbackProgram(IWiaDevMgr *iface, LONG lFlags, BSTR bstrDeviceID,
113                                                              const GUID *pEventGUID, BSTR bstrCommandline,
114                                                              BSTR bstrName, BSTR bstrDescription, BSTR bstrIcon)
115 {
116     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
117     FIXME("(%p, 0x%x, %s, %s, %s, %s, %s, %s): stub\n", This, lFlags, debugstr_w(bstrDeviceID),
118         debugstr_guid(pEventGUID), debugstr_w(bstrCommandline), debugstr_w(bstrName),
119         debugstr_w(bstrDescription), debugstr_w(bstrIcon));
120     return E_NOTIMPL;
121 }
122
123 static HRESULT WINAPI wiadevmgr_RegisterEventCallbackInterface(IWiaDevMgr *iface, LONG lFlags, BSTR bstrDeviceID,
124                                                                const GUID *pEventGUID, IWiaEventCallback *pIWiaEventCallback,
125                                                                IUnknown **pEventObject)
126 {
127     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
128     FIXME("(%p, 0x%x, %s, %s, %p, %p): stub\n", This, lFlags, debugstr_w(bstrDeviceID),
129         debugstr_guid(pEventGUID), pIWiaEventCallback, pEventObject);
130     return E_NOTIMPL;
131 }
132
133 static HRESULT WINAPI wiadevmgr_RegisterEventCallbackCLSID(IWiaDevMgr *iface, LONG lFlags, BSTR bstrDeviceID,
134                                                            const GUID *pEventGUID, const GUID *pClsID, BSTR bstrName,
135                                                            BSTR bstrDescription, BSTR bstrIcon)
136 {
137     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
138     FIXME("(%p, 0x%x, %s, %s, %s, %s, %s, %s): stub\n", This, lFlags, debugstr_w(bstrDeviceID),
139         debugstr_guid(pEventGUID), debugstr_guid(pClsID), debugstr_w(bstrName),
140         debugstr_w(bstrDescription), debugstr_w(bstrIcon));
141     return E_NOTIMPL;
142 }
143
144 static HRESULT WINAPI wiadevmgr_AddDeviceDlg(IWiaDevMgr *iface, HWND hwndParent, LONG lFlags)
145 {
146     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
147     FIXME("(%p, %p, 0x%x): stub\n", This, hwndParent, lFlags);
148     return E_NOTIMPL;
149 }
150
151 static const IWiaDevMgrVtbl WIASERVC_IWiaDevMgr_Vtbl =
152 {
153     wiadevmgr_QueryInterface,
154     wiadevmgr_AddRef,
155     wiadevmgr_Release,
156     wiadevmgr_EnumDeviceInfo,
157     wiadevmgr_CreateDevice,
158     wiadevmgr_SelectDeviceDlg,
159     wiadevmgr_SelectDeviceDlgID,
160     wiadevmgr_GetImageDlg,
161     wiadevmgr_RegisterEventCallbackProgram,
162     wiadevmgr_RegisterEventCallbackInterface,
163     wiadevmgr_RegisterEventCallbackCLSID,
164     wiadevmgr_AddDeviceDlg
165 };
166
167 HRESULT wiadevmgr_Constructor(IUnknown *pUnkOuter, LPVOID *ppObj)
168 {
169     wiadevmgr *This;
170     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
171     This = HeapAlloc(GetProcessHeap(), 0, sizeof(wiadevmgr));
172     if (This)
173     {
174         This->IWiaDevMgr_iface.lpVtbl = &WIASERVC_IWiaDevMgr_Vtbl;
175         This->ref = 1;
176         *ppObj = This;
177         return S_OK;
178     }
179     *ppObj = NULL;
180     return E_OUTOFMEMORY;
181 }