Initial stubbed implementation of UnixFolder's IDropTarget interface.
[wine] / dlls / shell32 / shellole.c
index a8f639b..9b92c26 100644 (file)
@@ -25,6 +25,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#define COBJMACROS
+
 #include "windef.h"
 #include "winbase.h"
 #include "shellapi.h"
@@ -69,6 +71,10 @@ struct {
        {&CLSID_DragDropHelper, &IDropTargetHelper_Constructor},
        {&CLSID_ControlPanel,   &IControlPanel_Constructor},
        {&CLSID_AutoComplete,   &IAutoComplete_Constructor},
+       {&CLSID_UnixFolder,     &UnixFolder_Constructor},
+       {&CLSID_UnixDosFolder,  &UnixDosFolder_Constructor},
+       {&CLSID_FolderShortcut, &FolderShortcut_Constructor},
+       {&CLSID_MyDocuments,    &MyDocuments_Constructor},
        {NULL,NULL}
 };
 
@@ -99,7 +105,7 @@ DWORD WINAPI __SHGUIDToStringW (REFGUID guid, LPWSTR str)
 
 /************************************************************************/
 
-LRESULT WINAPI SHCoCreateInstance(
+HRESULT WINAPI SHCoCreateInstance(
        LPCWSTR aclsid,
        const CLSID *clsid,
        LPUNKNOWN pUnkOuter,
@@ -159,14 +165,14 @@ LRESULT WINAPI SHCoCreateInstance(
 
        TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM, bLoadFromShell32);
 
-       /* now we create a instance */
+       /* now we create an instance */
        if (bLoadFromShell32) {
-           if (! SUCCEEDED(SHELL32_DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) {
+           if (! SUCCEEDED(DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) {
                ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid));
            }
        } else if (bLoadWithoutCOM) {
 
-           /* load a external dll without ole32 */
+           /* load an external dll without ole32 */
            HANDLE hLibrary;
            typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
            DllGetClassObjectFunc DllGetClassObject;
@@ -187,7 +193,7 @@ LRESULT WINAPI SHCoCreateInstance(
 
        } else {
 
-           /* load a external dll in the usual way */
+           /* load an external dll in the usual way */
            hres = CoCreateInstance(myclsid, pUnkOuter, CLSCTX_INPROC_SERVER, refiid, ppv);
            goto end;
        }
@@ -210,9 +216,9 @@ end:
 }
 
 /*************************************************************************
- * DllGetClassObject   [SHELL32.128]
+ * DllGetClassObject   [SHELL32.@]
  */
-HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
+HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
 {
        HRESULT hres = E_OUTOFMEMORY;
        IClassFactory * pcf = NULL;
@@ -274,18 +280,18 @@ DWORD WINAPI SHCLSIDFromStringAW (LPVOID clsid, CLSID *id)
  */
 
 /* set the vtable later */
-extern ICOM_VTABLE(IMalloc) VT_Shell_IMalloc32;
+static const IMallocVtbl VT_Shell_IMalloc32;
 
 /* this is the static object instance */
 typedef struct {
-       ICOM_VFIELD(IMalloc);
+       const IMallocVtbl *lpVtbl;
        DWORD dummy;
 } _ShellMalloc;
 
-_ShellMalloc Shell_Malloc = { &VT_Shell_IMalloc32,1};
+static _ShellMalloc Shell_Malloc = { &VT_Shell_IMalloc32,1};
 
 /* this is the global allocator of shell32 */
-IMalloc * ShellTaskAllocator = NULL;
+static IMalloc * ShellTaskAllocator = NULL;
 
 /******************************************************************************
  *              IShellMalloc_QueryInterface        [VTABLE]
@@ -315,7 +321,7 @@ static LPVOID WINAPI IShellMalloc_fnAlloc(LPMALLOC iface, DWORD cb)
 {
         LPVOID addr;
 
-       addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb);
+       addr = (LPVOID) LocalAlloc(LMEM_ZEROINIT, cb);
         TRACE("(%p,%ld);\n",addr,cb);
         return addr;
 }
@@ -329,14 +335,14 @@ static LPVOID WINAPI IShellMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb)
 
        if (pv) {
                if (cb) {
-                       addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, GMEM_ZEROINIT | GMEM_MOVEABLE);
+                       addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, LMEM_ZEROINIT | LMEM_MOVEABLE);
                } else {
                        LocalFree((HANDLE) pv);
                        addr = NULL;
                }
        } else {
                if (cb) {
-                       addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb);
+                       addr = (LPVOID) LocalAlloc(LMEM_ZEROINIT, cb);
                } else {
                        addr = NULL;
                }
@@ -382,9 +388,8 @@ static VOID WINAPI IShellMalloc_fnHeapMinimize(LPMALLOC iface)
        TRACE("()\n");
 }
 
-static ICOM_VTABLE(IMalloc) VT_Shell_IMalloc32 =
+static const IMallocVtbl VT_Shell_IMalloc32 =
 {
-       ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
        IShellMalloc_fnQueryInterface,
        IShellMalloc_fnAddRefRelease,
        IShellMalloc_fnAddRefRelease,
@@ -473,7 +478,7 @@ void WINAPI SHFree(LPVOID pv)
 /*************************************************************************
  * SHGetDesktopFolder                  [SHELL32.@]
  */
-DWORD WINAPI SHGetDesktopFolder(IShellFolder **psf)
+HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
 {
        HRESULT hres = S_OK;
        TRACE("\n");
@@ -491,22 +496,22 @@ DWORD WINAPI SHGetDesktopFolder(IShellFolder **psf)
  * SHCreateDefClassObject
  *
  * NOTES
- *  helper function for dll's without a own classfactory
- *  a generic classfactory is returned
- *  when the CreateInstance of the cf is called the callback is executed
+ *  Helper function for dlls without their own classfactory.
+ *  A generic classfactory is returned.
+ *  When the CreateInstance of the cf is called the callback is executed.
  */
 
 typedef struct
 {
-    ICOM_VFIELD(IClassFactory);
-    DWORD                       ref;
+    const IClassFactoryVtbl    *lpVtbl;
+    LONG                        ref;
     CLSID                      *rclsid;
     LPFNCREATEINSTANCE         lpfnCI;
     const IID *                        riidInst;
-    ULONG *                    pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
+    LONG *                     pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
 } IDefClFImpl;
 
-static ICOM_VTABLE(IClassFactory) dclfvt;
+static const IClassFactoryVtbl dclfvt;
 
 /**************************************************************************
  *  IDefClF_fnConstructor
@@ -516,7 +521,7 @@ IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll,
 {
        IDefClFImpl* lpclf;
 
-       lpclf = (IDefClFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
+       lpclf = HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
        lpclf->ref = 1;
        lpclf->lpVtbl = &dclfvt;
        lpclf->lpfnCI = lpfnCI;
@@ -534,7 +539,7 @@ IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll,
 static HRESULT WINAPI IDefClF_fnQueryInterface(
   LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
 {
-       ICOM_THIS(IDefClFImpl,iface);
+       IDefClFImpl *This = (IDefClFImpl *)iface;
 
        TRACE("(%p)->(%s)\n",This,shdebugstr_guid(riid));
 
@@ -554,20 +559,24 @@ static HRESULT WINAPI IDefClF_fnQueryInterface(
  */
 static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface)
 {
-       ICOM_THIS(IDefClFImpl,iface);
-       TRACE("(%p)->(count=%lu)\n",This,This->ref);
+       IDefClFImpl *This = (IDefClFImpl *)iface;
+       ULONG refCount = InterlockedIncrement(&This->ref);
+
+       TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
 
-       return InterlockedIncrement(&This->ref);
+       return refCount;
 }
 /******************************************************************************
  * IDefClF_fnRelease
  */
 static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
 {
-       ICOM_THIS(IDefClFImpl,iface);
-       TRACE("(%p)->(count=%lu)\n",This,This->ref);
+       IDefClFImpl *This = (IDefClFImpl *)iface;
+       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);
 
@@ -575,7 +584,7 @@ static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
          HeapFree(GetProcessHeap(),0,This);
          return 0;
        }
-       return This->ref;
+       return refCount;
 }
 /******************************************************************************
  * IDefClF_fnCreateInstance
@@ -583,7 +592,7 @@ static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
 static HRESULT WINAPI IDefClF_fnCreateInstance(
   LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
 {
-       ICOM_THIS(IDefClFImpl,iface);
+       IDefClFImpl *This = (IDefClFImpl *)iface;
 
        TRACE("%p->(%p,%s,%p)\n",This,pUnkOuter,shdebugstr_guid(riid),ppvObject);
 
@@ -604,14 +613,13 @@ static HRESULT WINAPI IDefClF_fnCreateInstance(
  */
 static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
 {
-       ICOM_THIS(IDefClFImpl,iface);
+       IDefClFImpl *This = (IDefClFImpl *)iface;
        TRACE("%p->(0x%x), not implemented\n",This, fLock);
        return E_NOTIMPL;
 }
 
-static ICOM_VTABLE(IClassFactory) dclfvt =
+static const IClassFactoryVtbl dclfvt =
 {
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     IDefClF_fnQueryInterface,
     IDefClF_fnAddRef,
   IDefClF_fnRelease,
@@ -635,13 +643,13 @@ HRESULT WINAPI SHCreateDefClassObject(
               shdebugstr_guid(riid), ppv, lpfnCI, pcRefDll, shdebugstr_guid(riidInst));
 
        if (! IsEqualCLSID(riid, &IID_IClassFactory) ) return E_NOINTERFACE;
-       if (! (pcf = IDefClF_fnConstructor(lpfnCI, pcRefDll, riidInst))) return E_OUTOFMEMORY;
+       if (! (pcf = IDefClF_fnConstructor(lpfnCI, (PLONG)pcRefDll, riidInst))) return E_OUTOFMEMORY;
        *ppv = pcf;
        return NOERROR;
 }
 
 /*************************************************************************
- *  DragAcceptFiles            [SHELL32.54]
+ *  DragAcceptFiles            [SHELL32.@]
  */
 void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
 {
@@ -657,7 +665,7 @@ void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
 }
 
 /*************************************************************************
- * DragFinish          [SHELL32.80]
+ * DragFinish          [SHELL32.@]
  */
 void WINAPI DragFinish(HDROP h)
 {
@@ -666,7 +674,7 @@ void WINAPI DragFinish(HDROP h)
 }
 
 /*************************************************************************
- * DragQueryPoint              [SHELL32.135]
+ * DragQueryPoint              [SHELL32.@]
  */
 BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
 {
@@ -685,8 +693,8 @@ BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
 }
 
 /*************************************************************************
- *  DragQueryFile              [SHELL32.81]
- *  DragQueryFileA             [SHELL32.82]
+ *  DragQueryFileA             [SHELL32.@]
+ *  DragQueryFile              [SHELL32.@]
  */
 UINT WINAPI DragQueryFileA(
        HDROP hDrop,
@@ -704,11 +712,11 @@ UINT WINAPI DragQueryFileA(
 
        lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
 
-        if(lpDropFileStruct->fWide == TRUE) {
+        if(lpDropFileStruct->fWide) {
             LPWSTR lpszFileW = NULL;
 
             if(lpszFile) {
-                lpszFileW = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR));
+                lpszFileW = HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR));
                 if(lpszFileW == NULL) {
                     goto end;
                 }
@@ -743,7 +751,7 @@ end:
 }
 
 /*************************************************************************
- *  DragQueryFileW             [SHELL32.133]
+ *  DragQueryFileW             [SHELL32.@]
  */
 UINT WINAPI DragQueryFileW(
        HDROP hDrop,
@@ -765,7 +773,7 @@ UINT WINAPI DragQueryFileW(
             LPSTR lpszFileA = NULL;
 
             if(lpszwFile) {
-                lpszFileA = (LPSTR) HeapAlloc(GetProcessHeap(), 0, lLength);
+                lpszFileA = HeapAlloc(GetProcessHeap(), 0, lLength);
                 if(lpszFileA == NULL) {
                     goto end;
                 }