Sync to Wine-20050211
James Hawkins <truiken@gmail.com>
- Use Interlocked* instead of ++/-- in AddRef/Release.
- Use only stored result of Interlocked* in AddRef/Release.
- Expand TRACEs to display the ref count.
Francois Gouget <fgouget@free.fr>
- Assorted spelling fixes.
Mike McCormack <mike@codeweavers.com>
- Implement GetAdvise and SetAdvise.
Henning Gerhardt <henning.gerhardt@web.de>
- A small spelling fix and a small update (thank to Andreas Mohr).
- Update German resources.
Joris Huizer <jorishuizer@planet.nl>
- add file_operation_delete
- add file_operation_checkFlags
- use these in SHFileOperationW replacing inline code
Modified: trunk/reactos/lib/shell32/autocomplete.c
Modified: trunk/reactos/lib/shell32/cpanelfolder.c
Modified: trunk/reactos/lib/shell32/dataobject.c
Modified: trunk/reactos/lib/shell32/dragdrophelper.c
Modified: trunk/reactos/lib/shell32/enumidlist.c
Modified: trunk/reactos/lib/shell32/folders.c
Modified: trunk/reactos/lib/shell32/memorystream.c
Modified: trunk/reactos/lib/shell32/pidl.c
Modified: trunk/reactos/lib/shell32/shell32_De.rc
Modified: trunk/reactos/lib/shell32/shelllink.c
Modified: trunk/reactos/lib/shell32/shellole.c
Modified: trunk/reactos/lib/shell32/shellord.c
Modified: trunk/reactos/lib/shell32/shellpath.c
Modified: trunk/reactos/lib/shell32/shfldr_desktop.c
Modified: trunk/reactos/lib/shell32/shfldr_fs.c
Modified: trunk/reactos/lib/shell32/shfldr_mycomp.c
Modified: trunk/reactos/lib/shell32/shlfileop.c
Modified: trunk/reactos/lib/shell32/shlfsbind.c
Modified: trunk/reactos/lib/shell32/shlview.c
Modified: trunk/reactos/lib/shell32/shv_bg_cmenu.c
Modified: trunk/reactos/lib/shell32/shv_item_cmenu.c

