From ca65a75bf4a350548a08c181ceab2f35fb014497 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Sat, 5 Jul 2014 00:35:43 +0000 Subject: [PATCH] [EXPLORER-NEW] * Fix a typo that broke tray notify icons. * Implement loading of Shell Service Objects. Works in win2003 but no idea if it works in ros since we don't have any SSO implemented yet ;P svn path=/branches/shell-experiments/; revision=63684 --- base/shell/explorer-new/CMakeLists.txt | 1 + base/shell/explorer-new/shellservice.c | 125 +++++++++++++++++++++++++ base/shell/explorer-new/trayntfy.c | 2 +- base/shell/explorer-new/traywnd.c | 25 ++++- 4 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 base/shell/explorer-new/shellservice.c diff --git a/base/shell/explorer-new/CMakeLists.txt b/base/shell/explorer-new/CMakeLists.txt index 021f78433ad..1cf3b9f051f 100644 --- a/base/shell/explorer-new/CMakeLists.txt +++ b/base/shell/explorer-new/CMakeLists.txt @@ -9,6 +9,7 @@ list(APPEND SOURCE explorer.c rshell.c settings.c + shellservice.c startmnu.c startup.c taskband.c diff --git a/base/shell/explorer-new/shellservice.c b/base/shell/explorer-new/shellservice.c new file mode 100644 index 00000000000..5f3f4405e92 --- /dev/null +++ b/base/shell/explorer-new/shellservice.c @@ -0,0 +1,125 @@ +/* +* ReactOS Explorer +* +* Copyright 2014 - David Quintana +* +* 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 Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "precomp.h" + +extern HRESULT InitShellServices(HDPA * phdpa); +extern HRESULT ShutdownShellServices(HDPA hdpa); + +static int CALLBACK InitializeAllCallback(void* pItem, void* pData) +{ + IOleCommandTarget * pOct = pItem; + HRESULT * phr = pData; + *phr = IOleCommandTarget_Exec(pOct, &CGID_ShellServiceObject, OLECMDID_NEW, OLECMDEXECOPT_DODEFAULT, NULL, NULL); + return SUCCEEDED(*phr); +} + +static int CALLBACK ShutdownAllCallback(void* pItem, void* pData) +{ + IOleCommandTarget * pOct = pItem; + IOleCommandTarget_Exec(pOct, &CGID_ShellServiceObject, OLECMDID_SAVE, OLECMDEXECOPT_DODEFAULT, NULL, NULL); + return TRUE; +} + +static int CALLBACK DeleteAllEnumCallback(void* pItem, void* pData) +{ + IOleCommandTarget * pOct = pItem; + IUnknown_Release(pOct); + return TRUE; +} + +HRESULT InitShellServices(HDPA * phdpa) +{ + IOleCommandTarget * pOct; + HKEY hkey; + CLSID clsid; + WCHAR name[MAX_PATH]; + WCHAR value[MAX_PATH]; + DWORD type; + LONG ret; + HDPA hdpa; + HRESULT hr = S_OK; + int count = 0; + + hdpa = DPA_Create(5); + + if (RegOpenKey(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ShellServiceObjectDelayLoad", + &hkey)) + { + return HRESULT_FROM_WIN32(GetLastError()); + } + + /* Enumerate */ + do + { + DWORD name_len = MAX_PATH; + DWORD value_len = sizeof(value); /* byte count! */ + + ret = RegEnumValueW(hkey, count, name, &name_len, 0, &type, (LPBYTE) &value, &value_len); + if (ret) + break; + + if (type != REG_SZ) + continue; + + hr = CLSIDFromString(value, &clsid); + if (FAILED(hr)) + goto cleanup; + + hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IOleCommandTarget, (VOID**) &pOct); + if (FAILED(hr)) + goto cleanup; + + DPA_AppendPtr(hdpa, pOct); + + count++; + } + while (1); + + if (ret != ERROR_NO_MORE_ITEMS) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + goto cleanup; + } + + RegCloseKey(hkey); + + /* Initialize */ + DPA_EnumCallback(hdpa, InitializeAllCallback, &hr); + if (FAILED(hr)) + goto cleanup; + + *phdpa = hdpa; + return count > 0 ? S_OK : S_FALSE; + +cleanup: + *phdpa = NULL; + ShutdownShellServices(hdpa); + return hr; +} + +HRESULT ShutdownShellServices(HDPA hdpa) +{ + DPA_EnumCallback(hdpa, ShutdownAllCallback, NULL); + DPA_EnumCallback(hdpa, DeleteAllEnumCallback, NULL); + DPA_Destroy(hdpa); + return S_OK; +} diff --git a/base/shell/explorer-new/trayntfy.c b/base/shell/explorer-new/trayntfy.c index 7d6fec7a739..a1f5fab12f5 100644 --- a/base/shell/explorer-new/trayntfy.c +++ b/base/shell/explorer-new/trayntfy.c @@ -437,7 +437,7 @@ SysPagerWnd_NotifyMsg(IN HWND hwnd, CopyMemory( &data, (PSYS_PAGER_COPY_DATA) cpData->lpData, - cpData->dwData); + cpData->cbData); iconData = &data.nicon_data; switch (data.notify_code) diff --git a/base/shell/explorer-new/traywnd.c b/base/shell/explorer-new/traywnd.c index 66c6ed4865d..7abf162892f 100644 --- a/base/shell/explorer-new/traywnd.c +++ b/base/shell/explorer-new/traywnd.c @@ -20,6 +20,9 @@ #include "precomp.h" +extern HRESULT InitShellServices(HDPA * phdpa); +extern HRESULT ShutdownShellServices(HDPA hdpa); + static const TRAYWINDOW_CTXMENU TrayWindowCtxMenu; #define WM_APP_TRAYDESTROY (WM_APP + 0x100) @@ -94,6 +97,8 @@ typedef struct HWND hwndTrayPropertiesOwner; HWND hwndRunFileDlgOwner; + + HDPA hdpaShellServices; } ITrayWindowImpl; BOOL LaunchCPanel(HWND hwnd, LPCTSTR applet) @@ -660,6 +665,8 @@ ITrayWindowImpl_ResizeWorkArea(IN OUT ITrayWindowImpl *This) { RECT rcTray,rcWorkArea; + return; + /* If monitor has changed then fix the previous monitors work area */ if (This->PreviousMonitor != This->Monitor) { @@ -768,10 +775,11 @@ ITrayWindowImpl_RegLoadSettings(IN OUT ITrayWindowImpl *This) /* FIXME: Are there more flags? */ - if (sr.Position > ABE_BOTTOM) - This->Position = ABE_BOTTOM; - else - This->Position = sr.Position; + //if (sr.Position > ABE_BOTTOM) + // This->Position = ABE_BOTTOM; + //else + // This->Position = sr.Position; + This->Position = ABE_LEFT; /* Try to find out which monitor the tray window was located on last. Here we're only interested in the monitor screen that we think @@ -986,6 +994,13 @@ ITrayWindowImpl_Destroy(ITrayWindowImpl *This) (void)InterlockedExchangePointer((PVOID*)&This->hWnd, NULL); + + if (This->hdpaShellServices != NULL) + { + ShutdownShellServices(This->hdpaShellServices); + This->hdpaShellServices = NULL; + } + if (This->himlStartBtn != NULL) { ImageList_Destroy(This->himlStartBtn); @@ -1586,6 +1601,8 @@ SetStartBtnImage: /* Align all controls on the tray window */ ITrayWindowImpl_AlignControls(This, NULL); + + InitShellServices(&(This->hdpaShellServices)); } static HRESULT STDMETHODCALLTYPE