2000-02-20 19:40:55 +01:00
|
|
|
/*
|
|
|
|
* shell change notification
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright 2000 Juergen Schmied
|
2000-02-20 19:40:55 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-02-20 19:40:55 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-02-20 19:40:55 +01:00
|
|
|
#include "pidl.h"
|
|
|
|
#include "shell32_main.h"
|
2001-08-16 20:49:56 +02:00
|
|
|
#include "undocshell.h"
|
2000-02-20 19:40:55 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
2000-02-20 19:40:55 +01:00
|
|
|
|
2001-08-16 20:12:56 +02:00
|
|
|
static CRITICAL_SECTION SHELL32_ChangenotifyCS = CRITICAL_SECTION_INIT("SHELL32_ChangenotifyCS");
|
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;
|
2001-11-06 22:01:32 +01:00
|
|
|
struct _NOTIFICATIONLIST *prev;
|
2000-02-20 19:40:55 +01:00
|
|
|
HWND hwnd; /* window to notify */
|
|
|
|
DWORD uMsg; /* message to send */
|
2001-11-06 22:01:32 +01:00
|
|
|
LPNOTIFYREGISTER apidl; /* array of entries 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)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2000-02-20 19:40:55 +01:00
|
|
|
int i;
|
|
|
|
item = ptr;
|
|
|
|
ptr = ptr->next;
|
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
TRACE("item=%p\n", item);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
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;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
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))
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2000-02-26 19:44:08 +01:00
|
|
|
TRACE("ptr=%p\n", ptr);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:40:55 +01:00
|
|
|
if (ptr == item)
|
|
|
|
{
|
|
|
|
int i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
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
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
LeaveCriticalSection(&SHELL32_ChangenotifyCS);
|
2000-02-20 19:40:55 +01:00
|
|
|
return ret;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:40:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* 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);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
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);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return DeleteNode((LPNOTIFICATIONLIST)hNotify);
|
2000-02-20 19:40:55 +01:00
|
|
|
}
|
|
|
|
|
2001-10-02 19:25:36 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* SHChangeNotifyUpdateEntryList [SHELL32.5]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
SHChangeNotifyUpdateEntryList(DWORD unknown1, DWORD unknown2,
|
|
|
|
DWORD unknown3, DWORD unknown4)
|
|
|
|
{
|
|
|
|
FIXME("(0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx)\n",
|
|
|
|
unknown1, unknown2, unknown3, unknown4);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2000-02-20 19:40:55 +01:00
|
|
|
/*************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* SHChangeNotify [SHELL32.@]
|
2000-02-20 19:40:55 +01:00
|
|
|
*/
|
|
|
|
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;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
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);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
EnterCriticalSection(&SHELL32_ChangenotifyCS);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
/* loop through the list */
|
|
|
|
ptr = head.next;
|
|
|
|
while(ptr != &tail)
|
|
|
|
{
|
|
|
|
TRACE("trying %p\n", ptr);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
if(wEventId & ptr->wEventMask)
|
|
|
|
{
|
|
|
|
TRACE("notifying\n");
|
|
|
|
SendMessageA(ptr->hwnd, ptr->uMsg, (WPARAM)pidl1, (LPARAM)pidl2);
|
|
|
|
}
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
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
|
|
|
/*************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* SHChangeNotify [SHELL32.@]
|
2000-03-24 21:46:04 +01:00
|
|
|
*/
|
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;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
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);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
EnterCriticalSection(&SHELL32_ChangenotifyCS);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
/* loop through the list */
|
|
|
|
ptr = head.next;
|
|
|
|
while(ptr != &tail)
|
|
|
|
{
|
|
|
|
TRACE("trying %p\n", ptr);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
if(wEventId & ptr->wEventMask)
|
|
|
|
{
|
|
|
|
TRACE("notifying\n");
|
|
|
|
SendMessageA(ptr->hwnd, ptr->uMsg, (WPARAM)&Pidls, (LPARAM)wEventId);
|
|
|
|
}
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-26 19:44:08 +01:00
|
|
|
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
|
|
|
/*************************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* SHChangeNotify [SHELL32.@]
|
2000-03-24 21:46:04 +01:00
|
|
|
*/
|
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;
|
|
|
|
}
|
|
|
|
|