- Partly implement IBandSite, IMenuBand
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Tue, 22 Sep 2009 18:30:39 +0000 (18:30 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Tue, 22 Sep 2009 18:30:39 +0000 (18:30 +0000)
svn path=/trunk/; revision=43112

reactos/dll/win32/shell32/precomp.h
reactos/dll/win32/shell32/regsvr.c
reactos/dll/win32/shell32/shell32_main.h
reactos/dll/win32/shell32/shellole.c
reactos/dll/win32/shell32/startmenu.c

index affe470..66ed12a 100644 (file)
@@ -68,6 +68,7 @@
 extern const GUID CLSID_AdminFolderShortcut;
 extern const GUID CLSID_FontsFolderShortcut;
 extern const GUID CLSID_StartMenu;
+extern const GUID CLSID_MenuBandSite;
 extern const GUID CLSID_OpenWith;
 extern const GUID CLSID_UnixFolder;
 extern const GUID CLSID_UnixDosFolder;
index 6e254c1..e7490c8 100644 (file)
@@ -19,8 +19,9 @@
  */
 #include <precomp.h>
 
-const GUID CLSID_AdminFolderShortcut     = {0xD20EA4E1, 0x3957, 0x11D2, {0xA4, 0x0B, 0x0C, 0x50, 0x20, 0x52, 0x41, 0x53} };
+const GUID CLSID_AdminFolderShortcut     = {0xD20EA4E1, 0x3957, 0x11D2, {0xA4, 0x0B, 0x0C, 0x50, 0x20, 0x52, 0x41, 0x53}};
 const GUID CLSID_StartMenu               = {0x4622AD11, 0xFF23, 0x11D0, {0x8D, 0x34, 0x00, 0xA0, 0xC9, 0x0F, 0x27, 0x19}};
+const GUID CLSID_MenuBandSite            = {0xE13EF4E4, 0xD2F2, 0x11d0, {0x98, 0x16, 0x00, 0xC0, 0x4F, 0xD9, 0x19, 0x72}};
 const GUID CLSID_OpenWith                = {0x09799AFB, 0xAD67, 0x11d1, {0xAB, 0xCD, 0x00, 0xC0, 0x4F, 0xC3, 0x09, 0x36}};
 const GUID CLSID_UnixFolder              = {0xcc702eb2, 0x7dc5, 0x11d9, {0xc6, 0x87, 0x00, 0x04, 0x23, 0x8a, 0x01, 0xcd}};
 const GUID CLSID_UnixDosFolder           = {0x9d20aae8, 0x0625, 0x44b0, {0x9c, 0xa7, 0x71, 0x88, 0x9c, 0x22, 0x54, 0xd9}};
@@ -720,6 +721,13 @@ static struct regsvr_coclass const coclass_list[] = {
        "shell32.dll",
        "Apartment"
     },
+    {   &CLSID_MenuBandSite,
+       "Menu Site",
+       0,
+       NULL,
+       "shell32.dll",
+       "Apartment"
+    },
     { NULL }                   /* list terminator */
 };
 
index 4bda761..1ec3d95 100644 (file)
@@ -113,6 +113,7 @@ HRESULT WINAPI RecycleBin_Constructor(IUnknown * pUnkOuter, REFIID riif, LPVOID
 HRESULT WINAPI SHEOW_Constructor(IUnknown * pUnkOuter, REFIID riif, LPVOID *ppv);
 HRESULT WINAPI ShellFSFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID *ppv);
 HRESULT WINAPI StartMenu_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID *ppv);