Modified: trunk/reactos/lib/shell32/autocomplete.c
--- trunk/reactos/lib/shell32/autocomplete.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/autocomplete.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -170,9 +170,11 @@
 	IAutoComplete * iface)
 {
     IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
+    ULONG refCount = InterlockedIncrement(&This->ref);
     
-    TRACE("(%p)->(%lu)\n",This,This->ref);
-    return ++(This->ref);
+    TRACE("(%p)->(%lu)\n", This, refCount - 1);
+
+    return refCount;
 }
 
 /******************************************************************************
@@ -182,10 +184,11 @@
 	IAutoComplete * iface)
 {
     IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
+    ULONG refCount = InterlockedDecrement(&This->ref);
     
-    TRACE("(%p)->(%lu)\n",This,This->ref);
+    TRACE("(%p)->(%lu)\n", This, refCount + 1);
 
-    if (!--(This->ref)) {
+    if (!refCount) {
 	TRACE(" destroying IAutoComplete(%p)\n",This);
         HeapFree(GetProcessHeap(), 0, This->quickComplete);
         HeapFree(GetProcessHeap(), 0, This->txtbackup);
@@ -194,9 +197,8 @@
 	if (This->enumstr)
 	    IEnumString_Release(This->enumstr);
 	HeapFree(GetProcessHeap(), 0, This);
-	return 0;
     }
-    return This->ref;
+    return refCount;
 }
 
 /******************************************************************************

Modified: trunk/reactos/lib/shell32/cpanelfolder.c
--- trunk/reactos/lib/shell32/cpanelfolder.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/cpanelfolder.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -181,26 +181,27 @@
 static ULONG WINAPI ISF_ControlPanel_fnAddRef(IShellFolder2 * iface)
 {
     ICPanelImpl *This = (ICPanelImpl *)iface;
+    ULONG refCount = InterlockedIncrement(&This->ref);
 
-    TRACE("(%p)->(count=%lu)\n", This, This->ref);
+    TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
 
-    return ++(This->ref);
+    return refCount;
 }
 
 static ULONG WINAPI ISF_ControlPanel_fnRelease(IShellFolder2 * iface)
 {
     ICPanelImpl *This = (ICPanelImpl *)iface;
+    ULONG refCount = InterlockedDecrement(&This->ref);
 
-    TRACE("(%p)->(count=%lu)\n", This, This->ref);
+    TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
 
-    if (!--(This->ref)) {
+    if (!refCount) {
         TRACE("-- destroying IShellFolder(%p)\n", This);
         if (This->pidlRoot)
             SHFree(This->pidlRoot);
         LocalFree((HLOCAL) This);
-        return 0;
     }
-    return This->ref;
+    return refCount;
 }
 
 /**************************************************************************

Modified: trunk/reactos/lib/shell32/dataobject.c
--- trunk/reactos/lib/shell32/dataobject.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/dataobject.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -124,16 +124,21 @@
 static ULONG WINAPI IEnumFORMATETC_fnAddRef(LPENUMFORMATETC iface)
 {
 	IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface;
-	TRACE("(%p)->(count=%lu)\n",This, This->ref);
-	return ++(This->ref);
+	ULONG refCount = InterlockedIncrement(&This->ref);
+
+	TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
+
+	return refCount;
 }
 
 static ULONG WINAPI IEnumFORMATETC_fnRelease(LPENUMFORMATETC iface)
 {
 	IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface;
-	TRACE("(%p)->()\n",This);
+	ULONG refCount = InterlockedDecrement(&This->ref);
 
-	if (!--(This->ref))
+	TRACE("(%p)->(%lu)\n", This, refCount + 1);
+
+	if (!refCount)
 	{
 	  TRACE(" destroying IEnumFORMATETC(%p)\n",This);
 	  if (This->pFmt)
@@ -143,7 +148,7 @@
 	  HeapFree(GetProcessHeap(),0,This);
 	  return 0;
 	}
-	return This->ref;
+	return refCount;
 }
 
 static HRESULT WINAPI IEnumFORMATETC_fnNext(LPENUMFORMATETC iface, ULONG celt, FORMATETC *rgelt, ULONG *pceltFethed)
@@ -291,8 +296,11 @@
 static ULONG WINAPI IDataObject_fnAddRef(LPDATAOBJECT iface)
 {
 	IDataObjectImpl *This = (IDataObjectImpl *)iface;
-	TRACE("(%p)->(count=%lu)\n",This, This->ref);
-	return ++(This->ref);
+	ULONG refCount = InterlockedIncrement(&This->ref);
+
+	TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
+
+	return refCount;
 }
 
 /**************************************************************************
@@ -301,17 +309,18 @@
 static ULONG WINAPI IDataObject_fnRelease(LPDATAOBJECT iface)
 {
 	IDataObjectImpl *This = (IDataObjectImpl *)iface;
-	TRACE("(%p)->()\n",This);
+	ULONG refCount = InterlockedDecrement(&This->ref);
 
-	if (!--(This->ref))
+	TRACE("(%p)->(%lu)\n", This, refCount + 1);
+
+	if (!refCount)
 	{
 	  TRACE(" destroying IDataObject(%p)\n",This);
 	  _ILFreeaPidl(This->apidl, This->cidl);
 	  ILFree(This->pidl),
 	  HeapFree(GetProcessHeap(),0,This);
-	  return 0;
 	}
-	return This->ref;
+	return refCount;
 }
 
 /**************************************************************************

Modified: trunk/reactos/lib/shell32/dragdrophelper.c
--- trunk/reactos/lib/shell32/dragdrophelper.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/dragdrophelper.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -113,24 +113,26 @@
 static ULONG WINAPI IDropTargetHelper_fnAddRef (IDropTargetHelper * iface)
 {
     IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface;
+    ULONG refCount = InterlockedIncrement(&This->ref);
 
-    TRACE ("(%p)->(count=%lu)\n", This, This->ref);
+    TRACE ("(%p)->(count=%lu)\n", This, refCount - 1);
 
-    return ++(This->ref);
+    return refCount;
 }
 
 static ULONG WINAPI IDropTargetHelper_fnRelease (IDropTargetHelper * iface)
 {
     IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface;
+    ULONG refCount = InterlockedDecrement(&This->ref);
 
-    TRACE ("(%p)->(count=%lu)\n", This, This->ref);
+    TRACE ("(%p)->(count=%lu)\n", This, refCount + 1);
 
-    if (!--(This->ref)) {
+    if (!refCount) {
         TRACE("-- destroying (%p)\n", This);
         LocalFree ((HLOCAL) This);
         return 0;
     }
-    return This->ref;
+    return refCount;
 }
 
 static HRESULT WINAPI IDropTargetHelper_fnDragEnter (

Modified: trunk/reactos/lib/shell32/enumidlist.c
--- trunk/reactos/lib/shell32/enumidlist.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/enumidlist.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -240,8 +240,11 @@
 	IEnumIDList * iface)
 {
 	IEnumIDListImpl *This = (IEnumIDListImpl *)iface;
-	TRACE("(%p)->(%lu)\n",This,This->ref);
-	return ++(This->ref);
+	ULONG refCount = InterlockedIncrement(&This->ref);
+
+	TRACE("(%p)->(%lu)\n", This, refCount - 1);
+
+	return refCount;
 }
 /******************************************************************************
  * IEnumIDList_fnRelease
@@ -250,16 +253,16 @@
 	IEnumIDList * iface)
 {
 	IEnumIDListImpl *This = (IEnumIDListImpl *)iface;
+	ULONG refCount = InterlockedDecrement(&This->ref);
 
-	TRACE("(%p)->(%lu)\n",This,This->ref);
+	TRACE("(%p)->(%lu)\n", This, refCount + 1);
 
-	if (!--(This->ref)) {
+	if (!refCount) {
 	  TRACE(" destroying IEnumIDList(%p)\n",This);
 	  DeleteList((IEnumIDList*)This);
 	  HeapFree(GetProcessHeap(),0,This);
-	  return 0;
 	}
-	return This->ref;
+	return refCount;
 }
 
 /**************************************************************************

Modified: trunk/reactos/lib/shell32/folders.c
--- trunk/reactos/lib/shell32/folders.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/folders.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -130,10 +130,11 @@
 static ULONG WINAPI IExtractIconW_fnAddRef(IExtractIconW * iface)
 {
 	IExtractIconWImpl *This = (IExtractIconWImpl *)iface;
+	ULONG refCount = InterlockedIncrement(&This->ref);
 
-	TRACE("(%p)->(count=%lu)\n",This, This->ref );
+	TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
 
-	return ++(This->ref);
+	return refCount;
 }
 /**************************************************************************
 *  IExtractIconW_Release
@@ -141,17 +142,18 @@
 static ULONG WINAPI IExtractIconW_fnRelease(IExtractIconW * iface)
 {
 	IExtractIconWImpl *This = (IExtractIconWImpl *)iface;
+	ULONG refCount = InterlockedDecrement(&This->ref);
 
-	TRACE("(%p)->()\n",This);
+	TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
 
-	if (!--(This->ref))
+	if (!refCount)
 	{
 	  TRACE(" destroying IExtractIcon(%p)\n",This);
 	  SHFree(This->pidl);
 	  HeapFree(GetProcessHeap(),0,This);
 	  return 0;
 	}
-	return This->ref;
+	return refCount;
 }
 
 static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags,

Modified: trunk/reactos/lib/shell32/memorystream.c
--- trunk/reactos/lib/shell32/memorystream.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/memorystream.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -127,10 +127,11 @@
 static ULONG WINAPI IStream_fnAddRef(IStream *iface)
 {
 	ISHFileStream *This = (ISHFileStream *)iface;
+	ULONG refCount = InterlockedIncrement(&This->ref);
 
-	TRACE("(%p)->(count=%lu)\n",This, This->ref);
+	TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
 
-	return ++(This->ref);
+	return refCount;
 }
 
 /**************************************************************************
@@ -139,16 +140,17 @@
 static ULONG WINAPI IStream_fnRelease(IStream *iface)
 {
 	ISHFileStream *This = (ISHFileStream *)iface;
+	ULONG refCount = InterlockedDecrement(&This->ref);
 
-	TRACE("(%p)->()\n",This);
+	TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
 
-	if (!--(This->ref))
+	if (!refCount)
 	{
 		TRACE(" destroying SHFileStream (%p)\n",This);
 		CloseHandle(This->handle);
 		HeapFree(GetProcessHeap(),0,This);
 	}
-	return This->ref;
+	return refCount;
 }
 
 static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG* pcbRead)

Modified: trunk/reactos/lib/shell32/pidl.c
--- trunk/reactos/lib/shell32/pidl.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/pidl.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -977,7 +977,7 @@
  *  IShellFolder uses that FileSystem Bind Data object of the BindContext
  *  to pass data about the current path element to the next object. This
  *  is used to avoid having to verify the current path element on disk, so
- *  that creating an ItemIDList from a non-existent path still can work.
+ *  that creating an ItemIDList from a nonexistent path still can work.
  */
 static HRESULT WINAPI _ILParsePathW(LPCWSTR path, LPWIN32_FIND_DATAW lpFindFile,
                              BOOL bBindCtx, LPITEMIDLIST *ppidl, LPDWORD prgfInOut)
