[EXPLORER]
authorDavid Quintana <gigaherz@gmail.com>
Fri, 7 Mar 2014 22:39:49 +0000 (22:39 +0000)
committerDavid Quintana <gigaherz@gmail.com>
Fri, 7 Mar 2014 22:39:49 +0000 (22:39 +0000)
* Rename the output to explorer_old

[EXPLORER-NEW]
* Rename the output to explorer
* Launch a browseui window when explorer is run with an existing shell process.

Shell-experiments will now be running the new shell by default.
This allows me to test the shell classes under more accurate conditions, so I was using it locally for a while.
I decided to commit because of two reasons:
1. It was making me temporarily revert some changes done to some files when I wanted to commit, and
2. It lets everyone see the results of the shell-experiments project without having to mess with the task manager.

Keep in mind that, as the branch name implies, it STILL is an experiment.

CORE-7586

svn path=/branches/shell-experiments/; revision=62449

base/shell/explorer-new/CMakeLists.txt
base/shell/explorer-new/explorer.c
base/shell/explorer/CMakeLists.txt
base/shell/filebrowser/CMakeLists.txt
base/shell/filebrowser/filebrowser.c
base/shell/rshell/CMakeLists.txt
dll/win32/browseui/CMakeLists.txt

index 0653b33..021f784 100644 (file)
@@ -19,10 +19,10 @@ list(APPEND SOURCE
     traywnd.c
     precomp.h)
 
-add_executable(explorer_new ${SOURCE} explorer.rc)
-target_link_libraries(explorer_new uuid)
-set_module_type(explorer_new win32gui UNICODE)
-add_importlibs(explorer_new
+add_executable(explorer ${SOURCE} explorer.rc)
+target_link_libraries(explorer uuid)
+set_module_type(explorer win32gui UNICODE)
+add_importlibs(explorer
     advapi32
     gdi32
     user32
@@ -37,5 +37,5 @@ add_importlibs(explorer_new
     msvcrt
     kernel32
     ntdll)
-add_pch(explorer_new precomp.h SOURCE)
-add_cd_file(TARGET explorer_new DESTINATION reactos FOR all)
+add_pch(explorer precomp.h SOURCE)
+add_cd_file(TARGET explorer DESTINATION reactos FOR all)
index a574a5b..c91a2f6 100644 (file)
@@ -381,6 +381,8 @@ _tWinMain(IN HINSTANCE hInstance,
     HANDLE hShellDesktop = NULL;
     BOOL CreateShellDesktop = FALSE;
 
+    DbgPrint("Explorer starting... Commandline: %S\n", lpCmdLine);
+
     if (RegOpenKey(HKEY_CURRENT_USER,
                    TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"),
                    &hkExplorer) != ERROR_SUCCESS)
@@ -442,10 +444,109 @@ _tWinMain(IN HINSTANCE hInstance,
     }
     else
     {
+        WCHAR root[MAX_PATH];
+        HMODULE hBrowseui;
+        HRESULT hr;
+        LPSHELLFOLDER pDesktopFolder = NULL;
+        LPITEMIDLIST pidlRoot = NULL;
+
         /* A shell is already loaded. Parse the command line arguments
            and unless we need to do something specific simply display
            the desktop in a separate explorer window */
         /* FIXME */
+
+        /* Commandline switches:
+         *
+         * /n               Open a new window, even if an existing one still exists.
+         * /e               Start with the explorer sidebar shown.
+         * /root,<object>   Open a window for the given object path.
+         * /select,<object> Open a window with the given object selected.
+         */
+        
+        /* FIXME: Do it right */
+        WCHAR* tmp = wcsstr(lpCmdLine,L"/root,");
+        if (tmp)
+        {
+            WCHAR* tmp2;
+            
+            tmp += 6; // skip to beginning of path
+            tmp2 = wcschr(tmp, L',');
+
+            if (tmp2)
+            {
+                wcsncpy(root, tmp, tmp2 - tmp);
+            }
+            else
+            {
+                wcscpy(root, tmp);
+            }
+        }
+        else
+        {
+            wcscpy(root, lpCmdLine);
+        }
+
+        if (root[0] == L'"')
+        {
+            int len = wcslen(root) - 2;
+            wcsncpy(root, root + 1, len);
+            root[len] = 0;
+        }
+
+        if (wcslen(root) > 0)
+        {
+            LPITEMIDLIST  pidl;
+            ULONG         chEaten;
+            ULONG         dwAttributes;
+
+            if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
+            {
+                hr = pDesktopFolder->lpVtbl->ParseDisplayName(pDesktopFolder,
+                    NULL,
+                    NULL,
+                    root,
+                    &chEaten,
+                    &pidl,
+                    &dwAttributes);
+                if (SUCCEEDED(hr))
+                {
+                    pidlRoot = pidl;
+                    DbgPrint("Got PIDL for folder '%S'\n", root);
+                }
+            }
+        }
+
+        if (!pidlRoot)
+        {
+            DbgPrint("No folder, getting PIDL for My Computer.\n", root);
+            hr = SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlRoot);
+            if (FAILED(hr))
+                return 0;
+        }
+
+        DbgPrint("Trying to open browser window... \n");
+
+        typedef HRESULT(WINAPI *SH_OPEN_NEW_FRAME)(LPITEMIDLIST pidl, IUnknown *paramC, long param10, long param14);
+        SH_OPEN_NEW_FRAME SHOpenNewFrame;
+
+        hBrowseui = LoadLibraryW(L"browseui.dll");
+        if (!hBrowseui)
+        {
+            DbgPrint("Browseui not found.. \n");
+            return 0;
+        }
+
+        SHOpenNewFrame = (SH_OPEN_NEW_FRAME) GetProcAddress(hBrowseui, (LPCSTR) 103);
+
+        hr = SHOpenNewFrame(pidlRoot, (IUnknown*)pDesktopFolder, 0, 0);
+        if (FAILED(hr))
+            return 0;
+
+        /* FIXME: we should wait a bit here and see if a window was created. If not we should exit this process. */
+        Sleep(1000);
+        ExitThread(0);
+
+        return 0;
     }
 
     if (Tray != NULL)
index 1763b27..5e9617f 100644 (file)
@@ -46,17 +46,17 @@ if(ARCH STREQUAL "i386")
     list(APPEND I386_SOURCE i386-stub-win32.c)
 endif()
 
-add_executable(explorer
+add_executable(explorer_old
     ${SOURCE}
     ${I386_SOURCE}
     services/startup.c
     explorer.rc)
 
-target_link_libraries(explorer comsupp wine uuid)
-set_module_type(explorer win32gui UNICODE)
+target_link_libraries(explorer_old comsupp wine uuid)
+set_module_type(explorer_old win32gui UNICODE)
 
-add_importlibs(explorer advapi32 gdi32 user32 ws2_32 msimg32 comctl32 ole32 oleaut32 shell32 shlwapi notifyhook msvcrt kernel32 ntdll)
-add_pch(explorer precomp.h SOURCE)
-add_dependencies(explorer psdk)
-add_cd_file(TARGET explorer DESTINATION reactos FOR all)
+add_importlibs(explorer_old advapi32 gdi32 user32 ws2_32 msimg32 comctl32 ole32 oleaut32 shell32 shlwapi notifyhook msvcrt kernel32 ntdll)
+add_pch(explorer_old precomp.h SOURCE)
+add_dependencies(explorer_old psdk)
+add_cd_file(TARGET explorer_old DESTINATION reactos FOR all)
 add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/explorer-cfg-template.xml DESTINATION reactos FOR all)
index 81209bc..05175a2 100644 (file)
@@ -11,4 +11,5 @@ add_importlibs(filebrowser
     shell32
     msvcrt
     kernel32)
-       
\ No newline at end of file
+
+add_cd_file(TARGET explorer DESTINATION reactos FOR all)add_cd_file(TARGET explorer DESTINATION reactos FOR all)
\ No newline at end of file
index a3d5dc2..8bbfe47 100644 (file)
@@ -33,7 +33,7 @@ int _tmain(int argc, _TCHAR* argv[])
     {
         SH_OPEN_NEW_FRAME SHOpenNewFrame = (SH_OPEN_NEW_FRAME)GetProcAddress(hBrowseui, (LPCSTR)103);
         LPITEMIDLIST pidlDrives;
-        HRESULT hRet = SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlDrives);
+        SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlDrives);
         SHOpenNewFrame((LPITEMIDLIST)pidlDrives, NULL, 0, 0);
     }
 
