1 | /* $Id: changenotify.c,v 1.1 2000-08-30 13:52:50 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 |
|
---|
20 | DEFAULT_DEBUG_CHANNEL(shell);
|
---|
21 |
|
---|
22 | static CRITICAL_SECTION SHELL32_ChangenotifyCS = CRITICAL_SECTION_INIT;
|
---|
23 |
|
---|
24 | /* internal list of notification clients (internal) */
|
---|
25 | typedef 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 entrys to watch*/
|
---|
32 | UINT cidl; /* number of pidls in array */
|
---|
33 | LONG wEventMask; /* subscribed events */
|
---|
34 | DWORD dwFlags; /* client flags */
|
---|
35 | } NOTIFICATIONLIST, *LPNOTIFICATIONLIST;
|
---|
36 |
|
---|
37 | static NOTIFICATIONLIST head;
|
---|
38 | static NOTIFICATIONLIST tail;
|
---|
39 |
|
---|
40 | void InitChangeNotifications()
|
---|
41 | {
|
---|
42 | TRACE("head=%p tail=%p\n", &head, &tail);
|
---|
43 | head.next = &tail;
|
---|
44 | tail.prev = &head;
|
---|
45 | }
|
---|
46 |
|
---|
47 | void 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 |
|
---|
77 | static 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 |
|
---|
98 | static 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 | */
|
---|
140 | HANDLE WINAPI
|
---|
141 | SHChangeNotifyRegister(
|
---|
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 | */
|
---|
177 | BOOL WINAPI
|
---|
178 | SHChangeNotifyDeregister(
|
---|
179 | HANDLE hNotify)
|
---|
180 | {
|
---|
181 | TRACE("(0x%08x)\n",hNotify);
|
---|
182 |
|
---|
183 | return DeleteNode((LPNOTIFICATIONLIST)hNotify);;
|
---|
184 | }
|
---|
185 |
|
---|
186 | /*************************************************************************
|
---|
187 | * SHChangeNotify [SHELL32.239]
|
---|
188 | */
|
---|
189 | void WINAPI SHChangeNotifyW (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
|
---|
190 | {
|
---|
191 | LPITEMIDLIST pidl1=(LPITEMIDLIST)dwItem1, pidl2=(LPITEMIDLIST)dwItem2;
|
---|
192 | LPNOTIFICATIONLIST ptr;
|
---|
193 |
|
---|
194 | TRACE("(0x%08lx,0x%08x,%p,%p):stub.\n", wEventId,uFlags,dwItem1,dwItem2);
|
---|
195 |
|
---|
196 | /* convert paths in IDLists*/
|
---|
197 | if(uFlags & SHCNF_PATHA)
|
---|
198 | {
|
---|
199 | DWORD dummy;
|
---|
200 | if (dwItem1) SHILCreateFromPathA((LPCSTR)dwItem1, &pidl1, &dummy);
|
---|
201 | if (dwItem2) SHILCreateFromPathA((LPCSTR)dwItem2, &pidl2, &dummy);
|
---|
202 | }
|
---|
203 |
|
---|
204 | EnterCriticalSection(&SHELL32_ChangenotifyCS);
|
---|
205 |
|
---|
206 | /* loop through the list */
|
---|
207 | ptr = head.next;
|
---|
208 | while(ptr != &tail)
|
---|
209 | {
|
---|
210 | TRACE("trying %p\n", ptr);
|
---|
211 |
|
---|
212 | if(wEventId & ptr->wEventMask)
|
---|
213 | {
|
---|
214 | TRACE("notifying\n");
|
---|
215 | SendMessageA(ptr->hwnd, ptr->uMsg, (WPARAM)pidl1, (LPARAM)pidl2);
|
---|
216 | }
|
---|
217 | ptr = ptr->next;
|
---|
218 | }
|
---|
219 |
|
---|
220 | LeaveCriticalSection(&SHELL32_ChangenotifyCS);
|
---|
221 |
|
---|
222 | if(uFlags & SHCNF_PATHA)
|
---|
223 | {
|
---|
224 | if (pidl1) SHFree(pidl1);
|
---|
225 | if (pidl2) SHFree(pidl2);
|
---|
226 | }
|
---|
227 | }
|
---|
228 |
|
---|
229 | /*************************************************************************
|
---|
230 | * SHChangeNotify [SHELL32.239]
|
---|
231 | */
|
---|
232 | void WINAPI SHChangeNotifyA (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
|
---|
233 | {
|
---|
234 | LPITEMIDLIST Pidls[2];
|
---|
235 | LPNOTIFICATIONLIST ptr;
|
---|
236 |
|
---|
237 | Pidls[0] = (LPITEMIDLIST)dwItem1;
|
---|
238 | Pidls[1] = (LPITEMIDLIST)dwItem2;
|
---|
239 |
|
---|
240 | TRACE("(0x%08lx,0x%08x,%p,%p):stub.\n", wEventId,uFlags,dwItem1,dwItem2);
|
---|
241 |
|
---|
242 | /* convert paths in IDLists*/
|
---|
243 | if(uFlags & SHCNF_PATHA)
|
---|
244 | {
|
---|
245 | DWORD dummy;
|
---|
246 | if (Pidls[0]) SHILCreateFromPathA((LPCSTR)dwItem1, &Pidls[0], &dummy);
|
---|
247 | if (Pidls[1]) SHILCreateFromPathA((LPCSTR)dwItem2, &Pidls[1], &dummy);
|
---|
248 | }
|
---|
249 |
|
---|
250 | EnterCriticalSection(&SHELL32_ChangenotifyCS);
|
---|
251 |
|
---|
252 | /* loop through the list */
|
---|
253 | ptr = head.next;
|
---|
254 | while(ptr != &tail)
|
---|
255 | {
|
---|
256 | TRACE("trying %p\n", ptr);
|
---|
257 |
|
---|
258 | if(wEventId & ptr->wEventMask)
|
---|
259 | {
|
---|
260 | TRACE("notifying\n");
|
---|
261 | SendMessageA(ptr->hwnd, ptr->uMsg, (WPARAM)&Pidls, (LPARAM)wEventId);
|
---|
262 | }
|
---|
263 | ptr = ptr->next;
|
---|
264 | }
|
---|
265 |
|
---|
266 | LeaveCriticalSection(&SHELL32_ChangenotifyCS);
|
---|
267 |
|
---|
268 | /* if we allocated it, free it */
|
---|
269 | if(uFlags & SHCNF_PATHA)
|
---|
270 | {
|
---|
271 | if (Pidls[0]) SHFree(Pidls[0]);
|
---|
272 | if (Pidls[1]) SHFree(Pidls[1]);
|
---|
273 | }
|
---|
274 | }
|
---|
275 |
|
---|
276 | /*************************************************************************
|
---|
277 | * SHChangeNotifyAW [SHELL32.239]
|
---|
278 | */
|
---|
279 | void WINAPI SHChangeNotifyAW (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
|
---|
280 | {
|
---|
281 | if(SHELL_OsIsUnicode())
|
---|
282 | SHChangeNotifyW (wEventId, uFlags, dwItem1, dwItem2);
|
---|
283 | else
|
---|
284 | SHChangeNotifyA (wEventId, uFlags, dwItem1, dwItem2);
|
---|
285 | }
|
---|
286 |
|
---|
287 | /*************************************************************************
|
---|
288 | * NTSHChangeNotifyRegister [SHELL32.640]
|
---|
289 | * NOTES
|
---|
290 | * Idlist is an array of structures and Count specifies how many items in the array
|
---|
291 | * (usually just one I think).
|
---|
292 | */
|
---|
293 | DWORD WINAPI NTSHChangeNotifyRegister(
|
---|
294 | HWND hwnd,
|
---|
295 | LONG events1,
|
---|
296 | LONG events2,
|
---|
297 | DWORD msg,
|
---|
298 | int count,
|
---|
299 | LPNOTIFYREGISTER idlist)
|
---|
300 | {
|
---|
301 | FIXME("(0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p):stub.\n",
|
---|
302 | hwnd,events1,events2,msg,count,idlist);
|
---|
303 | return 0;
|
---|
304 | }
|
---|
305 |
|
---|
306 | /*************************************************************************
|
---|
307 | * SHChangeNotification_Lock [SHELL32.644]
|
---|
308 | */
|
---|
309 | HANDLE WINAPI SHChangeNotification_Lock(
|
---|
310 | HANDLE hMemoryMap,
|
---|
311 | DWORD dwProcessId,
|
---|
312 | LPCITEMIDLIST **lppidls,
|
---|
313 | LPLONG lpwEventId)
|
---|
314 | {
|
---|
315 | FIXME("\n");
|
---|
316 | return 0;
|
---|
317 | }
|
---|
318 |
|
---|
319 | /*************************************************************************
|
---|
320 | * SHChangeNotification_Unlock [SHELL32.645]
|
---|
321 | */
|
---|
322 | BOOL WINAPI SHChangeNotification_Unlock (
|
---|
323 | HANDLE hLock)
|
---|
324 | {
|
---|
325 | FIXME("\n");
|
---|
326 | return 0;
|
---|
327 | }
|
---|
328 |
|
---|
329 | /*************************************************************************
|
---|
330 | * NTSHChangeNotifyDeregister [SHELL32.641]
|
---|
331 | */
|
---|
332 | DWORD WINAPI NTSHChangeNotifyDeregister(LONG x1)
|
---|
333 | {
|
---|
334 | FIXME("(0x%08lx):stub.\n",x1);
|
---|
335 | return 0;
|
---|
336 | }
|
---|
337 |
|
---|