@@ -1024,7 +1024,7 @@
  * SHSimpleIDListFromPath    [SHELL32.162]
  *
  * Creates a simple ItemIDList from a path and returns it. This function
- * does not fail on non-existent paths.
+ * does not fail on nonexistent paths.
  *
  * PARAMS
  *  path         [I]   path to parse and convert into an ItemIDList

Modified: trunk/reactos/lib/shell32/shell32_De.rc
--- trunk/reactos/lib/shell32/shell32_De.rc	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shell32_De.rc	2005-02-13 22:42:47 UTC (rev 13544)
@@ -188,3 +188,35 @@
        IDS_SHUTDOWN_TITLE      "Anhalten"
        IDS_SHUTDOWN_PROMPT     "M÷chten Sie die aktuelle ReactOS Sitzung beenden ?"
 }
+
+/* shell folder path default values */
+STRINGTABLE DISCARDABLE
+{
+	IDS_PROGRAMS		"Startmen³\\Programme"
+	IDS_PERSONAL		"Eigene Dateien"
+	IDS_FAVORITES		"Favoriten"
+	IDS_STARTUP		"Startmen³\\Programme\\Autostart"
+	IDS_RECENT		"Recent"
+	IDS_SENDTO		"SendTo"
+	IDS_STARTMENU		"Startmen³"
+	IDS_MYMUSIC		"Eigene Dateien\\Meine Musik"
+	IDS_MYVIDEO		"Eigene Dateien\\Meine Videos"
+	IDS_DESKTOPDIRECTORY	"Desktop"
+	IDS_NETHOOD		"Netzwerkumgebung"
+	IDS_TEMPLATES		"Vorlagen"
+	IDS_APPDATA		"Anwendungsdaten"
+	IDS_PRINTHOOD		"Druckumgebung"
+	IDS_LOCAL_APPDATA	"Lokale Einstellungen\\Anwendungsdaten"
+	IDS_INTERNET_CACHE	"Temporary Internet Files"
+	IDS_COOKIES		"Cookies"
+	IDS_HISTORY		"Verlauf"
+	IDS_PROGRAM_FILES	"Programme"
+	IDS_MYPICTURES		"Eigene Dateien\\Eigene Bilder"
+	IDS_PROGRAM_FILES_COMMON "Programme\\Gemeinsame Dateien"
+	IDS_COMMON_DOCUMENTS	"Dokumente"
+	IDS_ADMINTOOLS		"Startmen³\\Programme\\Verwaltung"
+	IDS_COMMON_MUSIC	"Dokumente\\Eigene Musik"
+	IDS_COMMON_PICTURES	"Dokumente\\Eigene Bilder"
+	IDS_COMMON_VIDEO	"Dokumente\\Eigene Videos"
+	IDS_CDBURN_AREA		"Lokale Einstellungen\\Anwendungsdaten\\Microsoft\\CD Burning"
+}

