Author: dquintana
Date: Mon Jul 28 13:18:57 2014
New Revision: 63750
URL:
http://svn.reactos.org/svn/reactos?rev=63750&view=rev
Log:
[HIVESFT.INF]
* Shell service object DLLs expect the ShellServiceObjectDelayLoad key to exist.
[SYSSETUP.INF]
* Mark stobject.dll to be registered during setup.
[STOBJECT]
* Implement icon handling.
* Implement rudimentary volume icon handler.
* Allow the volume icon to show the mute status of the primary audio device.
Modified:
branches/shell-experiments/boot/bootdata/hivesft.inf
branches/shell-experiments/dll/win32/stobject/CMakeLists.txt
branches/shell-experiments/dll/win32/stobject/precomp.h
branches/shell-experiments/dll/win32/stobject/resource.h
branches/shell-experiments/dll/win32/stobject/stobject.cpp
branches/shell-experiments/dll/win32/stobject/stobject.rc
branches/shell-experiments/media/inf/syssetup.inf
Modified: branches/shell-experiments/boot/bootdata/hivesft.inf
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/boot/bootdata…
==============================================================================
--- branches/shell-experiments/boot/bootdata/hivesft.inf [iso-8859-1] (original)
+++ branches/shell-experiments/boot/bootdata/hivesft.inf [iso-8859-1] Mon Jul 28 13:18:57
2014
@@ -108,6 +108,7 @@
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Setup","DriverCachePath",0x00020002,"%SystemRoot%\Driver
Cache"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls",,0x00000012
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions",,0x00000012
+HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad",,0x00000012
; FIXME - usetup doesn't handle extra paths
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","",0x00000000,"cmd
/c md ""%programfiles%\Internet Explorer\"" && move
%windir%\iexplore.exe ""%programfiles%\Internet Explorer\"" &&
""%programfiles%\Internet Explorer\iexplore.exe"" /RegServer"
Modified: branches/shell-experiments/dll/win32/stobject/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/sto…
==============================================================================
--- branches/shell-experiments/dll/win32/stobject/CMakeLists.txt [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/stobject/CMakeLists.txt [iso-8859-1] Mon Jul 28
13:18:57 2014
@@ -17,6 +17,7 @@
add_library(stobject SHARED
stobject.cpp
stobject.rc
+ volume.cpp
${CMAKE_CURRENT_BINARY_DIR}/stobject.def)
set_module_type(stobject win32dll UNICODE)
@@ -24,12 +25,14 @@
add_importlibs(stobject
advapi32
- ole32
+ winmm
+ ole32
+ shlwapi
+ shell32
+ comctl32
+ msvcrt
gdi32
user32
- comctl32
- shlwapi
- msvcrt
kernel32
ntdll)
Modified: branches/shell-experiments/dll/win32/stobject/precomp.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/sto…
==============================================================================
--- branches/shell-experiments/dll/win32/stobject/precomp.h [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/stobject/precomp.h [iso-8859-1] Mon Jul 28
13:18:57 2014
@@ -25,13 +25,85 @@
#include <strsafe.h>
#include <atlbase.h>
#include <atlcom.h>
+#include <atlwin.h>
+
+#include <shellapi.h>
#include <wine/debug.h>
#include <wine/unicode.h>
+#include "resource.h"
+
extern const GUID CLSID_SysTray;
-#include "resource.h"
+extern HINSTANCE g_hInstance;
+
+#define ID_ICON_VOLUME 0x4CB
+
+/* --------------- CSysTray callbacks ------------------------------ */
+
+typedef CWinTraits <
+ WS_POPUP | WS_DLGFRAME | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
+ WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_PALETTEWINDOW
+> CMessageWndClass;
+
+class CSysTray :
+ public CComCoClass<CSysTray, &CLSID_SysTray>,
+ public CComObjectRootEx<CComMultiThreadModelNoCS>,
+ public CWindowImpl<CSysTray, CWindow, CMessageWndClass>,
+ public IOleCommandTarget
+{
+ // TODO: keep icon handlers here
+
+ HWND hwndSysTray;
+
+ static DWORD WINAPI s_SysTrayThreadProc(PVOID param);
+ HRESULT SysTrayMessageLoop();
+ HRESULT SysTrayThreadProc();
+ HRESULT CreateSysTrayThread();
+ HRESULT DestroySysTrayWindow();
+
+ HRESULT InitIcons();
+ HRESULT ShutdownIcons();
+ HRESULT UpdateIcons();
+ HRESULT ProcessIconMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+public:
+ HRESULT NotifyIcon(INT code, UINT uId, HICON hIcon, LPCWSTR szTip);
+
+ HWND GetHWnd() { return m_hWnd; }
+
+protected:
+ BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT
&lResult, DWORD dwMsgMapID = 0);
+
+public:
+ CSysTray();
+ virtual ~CSysTray();
+
+ // *** IOleCommandTarget methods ***
+ virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds,
OLECMD prgCmds [], OLECMDTEXT *pCmdText);
+ virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
+
+ DECLARE_WND_CLASS_EX(_T("SystemTray_Main"), CS_GLOBALCLASS, COLOR_3DFACE)
+
+ DECLARE_REGISTRY_RESOURCEID(IDR_SYSTRAY)
+ DECLARE_NOT_AGGREGATABLE(CSysTray)
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ BEGIN_COM_MAP(CSysTray)
+ COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
+ END_COM_MAP()
+
+};
+
+/* --------------- Icon callbacks ------------------------------ */
+
+extern HRESULT STDMETHODCALLTYPE Volume_Init(_In_ CSysTray * pSysTray);
+extern HRESULT STDMETHODCALLTYPE Volume_Shutdown(_In_ CSysTray * pSysTray);
+extern HRESULT STDMETHODCALLTYPE Volume_Update(_In_ CSysTray * pSysTray);
+extern HRESULT STDMETHODCALLTYPE Volume_Message(_In_ CSysTray * pSysTray, UINT uMsg,
WPARAM wParam, LPARAM lParam);
+
+/* --------------- Utils ------------------------------ */
static __inline ULONG
Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
Modified: branches/shell-experiments/dll/win32/stobject/resource.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/sto…
==============================================================================
--- branches/shell-experiments/dll/win32/stobject/resource.h [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/stobject/resource.h [iso-8859-1] Mon Jul 28
13:18:57 2014
@@ -1,8 +1,8 @@
#pragma once
-#define IDI_ICON1 200
-#define IDI_ICON2 210
-#define IDI_ICON3 230
-#define IDI_ICON4 231
+#define IDI_BATTERY 200
+#define IDI_EXTRACT 210
+#define IDI_VOLUME 230
+#define IDI_VOLMUTE 231
-#define IDR_SYSTRAY 11001
+#define IDR_SYSTRAY 11001
Modified: branches/shell-experiments/dll/win32/stobject/stobject.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/sto…
==============================================================================
--- branches/shell-experiments/dll/win32/stobject/stobject.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/stobject/stobject.cpp [iso-8859-1] Mon Jul 28
13:18:57 2014
@@ -1,76 +1,238 @@
/*
* PROJECT: ReactOS system libraries
* LICENSE: GPL - See COPYING in the top level directory
- * FILE: dll\win32\stobject\stobject.c
+ * FILE: dll\win32\stobject\stobject.cpp
* PURPOSE: Systray shell service object
- * PROGRAMMERS: Copyright 2014 Robert Naumann
+ * PROGRAMMERS: Robert Naumann
+ David Quintana <gigaherz(a)gmail.com>
*/
#include "precomp.h"
#include <olectl.h>
+#include <atlwin.h>
WINE_DEFAULT_DEBUG_CHANNEL(stobject);
const GUID CLSID_SysTray = { 0x35CEC8A3, 0x2BE6, 0x11D2, { 0x87, 0x73, 0x92, 0xE2, 0x20,
0x52, 0x41, 0x53 } };
-class CShellTrayModule : public CComModule
-{
-public:
+HINSTANCE g_hInstance;
+
+typedef HRESULT(STDMETHODCALLTYPE * PFNSTINIT) (_In_ CSysTray * pSysTray);
+typedef HRESULT(STDMETHODCALLTYPE * PFNSTSHUTDOWN) (_In_ CSysTray * pSysTray);
+typedef HRESULT(STDMETHODCALLTYPE * PFNSTUPDATE) (_In_ CSysTray * pSysTray);
+typedef HRESULT(STDMETHODCALLTYPE * PFNSTMESSAGE) (_In_ CSysTray * pSysTray, UINT uMsg,
WPARAM wParam, LPARAM lParam);
+
+struct SysTrayIconHandlers_t
+{
+ PFNSTINIT pfnInit;
+ PFNSTSHUTDOWN pfnShutdown;
+ PFNSTUPDATE pfnUpdate;
+ PFNSTMESSAGE pfnMessage;
};
-class CSysTray :
- public CComCoClass<CSysTray, &CLSID_SysTray>,
- public CComObjectRootEx<CComMultiThreadModelNoCS>,
- public IOleCommandTarget
-{
- // TODO: keep icon handlers here
-
-public:
- CSysTray() {}
- virtual ~CSysTray() {}
-
- // *** IOleCommandTarget methods ***
- virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds,
OLECMD prgCmds [], OLECMDTEXT *pCmdText)
- {
- UNIMPLEMENTED;
- return S_OK;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
- {
- if (!IsEqualGUID(*pguidCmdGroup, CGID_ShellServiceObject))
- return E_FAIL;
-
- switch (nCmdID)
- {
- case OLECMDID_NEW: // init
- DbgPrint("CSysTray Init TODO: Initialize tray icon handlers.\n");
+SysTrayIconHandlers_t g_IconHandlers [] = {
+ { Volume_Init, Volume_Shutdown, Volume_Update, Volume_Message }
+};
+const int g_NumIcons = _countof(g_IconHandlers);
+
+HRESULT CSysTray::InitIcons()
+{
+ for (int i = 0; i < g_NumIcons; i++)
+ {
+ HRESULT hr = g_IconHandlers[i].pfnInit(this);
+ if (FAILED(hr))
+ return hr;
+ }
+
+ return S_OK;
+}
+
+HRESULT CSysTray::ShutdownIcons()
+{
+ for (int i = 0; i < g_NumIcons; i++)
+ {
+ HRESULT hr = g_IconHandlers[i].pfnShutdown(this);
+ if (FAILED(hr))
+ return hr;
+ }
+
+ return S_OK;
+}
+
+HRESULT CSysTray::UpdateIcons()
+{
+ for (int i = 0; i < g_NumIcons; i++)
+ {
+ HRESULT hr = g_IconHandlers[i].pfnUpdate(this);
+ if (FAILED(hr))
+ return hr;
+ }
+
+ return S_OK;
+}
+
+HRESULT CSysTray::ProcessIconMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ for (int i = 0; i < g_NumIcons; i++)
+ {
+ HRESULT hr = g_IconHandlers[i].pfnMessage(this, uMsg, wParam, lParam);
+ if (FAILED(hr))
+ return hr;
+
+ if (hr != S_FALSE)
+ return hr;
+ }
+
+ return S_OK;
+}
+
+HRESULT CSysTray::NotifyIcon(INT code, UINT uId, HICON hIcon, LPCWSTR szTip)
+{
+ NOTIFYICONDATA nim;
+ nim.cbSize = sizeof(NOTIFYICONDATA);
+ nim.uFlags = NIF_ICON | NIF_STATE | NIF_TIP;
+ nim.hIcon = hIcon;
+ nim.uID = uId;
+ nim.uCallbackMessage = uId;
+ nim.dwState = 0;
+ nim.dwStateMask = 0;
+ nim.hWnd = m_hWnd;
+ nim.uVersion = NOTIFYICON_VERSION;
+ if (szTip)
+ StringCchCopy(nim.szTip, _countof(nim.szTip), szTip);
+ else
+ nim.szTip[0] = 0;
+ BOOL ret = Shell_NotifyIcon(code, &nim);
+ return ret ? S_OK : E_FAIL;
+}
+
+DWORD WINAPI CSysTray::s_SysTrayThreadProc(PVOID param)
+{
+ CSysTray * st = (CSysTray*) param;
+ return st->SysTrayThreadProc();
+}
+
+HRESULT CSysTray::SysTrayMessageLoop()
+{
+ BOOL ret;
+ MSG msg;
+
+ while ((ret = GetMessage(&msg, NULL, 0, 0)) != 0)
+ {
+ if (ret < 0)
break;
- case OLECMDID_SAVE: // shutdown
- DbgPrint("CSysTray Shutdown TODO: Shutdown.\n");
- break;
- }
- return S_OK;
- }
-
- DECLARE_REGISTRY_RESOURCEID(IDR_SYSTRAY)
- DECLARE_NOT_AGGREGATABLE(CSysTray)
- DECLARE_PROTECT_FINAL_CONSTRUCT()
-
- BEGIN_COM_MAP(CSysTray)
- COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
- END_COM_MAP()
-};
-
+
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ return S_OK;
+}
+
+HRESULT CSysTray::SysTrayThreadProc()
+{
+ WCHAR strFileName[MAX_PATH];
+ GetModuleFileNameW(g_hInstance, strFileName, MAX_PATH);
+ HMODULE hLib = LoadLibraryW(strFileName);
+
+ CoInitializeEx(NULL, COINIT_DISABLE_OLE1DDE | COINIT_APARTMENTTHREADED);
+
+ Create(NULL);
+
+ HRESULT ret = SysTrayMessageLoop();
+
+ CoUninitialize();
+
+ FreeLibraryAndExitThread(hLib, ret);
+}
+
+HRESULT CSysTray::CreateSysTrayThread()
+{
+ DbgPrint("CSysTray Init TODO: Initialize tray icon handlers.\n");
+
+ HANDLE hThread = CreateThread(NULL, 0, s_SysTrayThreadProc, this, 0, NULL);
+
+ CloseHandle(hThread);
+
+ return S_OK;
+}
+
+HRESULT CSysTray::DestroySysTrayWindow()
+{
+ DestroyWindow();
+ hwndSysTray = NULL;
+ return S_OK;
+}
+
+CSysTray::CSysTray() {}
+CSysTray::~CSysTray() {}
+
+// *** IOleCommandTarget methods ***
+HRESULT STDMETHODCALLTYPE CSysTray::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds,
OLECMD prgCmds [], OLECMDTEXT *pCmdText)
+{
+ UNIMPLEMENTED;
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE CSysTray::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
+{
+ if (!IsEqualGUID(*pguidCmdGroup, CGID_ShellServiceObject))
+ return E_FAIL;
+
+ switch (nCmdID)
+ {
+ case OLECMDID_NEW: // init
+ return CreateSysTrayThread();
+ case OLECMDID_SAVE: // shutdown
+ return DestroySysTrayWindow();
+ }
+ return S_OK;
+}
+
+BOOL CSysTray::ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
LRESULT &lResult, DWORD dwMsgMapID)
+{
+ HRESULT hr;
+
+ if (hWnd != m_hWnd)
+ return FALSE;
+
+ switch (uMsg)
+ {
+ case WM_CREATE:
+ InitIcons();
+ SetTimer(1, 2000, NULL);
+ return TRUE;
+ case WM_TIMER:
+ UpdateIcons();
+ return TRUE;
+ case WM_DESTROY:
+ ShutdownIcons();
+ return TRUE;
+ }
+
+ DbgPrint("SysTray message received %u (%08p %08p)\n", uMsg, wParam,
lParam);
+
+ hr = ProcessIconMessage(uMsg, wParam, lParam);
+ if (FAILED(hr))
+ return FALSE;
+
+ if (hr == S_FALSE)
+ return FALSE;
+
+ return TRUE;
+}
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_SysTray, CSysTray)
END_OBJECT_MAP()
+class CShellTrayModule : public CComModule
+{
+};
+
CShellTrayModule gModule;
-HINSTANCE g_hInstance;
HRESULT RegisterShellServiceObject(REFGUID guidClass, LPCWSTR lpName, BOOL bRegister)
{
@@ -157,9 +319,9 @@
STDAPI
DllGetClassObject(
- REFCLSID rclsid,
- REFIID riid,
- LPVOID *ppv)
+REFCLSID rclsid,
+REFIID riid,
+LPVOID *ppv)
{
return gModule.DllGetClassObject(rclsid, riid, ppv);
}
Modified: branches/shell-experiments/dll/win32/stobject/stobject.rc
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/sto…
==============================================================================
--- branches/shell-experiments/dll/win32/stobject/stobject.rc [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/stobject/stobject.rc [iso-8859-1] Mon Jul 28
13:18:57 2014
@@ -6,10 +6,10 @@
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
-IDI_ICON1 ICON "resources/1.ico"
-IDI_ICON2 ICON "resources/2.ico"
-IDI_ICON3 ICON "resources/3.ico"
-IDI_ICON4 ICON "resources/4.ico"
+IDI_BATTERY ICON "resources/1.ico"
+IDI_EXTRACT ICON "resources/2.ico"
+IDI_VOLUME ICON "resources/3.ico"
+IDI_VOLMUTE ICON "resources/4.ico"
IDR_SYSTRAY REGISTRY "resources/rgs/systray.rgs"
Modified: branches/shell-experiments/media/inf/syssetup.inf
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/media/inf/sys…
==============================================================================
--- branches/shell-experiments/media/inf/syssetup.inf [iso-8859-1] (original)
+++ branches/shell-experiments/media/inf/syssetup.inf [iso-8859-1] Mon Jul 28 13:18:57
2014
@@ -95,6 +95,7 @@
11,,shell32.dll,3
11,,softpub.dll,1
11,,sti.dll,1
+11,,stobject.dll,1
11,,urlmon.dll,3
11,,vbscript.dll,1
11,,windowscodecs.dll,1