+HRESULT WINAPI MenuBandSite_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID *ppv);
 extern HRESULT CPanel_GetIconLocationW(LPCITEMIDLIST, LPWSTR, UINT, int*);
 HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
 HRESULT WINAPI CPanel_ExtractIconW(LPITEMIDLIST pidl, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
index 892d15b..5a5033f 100644 (file)
@@ -61,6 +61,7 @@ static const struct {
        {&CLSID_OpenWith,       &SHEOW_Constructor},
        {&dummy1,               &INewItem_Constructor},
        {&CLSID_StartMenu,      &StartMenu_Constructor},
+       {&CLSID_MenuBandSite,   &MenuBandSite_Constructor},
        {NULL,NULL}
 };
 
index c75bd5e..5b861d8 100644 (file)
@@ -26,15 +26,26 @@ typedef struct _tagStartMenu {
     const IMenuPopupVtbl *vtbl;
     const IObjectWithSiteVtbl *objectSiteVtbl;
     const IInitializeObjectVtbl *initObjectVtbl;
-    const IBandSiteVtbl *bandSiteVtbl;
+    const IMenuBandVtbl *menuBandVtbl;
     IUnknown *pUnkSite;
     LONG refCount;
+    IBandSite * pBandSite;
 } StartMenu, *LPStartMenu;
 
+typedef struct _tagMenuBandSite {
+    const IBandSiteVtbl * lpVtbl;
+    LONG refCount;
+
+    IUnknown ** Objects;
+    LONG ObjectsCount;
+
+} MenuBandSite, *LPMenuBandSite;
+
 static const IMenuPopupVtbl StartMenuVtbl;
 static const IObjectWithSiteVtbl StartMenu_ObjectWithSiteVtbl;
 static const IInitializeObjectVtbl StartMenu_InitializeObjectVtbl;
 static const IBandSiteVtbl StartMenu_BandSiteVtbl;
+static const IMenuBandVtbl StartMenu_MenuBandVtbl;
 
 static LPStartMenu __inline impl_from_IMenuPopup(IMenuPopup *iface)
 {
@@ -67,7 +78,7 @@ HRESULT WINAPI StartMenu_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *p
     This->vtbl = &StartMenuVtbl;
     This->objectSiteVtbl = &StartMenu_ObjectWithSiteVtbl;
     This->initObjectVtbl = &StartMenu_InitializeObjectVtbl;
-    This->bandSiteVtbl = &StartMenu_BandSiteVtbl;
+    This->menuBandVtbl = &StartMenu_MenuBandVtbl;
     This->refCount = 1;
 
     TRACE("StartMenu_Constructor returning %p\n", This);
@@ -87,7 +98,7 @@ static HRESULT WINAPI StartMenu_QueryInterface(IMenuPopup *iface, REFIID iid, LP
     StartMenu *This = impl_from_IMenuPopup(iface);
     *ppvOut = NULL;
 
-    TRACE("StartMenu_Constructor (%p, %s, %p)\n", iface, debugstr_guid(iid), ppvOut);
+    TRACE("StartMenu_QueryInterface (%p, %s, %p)\n", iface, debugstr_guid(iid), ppvOut);
 
     if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_IOleWindow)
      || IsEqualIID(iid, &IID_IDeskBar) || IsEqualIID(iid, &IID_IMenuPopup))
@@ -102,11 +113,6 @@ static HRESULT WINAPI StartMenu_QueryInterface(IMenuPopup *iface, REFIID iid, LP
     {
         *ppvOut = &This->initObjectVtbl;
     }
-    else if (IsEqualIID(iid, &IID_IBandSite))
-    {
-        *ppvOut = &This->bandSiteVtbl;
-    }
-
 
     if (*ppvOut)
     {
@@ -159,8 +165,10 @@ static HRESULT WINAPI StartMenu_SetClient(IMenuPopup *iface, IUnknown *punkClien
 static HRESULT WINAPI StartMenu_GetClient(IMenuPopup *iface, IUnknown **ppunkClient)
 {
     StartMenu * This = (StartMenu*)iface;
+
     TRACE("StartMenu_GetClient (%p, %p)\n", iface, ppunkClient);
-    *ppunkClient = (IUnknown*)&This->bandSiteVtbl;
+
+    *ppunkClient = (IUnknown*)This->pBandSite;
     IUnknown_AddRef(*ppunkClient);
     return S_OK;
 }
@@ -291,8 +299,15 @@ static ULONG WINAPI StartMenu_IInitializeObject_Release(IInitializeObject *iface
 
 static HRESULT WINAPI StartMenu_IInitializeObject_Initialize(IInitializeObject *iface)
 {
-    FIXME("StartMenu_IInitializeObject_Initialize Stub\n");
-    return S_OK;
+    HRESULT hr;
+    StartMenu *This = impl_from_IInitializeObject(iface);
+    TRACE("StartMenu_IInitializeObject_Initialize (%p)\n", iface);
+
+    hr = MenuBandSite_Constructor(NULL, &IID_IBandSite, (LPVOID*)&This->pBandSite);
+    if (FAILED(hr))
+        return hr;
+
+    return IBandSite_AddBand(This->pBandSite, (IUnknown*)&This->menuBandVtbl);
 }
 
 static const IInitializeObjectVtbl StartMenu_InitializeObjectVtbl =
@@ -304,71 +319,248 @@ static const IInitializeObjectVtbl StartMenu_InitializeObjectVtbl =
     StartMenu_IInitializeObject_Initialize,
 };
 
-//---------------------------------------------------------------------------------------------------------
-// IBandSite interface
+//--------------------------------------------------------------
+// IMenuBand interface
 
-static HRESULT WINAPI StartMenu_IBandSite_QueryInterface(IBandSite *iface, REFIID iid, LPVOID *ppvOut)
+
+static HRESULT STDMETHODCALLTYPE StartMenu_IMenuBand_QueryInterface(IMenuBand *iface, REFIID iid, LPVOID *ppvOut)
 {
-    StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, bandSiteVtbl);
-    TRACE("StartMenu_IBandSite_QueryInterface(%p, %s, %p)\n", iface, debugstr_guid(iid), ppvOut);
-    return StartMenu_QueryInterface((IMenuPopup *)This, iid, ppvOut);
+    StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, menuBandVtbl);
+
+    if (IsEqualIID(iid, &IID_IUnknown) ||
+        IsEqualIID(iid, &IID_IMenuBand))
+    {
+        *ppvOut = &This->menuBandVtbl;
+        IUnknown_AddRef((IUnknown*)*ppvOut);
+        return S_OK;
+    }
+
+    WARN("unsupported interface:(%p, %s, %p)\n", iface, debugstr_guid(iid), ppvOut);
+    return E_NOINTERFACE;
 }
 
-static ULONG WINAPI StartMenu_IBandSite_AddRef(IBandSite *iface)
+static ULONG STDMETHODCALLTYPE StartMenu_IMenuBand_AddRef(IMenuBand *iface)
 {
-    StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, bandSiteVtbl);
-    TRACE("StartMenu_IBandSite_AddRef(%p)\n", iface);
+    StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, menuBandVtbl);
+    TRACE("StartMenu_IInitializeObject_AddRef(%p)\n", This);
     return StartMenu_AddRef((IMenuPopup *)This);
 }
 