Modified: trunk/reactos/lib/shell32/shelllink.c
--- trunk/reactos/lib/shell32/shelllink.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shelllink.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -974,10 +974,11 @@
 static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface)
 {
 	IShellLinkImpl *This = (IShellLinkImpl *)iface;
+	ULONG refCount = InterlockedIncrement(&This->ref);
 
-	TRACE("(%p)->(count=%lu)\n",This,This->ref);
+	TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
 
-	return ++(This->ref);
+	return refCount;
 }
 /******************************************************************************
  *	IShellLinkA_Release
@@ -985,11 +986,12 @@
 static ULONG WINAPI IShellLinkA_fnRelease(IShellLinkA * iface)
 {
     IShellLinkImpl *This = (IShellLinkImpl *)iface;
+    ULONG refCount = InterlockedDecrement(&This->ref);
 
-    TRACE("(%p)->(count=%lu)\n",This,This->ref);
+    TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
 
-    if (--(This->ref))
-        return This->ref;
+    if (refCount)
+        return refCount;
 
     TRACE("-- destroying IShellLink(%p)\n",This);
 

Modified: trunk/reactos/lib/shell32/shellole.c
--- trunk/reactos/lib/shell32/shellole.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shellole.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -556,9 +556,11 @@
 static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface)
 {
 	IDefClFImpl *This = (IDefClFImpl *)iface;
-	TRACE("(%p)->(count=%lu)\n",This,This->ref);
+	ULONG refCount = InterlockedIncrement(&This->ref);
 
-	return InterlockedIncrement(&This->ref);
+	TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
+
+	return refCount;
 }
 /******************************************************************************
  * IDefClF_fnRelease
@@ -566,9 +568,11 @@
 static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
 {
 	IDefClFImpl *This = (IDefClFImpl *)iface;
-	TRACE("(%p)->(count=%lu)\n",This,This->ref);
+	ULONG refCount = InterlockedDecrement(&This->ref);
+	
+	TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
 
-	if (!InterlockedDecrement(&This->ref))
+	if (!refCount)
 	{
 	  if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
 
@@ -576,7 +580,7 @@
 	  HeapFree(GetProcessHeap(),0,This);
 	  return 0;
 	}
-	return This->ref;
+	return refCount;
 }
 /******************************************************************************
  * IDefClF_fnCreateInstance

Modified: trunk/reactos/lib/shell32/shellord.c
--- trunk/reactos/lib/shell32/shellord.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shellord.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -673,7 +673,7 @@
     if (ret == ERROR_SUCCESS) {
 	if (!( (type == REG_DWORD) ||
 	       ((type == REG_BINARY) && (datalen == 4)) )) {
-	    ERR("Error policy data for \"NoRecentDocsHistory\" not formated correctly, type=%ld, len=%ld\n",
+	    ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%ld, len=%ld\n",
 		type, datalen);
 	    return;
 	}

Modified: trunk/reactos/lib/shell32/shellpath.c
--- trunk/reactos/lib/shell32/shellpath.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shellpath.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -1995,7 +1995,7 @@
             else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
             {
                 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
-                 * version 6.0 returns E_FAIL for non-existing paths
+                 * version 6.0 returns E_FAIL for nonexistent paths
                  */
                 hr = E_FAIL;
             }

