ReactOS  0.4.14-dev-98-gb0d4763
internettoolbar.cpp File Reference
#include "precomp.h"
Include dependency graph for internettoolbar.cpp:

Go to the source code of this file.

Classes

class  CDockSite
 

Functions

virtual HRESULT STDMETHODCALLTYPE GetNameSpaceID (LPCITEMIDLIST, LPGUID)=0
 
virtual HRESULT STDMETHODCALLTYPE QueryNameSpace (ULONG, LPGUID, IShellFolder **)=0
 
virtual HRESULT STDMETHODCALLTYPE EnumNameSpace (ULONG, PULONG)=0
 
HRESULT WINAPI SHBindToFolder (LPCITEMIDLIST path, IShellFolder **newFolder)
 
HRESULT IUnknown_RelayWinEvent (IUnknown *punk, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
 
HRESULT IUnknown_ShowDW (IUnknown *punk, BOOL fShow)
 
HRESULT IUnknown_CloseDW (IUnknown *punk, DWORD dwReserved)
 
static HRESULT BindToDesktop (LPCITEMIDLIST pidl, IShellFolder **ppsfResult)
 
static HRESULT GetFavoritesFolder (IShellFolder **ppsfFavorites, LPITEMIDLIST *ppidl)
 

Variables

interface IShellFolder LPCITEMIDLIST
 
interface IShellFolder ULONG = 0
 

Function Documentation

◆ BindToDesktop()

static HRESULT BindToDesktop ( LPCITEMIDLIST  pidl,
IShellFolder **  ppsfResult 
)
static

Definition at line 372 of file internettoolbar.cpp.

373 {
374  HRESULT hr;
375  CComPtr<IShellFolder> psfDesktop;
376 
377  *ppsfResult = NULL;
378 
379  hr = SHGetDesktopFolder(&psfDesktop);
380  if (FAILED(hr))
381  return hr;
382 
383  hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, ppsfResult));
384 
385  return hr;
386 }
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LONG HRESULT
Definition: typedefs.h:77

Referenced by GetFavoritesFolder().

◆ EnumNameSpace()

virtual HRESULT STDMETHODCALLTYPE EnumNameSpace ( ULONG  ,
PULONG   
)
pure virtual

◆ GetFavoritesFolder()

static HRESULT GetFavoritesFolder ( IShellFolder **  ppsfFavorites,
LPITEMIDLIST ppidl 
)
static

Definition at line 388 of file internettoolbar.cpp.

389 {
390  HRESULT hr;
391  LPITEMIDLIST pidlUserFavorites;
392  LPITEMIDLIST pidlCommonFavorites;
393  CComPtr<IShellFolder> psfUserFavorites;
394  CComPtr<IShellFolder> psfCommonFavorites;
396 
397  if (ppsfFavorites)
398  *ppsfFavorites = NULL;
399 
400  if (ppidl)
401  *ppidl = NULL;
402 
403  hr = SHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidlUserFavorites);
404  if (FAILED(hr))
405  {
406  WARN("Failed to get the USER favorites folder. Trying to run with just the COMMON one.\n");
407 
408  hr = SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_FAVORITES, &pidlCommonFavorites);
409  if (FAILED_UNEXPECTEDLY(hr))
410  return hr;
411 
412  TRACE("COMMON favorites obtained.\n");
413  *ppidl = pidlCommonFavorites;
414  hr = BindToDesktop(pidlCommonFavorites, ppsfFavorites);
415  return hr;
416  }
417 
418  hr = SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_FAVORITES, &pidlCommonFavorites);
419  if (FAILED_UNEXPECTEDLY(hr))
420  {
421  WARN("Failed to get the COMMON favorites folder. Will use only the USER contents.\n");
422  *ppidl = pidlCommonFavorites;
423  hr = BindToDesktop(pidlUserFavorites, ppsfFavorites);
424  return hr;
425  }
426 
427  TRACE("Both COMMON and USER favorites folders obtained, merging them...\n");
428 
429  hr = BindToDesktop(pidlUserFavorites, &psfUserFavorites);
430  if (FAILED_UNEXPECTEDLY(hr))
431  return hr;
432 
433  hr = BindToDesktop(pidlCommonFavorites, &psfCommonFavorites);
434  if (FAILED_UNEXPECTEDLY(hr))
435  return hr;
436 
437  hr = CMergedFolder_CreateInstance(IID_PPV_ARG(IAugmentedShellFolder, &pasf));
438  if (FAILED_UNEXPECTEDLY(hr))
439  {
440  *ppsfFavorites = psfUserFavorites.Detach();
441  *ppidl = pidlUserFavorites;
442  ILFree(pidlCommonFavorites);
443  return hr;
444  }
445 
446  hr = pasf->AddNameSpace(NULL, psfUserFavorites, pidlUserFavorites, 0xFF00);
447  if (FAILED_UNEXPECTEDLY(hr))
448  return hr;
449 
450  hr = pasf->AddNameSpace(NULL, psfCommonFavorites, pidlCommonFavorites, 0);
451  if (FAILED_UNEXPECTEDLY(hr))
452  return hr;
453 
454  hr = pasf->QueryInterface(IID_PPV_ARG(IShellFolder, ppsfFavorites));
455  pasf.Release();
456 
457  // TODO: obtain the folder's PIDL
458 
459  ILFree(pidlCommonFavorites);
460  ILFree(pidlUserFavorites);
461 
462  return hr;
463 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_COMMON_FAVORITES
Definition: shlobj.h:2033
#define WARN(fmt,...)
Definition: debug.h:111
#define IID_PPV_ARG(Itype, ppType)
#define CSIDL_FAVORITES
Definition: shlobj.h:2009
static HRESULT BindToDesktop(LPCITEMIDLIST pidl, IShellFolder **ppsfResult)
smooth NULL
Definition: ftsmooth.c:416
#define CMergedFolder_CreateInstance
Definition: shellmenu.h:93
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2687
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
void Release()
Definition: atlcomcli.h:140
T * Detach()
Definition: atlcomcli.h:156
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by CMenuCallback::GetObject().

