1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988
|
/*
* Virtual Workplace folder
*
* Copyright 1997 Marcus Meissner
* Copyright 1998, 1999, 2002 Juergen Schmied
*
* 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 St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#define COBJMACROS
#define NONAMELESSUNION
#include "winerror.h"
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "wingdi.h"
#include "pidl.h"
#include "shlguid.h"
#include "undocshell.h"
#include "shell32_main.h"
#include "shresdef.h"
#include "shlwapi.h"
#include "wine/debug.h"
#include "debughlp.h"
#include "shfldr.h"
WINE_DEFAULT_DEBUG_CHANNEL (shell);
/***********************************************************************
* IShellFolder implementation
*/
typedef struct {
IShellFolder2 IShellFolder2_iface;
IPersistFolder2 IPersistFolder2_iface;
LONG ref;
/* both paths are parsible from the desktop */
LPITEMIDLIST pidlRoot; /* absolute pidl */
} IMyComputerFolderImpl;
static const IShellFolder2Vtbl vt_ShellFolder2;
static const IPersistFolder2Vtbl vt_PersistFolder2;
static inline IMyComputerFolderImpl *impl_from_IShellFolder2(IShellFolder2 *iface)
{
return CONTAINING_RECORD(iface, IMyComputerFolderImpl, IShellFolder2_iface);
}
static inline IMyComputerFolderImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface)
{
return CONTAINING_RECORD(iface, IMyComputerFolderImpl, IPersistFolder2_iface);
}
/***********************************************************************
* IShellFolder [MyComputer] implementation
*/
static const shvheader mycomputer_header[] = {
{IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
{IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
{IDS_SHV_COLUMN6, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
{IDS_SHV_COLUMN7, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
};
#define MYCOMPUTERSHELLVIEWCOLUMNS sizeof(mycomputer_header)/sizeof(shvheader)
/**************************************************************************
* ISF_MyComputer_Constructor
*/
HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
{
IMyComputerFolderImpl *sf;
TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
if (!ppv)
return E_POINTER;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
sf = LocalAlloc (LMEM_ZEROINIT, sizeof (IMyComputerFolderImpl));
if (!sf)
return E_OUTOFMEMORY;
sf->ref = 0;
sf->IShellFolder2_iface.lpVtbl = &vt_ShellFolder2;
sf->IPersistFolder2_iface.lpVtbl = &vt_PersistFolder2;
sf->pidlRoot = _ILCreateMyComputer (); /* my qualified pidl */
if (FAILED (IShellFolder2_QueryInterface (&sf->IShellFolder2_iface, riid, ppv)))
{
IShellFolder2_Release (&sf->IShellFolder2_iface);
return E_NOINTERFACE;
}
TRACE ("--(%p)\n", sf);
return S_OK;
}
/**************************************************************************
* ISF_MyComputer_fnQueryInterface
*
* NOTES supports not IPersist/IPersistFolder
*/
static HRESULT WINAPI ISF_MyComputer_fnQueryInterface (IShellFolder2 *iface,
REFIID riid, LPVOID *ppvObj)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
*ppvObj = NULL;
if (IsEqualIID (riid, &IID_IUnknown) ||
IsEqualIID (riid, &IID_IShellFolder) ||
IsEqualIID (riid, &IID_IShellFolder2))
{
*ppvObj = &This->IShellFolder2_iface;
}
else if (IsEqualIID (riid, &IID_IPersist) ||
IsEqualIID (riid, &IID_IPersistFolder) ||
IsEqualIID (riid, &IID_IPersistFolder2))
{
*ppvObj = &This->IPersistFolder2_iface;
}
if (*ppvObj)
{
IUnknown_AddRef ((IUnknown *) (*ppvObj));
TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
return S_OK;
}
TRACE ("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
static ULONG WINAPI ISF_MyComputer_fnAddRef (IShellFolder2 * iface)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE ("(%p)->(count=%u)\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE ("(%p)->(count=%u)\n", This, refCount + 1);
if (!refCount)
{
TRACE ("-- destroying IShellFolder(%p)\n", This);
SHFree (This->pidlRoot);
LocalFree (This);
}
return refCount;
}
/**************************************************************************
* ISF_MyComputer_fnParseDisplayName
*/
static HRESULT WINAPI ISF_MyComputer_fnParseDisplayName (IShellFolder2 *iface,
HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName,
DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
HRESULT hr = E_INVALIDARG;
LPCWSTR szNext = NULL;
WCHAR szElement[MAX_PATH];
LPITEMIDLIST pidlTemp = NULL;
CLSID clsid;
TRACE("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", This,
hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName),
pchEaten, ppidl, pdwAttributes);
*ppidl = 0;
if (pchEaten)
*pchEaten = 0; /* strange but like the original */
/* handle CLSID paths */
if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':')
{
szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
TRACE ("-- element: %s\n", debugstr_w (szElement));
SHCLSIDFromStringW (szElement + 2, &clsid);
pidlTemp = _ILCreateGuid (PT_GUID, &clsid);
}
/* do we have an absolute path name ? */
else if (PathGetDriveNumberW (lpszDisplayName) >= 0 &&
lpszDisplayName[2] == (WCHAR) '\\')
{
szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
/* make drive letter uppercase to enable PIDL comparison */
szElement[0] = toupper(szElement[0]);
pidlTemp = _ILCreateDrive (szElement);
}
if (szNext && *szNext)
{
hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp,
(LPOLESTR) szNext, pchEaten, pdwAttributes);
}
else
{
if (pdwAttributes && *pdwAttributes)
SHELL32_GetItemAttributes (&This->IShellFolder2_iface, pidlTemp, pdwAttributes);
hr = S_OK;
}
*ppidl = pidlTemp;
TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr);
return hr;
}
/* retrieve a map of drives that should be displayed */
static DWORD get_drive_map(void)
{
static const WCHAR policiesW[] = {'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'P','o','l','i','c','i','e','s','\\',
'E','x','p','l','o','r','e','r',0};
static const WCHAR nodrivesW[] = {'N','o','D','r','i','v','e','s',0};
static DWORD drive_mask;
static BOOL init_done = FALSE;
if (!init_done)
{
DWORD type, size, data, mask = 0;
HKEY hkey;
if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, policiesW, &hkey ))
{
size = sizeof(data);
if (!RegQueryValueExW( hkey, nodrivesW, NULL, &type, (LPBYTE)&data, &size ) && type == REG_DWORD)
mask |= data;
RegCloseKey( hkey );
}
if (!RegOpenKeyW( HKEY_CURRENT_USER, policiesW, &hkey ))
{
size = sizeof(data);
if (!RegQueryValueExW( hkey, nodrivesW, NULL, &type, (LPBYTE)&data, &size ) && type == REG_DWORD)
mask |= data;
RegCloseKey( hkey );
}
drive_mask = mask;
init_done = TRUE;
}
return GetLogicalDrives() & ~drive_mask;
}
/**************************************************************************
* CreateMyCompEnumList()
*/
static const WCHAR MyComputer_NameSpaceW[] = { 'S','O','F','T','W','A','R','E',
'\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
'o','r','e','r','\\','M','y','C','o','m','p','u','t','e','r','\\','N','a','m',
'e','s','p','a','c','e','\0' };
static BOOL CreateMyCompEnumList(IEnumIDListImpl *list, DWORD dwFlags)
{
BOOL ret = TRUE;
TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags);
/* enumerate the folders */
if (dwFlags & SHCONTF_FOLDERS)
{
WCHAR wszDriveName[] = {'A', ':', '\\', '\0'};
DWORD dwDrivemap = get_drive_map();
HKEY hkey;
UINT i;
while (ret && wszDriveName[0]<='Z')
{
if(dwDrivemap & 0x00000001L)
ret = AddToEnumList(list, _ILCreateDrive(wszDriveName));
wszDriveName[0]++;
dwDrivemap = dwDrivemap >> 1;
}
TRACE("-- (%p)-> enumerate (mycomputer shell extensions)\n",list);
for (i=0; i<2; i++) {
if (ret && !RegOpenKeyExW(i == 0 ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
MyComputer_NameSpaceW, 0, KEY_READ, &hkey))
{
WCHAR iid[50];
int i=0;
while (ret)
{
DWORD size;
LONG r;
size = sizeof(iid) / sizeof(iid[0]);
r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL);
if (ERROR_SUCCESS == r)
{
/* FIXME: shell extensions, shouldn't the type be
* PT_SHELLEXT? */
ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid));
i++;
}
else if (ERROR_NO_MORE_ITEMS == r)
break;
else
ret = FALSE;
}
RegCloseKey(hkey);
}
}
}
return ret;
}
/**************************************************************************
* ISF_MyComputer_fnEnumObjects
*/
static HRESULT WINAPI ISF_MyComputer_fnEnumObjects (IShellFolder2 *iface,
HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
IEnumIDListImpl *list;
TRACE("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This,
hwndOwner, dwFlags, ppEnumIDList);
if (!(list = IEnumIDList_Constructor()))
return E_OUTOFMEMORY;
CreateMyCompEnumList(list, dwFlags);
*ppEnumIDList = &list->IEnumIDList_iface;
TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
return S_OK;
}
/**************************************************************************
* ISF_MyComputer_fnBindToObject
*/
static HRESULT WINAPI ISF_MyComputer_fnBindToObject (IShellFolder2 *iface,
LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This,
pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut);
}
/**************************************************************************
* ISF_MyComputer_fnBindToStorage
*/
static HRESULT WINAPI ISF_MyComputer_fnBindToStorage (IShellFolder2 * iface,
LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This,
pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
*ppvOut = NULL;
return E_NOTIMPL;
}
/**************************************************************************
* ISF_MyComputer_fnCompareIDs
*/
static HRESULT WINAPI ISF_MyComputer_fnCompareIDs (IShellFolder2 *iface,
LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
HRESULT hr;
TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
hr = SHELL32_CompareIDs(&This->IShellFolder2_iface, lParam, pidl1, pidl2);
TRACE ("-- 0x%08x\n", hr);
return hr;
}
/**************************************************************************
* ISF_MyComputer_fnCreateViewObject
*/
static HRESULT WINAPI ISF_MyComputer_fnCreateViewObject (IShellFolder2 *iface,
HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
LPSHELLVIEW pShellView;
HRESULT hr = E_INVALIDARG;
TRACE("(%p)->(hwnd=%p,%s,%p)\n", This,
hwndOwner, shdebugstr_guid (riid), ppvOut);
if (!ppvOut)
return hr;
*ppvOut = NULL;
if (IsEqualIID (riid, &IID_IDropTarget))
{
WARN ("IDropTarget not implemented\n");
hr = E_NOTIMPL;
}
else if (IsEqualIID (riid, &IID_IContextMenu))
{
WARN ("IContextMenu not implemented\n");
hr = E_NOTIMPL;
}
else if (IsEqualIID (riid, &IID_IShellView))
{
pShellView = IShellView_Constructor ((IShellFolder *) iface);
if (pShellView)
{
hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
IShellView_Release (pShellView);
}
}
TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
return hr;
}
/**************************************************************************
* ISF_MyComputer_fnGetAttributesOf
*/
static HRESULT WINAPI ISF_MyComputer_fnGetAttributesOf (IShellFolder2 * iface,
UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
HRESULT hr = S_OK;
TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
if (!rgfInOut)
return E_INVALIDARG;
if (cidl && !apidl)
return E_INVALIDARG;
if (*rgfInOut == 0)
*rgfInOut = ~0;
if(cidl == 0){
IShellFolder2 *parent = NULL;
LPCITEMIDLIST rpidl = NULL;
hr = SHBindToParent(This->pidlRoot, &IID_IShellFolder2, (void **)&parent, &rpidl);
if(SUCCEEDED(hr)) {
SHELL32_GetItemAttributes(parent, rpidl, rgfInOut);
IShellFolder2_Release(parent);
}
} else {
while (cidl > 0 && *apidl) {
pdump (*apidl);
SHELL32_GetItemAttributes(&This->IShellFolder2_iface, *apidl, rgfInOut);
apidl++;
cidl--;
}
}
/* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
*rgfInOut &= ~SFGAO_VALIDATE;
TRACE ("-- result=0x%08x\n", *rgfInOut);
return hr;
}
/**************************************************************************
* ISF_MyComputer_fnGetUIObjectOf
*
* PARAMETERS
* hwndOwner [in] Parent window for any output
* cidl [in] array size
* apidl [in] simple pidl array
* riid [in] Requested Interface
* prgfInOut [ ] reserved
* ppvObject [out] Resulting Interface
*
*/
static HRESULT WINAPI ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface,
HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid,
UINT * prgfInOut, LPVOID * ppvOut)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
LPITEMIDLIST pidl;
IUnknown *pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", This,
hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
if (!ppvOut)
return hr;
*ppvOut = NULL;
if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1))
{
return ItemMenu_Constructor((IShellFolder*) iface, This->pidlRoot, apidl, cidl, riid, ppvOut);
}
else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1))
{
pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner,
This->pidlRoot, apidl, cidl);
hr = S_OK;
}
else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
{
pidl = ILCombine (This->pidlRoot, apidl[0]);
pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
SHFree (pidl);
hr = S_OK;
}
else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1))
{
pidl = ILCombine (This->pidlRoot, apidl[0]);
pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
SHFree (pidl);
hr = S_OK;
}
else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1))
{
hr = IShellFolder2_QueryInterface (iface, &IID_IDropTarget,
(LPVOID *) &pObj);
}
else if ((IsEqualIID(riid,&IID_IShellLinkW) ||
IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1))
{
pidl = ILCombine (This->pidlRoot, apidl[0]);
hr = IShellLink_ConstructFromFile(NULL, riid, pidl, &pObj);
SHFree (pidl);
}
else
hr = E_NOINTERFACE;
if (SUCCEEDED(hr) && !pObj)
hr = E_OUTOFMEMORY;
*ppvOut = pObj;
TRACE ("(%p)->hr=0x%08x\n", This, hr);
return hr;
}
/**************************************************************************
* ISF_MyComputer_fnGetDisplayNameOf
*/
static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface,
LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
LPWSTR pszPath;
HRESULT hr = S_OK;
TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
pdump (pidl);
if (!strRet)
return E_INVALIDARG;
pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR));
if (!pszPath)
return E_OUTOFMEMORY;
pszPath[0] = 0;
if (!pidl->mkid.cb)
{
/* parsing name like ::{...} */
pszPath[0] = ':';
pszPath[1] = ':';
SHELL32_GUIDToStringW(&CLSID_MyComputer, &pszPath[2]);
}
else if (_ILIsPidlSimple(pidl))
{
/* take names of special folders only if its only this folder */
if (_ILIsSpecialFolder(pidl))
{
GUID const *clsid;
clsid = _ILGetGUIDPointer (pidl);
if (clsid)
{
if (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)
{
static const WCHAR clsidW[] =
{ 'C','L','S','I','D','\\',0 };
static const WCHAR shellfolderW[] =
{ '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
static const WCHAR wantsForParsingW[] =
{ 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
'g',0 };
BOOL bWantsForParsing = FALSE;
WCHAR szRegPath[100];
LONG r;
/*
* We can only get a filesystem path from a shellfolder
* if the value WantsFORPARSING exists in
* CLSID\\{...}\\shellfolder
* exception: the MyComputer folder has this keys not
* but like any filesystem backed
* folder it needs these behaviour
*
* Get the "WantsFORPARSING" flag from the registry
*/
lstrcpyW (szRegPath, clsidW);
SHELL32_GUIDToStringW (clsid, &szRegPath[6]);
lstrcatW (szRegPath, shellfolderW);
r = SHGetValueW (HKEY_CLASSES_ROOT, szRegPath,
wantsForParsingW, NULL, NULL, NULL);
if (r == ERROR_SUCCESS)
bWantsForParsing = TRUE;
if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
bWantsForParsing)
{
/*
* We need the filesystem path to the destination folder
* Only the folder itself can know it
*/
hr = SHELL32_GetDisplayNameOfChild (iface, pidl,
dwFlags, pszPath, MAX_PATH);
}
else
{
LPWSTR p = pszPath;
/* parsing name like ::{...} */
p[0] = ':';
p[1] = ':';
p += 2;
p += SHELL32_GUIDToStringW(&CLSID_MyComputer, p);
/* \:: */
p[0] = '\\';
p[1] = ':';
p[2] = ':';
p += 3;
SHELL32_GUIDToStringW(clsid, p);
}
}
else
{
/* user friendly name */
HCR_GetClassNameW (clsid, pszPath, MAX_PATH);
}
}
else
{
/* append my own path */
_ILSimpleGetTextW (pidl, pszPath, MAX_PATH);
}
}
else if (_ILIsDrive(pidl))
{
_ILSimpleGetTextW (pidl, pszPath, MAX_PATH); /* append my own path */
/* long view "lw_name (C:)" */
if (!(dwFlags & SHGDN_FORPARSING))
{
static const WCHAR wszOpenBracket[] = {' ','(',0};
static const WCHAR wszCloseBracket[] = {')',0};
WCHAR wszDrive[32 /* label */ + 6 /* ' (C:)'\0 */] = {0};
GetVolumeInformationW (pszPath, wszDrive, sizeof(wszDrive)/sizeof(wszDrive[0]) - 5,
NULL, NULL, NULL, NULL, 0);
strcatW (wszDrive, wszOpenBracket);
lstrcpynW (wszDrive + strlenW(wszDrive), pszPath, 3);
strcatW (wszDrive, wszCloseBracket);
strcpyW (pszPath, wszDrive);
}
}
else
{
/* Neither a shell namespace extension nor a drive letter. */
ERR("Wrong pidl type\n");
CoTaskMemFree(pszPath);
return E_INVALIDARG;
}
}
else
{
/* Complex pidl. Let the child folder do the work */
hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, pszPath, MAX_PATH);
}
if (SUCCEEDED (hr))
{
/* Win9x always returns ANSI strings, NT always returns Unicode strings */
if (GetVersion() & 0x80000000)
{
strRet->uType = STRRET_CSTR;
if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->u.cStr, MAX_PATH,
NULL, NULL))
strRet->u.cStr[0] = '\0';
CoTaskMemFree(pszPath);
}
else
{
strRet->uType = STRRET_WSTR;
strRet->u.pOleStr = pszPath;
}
}
else
CoTaskMemFree(pszPath);
TRACE ("-- (%p)->(%s)\n", This, strRet->uType == STRRET_CSTR ? strRet->u.cStr : debugstr_w(strRet->u.pOleStr));
return hr;
}
/**************************************************************************
* ISF_MyComputer_fnSetNameOf
* Changes the name of a file object or subfolder, possibly changing its item
* identifier in the process.
*
* PARAMETERS
* hwndOwner [in] Owner window for output
* pidl [in] simple pidl of item to change
* lpszName [in] the items new display name
* dwFlags [in] SHGNO formatting flags
* ppidlOut [out] simple pidl returned
*/
static HRESULT WINAPI ISF_MyComputer_fnSetNameOf (
IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl,
LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This,
hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
return E_FAIL;
}
static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID (
IShellFolder2 * iface, GUID * pguid)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ISF_MyComputer_fnEnumSearches (
IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn (
IShellFolder2 *iface, DWORD dwRes, ULONG *pSort, ULONG *pDisplay)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
TRACE ("(%p)\n", This);
if (pSort)
*pSort = 0;
if (pDisplay)
*pDisplay = 0;
return S_OK;
}
static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState (
IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
TRACE ("(%p)->(%d %p)\n", This, iColumn, pcsFlags);
if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS)
return E_INVALIDARG;
*pcsFlags = mycomputer_header[iColumn].pcsFlags;
return S_OK;
}
static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface,
LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
/* FIXME: drive size >4GB is rolling over */
static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 *iface,
LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *psd)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
char szPath[MAX_PATH];
ULARGE_INTEGER ulBytes;
HRESULT hr = S_OK;
TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
if (!psd || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS)
return E_INVALIDARG;
if (!pidl)
return SHELL32_GetColumnDetails(mycomputer_header, iColumn, psd);
psd->str.u.cStr[0] = 0;
psd->str.uType = STRRET_CSTR;
switch (iColumn)
{
case 0: /* name */
hr = IShellFolder2_GetDisplayNameOf (iface, pidl,
SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
break;
case 1: /* type */
_ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 2: /* total size */
if (_ILIsDrive (pidl))
{
_ILSimpleGetText (pidl, szPath, MAX_PATH);
GetDiskFreeSpaceExA (szPath, NULL, &ulBytes, NULL);
StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH);
}
break;
case 3: /* free size */
if (_ILIsDrive (pidl))
{
_ILSimpleGetText (pidl, szPath, MAX_PATH);
GetDiskFreeSpaceExA (szPath, &ulBytes, NULL, NULL);
StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH);
}
break;
}
return hr;
}
static HRESULT WINAPI ISF_MyComputer_fnMapColumnToSCID (
IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
{
IMyComputerFolderImpl *This = impl_from_IShellFolder2(iface);
FIXME ("(%p)\n", This);
return E_NOTIMPL;
}
static const IShellFolder2Vtbl vt_ShellFolder2 =
{
ISF_MyComputer_fnQueryInterface,
ISF_MyComputer_fnAddRef,
ISF_MyComputer_fnRelease,
ISF_MyComputer_fnParseDisplayName,
ISF_MyComputer_fnEnumObjects,
ISF_MyComputer_fnBindToObject,
ISF_MyComputer_fnBindToStorage,
ISF_MyComputer_fnCompareIDs,
ISF_MyComputer_fnCreateViewObject,
ISF_MyComputer_fnGetAttributesOf,
ISF_MyComputer_fnGetUIObjectOf,
ISF_MyComputer_fnGetDisplayNameOf,
ISF_MyComputer_fnSetNameOf,
/* ShellFolder2 */
ISF_MyComputer_fnGetDefaultSearchGUID,
ISF_MyComputer_fnEnumSearches,
ISF_MyComputer_fnGetDefaultColumn,
ISF_MyComputer_fnGetDefaultColumnState,
ISF_MyComputer_fnGetDetailsEx,
ISF_MyComputer_fnGetDetailsOf,
ISF_MyComputer_fnMapColumnToSCID
};
/************************************************************************
* IMCFldr_PersistFolder2_QueryInterface
*/
static HRESULT WINAPI IMCFldr_PersistFolder2_QueryInterface (
IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj)
{
IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)\n", This);
return IShellFolder2_QueryInterface (&This->IShellFolder2_iface, iid, ppvObj);
}
/************************************************************************
* IMCFldr_PersistFolder2_AddRef
*/
static ULONG WINAPI IMCFldr_PersistFolder2_AddRef (IPersistFolder2 * iface)
{
IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)->(count=%u)\n", This, This->ref);
return IShellFolder2_AddRef (&This->IShellFolder2_iface);
}
/************************************************************************
* ISFPersistFolder_Release
*/
static ULONG WINAPI IMCFldr_PersistFolder2_Release (IPersistFolder2 * iface)
{
IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)->(count=%u)\n", This, This->ref);
return IShellFolder2_Release (&This->IShellFolder2_iface);
}
/************************************************************************
* IMCFldr_PersistFolder2_GetClassID
*/
static HRESULT WINAPI IMCFldr_PersistFolder2_GetClassID (
IPersistFolder2 * iface, CLSID * lpClassId)
{
IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)\n", This);
if (!lpClassId)
return E_POINTER;
*lpClassId = CLSID_MyComputer;
return S_OK;
}
/************************************************************************
* IMCFldr_PersistFolder2_Initialize
*
* NOTES: it makes no sense to change the pidl
*/
static HRESULT WINAPI IMCFldr_PersistFolder2_Initialize (
IPersistFolder2 * iface, LPCITEMIDLIST pidl)
{
IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)->(%p)\n", This, pidl);
return E_NOTIMPL;
}
/**************************************************************************
* IPersistFolder2_fnGetCurFolder
*/
static HRESULT WINAPI IMCFldr_PersistFolder2_GetCurFolder (
IPersistFolder2 * iface, LPITEMIDLIST * pidl)
{
IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)->(%p)\n", This, pidl);
if (!pidl)
return E_POINTER;
*pidl = ILClone (This->pidlRoot);
return S_OK;
}
static const IPersistFolder2Vtbl vt_PersistFolder2 =
{
IMCFldr_PersistFolder2_QueryInterface,
IMCFldr_PersistFolder2_AddRef,
IMCFldr_PersistFolder2_Release,
IMCFldr_PersistFolder2_GetClassID,
IMCFldr_PersistFolder2_Initialize,
IMCFldr_PersistFolder2_GetCurFolder
};
|