Modified: trunk/reactos/lib/shell32/shfldr_desktop.c
--- trunk/reactos/lib/shell32/shfldr_desktop.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shfldr_desktop.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -157,19 +157,21 @@
 static ULONG WINAPI ISF_Desktop_fnAddRef (IShellFolder2 * iface)
 {
     IGenericSFImpl *This = (IGenericSFImpl *)iface;
+    ULONG refCount = InterlockedIncrement(&This->ref);
 
-    TRACE ("(%p)->(count=%lu)\n", This, This->ref);
+    TRACE ("(%p)->(count=%lu)\n", This, refCount - 1);
 
-    return ++(This->ref);
+    return refCount;
 }
 
 static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface)
 {
     IGenericSFImpl *This = (IGenericSFImpl *)iface;
+    ULONG refCount = InterlockedDecrement(&This->ref);
 
-    TRACE ("(%p)->(count=%lu)\n", This, This->ref);
+    TRACE ("(%p)->(count=%lu)\n", This, refCount + 1);
 
-    if (!--(This->ref)) {
+    if (!refCount) {
 	TRACE ("-- destroying IShellFolder(%p)\n", This);
 	if (This->pidlRoot)
 	    SHFree (This->pidlRoot);
@@ -178,7 +180,7 @@
 	LocalFree ((HLOCAL) This);
         return 0;
     }
-    return This->ref;
+    return refCount;
 }
 
 /**************************************************************************

Modified: trunk/reactos/lib/shell32/shfldr_fs.c
--- trunk/reactos/lib/shell32/shfldr_fs.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shfldr_fs.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -173,19 +173,21 @@
 static ULONG WINAPI IUnknown_fnAddRef (IUnknown * iface)
 {
     IGenericSFImpl *This = (IGenericSFImpl *)iface;
+    ULONG refCount = InterlockedIncrement(&This->ref);
 
-    TRACE ("(%p)->(count=%lu)\n", This, This->ref);
+    TRACE ("(%p)->(count=%lu)\n", This, refCount - 1);
 
-    return ++(This->ref);
+    return refCount;
 }
 
 static ULONG WINAPI IUnknown_fnRelease (IUnknown * iface)
 {
     IGenericSFImpl *This = (IGenericSFImpl *)iface;
+    ULONG refCount = InterlockedDecrement(&This->ref);
 
-    TRACE ("(%p)->(count=%lu)\n", This, This->ref);
+    TRACE ("(%p)->(count=%lu)\n", This, refCount + 1);
 
-    if (!--(This->ref)) {
+    if (!refCount) {
 	TRACE ("-- destroying IShellFolder(%p)\n", This);
 
 	if (This->pidlRoot)
@@ -193,9 +195,8 @@
 	if (This->sPathTarget)
 	    SHFree (This->sPathTarget);
 	LocalFree ((HLOCAL) This);
-	return 0;
     }
-    return This->ref;
+    return refCount;
 }
 
 static IUnknownVtbl unkvt =

Modified: trunk/reactos/lib/shell32/shfldr_mycomp.c
--- trunk/reactos/lib/shell32/shfldr_mycomp.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shfldr_mycomp.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -160,26 +160,27 @@
 static ULONG WINAPI ISF_MyComputer_fnAddRef (IShellFolder2 * iface)
 {
     IGenericSFImpl *This = (IGenericSFImpl *)iface;
+    ULONG refCount = InterlockedIncrement(&This->ref);
 
-    TRACE ("(%p)->(count=%lu)\n", This, This->ref);
+    TRACE ("(%p)->(count=%lu)\n", This, refCount - 1);
 
-    return ++(This->ref);
+    return refCount;
 }
 
 static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface)
 {
     IGenericSFImpl *This = (IGenericSFImpl *)iface;
+    ULONG refCount = InterlockedDecrement(&This->ref);
 
-    TRACE ("(%p)->(count=%lu)\n", This, This->ref);
+    TRACE ("(%p)->(count=%lu)\n", This, refCount + 1);
 
-    if (!--(This->ref)) {
+    if (!refCount) {
         TRACE ("-- destroying IShellFolder(%p)\n", This);
         if (This->pidlRoot)
             SHFree (This->pidlRoot);
         LocalFree ((HLOCAL) This);
-        return 0;
     }
-    return This->ref;
+    return refCount;
 }
 
 /**************************************************************************

Modified: trunk/reactos/lib/shell32/shlfileop.c
--- trunk/reactos/lib/shell32/shlfileop.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shlfileop.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -861,6 +861,90 @@
 #define ERROR_SHELL_INTERNAL_FILE_NOT_FOUND 1026
 #define HIGH_ADR (LPWSTR)0xffffffff
 
+static int file_operation_delete( WIN32_FIND_DATAW *wfd,SHFILEOPSTRUCTW nFileOp, LPWSTR pFromFile,LPWSTR pTempFrom,HANDLE *hFind)
+
+{
+    LPWSTR lpFileName;
+    BOOL    b_Mask = (NULL != StrPBrkW(&pFromFile[1], wWildcardChars));
+    int retCode = 0;
+    do
+    {
+        lpFileName = wfd->cAlternateFileName;
+        if (!lpFileName[0])
+            lpFileName = wfd->cFileName;
+        if (IsDotDir(lpFileName) ||
+                ((b_Mask) && IsAttribDir(wfd->dwFileAttributes) && (nFileOp.fFlags & FOF_FILESONLY)))
+            continue;
+        SHFileStrCpyCatW(&pFromFile[1], lpFileName, NULL);
+        /* TODO: Check the SHELL_DeleteFileOrDirectoryW() function in shell32.dll */
+        if (IsAttribFile(wfd->dwFileAttributes))
+        {
+            if(SHNotifyDeleteFileW(pTempFrom) != ERROR_SUCCESS)
+            {
+                nFileOp.fAnyOperationsAborted = TRUE;
+                retCode = 0x78; /* value unknown */
+            }
+        }
+        else if(!SHELL_DeleteDirectoryW(pTempFrom, (!(nFileOp.fFlags & FOF_NOCONFIRMATION))))
+        {
+            nFileOp.fAnyOperationsAborted = TRUE;
+            retCode = 0x79; /* value unknown */
+        }
+    }
+    while (!nFileOp.fAnyOperationsAborted && FindNextFileW(*hFind,wfd));
+    FindClose(*hFind);
+    *hFind = INVALID_HANDLE_VALUE;
+    return retCode;
+}
+
+/*
+ * Summary of flags:
+ *
+ * implemented flags:
+ * FOF_MULTIDESTFILES, FOF_NOCONFIRMATION, FOF_FILESONLY
+ *
+ * unimplememented and ignored flags:
+ * FOF_CONFIRMMOUSE, FOF_SILENT, FOF_NOCONFIRMMKDIR,
+ *       FOF_SIMPLEPROGRESS, FOF_NOCOPYSECURITYATTRIBS
+ *
+ * partially implemented, breaks if file exists:
+ * FOF_RENAMEONCOLLISION
+ *
+ * unimplemented and break if any other flag set:
+ * FOF_ALLOWUNDO, FOF_WANTMAPPINGHANDLE
+ */
+
+static int file_operation_checkFlags(SHFILEOPSTRUCTW nFileOp)
+{
+    FILEOP_FLAGS OFl = ((FILEOP_FLAGS)nFileOp.fFlags & 0xfff);
+    long FuncSwitch = (nFileOp.wFunc & FO_MASK);
+    long level= nFileOp.wFunc >> 4;
+
+    TRACE("%s level=%ld nFileOp.fFlags=0x%x\n", 
+            debug_shfileops_action(FuncSwitch), level, nFileOp.fFlags);
+    /*    OFl &= (-1 - (FOF_MULTIDESTFILES | FOF_FILESONLY)); */
+    /*    OFl ^= (FOF_SILENT | FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOCONFIRMMKDIR); */
+    OFl &= (~(FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | FOF_FILESONLY));  /* implemented */
+    OFl ^= (FOF_SILENT | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS); /* ignored, if one */
+    OFl &= (~FOF_SIMPLEPROGRESS); /* ignored, only with FOF_SILENT */
+    if (OFl)
+    {
+        if (OFl & (~(FOF_CONFIRMMOUSE | FOF_SILENT | FOF_RENAMEONCOLLISION |
+                        FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS)))
+        {
+            TRACE("%s level=%ld lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n",
+                    debug_shfileops_action(FuncSwitch), level, OFl);
+            return 0x403; /* 1027, we need an extension to shlfileop */
+        }
+        else
+        {
+            TRACE("%s level=%ld lpFileOp->fFlags=0x%x not fully implemented, stub\n", 
+                    debug_shfileops_action(FuncSwitch), level, OFl);
+        } 
+    } 
+    return 0;
+}
+
 /*************************************************************************
  * SHFileOperationW          [SHELL32.@]
  *
@@ -884,8 +968,6 @@
 	int retCode = 0;
 	DWORD ToAttr;
 	DWORD ToPathAttr;
-	DWORD FromPathAttr;
-	FILEOP_FLAGS OFl = ((FILEOP_FLAGS)lpFileOp->fFlags & 0xfff);
 
 	BOOL b_Multi = (nFileOp.fFlags & FOF_MULTIDESTFILES);
 
@@ -904,6 +986,8 @@
 	long FuncSwitch = (nFileOp.wFunc & FO_MASK);
 	long level= nFileOp.wFunc>>4;
 
+        int ret;
+
 	/*  default no error */
 	nFileOp.fAnyOperationsAborted = FALSE;
 