-static ULONG WINAPI StartMenu_IBandSite_Release(IBandSite *iface)
+static ULONG STDMETHODCALLTYPE StartMenu_IMenuBand_Release(IMenuBand *iface)
 {
-    StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, bandSiteVtbl);
-    TRACE("StartMenu_IBandSite_Release (%p)\n", iface);
+    StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, menuBandVtbl);
+    TRACE("StartMenu_IInitializeObject_Release (%p)\n", This);
     return StartMenu_Release((IMenuPopup *)This);
 }
 
+HRESULT STDMETHODCALLTYPE StartMenu_IMenuBand_IsMenuMessage(IMenuBand *iface, MSG *pmsg)
+{
+    StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, menuBandVtbl);
+    TRACE("StartMenu_IMenuBand_IsMenuMessage Stub(%p)\n", This);
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE StartMenu_IMenuBand_TranslateMenuMessage(IMenuBand *iface, MSG *pmsg, LRESULT *plRet)
+{
+    StartMenu *This = (StartMenu*)CONTAINING_RECORD(iface, StartMenu, menuBandVtbl);
+    TRACE("StartMenu_IMenuBand_TranslateMenuMessage Stub(%p)\n", This);
+    return E_NOTIMPL;
+}
+
+
+static const IMenuBandVtbl StartMenu_MenuBandVtbl =
+{
+    /* IUnknown methods */
+    StartMenu_IMenuBand_QueryInterface,
+    StartMenu_IMenuBand_AddRef,
+    StartMenu_IMenuBand_Release,
+    /* IMenuBand methods */
+    StartMenu_IMenuBand_IsMenuMessage,
+    StartMenu_IMenuBand_TranslateMenuMessage,
+};
+
+
+//---------------------------------------------------------------------------------------------------------
+// IBandSite interface
+
+
+HRESULT WINAPI MenuBandSite_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
+{
+    MenuBandSite *This;
+    HRESULT hr;
+
+    TRACE("StartMenu_Constructor(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppv);
+
+    if (pUnkOuter)
+        return E_POINTER;
+
+    This = CoTaskMemAlloc(sizeof(MenuBandSite));
+    if (!This)
+        return E_OUTOFMEMORY;
+
+    ZeroMemory(This, sizeof(MenuBandSite));
+    This->lpVtbl = &StartMenu_BandSiteVtbl;
+
+    hr = IUnknown_QueryInterface((IUnknown*)&This->lpVtbl, riid, ppv);
+
+    if (FAILED(hr))
+    {
+        CoTaskMemFree(This);
+        return hr;
+    }
+
+    TRACE("StartMenu_Constructor returning %p\n", This);
+    *ppv = (IUnknown *)This;
+    return S_OK;
+}
+
+static HRESULT WINAPI BandSite_QueryInterface(IBandSite *iface, REFIID iid, LPVOID *ppvOut)
+{
+    MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl);
+
+    if (IsEqualIID(iid, &IID_IUnknown) ||
+        IsEqualIID(iid, &IID_IBandSite))
+    {
+        *ppvOut = &This->lpVtbl;
+        IUnknown_AddRef((IUnknown*)*ppvOut);
+        return S_OK;
+    }
+
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI BandSite_AddRef(IBandSite *iface)
+{
+    MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl);
+    TRACE("BandSite_AddRef(%p)\n", iface);
+    return InterlockedIncrement(&This->refCount);
+}
+
+static ULONG WINAPI BandSite_Release(IBandSite *iface)
+{
+    LONG ret;
+    MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl);
+
+    ret = InterlockedDecrement(&This->refCount);
+    TRACE("BandSite_Release refCount %u\n", ret);
+
+    if (ret == 0)
+    {
+        CoTaskMemFree(This->Objects);
+        CoTaskMemFree(This);
+    }
+
+    return ret;
+}
+
 
