source: trunk/src/shell32/changenotify.c@ 8266

Last change on this file since 8266 was 8048, checked in by sandervl, 23 years ago

PH: Wine resync + OS2 integration

File size: 7.9 KB
Line 
1/* $Id: changenotify.c,v 1.2 2002-03-08 11:00:58 sandervl Exp $ */
2/*
3 * shell change notification
4 *
5 * Juergen Schmied <juergen.schmied@debitel.de>
6 *
7 */
8#ifdef __WIN32OS2__
9#define ICOM_CINTERFACE 1
10#include <odin.h>
11#endif
12
13#include <string.h>
14
15#include "debugtools.h"
16#include "pidl.h"
17#include "shell32_main.h"
18#include "wine/undocshell.h"
19
20DEFAULT_DEBUG_CHANNEL(shell);
21
22static CRITICAL_SECTION SHELL32_ChangenotifyCS = CRITICAL_SECTION_INIT;
23
24/* internal list of notification clients (internal) */
25typedef struct _NOTIFICATIONLIST
26{
27 struct _NOTIFICATIONLIST *next;
28 struct _NOTIFICATIONLIST *prev;
29 HWND hwnd; /* window to notify */
30 DWORD uMsg; /* message to send */
31 LPNOTIFYREGISTER apidl; /* array of entries to watch*/
32 UINT cidl; /* number of pidls in array */
33 LONG wEventMask; /* subscribed events */
34 DWORD dwFlags; /* client flags */
35} NOTIFICATIONLIST, *LPNOTIFICATIONLIST;
36
37static NOTIFICATIONLIST head;
38static NOTIFICATIONLIST tail;
39
40void InitChangeNotifications()
41{
42 TRACE("head=%p tail=%p\n", &head, &tail);
43 head.next = &tail;
44 tail.prev = &head;
45}
46
47void FreeChangeNotifications()
48{
49 LPNOTIFICATIONLIST ptr, item;
50
51 TRACE("\n");
52
53 EnterCriticalSection(&SHELL32_ChangenotifyCS);
54 ptr = head.next;
55
56 while(ptr != &tail)
57 {
58 int i;
59 item = ptr;
60 ptr = ptr->next;
61
62 TRACE("item=%p\n", item);
63
64 /* free the item */
65 for (i=0; i<item->cidl;i++) SHFree(item->apidl[i].pidlPath);
66 SHFree(item->apidl);
67 SHFree(item);
68 }
69 head.next = NULL;
70 tail.prev = NULL;
71
72 LeaveCriticalSection(&SHELL32_ChangenotifyCS);
73
74 DeleteCriticalSection(&SHELL32_ChangenotifyCS);
75}
76
77static BOOL AddNode(LPNOTIFICATIONLIST item)
78{
79 LPNOTIFICATIONLIST last;
80
81 EnterCriticalSection(&SHELL32_ChangenotifyCS);
82
83 /* get last entry */
84 last = tail.prev;
85
86 /* link items */
87 last->next = item;
88 item->prev = last;
89 item->next = &tail;
90 tail.prev = item;
91 TRACE("item=%p prev=%p next=%p\n", item, item->prev, item->next);
92
93 LeaveCriticalSection(&SHELL32_ChangenotifyCS);
94
95 return TRUE;
96}
97
98static BOOL DeleteNode(LPNOTIFICATIONLIST item)
99{
100 LPNOTIFICATIONLIST ptr;
101 int ret = FALSE;
102
103 TRACE("item=%p\n", item);
104
105 EnterCriticalSection(&SHELL32_ChangenotifyCS);
106
107 ptr = head.next;
108 while((ptr != &tail) && (ret == FALSE))
109 {
110 TRACE("ptr=%p\n", ptr);
111
112 if (ptr == item)
113 {
114 int i;
115
116 TRACE("item=%p prev=%p next=%p\n", item, item->prev, item->next);
117
118 /* remove item from list */
119 item->prev->next = item->next;
120 item->next->prev = item->prev;
121
122 /* free the item */
123 for (i=0; i<item->cidl;i++) SHFree(item->apidl[i].pidlPath);
124 SHFree(item->apidl);
125 SHFree(item);
126 ret = TRUE;
127 }
128 ptr = ptr->next;
129 }
130
131 LeaveCriticalSection(&SHELL32_ChangenotifyCS);
132 return ret;
133
134}
135
136/*************************************************************************
137 * SHChangeNotifyRegister [SHELL32.2]
138 *
139 */
140HANDLE WINAPI
141SHChangeNotifyRegister(
142 HWND hwnd,
143 LONG dwFlags,
144 LONG wEventMask,
145 DWORD uMsg,
146 int cItems,
147 LPCNOTIFYREGISTER lpItems)
148{
149 LPNOTIFICATIONLIST item;
150 int i;
151
152 item = SHAlloc(sizeof(NOTIFICATIONLIST));
153
154 TRACE("(0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p) item=%p\n",
155 hwnd,dwFlags,wEventMask,uMsg,cItems,lpItems,item);
156
157 item->next = NULL;
158 item->prev = NULL;
159 item->cidl = cItems;
160 item->apidl = SHAlloc(sizeof(NOTIFYREGISTER) * cItems);
161 for(i=0;i<cItems;i++)
162 {
163 item->apidl[i].pidlPath = ILClone(lpItems[i].pidlPath);
164 item->apidl[i].bWatchSubtree = lpItems[i].bWatchSubtree;
165 }
166 item->hwnd = hwnd;
167 item->uMsg = uMsg;
168 item->wEventMask = wEventMask;
169 item->dwFlags = dwFlags;
170 AddNode(item);
171 return (HANDLE)item;
172}
173
174/*************************************************************************
175 * SHChangeNotifyDeregister [SHELL32.4]
176 */
177BOOL WINAPI
178SHChangeNotifyDeregister(
179 HANDLE hNotify)
180{
181 TRACE("(0x%08x)\n",hNotify);
182
183 return DeleteNode((LPNOTIFICATIONLIST)hNotify);;
184}
185
186/*************************************************************************
187 * SHChangeNotifyUpdateEntryList [SHELL32.5]
188 */
189BOOL WINAPI
190SHChangeNotifyUpdateEntryList(DWORD unknown1, DWORD unknown2,
191 DWORD unknown3, DWORD unknown4)
192{
193 FIXME("(0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx)\n",
194 unknown1, unknown2, unknown3, unknown4);
195
196 return -1;
197}
198
199/*************************************************************************
200 * SHChangeNotify [SHELL32.239]
201 */
202void WINAPI SHChangeNotifyW (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
203{
204 LPITEMIDLIST pidl1=(LPITEMIDLIST)dwItem1, pidl2=(LPITEMIDLIST)dwItem2;
205 LPNOTIFICATIONLIST ptr;
206
207 TRACE("(0x%08lx,0x%08x,%p,%p):stub.\n", wEventId,uFlags,dwItem1,dwItem2);
208
209 /* convert paths in IDLists*/
210 if(uFlags & SHCNF_PATHA)
211 {
212 DWORD dummy;
213 if (dwItem1) SHILCreateFromPathA((LPCSTR)dwItem1, &pidl1, &dummy);
214 if (dwItem2) SHILCreateFromPathA((LPCSTR)dwItem2, &pidl2, &dummy);
215 }
216
217 EnterCriticalSection(&SHELL32_ChangenotifyCS);
218
219 /* loop through the list */
220 ptr = head.next;
221 while(ptr != &tail)
222 {
223 TRACE("trying %p\n", ptr);
224
225 if(wEventId & ptr->wEventMask)
226 {
227 TRACE("notifying\n");
228 SendMessageA(ptr->hwnd, ptr->uMsg, (WPARAM)pidl1, (LPARAM)pidl2);
229 }
230 ptr = ptr->next;
231 }
232
233 LeaveCriticalSection(&SHELL32_ChangenotifyCS);
234
235 if(uFlags & SHCNF_PATHA)
236 {
237 if (pidl1) SHFree(pidl1);
238 if (pidl2) SHFree(pidl2);
239 }
240}
241
242/*************************************************************************
243 * SHChangeNotify [SHELL32.239]
244 */
245void WINAPI SHChangeNotifyA (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
246{
247 LPITEMIDLIST Pidls[2];
248 LPNOTIFICATIONLIST ptr;
249
250 Pidls[0] = (LPITEMIDLIST)dwItem1;
251 Pidls[1] = (LPITEMIDLIST)dwItem2;
252
253 TRACE("(0x%08lx,0x%08x,%p,%p):stub.\n", wEventId,uFlags,dwItem1,dwItem2);
254
255 /* convert paths in IDLists*/
256 if(uFlags & SHCNF_PATHA)
257 {
258 DWORD dummy;
259 if (Pidls[0]) SHILCreateFromPathA((LPCSTR)dwItem1, &Pidls[0], &dummy);
260 if (Pidls[1]) SHILCreateFromPathA((LPCSTR)dwItem2, &Pidls[1], &dummy);
261 }
262
263 EnterCriticalSection(&SHELL32_ChangenotifyCS);
264
265 /* loop through the list */
266 ptr = head.next;
267 while(ptr != &tail)
268 {
269 TRACE("trying %p\n", ptr);
270
271 if(wEventId & ptr->wEventMask)
272 {
273 TRACE("notifying\n");
274 SendMessageA(ptr->hwnd, ptr->uMsg, (WPARAM)&Pidls, (LPARAM)wEventId);
275 }
276 ptr = ptr->next;
277 }
278
279 LeaveCriticalSection(&SHELL32_ChangenotifyCS);
280
281 /* if we allocated it, free it */
282 if(uFlags & SHCNF_PATHA)
283 {
284 if (Pidls[0]) SHFree(Pidls[0]);
285 if (Pidls[1]) SHFree(Pidls[1]);
286 }
287}
288
289/*************************************************************************
290 * SHChangeNotifyAW [SHELL32.239]
291 */
292void WINAPI SHChangeNotifyAW (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
293{
294 if(SHELL_OsIsUnicode())
295 SHChangeNotifyW (wEventId, uFlags, dwItem1, dwItem2);
296 else
297 SHChangeNotifyA (wEventId, uFlags, dwItem1, dwItem2);
298}
299
300/*************************************************************************
301 * NTSHChangeNotifyRegister [SHELL32.640]
302 * NOTES
303 * Idlist is an array of structures and Count specifies how many items in the array
304 * (usually just one I think).
305 */
306DWORD WINAPI NTSHChangeNotifyRegister(
307 HWND hwnd,
308 LONG events1,
309 LONG events2,
310 DWORD msg,
311 int count,
312 LPNOTIFYREGISTER idlist)
313{
314 FIXME("(0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p):stub.\n",
315 hwnd,events1,events2,msg,count,idlist);
316 return 0;
317}
318
319/*************************************************************************
320 * SHChangeNotification_Lock [SHELL32.644]
321 */
322HANDLE WINAPI SHChangeNotification_Lock(
323 HANDLE hMemoryMap,
324 DWORD dwProcessId,
325 LPCITEMIDLIST **lppidls,
326 LPLONG lpwEventId)
327{
328 FIXME("\n");
329 return 0;
330}
331
332/*************************************************************************
333 * SHChangeNotification_Unlock [SHELL32.645]
334 */
335BOOL WINAPI SHChangeNotification_Unlock (
336 HANDLE hLock)
337{
338 FIXME("\n");
339 return 0;
340}
341
342/*************************************************************************
343 * NTSHChangeNotifyDeregister [SHELL32.641]
344 */
345DWORD WINAPI NTSHChangeNotifyDeregister(LONG x1)
346{
347 FIXME("(0x%08lx):stub.\n",x1);
348 return 0;
349}
350
Note: See TracBrowser for help on using the repository browser.