@@ -932,47 +1016,12 @@
          * create dir              0 0 0 0 0 0 1 0
          */
 
-        /*
-         * Summary of flags:
-         *
-         * implemented flags:
-         * FOF_MULTIDESTFILES, FOF_NOCONFIRMATION, FOF_FILESONLY
-         *
-         * unimplememented and ignored flags:
-         * FOF_CONFIRMMOUSE, FOF_SILENT, FOF_NOCONFIRMMKDIR,
-         *       FOF_SIMPLEPROGRESS, FOF_NOCOPYSECURITYATTRIBS
-         *
-         * partially implemented, breaks if file exists:
-         * FOF_RENAMEONCOLLISION
-         *
-         * unimplemented and break if any other flag set:
-         * FOF_ALLOWUNDO, FOF_WANTMAPPINGHANDLE
-         */
-
-        TRACE("%s level=%ld nFileOp.fFlags=0x%x\n", 
-                debug_shfileops_action(FuncSwitch), level, lpFileOp->fFlags);
-
-        /*    OFl &= (-1 - (FOF_MULTIDESTFILES | FOF_FILESONLY)); */
-        /*    OFl ^= (FOF_SILENT | FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOCONFIRMMKDIR); */
-        OFl &= (~(FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | FOF_FILESONLY));  /* implemented */
-        OFl ^= (FOF_SILENT | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS); /* ignored, if one */
-        OFl &= (~FOF_SIMPLEPROGRESS);                      /* ignored, only with FOF_SILENT */
-        if (OFl)
+        ret = file_operation_checkFlags(nFileOp);
+        if (ret != 0)
         {
-	    if (OFl & (~(FOF_CONFIRMMOUSE | FOF_SILENT | FOF_RENAMEONCOLLISION |
-	                 FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS)))
-	    {
-                TRACE("%s level=%ld lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n",
-                      debug_shfileops_action(FuncSwitch), level, OFl);
-                retCode = 0x403; /* 1027, we need an extension to shlfileop */
-                goto shfileop_end;
-	    }
-	    else
-	    {
-                TRACE("%s level=%ld lpFileOp->fFlags=0x%x not fully implemented, stub\n", 
-                      debug_shfileops_action(FuncSwitch), level, OFl);
-	    } 
-        } 
+            retCode = ret;
+            goto shfileop_end;
+        }
 
         if ((pNextFrom) && (!(b_MultiTo) || (pNextTo)))
         {
@@ -1055,12 +1104,13 @@
                     goto shfileop_end;
                 }
 	    }
