2000-02-20 19:40:55 +01:00
|
|
|
/*
|
|
|
|
* shell change notification
|
|
|
|
*
|
|
|
|
* Juergen Schmied <juergen.schmied@debitel.de>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "debugtools.h"
|
|
|
|
#include "pidl.h"
|
|
|
|
#include "shell32_main.h"
|
|
|
|
#include "wine/undocshell.h"
|
|
|
|
|
2000-04-08 23:06:06 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(shell);
|
2000-02-20 19:40:55 +01:00
|
|
|
|
2000-04-08 23:06:06 +02:00
|
|
|
static CRITICAL_SECTION SHELL32_ChangenotifyCS = CRITICAL_SECTION_INIT;
|
2000-02-20 19:40:55 +01:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
/* internal list of notification clients (internal) */
|
2000-02-20 19:40:55 +01:00
|
|
|
typedef struct _NOTIFICATIONLIST
|
|
|
|
{
|
|
|
|
struct _NOTIFICATIONLIST *next;
|
|
|
|
struct _NOTIFICATIONLIST *prev;
|
|
|
|
HWND hwnd; /* window to notify */
|
|
|
|
DWORD uMsg; /* message to send */
|
2000-02-26 19:44:08 +01:00
|
|
|
LPNOTIFYREGISTER apidl; /* array of entrys to watch*/
|
2000-02-20 19:40:55 +01:00
|
|
|
UINT cidl; /* number of pidls in array */
|
|
|
|
LONG wEventMask; /* subscribed events */
|
|
|
|
DWORD dwFlags; /* client flags */
|
|
|
|
} NOTIFICATIONLIST, *LPNOTIFICATIONLIST;
|
|
|
|
|
2000-04-08 23:06:06 +02:00
|
|
|
static NOTIFICATIONLIST head;
|
|
|
|
static NOTIFICATIONLIST tail;
|
2000-02-20 19:40:55 +01:00
|
|
|
|
|
|
|
void InitChangeNotifications()
|
|
|
|
{
|
2000-02-26 19:44:08 +01:00
|
|
|
TRACE("head=%p tail=%p\n", &head, &tail);
|
2000-02-20 19:40:55 +01:00
|
|
|
head.next = &tail;
|
|
|
|
tail.prev = &head;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeChangeNotifications()
|
|
|
|
{
|
|
|
|
LPNOTIFICATIONLIST ptr, item;
|
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
EnterCriticalSection(&SHELL32_ChangenotifyCS);
|
2000-02-20 19:40:55 +01:00
|
|
|
ptr = head.next;
|
|
|
|
|
|
|
|
while(ptr != &tail)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
item = ptr;
|
|
|
|
ptr = ptr->next;
|
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
TRACE("item=%p\n", item);
|
|
|
|
|
2000-02-20 19:40:55 +01:00
|
|
|
/* free the item */
|
2000-02-26 19:44:08 +01:00
|
|
|
for (i=0; i<item->cidl;i++) SHFree(item->apidl[i].pidlPath);
|
2000-02-20 19:40:55 +01:00
|
|
|
SHFree(item->apidl);
|
|
|
|
SHFree(item);
|
|
|
|
}
|
|
|
|
head.next = NULL;
|
|
|
|
tail.prev = NULL;
|
2000-02-26 19:44:08 +01:00
|
|
|
|
|
|
|
LeaveCriticalSection(&SHELL32_ChangenotifyCS);
|
|
|
|
|
|
|
|
DeleteCriticalSection(&SHELL32_ChangenotifyCS);
|
2000-02-20 19:40:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL AddNode(LPNOTIFICATIONLIST item)
|
|
|
|
{
|
|
|
|
LPNOTIFICATIONLIST last;
|
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
EnterCriticalSection(&SHELL32_ChangenotifyCS);
|
2000-02-20 19:40:55 +01:00
|
|
|
|
|
|
|
/* get last entry */
|
|
|
|
last = tail.prev;
|
|
|
|
|
|
|
|
/* link items */
|
|
|
|
last->next = item;
|
|
|
|
item->prev = last;
|
|
|
|
item->next = &tail;
|
|
|
|
tail.prev = item;
|
2000-02-26 19:44:08 +01:00
|
|
|
TRACE("item=%p prev=%p next=%p\n", item, item->prev, item->next);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&SHELL32_ChangenotifyCS);
|
2000-02-20 19:40:55 +01:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
return TRUE;
|
2000-02-20 19:40:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL DeleteNode(LPNOTIFICATIONLIST item)
|
|
|
|
{
|
|
|
|
LPNOTIFICATIONLIST ptr;
|
|
|
|
int ret = FALSE;
|
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
TRACE("item=%p\n", item);
|
|
|
|
|
|
|
|
EnterCriticalSection(&SHELL32_ChangenotifyCS);
|
2000-02-20 19:40:55 +01:00
|
|
|
|
|
|
|
ptr = head.next;
|
2000-02-26 19:44:08 +01:00
|
|
|
while((ptr != &tail) && (ret == FALSE))
|
2000-02-20 19:40:55 +01:00
|
|
|
{
|
2000-02-26 19:44:08 +01:00
|
|
|
TRACE("ptr=%p\n", ptr);
|
|
|
|
|
2000-02-20 19:40:55 +01:00
|
|
|
if (ptr == item)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
TRACE("item=%p prev=%p next=%p\n", item, item->prev, item->next);
|
|
|
|
|
2000-02-20 19:40:55 +01:00
|
|
|
/* remove item from list */
|
|
|
|
item->prev->next = item->next;
|
|
|
|
item->next->prev = item->prev;
|
|
|
|
|
|
|
|
/* free the item */
|
2000-02-26 19:44:08 +01:00
|
|
|
for (i=0; i<item->cidl;i++) SHFree(item->apidl[i].pidlPath);
|
2000-02-20 19:40:55 +01:00
|
|
|
SHFree(item->apidl);
|
|
|
|
SHFree(item);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
2000-02-26 19:44:08 +01:00
|
|
|
ptr = ptr->next;
|
2000-02-20 19:40:55 +01:00
|
|
|
}
|
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
LeaveCriticalSection(&SHELL32_ChangenotifyCS);
|
2000-02-20 19:40:55 +01:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHChangeNotifyRegister [SHELL32.2]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI
|
|
|
|
SHChangeNotifyRegister(
|
|
|
|
HWND hwnd,
|
|
|
|
LONG dwFlags,
|
|
|
|
LONG wEventMask,
|
|
|
|
DWORD uMsg,
|
|
|
|
int cItems,
|
2000-02-26 19:44:08 +01:00
|
|
|
LPCNOTIFYREGISTER lpItems)
|
2000-02-20 19:40:55 +01:00
|
|
|
{
|
|
|
|
LPNOTIFICATIONLIST item;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
item = SHAlloc(sizeof(NOTIFICATIONLIST));
|
2000-02-26 19:44:08 +01:00
|
|
|
|
|
|
|
TRACE("(0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p) item=%p\n",
|
|
|
|
hwnd,dwFlags,wEventMask,uMsg,cItems,lpItems,item);
|
|
|
|
|
2000-02-20 19:40:55 +01:00
|
|
|
item->next = NULL;
|
|
|
|
item->prev = NULL;
|
|
|
|
item->cidl = cItems;
|
|
|
|
item->apidl = SHAlloc(sizeof(NOTIFYREGISTER) * cItems);
|
|
|
|
for(i=0;i<cItems;i++)
|
|
|
|
{
|
2000-02-26 19:44:08 +01:00
|
|
|
item->apidl[i].pidlPath = ILClone(lpItems[i].pidlPath);
|
|
|
|
item->apidl[i].bWatchSubtree = lpItems[i].bWatchSubtree;
|
2000-02-20 19:40:55 +01:00
|
|
|
}
|
|
|
|
item->hwnd = hwnd;
|
|
|
|
item->uMsg = uMsg;
|
|
|
|
item->wEventMask = wEventMask;
|
|
|
|
item->dwFlags = dwFlags;
|
|
|
|
AddNode(item);
|
|
|
|
return (HANDLE)item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHChangeNotifyDeregister [SHELL32.4]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
SHChangeNotifyDeregister(
|
|
|
|
HANDLE hNotify)
|
|
|
|
{
|
|
|
|
TRACE("(0x%08x)\n",hNotify);
|
|
|
|
|
|
|
|
return DeleteNode((LPNOTIFICATIONLIST)hNotify);;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHChangeNotify [SHELL32.239]
|
|
|
|
*/
|
|
|
|
void WINAPI SHChangeNotifyW (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
|
|
|
|
{
|
2000-02-26 19:44:08 +01:00
|
|
|
LPITEMIDLIST pidl1=(LPITEMIDLIST)dwItem1, pidl2=(LPITEMIDLIST)dwItem2;
|
|
|
|
LPNOTIFICATIONLIST ptr;
|
|
|
|
|
|
|
|
TRACE("(0x%08lx,0x%08x,%p,%p):stub.\n", wEventId,uFlags,dwItem1,dwItem2);
|
|
|
|
|
|
|
|
/* convert paths in IDLists*/
|
|
|
|
if(uFlags & SHCNF_PATHA)
|
|
|
|
{
|
|
|
|
DWORD dummy;
|
|
|
|
if (dwItem1) SHILCreateFromPathA((LPCSTR)dwItem1, &pidl1, &dummy);
|
|
|
|
if (dwItem2) SHILCreateFromPathA((LPCSTR)dwItem2, &pidl2, &dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&SHELL32_ChangenotifyCS);
|
|
|
|
|
|
|
|
/* loop through the list */
|
|
|
|
ptr = head.next;
|
|
|
|
while(ptr != &tail)
|
|
|
|
{
|
|
|
|
TRACE("trying %p\n", ptr);
|
|
|
|
|
|
|
|
if(wEventId & ptr->wEventMask)
|
|
|
|
{
|
|
|
|
TRACE("notifying\n");
|
|
|
|
SendMessageA(ptr->hwnd, ptr->uMsg, (WPARAM)pidl1, (LPARAM)pidl2);
|
|
|
|
}
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&SHELL32_ChangenotifyCS);
|
|
|
|
|
|
|
|
if(uFlags & SHCNF_PATHA)
|
|
|
|
{
|
2000-03-26 20:15:26 +02:00
|
|
|
if (pidl1) SHFree(pidl1);
|
|
|
|
if (pidl2) SHFree(pidl2);
|
2000-02-26 19:44:08 +01:00
|
|
|
}
|
2000-02-20 19:40:55 +01:00
|
|
|
}
|
|
|
|
|
2000-03-24 21:46:04 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* SHChangeNotify [SHELL32.239]
|
|
|
|
*/
|
2000-02-20 19:40:55 +01:00
|
|
|
void WINAPI SHChangeNotifyA (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
|
|
|
|
{
|
2000-02-26 19:44:08 +01:00
|
|
|
LPITEMIDLIST Pidls[2];
|
|
|
|
LPNOTIFICATIONLIST ptr;
|
|
|
|
|
|
|
|
Pidls[0] = (LPITEMIDLIST)dwItem1;
|
|
|
|
Pidls[1] = (LPITEMIDLIST)dwItem2;
|
|
|
|
|
|
|
|
TRACE("(0x%08lx,0x%08x,%p,%p):stub.\n", wEventId,uFlags,dwItem1,dwItem2);
|
|
|
|
|
|
|
|
/* convert paths in IDLists*/
|
|
|
|
if(uFlags & SHCNF_PATHA)
|
|
|
|
{
|
|
|
|
DWORD dummy;
|
|
|
|
if (Pidls[0]) SHILCreateFromPathA((LPCSTR)dwItem1, &Pidls[0], &dummy);
|
|
|
|
if (Pidls[1]) SHILCreateFromPathA((LPCSTR)dwItem2, &Pidls[1], &dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&SHELL32_ChangenotifyCS);
|
|
|
|
|
|
|
|
/* loop through the list */
|
|
|
|
ptr = head.next;
|
|
|
|
while(ptr != &tail)
|
|
|
|
{
|
|
|
|
TRACE("trying %p\n", ptr);
|
|
|
|
|
|
|
|
if(wEventId & ptr->wEventMask)
|
|
|
|
{
|
|
|
|
TRACE("notifying\n");
|
|
|
|
SendMessageA(ptr->hwnd, ptr->uMsg, (WPARAM)&Pidls, (LPARAM)wEventId);
|
|
|
|
}
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&SHELL32_ChangenotifyCS);
|
|
|
|
|
|
|
|
/* if we allocated it, free it */
|
|
|
|
if(uFlags & SHCNF_PATHA)
|
|
|
|
{
|
2000-03-26 20:15:26 +02:00
|
|
|
if (Pidls[0]) SHFree(Pidls[0]);
|
|
|
|
if (Pidls[1]) SHFree(Pidls[1]);
|
2000-02-26 19:44:08 +01:00
|
|
|
}
|
2000-02-20 19:40:55 +01:00
|
|
|
}
|
|
|
|
|
2000-03-24 21:46:04 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* SHChangeNotifyAW [SHELL32.239]
|
|
|
|
*/
|
2000-02-20 19:40:55 +01:00
|
|
|
void WINAPI SHChangeNotifyAW (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
|
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
if(SHELL_OsIsUnicode())
|
2000-02-26 14:17:55 +01:00
|
|
|
SHChangeNotifyW (wEventId, uFlags, dwItem1, dwItem2);
|
|
|
|
else
|
|
|
|
SHChangeNotifyA (wEventId, uFlags, dwItem1, dwItem2);
|
2000-02-20 19:40:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* NTSHChangeNotifyRegister [SHELL32.640]
|
|
|
|
* NOTES
|
|
|
|
* Idlist is an array of structures and Count specifies how many items in the array
|
|
|
|
* (usually just one I think).
|
|
|
|
*/
|
|
|
|
DWORD WINAPI NTSHChangeNotifyRegister(
|
|
|
|
HWND hwnd,
|
|
|
|
LONG events1,
|
|
|
|
LONG events2,
|
|
|
|
DWORD msg,
|
|
|
|
int count,
|
|
|
|
LPNOTIFYREGISTER idlist)
|
|
|
|
{
|
|
|
|
FIXME("(0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p):stub.\n",
|
|
|
|
hwnd,events1,events2,msg,count,idlist);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHChangeNotification_Lock [SHELL32.644]
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI SHChangeNotification_Lock(
|
|
|
|
HANDLE hMemoryMap,
|
|
|
|
DWORD dwProcessId,
|
|
|
|
LPCITEMIDLIST **lppidls,
|
|
|
|
LPLONG lpwEventId)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHChangeNotification_Unlock [SHELL32.645]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SHChangeNotification_Unlock (
|
|
|
|
HANDLE hLock)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* NTSHChangeNotifyDeregister [SHELL32.641]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI NTSHChangeNotifyDeregister(LONG x1)
|
|
|
|
{
|
|
|
|
FIXME("(0x%08lx):stub.\n",x1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|