index 46d23a7..2dbb3a5 100644 (file)
@@ -47,7 +47,13 @@ add_cd_file(TARGET rshell DESTINATION reactos FOR all)
 add_custom_command(TARGET rshell POST_BUILD 
   COMMAND "${CMAKE_COMMAND}" -E copy 
      "$<TARGET_FILE:rshell>"
-     "$<TARGET_FILE_DIR:explorer_new>/$<TARGET_FILE_NAME:rshell>" 
+     "$<TARGET_FILE_DIR:explorer>/$<TARGET_FILE_NAME:rshell>" 
+  COMMENT "Copying to output directory")
+
+add_custom_command(TARGET rshell POST_BUILD 
+  COMMAND "${CMAKE_COMMAND}" -E copy 
+     "$<TARGET_FILE:rshell>"
+     "$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:rshell>" 
   COMMENT "Copying to output directory")
 
 add_custom_command(TARGET rshell POST_BUILD 
index b242d01..dee148b 100644 (file)
@@ -65,3 +65,9 @@ add_custom_command(TARGET browseui POST_BUILD
      "$<TARGET_FILE:browseui>"
      "$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:browseui>" 
   COMMENT "Copying to output directory")
+
+add_custom_command(TARGET browseui POST_BUILD 
+  COMMAND "${CMAKE_COMMAND}" -E copy 
+     "$<TARGET_FILE:browseui>"
+     "$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:browseui>" 
+  COMMENT "Copying to output directory")