-
+             
 	    hFind = FindFirstFileW(pFrom, &wfd);
 	    if (INVALID_HANDLE_VALUE == hFind)
 	    {
                 if ((FO_DELETE == FuncSwitch) && (b_Mask))
                 {
+                    DWORD FromPathAttr;
                     pFromFile[0] = '\0';
                     FromPathAttr = GetFileAttributesW(pTempFrom);
                     pFromFile[0] = '\\';
@@ -1080,37 +1130,13 @@
             /* ??? b_Mask = (!SHFileStrICmpA(&pFromFile[1], &wfd.cFileName[0], HIGH_ADR, HIGH_ADR)); */
 	    if (!pTo) /* FO_DELETE */
 	    {
-                do
+                ret = file_operation_delete(&wfd,nFileOp,pFromFile,pTempFrom,&hFind);
+                /* if ret is not 0, nFileOp.fAnyOperationsAborted is TRUE */
+                if (ret != 0)
                 {
-                    lpFileName = wfd.cAlternateFileName;
-                    if (!lpFileName[0])
-                        lpFileName = wfd.cFileName;
-                    if (IsDotDir(lpFileName) ||
-                        ((b_Mask) && IsAttribDir(wfd.dwFileAttributes) && (nFileOp.fFlags & FOF_FILESONLY)))
-                        continue;
-                    SHFileStrCpyCatW(&pFromFile[1], lpFileName, NULL);
-                    /* TODO: Check the SHELL_DeleteFileOrDirectoryW() function in shell32.dll */
-                    if (IsAttribFile(wfd.dwFileAttributes))
-                    {
-                        if(SHNotifyDeleteFileW(pTempFrom) != ERROR_SUCCESS)
-                        {
-                            nFileOp.fAnyOperationsAborted = TRUE;
-                            retCode = 0x78; /* value unknown */
-                        }
-                    }
-                    else
-                    {
-                        if(!SHELL_DeleteDirectoryW(pTempFrom, (!(nFileOp.fFlags & FOF_NOCONFIRMATION))))
-                        {
-                            nFileOp.fAnyOperationsAborted = TRUE;
-                            retCode = 0x79; /* value unknown */
-                        }
-                    }
-                } while (!nFileOp.fAnyOperationsAborted && FindNextFileW(hFind, &wfd));
-                FindClose(hFind);
-                hFind = INVALID_HANDLE_VALUE;
-                if (nFileOp.fAnyOperationsAborted)
-                    goto shfileop_end;
+                  retCode = ret;
+                  goto shfileop_end;
+                }
                 continue;
 	    } /* FO_DELETE ends, pTo must be always valid from here */
 

Modified: trunk/reactos/lib/shell32/shlfsbind.c
--- trunk/reactos/lib/shell32/shlfsbind.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shlfsbind.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -179,22 +179,26 @@
 static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface)
 {
 	IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
-	TRACE("(%p)\n", This);
-	return InterlockedIncrement(&This->ref);
+	ULONG refCount = InterlockedIncrement(&This->ref);
+
+	TRACE("(%p)->(count=%li)\n", This, refCount - 1);
+
+	return refCount;
 }
 
 static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface)
 {
 	IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
-	TRACE("(%p)\n", This);
+	ULONG refCount = InterlockedDecrement(&This->ref);
+	
+	TRACE("(%p)->(count=%li)\n", This, refCount + 1);
 
-	if (!InterlockedDecrement(&This->ref))
+	if (!refCount)
 	{
 	  TRACE(" destroying ISFBindPidl(%p)\n",This);
 	  HeapFree(GetProcessHeap(), 0, This);
-	  return 0;
 	}
-	return This->ref;
+	return refCount;
 }
 
 static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)

