Commit b347a392 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

sti: COM cleanup for sti.c.

parent 0406b5d5
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
#include "objbase.h" #include "objbase.h"
#include "sti.h" #include "sti.h"
#include "sti_private.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"
...@@ -44,33 +42,41 @@ static const WCHAR registeredAppsLaunchPath[] = { ...@@ -44,33 +42,41 @@ static const WCHAR registeredAppsLaunchPath[] = {
'R','e','g','i','s','t','e','r','e','d',' ','A','p','p','l','i','c','a','t','i','o','n','s',0 'R','e','g','i','s','t','e','r','e','d',' ','A','p','p','l','i','c','a','t','i','o','n','s',0
}; };
static inline stillimage *impl_from_StillImageW(IStillImageW *iface) typedef struct _stillimage
{
IStillImageW IStillImageW_iface;
IUnknown IUnknown_iface;
IUnknown *pUnkOuter;
LONG ref;
} stillimage;
static inline stillimage *impl_from_IStillImageW(IStillImageW *iface)
{ {
return (stillimage *)((char*)iface - FIELD_OFFSET(stillimage, lpVtbl)); return CONTAINING_RECORD(iface, stillimage, IStillImageW_iface);
} }
static HRESULT WINAPI stillimagew_QueryInterface(IStillImageW *iface, REFIID riid, void **ppvObject) static HRESULT WINAPI stillimagew_QueryInterface(IStillImageW *iface, REFIID riid, void **ppvObject)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject); TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject); return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
} }
static ULONG WINAPI stillimagew_AddRef(IStillImageW *iface) static ULONG WINAPI stillimagew_AddRef(IStillImageW *iface)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
return IUnknown_AddRef(This->pUnkOuter); return IUnknown_AddRef(This->pUnkOuter);
} }
static ULONG WINAPI stillimagew_Release(IStillImageW *iface) static ULONG WINAPI stillimagew_Release(IStillImageW *iface)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
return IUnknown_Release(This->pUnkOuter); return IUnknown_Release(This->pUnkOuter);
} }
static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hinst, DWORD dwVersion) static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hinst, DWORD dwVersion)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
TRACE("(%p, %p, 0x%X)\n", This, hinst, dwVersion); TRACE("(%p, %p, 0x%X)\n", This, hinst, dwVersion);
return S_OK; return S_OK;
} }
...@@ -78,7 +84,7 @@ static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hins ...@@ -78,7 +84,7 @@ static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hins
static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwType, DWORD dwFlags, static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwType, DWORD dwFlags,
DWORD *pdwItemsReturned, LPVOID *ppBuffer) DWORD *pdwItemsReturned, LPVOID *ppBuffer)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %u, 0x%X, %p, %p): stub\n", This, dwType, dwFlags, pdwItemsReturned, ppBuffer); FIXME("(%p, %u, 0x%X, %p, %p): stub\n", This, dwType, dwFlags, pdwItemsReturned, ppBuffer);
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -86,7 +92,7 @@ static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwTyp ...@@ -86,7 +92,7 @@ static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwTyp
static HRESULT WINAPI stillimagew_GetDeviceInfo(IStillImageW *iface, LPWSTR pwszDeviceName, static HRESULT WINAPI stillimagew_GetDeviceInfo(IStillImageW *iface, LPWSTR pwszDeviceName,
LPVOID *ppBuffer) LPVOID *ppBuffer)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), ppBuffer); FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), ppBuffer);
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -94,7 +100,7 @@ static HRESULT WINAPI stillimagew_GetDeviceInfo(IStillImageW *iface, LPWSTR pwsz ...@@ -94,7 +100,7 @@ static HRESULT WINAPI stillimagew_GetDeviceInfo(IStillImageW *iface, LPWSTR pwsz
static HRESULT WINAPI stillimagew_CreateDevice(IStillImageW *iface, LPWSTR pwszDeviceName, DWORD dwMode, static HRESULT WINAPI stillimagew_CreateDevice(IStillImageW *iface, LPWSTR pwszDeviceName, DWORD dwMode,
PSTIDEVICEW *pDevice, LPUNKNOWN pUnkOuter) PSTIDEVICEW *pDevice, LPUNKNOWN pUnkOuter)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %s, %u, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), dwMode, pDevice, pUnkOuter); FIXME("(%p, %s, %u, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), dwMode, pDevice, pUnkOuter);
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -102,7 +108,7 @@ static HRESULT WINAPI stillimagew_CreateDevice(IStillImageW *iface, LPWSTR pwszD ...@@ -102,7 +108,7 @@ static HRESULT WINAPI stillimagew_CreateDevice(IStillImageW *iface, LPWSTR pwszD
static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName, static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
LPDWORD pType, LPBYTE pData, LPDWORD cbData) LPDWORD pType, LPBYTE pData, LPDWORD cbData)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %s, %s, %p, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName), FIXME("(%p, %s, %s, %p, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
pType, pData, cbData); pType, pData, cbData);
return E_NOTIMPL; return E_NOTIMPL;
...@@ -111,7 +117,7 @@ static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pws ...@@ -111,7 +117,7 @@ static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pws
static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName, static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
DWORD type, LPBYTE pData, DWORD cbData) DWORD type, LPBYTE pData, DWORD cbData)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %s, %s, %u, %p, %u): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName), FIXME("(%p, %s, %s, %u, %p, %u): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
type, pData, cbData); type, pData, cbData);
return E_NOTIMPL; return E_NOTIMPL;
...@@ -120,7 +126,7 @@ static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pws ...@@ -120,7 +126,7 @@ static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pws
static HRESULT WINAPI stillimagew_GetSTILaunchInformation(IStillImageW *iface, LPWSTR pwszDeviceName, static HRESULT WINAPI stillimagew_GetSTILaunchInformation(IStillImageW *iface, LPWSTR pwszDeviceName,
DWORD *pdwEventCode, LPWSTR pwszEventName) DWORD *pdwEventCode, LPWSTR pwszEventName)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %p, %p, %p): stub\n", This, pwszDeviceName, FIXME("(%p, %p, %p, %p): stub\n", This, pwszDeviceName,
pdwEventCode, pwszEventName); pdwEventCode, pwszEventName);
return E_NOTIMPL; return E_NOTIMPL;
...@@ -136,7 +142,7 @@ static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface, ...@@ -136,7 +142,7 @@ static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface,
HKEY registeredAppsKey = NULL; HKEY registeredAppsKey = NULL;
DWORD ret; DWORD ret;
HRESULT hr = S_OK; HRESULT hr = S_OK;
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
TRACE("(%p, %s, %s)\n", This, debugstr_w(pwszAppName), debugstr_w(pwszCommandLine)); TRACE("(%p, %s, %s)\n", This, debugstr_w(pwszAppName), debugstr_w(pwszCommandLine));
...@@ -165,7 +171,7 @@ static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface, ...@@ -165,7 +171,7 @@ static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface,
static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName) static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
HKEY registeredAppsKey = NULL; HKEY registeredAppsKey = NULL;
DWORD ret; DWORD ret;
HRESULT hr = S_OK; HRESULT hr = S_OK;
...@@ -188,7 +194,7 @@ static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *ifac ...@@ -188,7 +194,7 @@ static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *ifac
static HRESULT WINAPI stillimagew_EnableHwNotifications(IStillImageW *iface, LPCWSTR pwszDeviceName, static HRESULT WINAPI stillimagew_EnableHwNotifications(IStillImageW *iface, LPCWSTR pwszDeviceName,
BOOL bNewState) BOOL bNewState)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %s, %u): stub\n", This, debugstr_w(pwszDeviceName), bNewState); FIXME("(%p, %s, %u): stub\n", This, debugstr_w(pwszDeviceName), bNewState);
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -196,14 +202,14 @@ static HRESULT WINAPI stillimagew_EnableHwNotifications(IStillImageW *iface, LPC ...@@ -196,14 +202,14 @@ static HRESULT WINAPI stillimagew_EnableHwNotifications(IStillImageW *iface, LPC
static HRESULT WINAPI stillimagew_GetHwNotificationState(IStillImageW *iface, LPCWSTR pwszDeviceName, static HRESULT WINAPI stillimagew_GetHwNotificationState(IStillImageW *iface, LPCWSTR pwszDeviceName,
BOOL *pbCurrentState) BOOL *pbCurrentState)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), pbCurrentState); FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), pbCurrentState);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI stillimagew_RefreshDeviceBus(IStillImageW *iface, LPCWSTR pwszDeviceName) static HRESULT WINAPI stillimagew_RefreshDeviceBus(IStillImageW *iface, LPCWSTR pwszDeviceName)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %s): stub\n", This, debugstr_w(pwszDeviceName)); FIXME("(%p, %s): stub\n", This, debugstr_w(pwszDeviceName));
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -211,7 +217,7 @@ static HRESULT WINAPI stillimagew_RefreshDeviceBus(IStillImageW *iface, LPCWSTR ...@@ -211,7 +217,7 @@ static HRESULT WINAPI stillimagew_RefreshDeviceBus(IStillImageW *iface, LPCWSTR
static HRESULT WINAPI stillimagew_LaunchApplicationForDevice(IStillImageW *iface, LPWSTR pwszDeviceName, static HRESULT WINAPI stillimagew_LaunchApplicationForDevice(IStillImageW *iface, LPWSTR pwszDeviceName,
LPWSTR pwszAppName, LPSTINOTIFY pStiNotify) LPWSTR pwszAppName, LPSTINOTIFY pStiNotify)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %s, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pwszAppName), FIXME("(%p, %s, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pwszAppName),
pStiNotify); pStiNotify);
return E_NOTIMPL; return E_NOTIMPL;
...@@ -219,14 +225,14 @@ static HRESULT WINAPI stillimagew_LaunchApplicationForDevice(IStillImageW *iface ...@@ -219,14 +225,14 @@ static HRESULT WINAPI stillimagew_LaunchApplicationForDevice(IStillImageW *iface
static HRESULT WINAPI stillimagew_SetupDeviceParameters(IStillImageW *iface, PSTI_DEVICE_INFORMATIONW pDevInfo) static HRESULT WINAPI stillimagew_SetupDeviceParameters(IStillImageW *iface, PSTI_DEVICE_INFORMATIONW pDevInfo)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %p): stub\n", This, pDevInfo); FIXME("(%p, %p): stub\n", This, pDevInfo);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI stillimagew_WriteToErrorLog(IStillImageW *iface, DWORD dwMessageType, LPCWSTR pszMessage) static HRESULT WINAPI stillimagew_WriteToErrorLog(IStillImageW *iface, DWORD dwMessageType, LPCWSTR pszMessage)
{ {
stillimage *This = impl_from_StillImageW(iface); stillimage *This = impl_from_IStillImageW(iface);
FIXME("(%p, %u, %s): stub\n", This, dwMessageType, debugstr_w(pszMessage)); FIXME("(%p, %u, %s): stub\n", This, dwMessageType, debugstr_w(pszMessage));
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -253,21 +259,21 @@ static const struct IStillImageWVtbl stillimagew_vtbl = ...@@ -253,21 +259,21 @@ static const struct IStillImageWVtbl stillimagew_vtbl =
stillimagew_WriteToErrorLog stillimagew_WriteToErrorLog
}; };
static inline stillimage *impl_from_InternalUnknown(IUnknown *iface) static inline stillimage *impl_from_IUnknown(IUnknown *iface)
{ {
return (stillimage *)((char*)iface - FIELD_OFFSET(stillimage, lpInternalUnkVtbl)); return CONTAINING_RECORD(iface, stillimage, IUnknown_iface);
} }
static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject) static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject)
{ {
stillimage *This = impl_from_InternalUnknown(iface); stillimage *This = impl_from_IUnknown(iface);
TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject); TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
if (IsEqualGUID(riid, &IID_IUnknown)) if (IsEqualGUID(riid, &IID_IUnknown))
*ppvObject = iface; *ppvObject = iface;
else if (IsEqualGUID(riid, &IID_IStillImageW)) else if (IsEqualGUID(riid, &IID_IStillImageW))
*ppvObject = &This->lpVtbl; *ppvObject = &This->IStillImageW_iface;
else else
{ {
if (IsEqualGUID(riid, &IID_IStillImageA)) if (IsEqualGUID(riid, &IID_IStillImageA))
...@@ -284,14 +290,14 @@ static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void ...@@ -284,14 +290,14 @@ static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void
static ULONG WINAPI Internal_AddRef(IUnknown *iface) static ULONG WINAPI Internal_AddRef(IUnknown *iface)
{ {
stillimage *This = impl_from_InternalUnknown(iface); stillimage *This = impl_from_IUnknown(iface);
return InterlockedIncrement(&This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI Internal_Release(IUnknown *iface) static ULONG WINAPI Internal_Release(IUnknown *iface)
{ {
ULONG ref; ULONG ref;
stillimage *This = impl_from_InternalUnknown(iface); stillimage *This = impl_from_IUnknown(iface);
ref = InterlockedDecrement(&This->ref); ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0)
...@@ -328,21 +334,21 @@ HRESULT WINAPI StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, PSTIW *ppSti, LP ...@@ -328,21 +334,21 @@ HRESULT WINAPI StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, PSTIW *ppSti, LP
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(stillimage)); This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(stillimage));
if (This) if (This)
{ {
This->lpVtbl = &stillimagew_vtbl; This->IStillImageW_iface.lpVtbl = &stillimagew_vtbl;
This->lpInternalUnkVtbl = &internal_unk_vtbl; This->IUnknown_iface.lpVtbl = &internal_unk_vtbl;
if (pUnkOuter) if (pUnkOuter)
This->pUnkOuter = pUnkOuter; This->pUnkOuter = pUnkOuter;
else else
This->pUnkOuter = (IUnknown*) &This->lpInternalUnkVtbl; This->pUnkOuter = &This->IUnknown_iface;
This->ref = 1; This->ref = 1;
hr = IStillImage_Initialize((IStillImageW*) &This->lpVtbl, hinst, dwVer); hr = IStillImage_Initialize(&This->IStillImageW_iface, hinst, dwVer);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
if (pUnkOuter) if (pUnkOuter)
*ppSti = (IStillImageW*) &This->lpInternalUnkVtbl; *ppSti = (IStillImageW*) &This->IUnknown_iface;
else else
*ppSti = (IStillImageW*) &This->lpVtbl; *ppSti = &This->IStillImageW_iface;
} }
} }
else else
......
/*
* STI private definitions
*
* Copyright 2009 Damjan Jovanovic
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __STI_PRIVATE__
#define __STI_PRIVATE__
typedef struct _stillimage
{
const struct IStillImageWVtbl *lpVtbl;
const struct IUnknownVtbl *lpInternalUnkVtbl;
IUnknown *pUnkOuter;
LONG ref;
} stillimage;
#endif /* __STI_PRIVATE__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment