2 * shell change notification
4 * Copyright 2000 Juergen Schmied
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/debug.h"
25 #include "shell32_main.h"
26 #include "undocshell.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
30 static CRITICAL_SECTION SHELL32_ChangenotifyCS
= CRITICAL_SECTION_INIT("SHELL32_ChangenotifyCS");
32 /* internal list of notification clients (internal) */
33 typedef struct _NOTIFICATIONLIST
35 struct _NOTIFICATIONLIST
*next
;
36 struct _NOTIFICATIONLIST
*prev
;
37 HWND hwnd
; /* window to notify */
38 DWORD uMsg
; /* message to send */
39 LPNOTIFYREGISTER apidl
; /* array of entries to watch*/
40 UINT cidl
; /* number of pidls in array */
41 LONG wEventMask
; /* subscribed events */
42 DWORD dwFlags
; /* client flags */
43 } NOTIFICATIONLIST
, *LPNOTIFICATIONLIST
;
45 static NOTIFICATIONLIST head
;
46 static NOTIFICATIONLIST tail
;
48 void InitChangeNotifications()
50 TRACE("head=%p tail=%p\n", &head
, &tail
);
55 void FreeChangeNotifications()
57 LPNOTIFICATIONLIST ptr
, item
;
61 EnterCriticalSection(&SHELL32_ChangenotifyCS
);
70 TRACE("item=%p\n", item
);
73 for (i
=0; i
<item
->cidl
;i
++) SHFree(item
->apidl
[i
].pidlPath
);
80 LeaveCriticalSection(&SHELL32_ChangenotifyCS
);
82 DeleteCriticalSection(&SHELL32_ChangenotifyCS
);
85 static BOOL
AddNode(LPNOTIFICATIONLIST item
)
87 LPNOTIFICATIONLIST last
;
89 EnterCriticalSection(&SHELL32_ChangenotifyCS
);
99 TRACE("item=%p prev=%p next=%p\n", item
, item
->prev
, item
->next
);
101 LeaveCriticalSection(&SHELL32_ChangenotifyCS
);
106 static BOOL
DeleteNode(LPNOTIFICATIONLIST item
)
108 LPNOTIFICATIONLIST ptr
;
111 TRACE("item=%p\n", item
);
113 EnterCriticalSection(&SHELL32_ChangenotifyCS
);
118 TRACE("ptr=%p\n", ptr
);
124 TRACE("item=%p prev=%p next=%p\n", item
, item
->prev
, item
->next
);
126 /* remove item from list */
127 item
->prev
->next
= item
->next
;
128 item
->next
->prev
= item
->prev
;
131 for (i
=0; i
<item
->cidl
;i
++) SHFree(item
->apidl
[i
].pidlPath
);
141 LeaveCriticalSection(&SHELL32_ChangenotifyCS
);
146 /*************************************************************************
147 * SHChangeNotifyRegister [SHELL32.2]
151 SHChangeNotifyRegister(
157 LPCNOTIFYREGISTER lpItems
)
159 LPNOTIFICATIONLIST item
;
162 item
= SHAlloc(sizeof(NOTIFICATIONLIST
));
164 TRACE("(%p,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p) item=%p\n",
165 hwnd
,dwFlags
,wEventMask
,uMsg
,cItems
,lpItems
,item
);
170 item
->apidl
= SHAlloc(sizeof(NOTIFYREGISTER
) * cItems
);
171 for(i
=0;i
<cItems
;i
++)
173 item
->apidl
[i
].pidlPath
= ILClone(lpItems
[i
].pidlPath
);
174 item
->apidl
[i
].bWatchSubtree
= lpItems
[i
].bWatchSubtree
;
178 item
->wEventMask
= wEventMask
;
179 item
->dwFlags
= dwFlags
;
184 /*************************************************************************
185 * SHChangeNotifyDeregister [SHELL32.4]
188 SHChangeNotifyDeregister(
191 TRACE("(%p)\n",hNotify
);
193 return DeleteNode((LPNOTIFICATIONLIST
)hNotify
);
196 /*************************************************************************
197 * SHChangeNotifyUpdateEntryList [SHELL32.5]
200 SHChangeNotifyUpdateEntryList(DWORD unknown1
, DWORD unknown2
,
201 DWORD unknown3
, DWORD unknown4
)
203 FIXME("(0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx)\n",
204 unknown1
, unknown2
, unknown3
, unknown4
);
209 /*************************************************************************
210 * SHChangeNotify [SHELL32.@]
212 void WINAPI
SHChangeNotifyW (LONG wEventId
, UINT uFlags
, LPCVOID dwItem1
, LPCVOID dwItem2
)
214 LPITEMIDLIST pidl1
=(LPITEMIDLIST
)dwItem1
, pidl2
=(LPITEMIDLIST
)dwItem2
;
215 LPNOTIFICATIONLIST ptr
;
217 TRACE("(0x%08lx,0x%08x,%p,%p):stub.\n", wEventId
,uFlags
,dwItem1
,dwItem2
);
219 /* convert paths in IDLists*/
220 if(uFlags
& SHCNF_PATHA
)
223 if (dwItem1
) SHILCreateFromPathA((LPCSTR
)dwItem1
, &pidl1
, &dummy
);
224 if (dwItem2
) SHILCreateFromPathA((LPCSTR
)dwItem2
, &pidl2
, &dummy
);
227 EnterCriticalSection(&SHELL32_ChangenotifyCS
);
229 /* loop through the list */
233 TRACE("trying %p\n", ptr
);
235 if(wEventId
& ptr
->wEventMask
)
237 TRACE("notifying\n");
238 SendMessageA(ptr
->hwnd
, ptr
->uMsg
, (WPARAM
)pidl1
, (LPARAM
)pidl2
);
243 LeaveCriticalSection(&SHELL32_ChangenotifyCS
);
245 if(uFlags
& SHCNF_PATHA
)
247 if (pidl1
) SHFree(pidl1
);
248 if (pidl2
) SHFree(pidl2
);
252 /*************************************************************************
253 * SHChangeNotify [SHELL32.@]
255 void WINAPI
SHChangeNotifyA (LONG wEventId
, UINT uFlags
, LPCVOID dwItem1
, LPCVOID dwItem2
)
257 LPITEMIDLIST Pidls
[2];
258 LPNOTIFICATIONLIST ptr
;
260 Pidls
[0] = (LPITEMIDLIST
)dwItem1
;
261 Pidls
[1] = (LPITEMIDLIST
)dwItem2
;
263 TRACE("(0x%08lx,0x%08x,%p,%p):stub.\n", wEventId
,uFlags
,dwItem1
,dwItem2
);
265 /* convert paths in IDLists*/
266 if(uFlags
& SHCNF_PATHA
)
269 if (Pidls
[0]) SHILCreateFromPathA((LPCSTR
)dwItem1
, &Pidls
[0], &dummy
);
270 if (Pidls
[1]) SHILCreateFromPathA((LPCSTR
)dwItem2
, &Pidls
[1], &dummy
);
273 EnterCriticalSection(&SHELL32_ChangenotifyCS
);
275 /* loop through the list */
279 TRACE("trying %p\n", ptr
);
281 if(wEventId
& ptr
->wEventMask
)
283 TRACE("notifying\n");
284 SendMessageA(ptr
->hwnd
, ptr
->uMsg
, (WPARAM
)&Pidls
, (LPARAM
)wEventId
);
289 LeaveCriticalSection(&SHELL32_ChangenotifyCS
);
291 /* if we allocated it, free it */
292 if(uFlags
& SHCNF_PATHA
)
294 if (Pidls
[0]) SHFree(Pidls
[0]);
295 if (Pidls
[1]) SHFree(Pidls
[1]);
299 /*************************************************************************
300 * SHChangeNotify [SHELL32.@]
302 void WINAPI
SHChangeNotifyAW (LONG wEventId
, UINT uFlags
, LPCVOID dwItem1
, LPCVOID dwItem2
)
304 if(SHELL_OsIsUnicode())
305 SHChangeNotifyW (wEventId
, uFlags
, dwItem1
, dwItem2
);
307 SHChangeNotifyA (wEventId
, uFlags
, dwItem1
, dwItem2
);
310 /*************************************************************************
311 * NTSHChangeNotifyRegister [SHELL32.640]
313 * Idlist is an array of structures and Count specifies how many items in the array
314 * (usually just one I think).
316 DWORD WINAPI
NTSHChangeNotifyRegister(
322 LPNOTIFYREGISTER idlist
)
324 FIXME("(%p,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p):stub.\n",
325 hwnd
,events1
,events2
,msg
,count
,idlist
);
329 /*************************************************************************
330 * SHChangeNotification_Lock [SHELL32.644]
332 HANDLE WINAPI
SHChangeNotification_Lock(
335 LPCITEMIDLIST
**lppidls
,
342 /*************************************************************************
343 * SHChangeNotification_Unlock [SHELL32.645]
345 BOOL WINAPI
SHChangeNotification_Unlock (
352 /*************************************************************************
353 * NTSHChangeNotifyDeregister [SHELL32.641]
355 DWORD WINAPI
NTSHChangeNotifyDeregister(LONG x1
)
357 FIXME("(0x%08lx):stub.\n",x1
);