Modified: trunk/reactos/lib/shell32/shlview.c
--- trunk/reactos/lib/shell32/shlview.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shlview.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -97,6 +97,9 @@
         LISTVIEW_SORT_INFO ListViewSortInfo;
 	ULONG			hNotify;	/* change notification handle */
 	HANDLE		hAccel;
+	DWORD		dwAspects;
+	DWORD		dwAdvf;
+	IAdviseSink    *pAdvSink;
 } IShellViewImpl;
 
 static struct IShellViewVtbl svvt;
@@ -1639,10 +1642,11 @@
 static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
 {
 	IShellViewImpl *This = (IShellViewImpl *)iface;
+	ULONG refCount = InterlockedIncrement(&This->ref);
 
-	TRACE("(%p)->(count=%lu)\n",This,This->ref);
+	TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
 
-	return ++(This->ref);
+	return refCount;
 }
 /**********************************************************
 *  IShellView_Release
@@ -1650,10 +1654,11 @@
 static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
 {
 	IShellViewImpl *This = (IShellViewImpl *)iface;
+	ULONG refCount = InterlockedDecrement(&This->ref);
 
-	TRACE("(%p)->()\n",This);
+	TRACE("(%p)->(count=%li)\n", This, refCount + 1);
 
-	if (!--(This->ref))
+	if (!refCount)
 	{
 	  TRACE(" destroying IShellView(%p)\n",This);
 
@@ -1665,13 +1670,15 @@
 	  if(This->pSF2Parent)
 	    IShellFolder2_Release(This->pSF2Parent);
 
-	  if (This->apidl)
+	  if(This->apidl)
 	    SHFree(This->apidl);
 
+	  if(This->pAdvSink)
+	    IAdviseSink_Release(This->pAdvSink);
+
 	  HeapFree(GetProcessHeap(),0,This);
-	  return 0;
 	}
-	return This->ref;
+	return refCount;
 }
 
 /**********************************************************
@@ -2374,10 +2381,17 @@
 
 	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
 
-	FIXME("Stub: This=%p\n",This);
+	FIXME("partial stub: %p %08lx %08lx %p\n",
+              This, aspects, advf, pAdvSink);
 
-	return E_NOTIMPL;
+	/* FIXME: we set the AdviseSink, but never use it to send any advice */
+	This->pAdvSink = pAdvSink;
+	This->dwAspects = aspects;
+	This->dwAdvf = advf;
+
+	return S_OK;
 }
+
 static HRESULT WINAPI ISVViewObject_GetAdvise(
 	IViewObject 	*iface,
 	DWORD* pAspects,
@@ -2387,9 +2401,20 @@
 
 	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
 
-	FIXME("Stub: This=%p\n",This);
+	TRACE("This=%p pAspects=%p pAdvf=%p ppAdvSink=%p\n",
+              This, pAspects, pAdvf, ppAdvSink);
 
-	return E_NOTIMPL;
+	if( ppAdvSink )
+	{
+		IAdviseSink_AddRef( This->pAdvSink );
+		*ppAdvSink = This->pAdvSink;
+	}
+	if( pAspects )
+		*pAspects = This->dwAspects;
+	if( pAdvf )
+		*pAdvf = This->dwAdvf;
+
+	return S_OK;
 }
 
 

Modified: trunk/reactos/lib/shell32/shv_bg_cmenu.c
--- trunk/reactos/lib/shell32/shv_bg_cmenu.c	2005-02-13 22:08:14 UTC (rev 13543)
+++ trunk/reactos/lib/shell32/shv_bg_cmenu.c	2005-02-13 22:42:47 UTC (rev 13544)
@@ -106,10 +106,11 @@
 static ULONG WINAPI ISVBgCm_fnAddRef(IContextMenu2 *iface)
 {
 	BgCmImpl *This = (BgCmImpl *)iface;
+	ULONG refCount = InterlockedIncrement(&This->ref);
 
-	TRACE("(%p)->(count=%lu)\n",This, This->ref);
+	TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
 
-	return ++(This->ref);
+	return refCount;
 }
 
 /**************************************************************************
@@ -118,10 +119,11 @@
 static ULONG WINAPI ISVBgCm_fnRelease(IContextMenu2 *iface)
 {
 	BgCmImpl *This = (BgCmImpl *)iface;
+	ULONG refCount = InterlockedDecrement(&This->ref);
 
-	TRACE("(%p)->()\n",This);
+	TRACE("(%p)->(count=%li)\n", This, refCount + 1);
 
-	if (!--(This->ref))
+	if (!refCount)
 	{
 	  TRACE(" destroying IContextMenu(%p)\n",This);
 
@@ -129,10 +131,8 @@
 	    IShellFolder_Release(This->pSFParent);
 
 	  HeapFree(GetProcessHeap(),0,This);
-	  return 0;
 	}
-
-	return This->ref;
+	return refCount;
 }
[truncated at 1000 lines; 45 more skipped]