◆ GetNameSpaceID()

virtual HRESULT STDMETHODCALLTYPE GetNameSpaceID ( LPCITEMIDLIST  ,
LPGUID   
)
pure virtual

◆ IUnknown_CloseDW()

HRESULT IUnknown_CloseDW ( IUnknown punk,
DWORD  dwReserved 
)

Definition at line 104 of file internettoolbar.cpp.

105 {
106  CComPtr<IDockingWindow> dockingWindow;
107  HRESULT hResult = punk->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
108  if (FAILED_UNEXPECTEDLY(hResult))
109  return hResult;
110  hResult = dockingWindow->CloseDW(dwReserved);
111  if (FAILED_UNEXPECTEDLY(hResult))
112  return hResult;
113  return S_OK;
114 }
#define IID_PPV_ARG(Itype, ppType)
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define S_OK
Definition: intsafe.h:59
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)

Referenced by CInternetToolbar::CloseDW().

◆ IUnknown_RelayWinEvent()

HRESULT IUnknown_RelayWinEvent ( IUnknown punk,
HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT theResult 
)

Definition at line 78 of file internettoolbar.cpp.

79 {
80  CComPtr<IWinEventHandler> menuWinEventHandler;
81  HRESULT hResult = punk->QueryInterface(IID_PPV_ARG(IWinEventHandler, &menuWinEventHandler));
82  if (FAILED_UNEXPECTEDLY(hResult))
83  return hResult;
84  hResult = menuWinEventHandler->IsWindowOwner(hWnd);
85  if (FAILED_UNEXPECTEDLY(hResult))
86  return hResult;
87  if (hResult == S_OK)
88  return menuWinEventHandler->OnWinEvent(hWnd, uMsg, wParam, lParam, theResult);
89  return S_FALSE;
90 }
HWND hWnd
Definition: settings.c:17
#define IID_PPV_ARG(Itype, ppType)
WPARAM wParam
Definition: combotst.c:138
#define S_FALSE
Definition: winerror.h:2357
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define S_OK
Definition: intsafe.h:59
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
LPARAM lParam
Definition: combotst.c:139

Referenced by CInternetToolbar::OnWinEvent().

◆ IUnknown_ShowDW()

HRESULT IUnknown_ShowDW ( IUnknown punk,
BOOL  fShow 
)

Definition at line 92 of file internettoolbar.cpp.

93 {
94  CComPtr<IDockingWindow> dockingWindow;
95  HRESULT hResult = punk->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
96  if (FAILED_UNEXPECTEDLY(hResult))
97  return hResult;
98  hResult = dockingWindow->ShowDW(fShow);
99  if (FAILED_UNEXPECTEDLY(hResult))
100  return hResult;
101  return S_OK;
102 }
#define IID_PPV_ARG(Itype, ppType)
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define S_OK
Definition: intsafe.h:59
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)

Referenced by CShellBrowser::Exec(), CShellBrowser::Initialize(), and CInternetToolbar::ShowDW().

◆ QueryNameSpace()

virtual HRESULT STDMETHODCALLTYPE QueryNameSpace ( ULONG  ,
LPGUID  ,
IShellFolder **   
)
pure virtual

◆ SHBindToFolder()

HRESULT WINAPI SHBindToFolder ( LPCITEMIDLIST  path,
IShellFolder **  newFolder 
)

Definition at line 154 of file shellbrowser.cpp.

155 {
156  CComPtr<IShellFolder> desktop;
157 
158  HRESULT hr = ::SHGetDesktopFolder(&desktop);
159  if (FAILED_UNEXPECTEDLY(hr))
160  return E_FAIL;
161  if (path == NULL || path->mkid.cb == 0)
162  {
163  *newFolder = desktop;
164  desktop.p->AddRef ();
165  return S_OK;
166  }
167  return desktop->BindToObject (path, NULL, IID_PPV_ARG(IShellFolder, newFolder));
168 }
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
ULONG AddRef()
#define S_OK
Definition: intsafe.h:59
Definition: services.c:325

Referenced by CShellBrowser::BrowseToPIDL().

Variable Documentation

◆ LPCITEMIDLIST

◆ ULONG

Definition at line 32 of file internettoolbar.cpp.