Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
f686cfab
Commit
f686cfab
authored
Jul 16, 2007
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jul 16, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell32: Add a cache for queried shell folder interfaces.
parent
663c0146
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
6 deletions
+101
-6
shlfolder.c
dlls/shell32/shlfolder.c
+101
-6
No files found.
dlls/shell32/shlfolder.c
View file @
f686cfab
...
...
@@ -50,6 +50,28 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
shell
);
static
CRITICAL_SECTION
SHELL32_SF_ClassCacheCS
;
static
CRITICAL_SECTION_DEBUG
critsect_debug
=
{
0
,
0
,
&
SHELL32_SF_ClassCacheCS
,
{
&
critsect_debug
.
ProcessLocksList
,
&
critsect_debug
.
ProcessLocksList
},
0
,
0
,
{
(
DWORD_PTR
)(
__FILE__
": SHELL32_SF_ClassCacheCS"
)
}
};
static
CRITICAL_SECTION
SHELL32_SF_ClassCacheCS
=
{
&
critsect_debug
,
-
1
,
0
,
0
,
0
,
0
};
/* IShellFolder class cache */
struct
_sf_cls_cache_entry
{
CLSID
clsid
;
LPVOID
pv
;
};
static
struct
_sf_class_cache
{
DWORD
allocated
,
used
;
struct
_sf_cls_cache_entry
*
sf_cls_cache_entry
;
}
sf_cls_cache
;
static
const
WCHAR
wszDotShellClassInfo
[]
=
{
'.'
,
'S'
,
'h'
,
'e'
,
'l'
,
'l'
,
'C'
,
'l'
,
'a'
,
's'
,
's'
,
'I'
,
'n'
,
'f'
,
'o'
,
0
};
...
...
@@ -182,6 +204,66 @@ HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc,
return
hr
;
}
static
BOOL
get_iface_from_cache
(
REFCLSID
clsid
,
LPVOID
*
ppvOut
)
{
BOOL
ret
=
FALSE
;
int
i
;
EnterCriticalSection
(
&
SHELL32_SF_ClassCacheCS
);
for
(
i
=
0
;
i
<
sf_cls_cache
.
used
;
i
++
)
{
if
(
IsEqualIID
(
&
sf_cls_cache
.
sf_cls_cache_entry
[
i
].
clsid
,
clsid
))
{
*
ppvOut
=
sf_cls_cache
.
sf_cls_cache_entry
[
i
].
pv
;
/* Pin it */
IUnknown_AddRef
((
IUnknown
*
)
*
ppvOut
);
ret
=
TRUE
;
break
;
}
}
LeaveCriticalSection
(
&
SHELL32_SF_ClassCacheCS
);
return
ret
;
}
static
void
add_iface_to_cache
(
REFCLSID
clsid
,
LPVOID
pv
)
{
EnterCriticalSection
(
&
SHELL32_SF_ClassCacheCS
);
if
(
sf_cls_cache
.
used
>=
sf_cls_cache
.
allocated
)
{
DWORD
allocated
;
struct
_sf_cls_cache_entry
*
sf_cls_cache_entry
;
if
(
!
sf_cls_cache
.
allocated
)
{
allocated
=
4
;
sf_cls_cache_entry
=
HeapAlloc
(
GetProcessHeap
(),
0
,
4
*
sizeof
(
*
sf_cls_cache_entry
));
}
else
{
allocated
=
sf_cls_cache
.
allocated
*
2
;
sf_cls_cache_entry
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
sf_cls_cache
.
sf_cls_cache_entry
,
allocated
*
sizeof
(
*
sf_cls_cache_entry
));
}
if
(
!
sf_cls_cache_entry
)
return
;
sf_cls_cache
.
allocated
=
allocated
;
sf_cls_cache
.
sf_cls_cache_entry
=
sf_cls_cache_entry
;
}
/* Pin it */
IUnknown_AddRef
((
IUnknown
*
)
pv
);
sf_cls_cache
.
sf_cls_cache_entry
[
sf_cls_cache
.
used
].
clsid
=
*
clsid
;
sf_cls_cache
.
sf_cls_cache_entry
[
sf_cls_cache
.
used
].
pv
=
pv
;
sf_cls_cache
.
used
++
;
LeaveCriticalSection
(
&
SHELL32_SF_ClassCacheCS
);
}
/***********************************************************************
* SHELL32_CoCreateInitSF
*
...
...
@@ -193,13 +275,26 @@ HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc,
* In this case the absolute path is built from pidlChild (eg. C:)
*/
static
HRESULT
SHELL32_CoCreateInitSF
(
LPCITEMIDLIST
pidlRoot
,
LPCWSTR
pathRoot
,
LPCITEMIDLIST
pidlChild
,
REFCLSID
clsid
,
REFIID
ri
id
,
LPVOID
*
ppvOut
)
LPCITEMIDLIST
pidlChild
,
REFCLSID
cls
id
,
LPVOID
*
ppvOut
)
{
HRESULT
hr
;
HRESULT
hr
=
S_OK
;
TRACE
(
"%p %s %p
\n
"
,
pidlRoot
,
debugstr_w
(
pathRoot
),
pidlChild
);
if
(
SUCCEEDED
((
hr
=
SHCoCreateInstance
(
NULL
,
clsid
,
NULL
,
riid
,
ppvOut
))))
{
if
(
!
get_iface_from_cache
(
clsid
,
ppvOut
))
{
hr
=
SHCoCreateInstance
(
NULL
,
clsid
,
NULL
,
&
IID_IShellFolder
,
ppvOut
);
if
(
SUCCEEDED
(
hr
))
{
TRACE
(
"loaded %p %s
\n
"
,
*
ppvOut
,
wine_dbgstr_guid
(
clsid
));
add_iface_to_cache
(
clsid
,
*
ppvOut
);
}
}
else
TRACE
(
"found in the cache %p %s
\n
"
,
*
ppvOut
,
wine_dbgstr_guid
(
clsid
));
if
(
SUCCEEDED
(
hr
))
{
LPITEMIDLIST
pidlAbsolute
=
ILCombine
(
pidlRoot
,
pidlChild
);
IPersistFolder
*
pPF
;
IPersistFolder3
*
ppf
;
...
...
@@ -275,7 +370,7 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
if
((
clsid
=
_ILGetGUIDPointer
(
pidlChild
)))
{
/* virtual folder */
hr
=
SHELL32_CoCreateInitSF
(
pidlRoot
,
pathRoot
,
pidlChild
,
clsid
,
&
IID_IShellFolder
,
(
LPVOID
*
)
&
pSF
);
hr
=
SHELL32_CoCreateInitSF
(
pidlRoot
,
pathRoot
,
pidlChild
,
clsid
,
(
LPVOID
*
)
&
pSF
);
}
else
{
/* file system folder */
CLSID
clsidFolder
=
CLSID_ShellFSFolder
;
...
...
@@ -294,8 +389,8 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
wszDotShellClassInfo
,
wszCLSID
,
wszCLSIDValue
,
CHARS_IN_GUID
))
CLSIDFromString
(
wszCLSIDValue
,
&
clsidFolder
);
hr
=
SHELL32_CoCreateInitSF
(
pidlRoot
,
pathRoot
,
pidlChild
,
&
clsidFolder
,
&
IID_IShell
Folder
,
(
LPVOID
*
)
&
pSF
);
hr
=
SHELL32_CoCreateInitSF
(
pidlRoot
,
pathRoot
,
pidlChild
,
&
clsid
Folder
,
(
LPVOID
*
)
&
pSF
);
}
ILFree
(
pidlChild
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment