Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * shell change notification |
| 3 | * |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 4 | * Copyright 2000 Juergen Schmied |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 5 | * |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 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. |
| 10 | * |
| 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. |
| 15 | * |
| 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 |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 21 | #include <stdarg.h> |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 22 | #include <string.h> |
| 23 | |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 24 | #define NONAMELESSUNION |
| 25 | #define NONAMELESSSTRUCT |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 26 | #include "windef.h" |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 27 | #include "winbase.h" |
| 28 | #include "wine/debug.h" |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 29 | #include "wingdi.h" |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 30 | #include "shell32_main.h" |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 31 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 32 | WINE_DEFAULT_DEBUG_CHANNEL(shell); |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 33 | |
Alexandre Julliard | 19b6a49 | 2003-08-12 23:50:54 +0000 | [diff] [blame] | 34 | static CRITICAL_SECTION SHELL32_ChangenotifyCS; |
| 35 | static CRITICAL_SECTION_DEBUG critsect_debug = |
| 36 | { |
| 37 | 0, 0, &SHELL32_ChangenotifyCS, |
| 38 | { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, |
Alexandre Julliard | 20a1a20 | 2005-09-09 10:19:44 +0000 | [diff] [blame] | 39 | 0, 0, { (DWORD_PTR)(__FILE__ ": SHELL32_ChangenotifyCS") } |
Alexandre Julliard | 19b6a49 | 2003-08-12 23:50:54 +0000 | [diff] [blame] | 40 | }; |
| 41 | static CRITICAL_SECTION SHELL32_ChangenotifyCS = { &critsect_debug, -1, 0, 0, 0, 0 }; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 42 | |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 43 | typedef SHChangeNotifyEntry *LPNOTIFYREGISTER; |
| 44 | |
Juergen Schmied | 50f067b | 2000-02-26 18:44:08 +0000 | [diff] [blame] | 45 | /* internal list of notification clients (internal) */ |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 46 | typedef struct _NOTIFICATIONLIST |
| 47 | { |
| 48 | struct _NOTIFICATIONLIST *next; |
Francois Gouget | 070e749 | 2001-11-06 21:01:32 +0000 | [diff] [blame] | 49 | struct _NOTIFICATIONLIST *prev; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 50 | HWND hwnd; /* window to notify */ |
| 51 | DWORD uMsg; /* message to send */ |
Francois Gouget | 070e749 | 2001-11-06 21:01:32 +0000 | [diff] [blame] | 52 | LPNOTIFYREGISTER apidl; /* array of entries to watch*/ |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 53 | UINT cidl; /* number of pidls in array */ |
| 54 | LONG wEventMask; /* subscribed events */ |
Francois Gouget | 3ca7612 | 2003-07-15 20:53:39 +0000 | [diff] [blame] | 55 | LONG wSignalledEvent; /* event that occurred */ |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 56 | DWORD dwFlags; /* client flags */ |
Martin Fuchs | 63fecde | 2003-09-02 01:01:06 +0000 | [diff] [blame] | 57 | LPCITEMIDLIST pidlSignaled; /*pidl of the path that caused the signal*/ |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 58 | |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 59 | } NOTIFICATIONLIST, *LPNOTIFICATIONLIST; |
| 60 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 61 | static NOTIFICATIONLIST *head, *tail; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 62 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 63 | #define SHCNE_NOITEMEVENTS ( \ |
| 64 | SHCNE_ASSOCCHANGED ) |
| 65 | |
| 66 | #define SHCNE_ONEITEMEVENTS ( \ |
| 67 | SHCNE_ATTRIBUTES | SHCNE_CREATE | SHCNE_DELETE | SHCNE_DRIVEADD | \ |
| 68 | SHCNE_DRIVEADDGUI | SHCNE_DRIVEREMOVED | SHCNE_FREESPACE | \ |
| 69 | SHCNE_MEDIAINSERTED | SHCNE_MEDIAREMOVED | SHCNE_MKDIR | \ |
| 70 | SHCNE_NETSHARE | SHCNE_NETUNSHARE | SHCNE_RMDIR | \ |
| 71 | SHCNE_SERVERDISCONNECT | SHCNE_UPDATEDIR | SHCNE_UPDATEIMAGE ) |
| 72 | |
| 73 | #define SHCNE_TWOITEMEVENTS ( \ |
| 74 | SHCNE_RENAMEFOLDER | SHCNE_RENAMEITEM | SHCNE_UPDATEITEM ) |
| 75 | |
| 76 | /* for dumping events */ |
| 77 | static const char * DumpEvent( LONG event ) |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 78 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 79 | if( event == SHCNE_ALLEVENTS ) |
| 80 | return "SHCNE_ALLEVENTS"; |
| 81 | #define DUMPEV(x) ,( event & SHCNE_##x )? #x " " : "" |
| 82 | return wine_dbg_sprintf( "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s" |
| 83 | DUMPEV(RENAMEITEM) |
| 84 | DUMPEV(CREATE) |
| 85 | DUMPEV(DELETE) |
| 86 | DUMPEV(MKDIR) |
| 87 | DUMPEV(RMDIR) |
| 88 | DUMPEV(MEDIAINSERTED) |
| 89 | DUMPEV(MEDIAREMOVED) |
| 90 | DUMPEV(DRIVEREMOVED) |
| 91 | DUMPEV(DRIVEADD) |
| 92 | DUMPEV(NETSHARE) |
| 93 | DUMPEV(NETUNSHARE) |
| 94 | DUMPEV(ATTRIBUTES) |
| 95 | DUMPEV(UPDATEDIR) |
| 96 | DUMPEV(UPDATEITEM) |
| 97 | DUMPEV(SERVERDISCONNECT) |
| 98 | DUMPEV(UPDATEIMAGE) |
| 99 | DUMPEV(DRIVEADDGUI) |
| 100 | DUMPEV(RENAMEFOLDER) |
| 101 | DUMPEV(FREESPACE) |
| 102 | DUMPEV(EXTENDED_EVENT) |
| 103 | DUMPEV(ASSOCCHANGED) |
| 104 | DUMPEV(INTERRUPT) |
| 105 | ); |
| 106 | #undef DUMPEV |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 109 | static const char * NodeName(LPNOTIFICATIONLIST item) |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 110 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 111 | const char *str; |
| 112 | WCHAR path[MAX_PATH]; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 113 | |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 114 | if(SHGetPathFromIDListW(item->apidl[0].pidl, path )) |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 115 | str = wine_dbg_sprintf("%s", debugstr_w(path)); |
| 116 | else |
| 117 | str = wine_dbg_sprintf("<not a disk file>" ); |
| 118 | return str; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 119 | } |
| 120 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 121 | static void AddNode(LPNOTIFICATIONLIST item) |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 122 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 123 | TRACE("item %p\n", item ); |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 124 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 125 | /* link items */ |
| 126 | item->prev = tail; |
| 127 | item->next = NULL; |
| 128 | if( tail ) |
| 129 | tail->next = item; |
| 130 | else |
| 131 | head = item; |
| 132 | tail = item; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 133 | } |
| 134 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 135 | static LPNOTIFICATIONLIST FindNode( HANDLE hitem ) |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 136 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 137 | LPNOTIFICATIONLIST ptr; |
| 138 | for( ptr = head; ptr; ptr = ptr->next ) |
| 139 | if( ptr == (LPNOTIFICATIONLIST) hitem ) |
| 140 | return ptr; |
| 141 | return NULL; |
| 142 | } |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 143 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 144 | static void DeleteNode(LPNOTIFICATIONLIST item) |
| 145 | { |
| 146 | UINT i; |
Juergen Schmied | 50f067b | 2000-02-26 18:44:08 +0000 | [diff] [blame] | 147 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 148 | TRACE("item=%p prev=%p next=%p\n", item, item->prev, item->next); |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 149 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 150 | /* remove item from list */ |
| 151 | if( item->prev ) |
| 152 | item->prev->next = item->next; |
| 153 | else |
| 154 | head = item->next; |
| 155 | if( item->next ) |
| 156 | item->next->prev = item->prev; |
| 157 | else |
| 158 | tail = item->prev; |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 159 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 160 | /* free the item */ |
| 161 | for (i=0; i<item->cidl; i++) |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 162 | SHFree((LPITEMIDLIST)item->apidl[i].pidl); |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 163 | SHFree(item->apidl); |
| 164 | SHFree(item); |
| 165 | } |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 166 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 167 | void InitChangeNotifications(void) |
| 168 | { |
| 169 | } |
Juergen Schmied | 50f067b | 2000-02-26 18:44:08 +0000 | [diff] [blame] | 170 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 171 | void FreeChangeNotifications(void) |
| 172 | { |
| 173 | TRACE("\n"); |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 174 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 175 | EnterCriticalSection(&SHELL32_ChangenotifyCS); |
Knut St. Osmundsen | 886bdb0 | 2002-06-28 17:34:35 +0000 | [diff] [blame] | 176 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 177 | while( head ) |
| 178 | DeleteNode( head ); |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 179 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 180 | LeaveCriticalSection(&SHELL32_ChangenotifyCS); |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 181 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 182 | DeleteCriticalSection(&SHELL32_ChangenotifyCS); |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /************************************************************************* |
| 186 | * SHChangeNotifyRegister [SHELL32.2] |
| 187 | * |
| 188 | */ |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 189 | ULONG WINAPI |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 190 | SHChangeNotifyRegister( |
| 191 | HWND hwnd, |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 192 | int fSources, |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 193 | LONG wEventMask, |
Rolf Kalbermatter | c667052 | 2003-08-29 22:11:23 +0000 | [diff] [blame] | 194 | UINT uMsg, |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 195 | int cItems, |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 196 | SHChangeNotifyEntry *lpItems) |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 197 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 198 | LPNOTIFICATIONLIST item; |
Rolf Kalbermatter | c667052 | 2003-08-29 22:11:23 +0000 | [diff] [blame] | 199 | int i; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 200 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 201 | item = SHAlloc(sizeof(NOTIFICATIONLIST)); |
Juergen Schmied | 50f067b | 2000-02-26 18:44:08 +0000 | [diff] [blame] | 202 | |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 203 | TRACE("(%p,0x%08x,0x%08lx,0x%08x,%d,%p) item=%p\n", |
| 204 | hwnd, fSources, wEventMask, uMsg, cItems, lpItems, item); |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 205 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 206 | item->next = NULL; |
| 207 | item->prev = NULL; |
| 208 | item->cidl = cItems; |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 209 | item->apidl = SHAlloc(sizeof(SHChangeNotifyEntry) * cItems); |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 210 | for(i=0;i<cItems;i++) |
| 211 | { |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 212 | item->apidl[i].pidl = ILClone(lpItems[i].pidl); |
| 213 | item->apidl[i].fRecursive = lpItems[i].fRecursive; |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 214 | } |
| 215 | item->hwnd = hwnd; |
| 216 | item->uMsg = uMsg; |
| 217 | item->wEventMask = wEventMask; |
| 218 | item->wSignalledEvent = 0; |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 219 | item->dwFlags = fSources; |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 220 | |
| 221 | TRACE("new node: %s\n", NodeName( item )); |
| 222 | |
| 223 | EnterCriticalSection(&SHELL32_ChangenotifyCS); |
| 224 | |
| 225 | AddNode(item); |
| 226 | |
| 227 | LeaveCriticalSection(&SHELL32_ChangenotifyCS); |
| 228 | |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 229 | return (ULONG)item; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | /************************************************************************* |
| 233 | * SHChangeNotifyDeregister [SHELL32.4] |
| 234 | */ |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 235 | BOOL WINAPI SHChangeNotifyDeregister(ULONG hNotify) |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 236 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 237 | LPNOTIFICATIONLIST node; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 238 | |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 239 | TRACE("(0x%08lx)\n", hNotify); |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 240 | |
| 241 | EnterCriticalSection(&SHELL32_ChangenotifyCS); |
| 242 | |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 243 | node = FindNode((HANDLE)hNotify); |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 244 | if( node ) |
| 245 | DeleteNode(node); |
| 246 | |
| 247 | LeaveCriticalSection(&SHELL32_ChangenotifyCS); |
| 248 | |
| 249 | return node?TRUE:FALSE; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | /************************************************************************* |
Guy Albertelli | 60b59be | 2001-10-02 17:25:36 +0000 | [diff] [blame] | 253 | * SHChangeNotifyUpdateEntryList [SHELL32.5] |
| 254 | */ |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 255 | BOOL WINAPI SHChangeNotifyUpdateEntryList(DWORD unknown1, DWORD unknown2, |
Guy Albertelli | 60b59be | 2001-10-02 17:25:36 +0000 | [diff] [blame] | 256 | DWORD unknown3, DWORD unknown4) |
| 257 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 258 | FIXME("(0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx)\n", |
| 259 | unknown1, unknown2, unknown3, unknown4); |
Guy Albertelli | 60b59be | 2001-10-02 17:25:36 +0000 | [diff] [blame] | 260 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 261 | return -1; |
| 262 | } |
| 263 | |
Eric Pouech | 0a25896 | 2004-11-30 21:38:57 +0000 | [diff] [blame] | 264 | static BOOL should_notify( LPCITEMIDLIST changed, LPCITEMIDLIST watched, BOOL sub ) |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 265 | { |
| 266 | TRACE("%p %p %d\n", changed, watched, sub ); |
| 267 | if ( !watched ) |
| 268 | return FALSE; |
| 269 | if (ILIsEqual( watched, changed ) ) |
| 270 | return TRUE; |
| 271 | if( sub && ILIsParent( watched, changed, FALSE ) ) |
| 272 | return TRUE; |
| 273 | return FALSE; |
Guy Albertelli | 60b59be | 2001-10-02 17:25:36 +0000 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | /************************************************************************* |
Patrik Stridvall | 3ca9823 | 2001-06-20 23:03:14 +0000 | [diff] [blame] | 277 | * SHChangeNotify [SHELL32.@] |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 278 | */ |
Rolf Kalbermatter | 49e1b69 | 2003-01-21 19:36:24 +0000 | [diff] [blame] | 279 | void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2) |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 280 | { |
Eric Pouech | 0a25896 | 2004-11-30 21:38:57 +0000 | [diff] [blame] | 281 | LPCITEMIDLIST Pidls[2]; |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 282 | LPNOTIFICATIONLIST ptr; |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 283 | UINT typeFlag = uFlags & SHCNF_TYPE; |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 284 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 285 | Pidls[0] = NULL; |
| 286 | Pidls[1] = NULL; |
Juergen Schmied | 50f067b | 2000-02-26 18:44:08 +0000 | [diff] [blame] | 287 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 288 | TRACE("(0x%08lx,0x%08x,%p,%p):stub.\n", wEventId, uFlags, dwItem1, dwItem2); |
Juergen Schmied | 50f067b | 2000-02-26 18:44:08 +0000 | [diff] [blame] | 289 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 290 | if( ( wEventId & SHCNE_NOITEMEVENTS ) && ( dwItem1 || dwItem2 ) ) |
| 291 | { |
| 292 | TRACE("dwItem1 and dwItem2 are not zero, but should be\n"); |
| 293 | dwItem1 = 0; |
| 294 | dwItem2 = 0; |
| 295 | return; |
| 296 | } |
| 297 | else if( ( wEventId & SHCNE_ONEITEMEVENTS ) && dwItem2 ) |
| 298 | { |
| 299 | TRACE("dwItem2 is not zero, but should be\n"); |
| 300 | dwItem2 = 0; |
| 301 | return; |
| 302 | } |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 303 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 304 | if( ( ( wEventId & SHCNE_NOITEMEVENTS ) && |
| 305 | ( wEventId & ~SHCNE_NOITEMEVENTS ) ) || |
| 306 | ( ( wEventId & SHCNE_ONEITEMEVENTS ) && |
| 307 | ( wEventId & ~SHCNE_ONEITEMEVENTS ) ) || |
| 308 | ( ( wEventId & SHCNE_TWOITEMEVENTS ) && |
| 309 | ( wEventId & ~SHCNE_TWOITEMEVENTS ) ) ) |
| 310 | { |
| 311 | WARN("mutually incompatible events listed\n"); |
| 312 | return; |
| 313 | } |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 314 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 315 | /* convert paths in IDLists*/ |
| 316 | switch (typeFlag) |
| 317 | { |
| 318 | case SHCNF_PATHA: |
Rolf Kalbermatter | 2a49333 | 2003-09-15 22:09:46 +0000 | [diff] [blame] | 319 | if (dwItem1) Pidls[0] = SHSimpleIDListFromPathA((LPCSTR)dwItem1); |
| 320 | if (dwItem2) Pidls[1] = SHSimpleIDListFromPathA((LPCSTR)dwItem2); |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 321 | break; |
| 322 | case SHCNF_PATHW: |
Rolf Kalbermatter | 2a49333 | 2003-09-15 22:09:46 +0000 | [diff] [blame] | 323 | if (dwItem1) Pidls[0] = SHSimpleIDListFromPathW((LPCWSTR)dwItem1); |
| 324 | if (dwItem2) Pidls[1] = SHSimpleIDListFromPathW((LPCWSTR)dwItem2); |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 325 | break; |
| 326 | case SHCNF_IDLIST: |
Eric Pouech | 0a25896 | 2004-11-30 21:38:57 +0000 | [diff] [blame] | 327 | Pidls[0] = (LPCITEMIDLIST)dwItem1; |
| 328 | Pidls[1] = (LPCITEMIDLIST)dwItem2; |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 329 | break; |
| 330 | case SHCNF_PRINTERA: |
| 331 | case SHCNF_PRINTERW: |
Francois Gouget | 6b6ed72 | 2004-01-27 00:01:43 +0000 | [diff] [blame] | 332 | FIXME("SHChangeNotify with (uFlags & SHCNF_PRINTER)\n"); |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 333 | return; |
| 334 | case SHCNF_DWORD: |
| 335 | default: |
| 336 | FIXME("unknown type %08x\n",typeFlag); |
| 337 | return; |
| 338 | } |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 339 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 340 | { |
| 341 | WCHAR path[MAX_PATH]; |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 342 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 343 | if( Pidls[0] && SHGetPathFromIDListW(Pidls[0], path )) |
| 344 | TRACE("notify %08lx on item1 = %s\n", wEventId, debugstr_w(path)); |
| 345 | |
| 346 | if( Pidls[1] && SHGetPathFromIDListW(Pidls[1], path )) |
| 347 | TRACE("notify %08lx on item2 = %s\n", wEventId, debugstr_w(path)); |
| 348 | } |
Juergen Schmied | 50f067b | 2000-02-26 18:44:08 +0000 | [diff] [blame] | 349 | |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 350 | EnterCriticalSection(&SHELL32_ChangenotifyCS); |
| 351 | |
| 352 | /* loop through the list */ |
| 353 | for( ptr = head; ptr; ptr = ptr->next ) |
| 354 | { |
| 355 | BOOL notify; |
| 356 | DWORD i; |
| 357 | |
| 358 | notify = FALSE; |
| 359 | |
| 360 | TRACE("trying %p\n", ptr); |
| 361 | |
| 362 | for( i=0; (i<ptr->cidl) && !notify ; i++ ) |
| 363 | { |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 364 | LPCITEMIDLIST pidl = ptr->apidl[i].pidl; |
| 365 | BOOL subtree = ptr->apidl[i].fRecursive; |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 366 | |
| 367 | if (wEventId & ptr->wEventMask) |
| 368 | { |
| 369 | if( !pidl ) /* all ? */ |
| 370 | notify = TRUE; |
| 371 | else if( wEventId & SHCNE_NOITEMEVENTS ) |
| 372 | notify = TRUE; |
| 373 | else if( wEventId & ( SHCNE_ONEITEMEVENTS | SHCNE_TWOITEMEVENTS ) ) |
| 374 | notify = should_notify( Pidls[0], pidl, subtree ); |
| 375 | else if( wEventId & SHCNE_TWOITEMEVENTS ) |
| 376 | notify = should_notify( Pidls[1], pidl, subtree ); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | if( !notify ) |
| 381 | continue; |
| 382 | |
| 383 | ptr->pidlSignaled = ILClone(Pidls[0]); |
| 384 | |
| 385 | TRACE("notifying %s, event %s(%lx) before\n", NodeName( ptr ), DumpEvent( |
| 386 | wEventId ),wEventId ); |
| 387 | |
| 388 | ptr->wSignalledEvent |= wEventId; |
Ulrich Czekalla | a91b2ef | 2004-02-02 23:08:54 +0000 | [diff] [blame] | 389 | |
Ulrich Czekalla | ed3d86f | 2004-06-02 21:33:47 +0000 | [diff] [blame] | 390 | if (ptr->dwFlags & SHCNRF_NewDelivery) |
| 391 | SendMessageA(ptr->hwnd, ptr->uMsg, (WPARAM) ptr, (LPARAM) GetCurrentProcessId()); |
| 392 | else |
| 393 | SendMessageA(ptr->hwnd, ptr->uMsg, (WPARAM)Pidls, wEventId); |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 394 | |
| 395 | TRACE("notifying %s, event %s(%lx) after\n", NodeName( ptr ), DumpEvent( |
| 396 | wEventId ),wEventId ); |
| 397 | |
| 398 | } |
| 399 | TRACE("notify Done\n"); |
| 400 | LeaveCriticalSection(&SHELL32_ChangenotifyCS); |
| 401 | |
Rolf Kalbermatter | 2a49333 | 2003-09-15 22:09:46 +0000 | [diff] [blame] | 402 | /* if we allocated it, free it. The ANSI flag is also set in its Unicode sibling. */ |
| 403 | if ((typeFlag & SHCNF_PATHA) || (typeFlag & SHCNF_PRINTERA)) |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 404 | { |
Eric Pouech | 0a25896 | 2004-11-30 21:38:57 +0000 | [diff] [blame] | 405 | if (Pidls[0]) SHFree((LPITEMIDLIST)Pidls[0]); |
| 406 | if (Pidls[1]) SHFree((LPITEMIDLIST)Pidls[1]); |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 407 | } |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 408 | } |
| 409 | |
Patrik Stridvall | fcfacb9 | 2000-03-24 20:46:04 +0000 | [diff] [blame] | 410 | /************************************************************************* |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 411 | * NTSHChangeNotifyRegister [SHELL32.640] |
| 412 | * NOTES |
| 413 | * Idlist is an array of structures and Count specifies how many items in the array |
| 414 | * (usually just one I think). |
| 415 | */ |
| 416 | DWORD WINAPI NTSHChangeNotifyRegister( |
| 417 | HWND hwnd, |
| 418 | LONG events1, |
| 419 | LONG events2, |
| 420 | DWORD msg, |
| 421 | int count, |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 422 | SHChangeNotifyEntry *idlist) |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 423 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 424 | FIXME("(%p,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p):semi stub.\n", |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 425 | hwnd,events1,events2,msg,count,idlist); |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 426 | |
| 427 | return (DWORD) SHChangeNotifyRegister(hwnd, events1, events2, msg, count, idlist); |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | /************************************************************************* |
| 431 | * SHChangeNotification_Lock [SHELL32.644] |
| 432 | */ |
| 433 | HANDLE WINAPI SHChangeNotification_Lock( |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 434 | HANDLE hChange, |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 435 | DWORD dwProcessId, |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 436 | LPITEMIDLIST **lppidls, |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 437 | LPLONG lpwEventId) |
| 438 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 439 | DWORD i; |
| 440 | LPNOTIFICATIONLIST node; |
Eric Pouech | 0a25896 | 2004-11-30 21:38:57 +0000 | [diff] [blame] | 441 | LPCITEMIDLIST *idlist; |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 442 | |
| 443 | TRACE("%p %08lx %p %p\n", hChange, dwProcessId, lppidls, lpwEventId); |
| 444 | |
| 445 | /* EnterCriticalSection(&SHELL32_ChangenotifyCS); */ |
| 446 | |
| 447 | node = FindNode( hChange ); |
| 448 | if( node ) |
| 449 | { |
| 450 | idlist = SHAlloc( sizeof(LPCITEMIDLIST *) * node->cidl ); |
| 451 | for(i=0; i<node->cidl; i++) |
Eric Pouech | 0a25896 | 2004-11-30 21:38:57 +0000 | [diff] [blame] | 452 | idlist[i] = (LPCITEMIDLIST)node->pidlSignaled; |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 453 | *lpwEventId = node->wSignalledEvent; |
Eric Pouech | 0a25896 | 2004-11-30 21:38:57 +0000 | [diff] [blame] | 454 | *lppidls = (LPITEMIDLIST*)idlist; |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 455 | node->wSignalledEvent = 0; |
| 456 | } |
| 457 | else |
| 458 | ERR("Couldn't find %p\n", hChange ); |
| 459 | |
| 460 | /* LeaveCriticalSection(&SHELL32_ChangenotifyCS); */ |
| 461 | |
| 462 | return (HANDLE) node; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | /************************************************************************* |
| 466 | * SHChangeNotification_Unlock [SHELL32.645] |
| 467 | */ |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 468 | BOOL WINAPI SHChangeNotification_Unlock ( HANDLE hLock) |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 469 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 470 | TRACE("\n"); |
| 471 | return 1; |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | /************************************************************************* |
| 475 | * NTSHChangeNotifyDeregister [SHELL32.641] |
| 476 | */ |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 477 | DWORD WINAPI NTSHChangeNotifyDeregister(ULONG x1) |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 478 | { |
Mike McCormack | 1351e23 | 2003-06-23 19:49:40 +0000 | [diff] [blame] | 479 | FIXME("(0x%08lx):semi stub.\n",x1); |
| 480 | |
Rolf Kalbermatter | 58c0561 | 2003-09-22 19:24:13 +0000 | [diff] [blame] | 481 | return SHChangeNotifyDeregister( x1 ); |
Juergen Schmied | b070313 | 2000-02-20 18:40:55 +0000 | [diff] [blame] | 482 | } |