-static HRESULT STDMETHODCALLTYPE StartMenu_IBandSite_AddBand(IBandSite *iface, IUnknown *punk)
+static HRESULT STDMETHODCALLTYPE BandSite_AddBand(IBandSite *iface, IUnknown *punk)
 {
-    FIXME("StartMenu_IBandSite_AddBand Stub punk %p\n", punk);
+    IUnknown ** Objects;
+    MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl);
+
+    TRACE("StartMenu_IBandSite_AddBand Stub punk %p\n", punk);
+
+    if (!punk)
+        return E_FAIL;
+
+    Objects = (IUnknown**) CoTaskMemAlloc(sizeof(IUnknown*) * (This->ObjectsCount + 1));
+    if (!Objects)
+        return E_FAIL;
+
+    RtlMoveMemory(Objects, This->Objects, sizeof(IUnknown*) * This->ObjectsCount);
+
+    CoTaskMemFree(This->Objects);
+
+    This->Objects = Objects;
+    Objects[This->ObjectsCount] = punk;
+
+    IUnknown_AddRef(punk);
+
+    This->ObjectsCount++;
+
+
     return S_OK;
 }
 
-static HRESULT STDMETHODCALLTYPE StartMenu_IBandSite_EnumBands(IBandSite *iface, UINT uBand, DWORD *pdwBandID)
+static HRESULT STDMETHODCALLTYPE BandSite_EnumBands(IBandSite *iface, UINT uBand, DWORD *pdwBandID)
 {
-    FIXME("StartMenu_IBandSite_EnumBands Stub uBand %uu pdwBandID %p\n", uBand, pdwBandID);
+    ULONG Index, ObjectCount;
+    MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl);
+
+    TRACE("StartMenu_IBandSite_EnumBands Stub uBand %uu pdwBandID %p\n", uBand, pdwBandID);
+
+    if (uBand == (UINT)-1)
+        return This->ObjectsCount;
+
+    ObjectCount = 0;
+
+    for(Index = 0; Index < This->ObjectsCount; Index++)
+    {
+        if (This->Objects[Index] != NULL)
+        {
+            if (uBand == ObjectCount)
+            {
+                *pdwBandID = Index;
+                return S_OK;
+            }
+            ObjectCount++;
+        }
+    }
     return E_FAIL;
 }
-static HRESULT STDMETHODCALLTYPE StartMenu_IBandSite_QueryBand(IBandSite *iface, DWORD dwBandID, IDeskBand **ppstb, DWORD *pdwState, LPWSTR pszName, int cchName)
+
+static HRESULT STDMETHODCALLTYPE BandSite_QueryBand(IBandSite *iface, DWORD dwBandID, IDeskBand **ppstb, DWORD *pdwState, LPWSTR pszName, int cchName)
 {
     FIXME("StartMenu_IBandSite_QueryBand Stub dwBandID %u IDeskBand %p pdwState %p Name %p cchName %u\n", dwBandID, ppstb, pdwState, pszName, cchName);
     return E_FAIL;
 }
 
-static HRESULT STDMETHODCALLTYPE StartMenu_IBandSite_SetBandState(IBandSite *iface, DWORD dwBandID, DWORD dwMask, DWORD dwState)
+static HRESULT STDMETHODCALLTYPE BandSite_SetBandState(IBandSite *iface, DWORD dwBandID, DWORD dwMask, DWORD dwState)
 {
     FIXME("StartMenu_IBandSite_SetBandState Stub dwBandID %u dwMask %x dwState %u\n", dwBandID, dwMask, dwState);
     return E_FAIL;
 }
