ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

sti.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2002 Aric Stewart for CodeWeavers
00003  * Copyright (C) 2009 Damjan Jovanovic
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00018  */
00019 
00020 #include <stdarg.h>
00021 
00022 #define COBJMACROS
00023 
00024 #include "windef.h"
00025 #include "winbase.h"
00026 #include "winreg.h"
00027 #include "winerror.h"
00028 #include "objbase.h"
00029 #include "sti.h"
00030 
00031 #include "wine/debug.h"
00032 #include "wine/unicode.h"
00033 
00034 WINE_DEFAULT_DEBUG_CHANNEL(sti);
00035 
00036 static const WCHAR registeredAppsLaunchPath[] = {
00037     'S','O','F','T','W','A','R','E','\\',
00038     'M','i','c','r','o','s','o','f','t','\\',
00039     'W','i','n','d','o','w','s','\\',
00040     'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
00041     'S','t','i','l','l','I','m','a','g','e','\\',
00042     'R','e','g','i','s','t','e','r','e','d',' ','A','p','p','l','i','c','a','t','i','o','n','s',0
00043 };
00044 
00045 typedef struct _stillimage
00046 {
00047     IStillImageW IStillImageW_iface;
00048     IUnknown IUnknown_iface;
00049     IUnknown *pUnkOuter;
00050     LONG ref;
00051 } stillimage;
00052 
00053 static inline stillimage *impl_from_IStillImageW(IStillImageW *iface)
00054 {
00055     return CONTAINING_RECORD(iface, stillimage, IStillImageW_iface);
00056 }
00057 
00058 static HRESULT WINAPI stillimagew_QueryInterface(IStillImageW *iface, REFIID riid, void **ppvObject)
00059 {
00060     stillimage *This = impl_from_IStillImageW(iface);
00061     TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
00062     return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
00063 }
00064 
00065 static ULONG WINAPI stillimagew_AddRef(IStillImageW *iface)
00066 {
00067     stillimage *This = impl_from_IStillImageW(iface);
00068     return IUnknown_AddRef(This->pUnkOuter);
00069 }
00070 
00071 static ULONG WINAPI stillimagew_Release(IStillImageW *iface)
00072 {
00073     stillimage *This = impl_from_IStillImageW(iface);
00074     return IUnknown_Release(This->pUnkOuter);
00075 }
00076 
00077 static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hinst, DWORD dwVersion)
00078 {
00079     stillimage *This = impl_from_IStillImageW(iface);
00080     TRACE("(%p, %p, 0x%X)\n", This, hinst, dwVersion);
00081     return S_OK;
00082 }
00083 
00084 static HRESULT WINAPI stillimagew_GetDeviceList(IStillImageW *iface, DWORD dwType, DWORD dwFlags,
00085                                                 DWORD *pdwItemsReturned, LPVOID *ppBuffer)
00086 {
00087     stillimage *This = impl_from_IStillImageW(iface);
00088     FIXME("(%p, %u, 0x%X, %p, %p): stub\n", This, dwType, dwFlags, pdwItemsReturned, ppBuffer);
00089     return E_NOTIMPL;
00090 }
00091 
00092 static HRESULT WINAPI stillimagew_GetDeviceInfo(IStillImageW *iface, LPWSTR pwszDeviceName,
00093                                                 LPVOID *ppBuffer)
00094 {
00095     stillimage *This = impl_from_IStillImageW(iface);
00096     FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), ppBuffer);
00097     return E_NOTIMPL;
00098 }
00099 
00100 static HRESULT WINAPI stillimagew_CreateDevice(IStillImageW *iface, LPWSTR pwszDeviceName, DWORD dwMode,
00101                                                PSTIDEVICEW *pDevice, LPUNKNOWN pUnkOuter)
00102 {
00103     stillimage *This = impl_from_IStillImageW(iface);
00104     FIXME("(%p, %s, %u, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), dwMode, pDevice, pUnkOuter);
00105     return E_NOTIMPL;
00106 }
00107 
00108 static HRESULT WINAPI stillimagew_GetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
00109                                                  LPDWORD pType, LPBYTE pData, LPDWORD cbData)
00110 {
00111     stillimage *This = impl_from_IStillImageW(iface);
00112     FIXME("(%p, %s, %s, %p, %p, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
00113         pType, pData, cbData);
00114     return E_NOTIMPL;
00115 }
00116 
00117 static HRESULT WINAPI stillimagew_SetDeviceValue(IStillImageW *iface, LPWSTR pwszDeviceName, LPWSTR pValueName,
00118                                                  DWORD type, LPBYTE pData, DWORD cbData)
00119 {
00120     stillimage *This = impl_from_IStillImageW(iface);
00121     FIXME("(%p, %s, %s, %u, %p, %u): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pValueName),
00122         type, pData, cbData);
00123     return E_NOTIMPL;
00124 }
00125 
00126 static HRESULT WINAPI stillimagew_GetSTILaunchInformation(IStillImageW *iface, LPWSTR pwszDeviceName,
00127                                                           DWORD *pdwEventCode, LPWSTR pwszEventName)
00128 {
00129     stillimage *This = impl_from_IStillImageW(iface);
00130     FIXME("(%p, %p, %p, %p): stub\n", This, pwszDeviceName,
00131         pdwEventCode, pwszEventName);
00132     return E_NOTIMPL;
00133 }
00134 
00135 static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName,
00136                                                             LPWSTR pwszCommandLine)
00137 {
00138     static const WCHAR format[] = {'%','s',' ','%','s',0};
00139     static const WCHAR commandLineSuffix[] = {
00140         '/','S','t','i','D','e','v','i','c','e',':','%','1',' ',
00141         '/','S','t','i','E','v','e','n','t',':','%','2',0};
00142     HKEY registeredAppsKey = NULL;
00143     DWORD ret;
00144     HRESULT hr = S_OK;
00145     stillimage *This = impl_from_IStillImageW(iface);
00146 
00147     TRACE("(%p, %s, %s)\n", This, debugstr_w(pwszAppName), debugstr_w(pwszCommandLine));
00148 
00149     ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, &registeredAppsKey);
00150     if (ret == ERROR_SUCCESS)
00151     {
00152         WCHAR *value = HeapAlloc(GetProcessHeap(), 0,
00153             (lstrlenW(pwszCommandLine) + 1 + lstrlenW(commandLineSuffix) + 1) * sizeof(WCHAR));
00154         if (value)
00155         {
00156             sprintfW(value, format, pwszCommandLine, commandLineSuffix);
00157             ret = RegSetValueExW(registeredAppsKey, pwszAppName, 0,
00158                 REG_SZ, (BYTE*)value, (lstrlenW(value)+1)*sizeof(WCHAR));
00159             if (ret != ERROR_SUCCESS)
00160                 hr = HRESULT_FROM_WIN32(ret);
00161             HeapFree(GetProcessHeap(), 0, value);
00162         }
00163         else
00164             hr = E_OUTOFMEMORY;
00165         RegCloseKey(registeredAppsKey);
00166     }
00167     else
00168         hr = HRESULT_FROM_WIN32(ret);
00169     return hr;
00170 }
00171 
00172 static HRESULT WINAPI stillimagew_UnregisterLaunchApplication(IStillImageW *iface, LPWSTR pwszAppName)
00173 {
00174     stillimage *This = impl_from_IStillImageW(iface);
00175     HKEY registeredAppsKey = NULL;
00176     DWORD ret;
00177     HRESULT hr = S_OK;
00178 
00179     TRACE("(%p, %s)\n", This, debugstr_w(pwszAppName));
00180 
00181     ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, &registeredAppsKey);
00182     if (ret == ERROR_SUCCESS)
00183     {
00184         ret = RegDeleteValueW(registeredAppsKey, pwszAppName);
00185         if (ret != ERROR_SUCCESS)
00186             hr = HRESULT_FROM_WIN32(ret);
00187         RegCloseKey(registeredAppsKey);
00188     }
00189     else
00190         hr = HRESULT_FROM_WIN32(ret);
00191     return hr;
00192 }
00193 
00194 static HRESULT WINAPI stillimagew_EnableHwNotifications(IStillImageW *iface, LPCWSTR pwszDeviceName,
00195                                                         BOOL bNewState)
00196 {
00197     stillimage *This = impl_from_IStillImageW(iface);
00198     FIXME("(%p, %s, %u): stub\n", This, debugstr_w(pwszDeviceName), bNewState);
00199     return E_NOTIMPL;
00200 }
00201 
00202 static HRESULT WINAPI stillimagew_GetHwNotificationState(IStillImageW *iface, LPCWSTR pwszDeviceName,
00203                                                          BOOL *pbCurrentState)
00204 {
00205     stillimage *This = impl_from_IStillImageW(iface);
00206     FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), pbCurrentState);
00207     return E_NOTIMPL;
00208 }
00209 
00210 static HRESULT WINAPI stillimagew_RefreshDeviceBus(IStillImageW *iface, LPCWSTR pwszDeviceName)
00211 {
00212     stillimage *This = impl_from_IStillImageW(iface);
00213     FIXME("(%p, %s): stub\n", This, debugstr_w(pwszDeviceName));
00214     return E_NOTIMPL;
00215 }
00216 
00217 static HRESULT WINAPI stillimagew_LaunchApplicationForDevice(IStillImageW *iface, LPWSTR pwszDeviceName,
00218                                                              LPWSTR pwszAppName, LPSTINOTIFY pStiNotify)
00219 {
00220     stillimage *This = impl_from_IStillImageW(iface);
00221     FIXME("(%p, %s, %s, %p): stub\n", This, debugstr_w(pwszDeviceName), debugstr_w(pwszAppName),
00222         pStiNotify);
00223     return E_NOTIMPL;
00224 }
00225 
00226 static HRESULT WINAPI stillimagew_SetupDeviceParameters(IStillImageW *iface, PSTI_DEVICE_INFORMATIONW pDevInfo)
00227 {
00228     stillimage *This = impl_from_IStillImageW(iface);
00229     FIXME("(%p, %p): stub\n", This, pDevInfo);
00230     return E_NOTIMPL;
00231 }
00232 
00233 static HRESULT WINAPI stillimagew_WriteToErrorLog(IStillImageW *iface, DWORD dwMessageType, LPCWSTR pszMessage)
00234 {
00235     stillimage *This = impl_from_IStillImageW(iface);
00236     FIXME("(%p, %u, %s): stub\n", This, dwMessageType, debugstr_w(pszMessage));
00237     return E_NOTIMPL;
00238 }
00239 
00240 static const struct IStillImageWVtbl stillimagew_vtbl =
00241 {
00242     stillimagew_QueryInterface,
00243     stillimagew_AddRef,
00244     stillimagew_Release,
00245     stillimagew_Initialize,
00246     stillimagew_GetDeviceList,
00247     stillimagew_GetDeviceInfo,
00248     stillimagew_CreateDevice,
00249     stillimagew_GetDeviceValue,
00250     stillimagew_SetDeviceValue,
00251     stillimagew_GetSTILaunchInformation,
00252     stillimagew_RegisterLaunchApplication,
00253     stillimagew_UnregisterLaunchApplication,
00254     stillimagew_EnableHwNotifications,
00255     stillimagew_GetHwNotificationState,
00256     stillimagew_RefreshDeviceBus,
00257     stillimagew_LaunchApplicationForDevice,
00258     stillimagew_SetupDeviceParameters,
00259     stillimagew_WriteToErrorLog
00260 };
00261 
00262 static inline stillimage *impl_from_IUnknown(IUnknown *iface)
00263 {
00264     return CONTAINING_RECORD(iface, stillimage, IUnknown_iface);
00265 }
00266 
00267 static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject)
00268 {
00269     stillimage *This = impl_from_IUnknown(iface);
00270 
00271     TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
00272 
00273     if (IsEqualGUID(riid, &IID_IUnknown))
00274         *ppvObject = iface;
00275     else if (IsEqualGUID(riid, &IID_IStillImageW))
00276         *ppvObject = &This->IStillImageW_iface;
00277     else
00278     {
00279         if (IsEqualGUID(riid, &IID_IStillImageA))
00280             FIXME("interface IStillImageA is unsupported on Windows Vista too, please report if it's needed\n");
00281         else
00282             FIXME("interface %s not implemented\n", debugstr_guid(riid));
00283         *ppvObject = NULL;
00284         return E_NOINTERFACE;
00285     }
00286 
00287     IUnknown_AddRef((IUnknown*) *ppvObject);
00288     return S_OK;
00289 }
00290 
00291 static ULONG WINAPI Internal_AddRef(IUnknown *iface)
00292 {
00293     stillimage *This = impl_from_IUnknown(iface);
00294     return InterlockedIncrement(&This->ref);
00295 }
00296 
00297 static ULONG WINAPI Internal_Release(IUnknown *iface)
00298 {
00299     ULONG ref;
00300     stillimage *This = impl_from_IUnknown(iface);
00301 
00302     ref = InterlockedDecrement(&This->ref);
00303     if (ref == 0)
00304         HeapFree(GetProcessHeap(), 0, This);
00305     return ref;
00306 }
00307 
00308 static const struct IUnknownVtbl internal_unk_vtbl =
00309 {
00310     Internal_QueryInterface,
00311     Internal_AddRef,
00312     Internal_Release
00313 };
00314 
00315 /******************************************************************************
00316  *           StiCreateInstanceA   (STI.@)
00317  */
00318 HRESULT WINAPI StiCreateInstanceA(HINSTANCE hinst, DWORD dwVer, PSTIA *ppSti, LPUNKNOWN pUnkOuter)
00319 {
00320     FIXME("(%p, %u, %p, %p): stub, unimplemented on Windows Vista too, please report if it's needed\n", hinst, dwVer, ppSti, pUnkOuter);
00321     return STG_E_UNIMPLEMENTEDFUNCTION;
00322 }
00323 
00324 /******************************************************************************
00325  *           StiCreateInstanceW   (STI.@)
00326  */
00327 HRESULT WINAPI StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, PSTIW *ppSti, LPUNKNOWN pUnkOuter)
00328 {
00329     stillimage *This;
00330     HRESULT hr;
00331 
00332     TRACE("(%p, %u, %p, %p)\n", hinst, dwVer, ppSti, pUnkOuter);
00333 
00334     This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(stillimage));
00335     if (This)
00336     {
00337         This->IStillImageW_iface.lpVtbl = &stillimagew_vtbl;
00338         This->IUnknown_iface.lpVtbl = &internal_unk_vtbl;
00339         if (pUnkOuter)
00340             This->pUnkOuter = pUnkOuter;
00341         else
00342             This->pUnkOuter = &This->IUnknown_iface;
00343         This->ref = 1;
00344 
00345         hr = IStillImage_Initialize(&This->IStillImageW_iface, hinst, dwVer);
00346         if (SUCCEEDED(hr))
00347         {
00348             if (pUnkOuter)
00349                 *ppSti = (IStillImageW*) &This->IUnknown_iface;
00350             else
00351                 *ppSti = &This->IStillImageW_iface;
00352         }
00353     }
00354     else
00355         hr = E_OUTOFMEMORY;
00356 
00357     return hr;
00358 }

Generated on Sat May 26 2012 04:25:09 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.