-static HRESULT STDMETHODCALLTYPE StartMenu_IBandSite_RemoveBand(IBandSite *iface, DWORD dwBandID)
+static HRESULT STDMETHODCALLTYPE BandSite_RemoveBand(IBandSite *iface, DWORD dwBandID)
 {
-    FIXME("StartMenu_IBandSite_RemoveBand Stub dwBandID %p\n", dwBandID);
-    return E_FAIL;
+    MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl);
+    TRACE("StartMenu_IBandSite_RemoveBand Stub dwBandID %u\n", dwBandID);
+
+    if (This->ObjectsCount <= dwBandID)
+        return E_FAIL;
+
+    if (This->Objects[dwBandID])
+    {
+        This->Objects[dwBandID]->lpVtbl->Release(This->Objects[dwBandID]);
+        This->Objects[dwBandID] = NULL;
+    }
+
+    return S_OK;
 }
 
-static HRESULT STDMETHODCALLTYPE StartMenu_IBandSite_GetBandObject(IBandSite *iface, DWORD dwBandID, REFIID riid, void **ppv)
+static HRESULT STDMETHODCALLTYPE BandSite_GetBandObject(IBandSite *iface, DWORD dwBandID, REFIID riid, void **ppv)
 {
-    FIXME("StartMenu_IBandSite_GetBandObject Stub dwBandID %u riid %p ppv %p\n", dwBandID, riid, ppv);
+    MenuBandSite *This = (MenuBandSite*)CONTAINING_RECORD(iface, MenuBandSite, lpVtbl);
+
+    TRACE("StartMenu_IBandSite_GetBandObject Stub dwBandID %u riid %p ppv %p\n", dwBandID, riid, ppv);
+
+    if (This->ObjectsCount <= dwBandID)
+        return E_FAIL;
+
+    if (This->Objects[dwBandID])
+    {
+        return IUnknown_QueryInterface(This->Objects[dwBandID], riid, ppv);
+    }
+
     return E_FAIL;
 }
-static HRESULT STDMETHODCALLTYPE StartMenu_IBandSite_SetBandSiteInfo(IBandSite *iface, const BANDSITEINFO *pbsinfo)
+static HRESULT STDMETHODCALLTYPE BandSite_SetBandSiteInfo(IBandSite *iface, const BANDSITEINFO *pbsinfo)
 {
     FIXME("StartMenu_IBandSite_SetBandSiteInfo Stub pbsinfo %p\n", pbsinfo);
     return E_FAIL;
 
 }
-static HRESULT STDMETHODCALLTYPE StartMenu_IBandSite_GetBandSiteInfo(IBandSite *iface, BANDSITEINFO *pbsinfo)
+static HRESULT STDMETHODCALLTYPE BandSite_GetBandSiteInfo(IBandSite *iface, BANDSITEINFO *pbsinfo)
 {
     FIXME("StartMenu_IBandSite_GetBandSiteInfo Stub pbsinfo %p\n", pbsinfo);
     return E_FAIL;
@@ -376,16 +568,16 @@ static HRESULT STDMETHODCALLTYPE StartMenu_IBandSite_GetBandSiteInfo(IBandSite *
 
 static const IBandSiteVtbl StartMenu_BandSiteVtbl =
 {
-    StartMenu_IBandSite_QueryInterface,
-    StartMenu_IBandSite_AddRef,
-    StartMenu_IBandSite_Release,
-    StartMenu_IBandSite_AddBand,
-    StartMenu_IBandSite_EnumBands,
-    StartMenu_IBandSite_QueryBand,
-    StartMenu_IBandSite_SetBandState,
-    StartMenu_IBandSite_RemoveBand,
-    StartMenu_IBandSite_GetBandObject,
-    StartMenu_IBandSite_SetBandSiteInfo,
-    StartMenu_IBandSite_GetBandSiteInfo
+    BandSite_QueryInterface,
+    BandSite_AddRef,
+    BandSite_Release,
+    BandSite_AddBand,
+    BandSite_EnumBands,
+    BandSite_QueryBand,
+    BandSite_SetBandState,
+    BandSite_RemoveBand,
+    BandSite_GetBandObject,
+    BandSite_SetBandSiteInfo,
+    BandSite_GetBandSiteInfo
 };