Nikolay Sivov : scrrun: Added IFolderCollection stub.

Alexandre Julliard julliard at winehq.org
Fri Jan 3 11:23:15 CST 2014


Module: wine
Branch: master
Commit: 2a3f1560bb403d387a67ef99aae6e2e56b2e476b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2a3f1560bb403d387a67ef99aae6e2e56b2e476b

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri Jan  3 16:33:43 2014 +0400

scrrun: Added IFolderCollection stub.

---

 dlls/scrrun/filesystem.c       |  178 +++++++++++++++++++++++++++++++++++++++-
 dlls/scrrun/scrrun.c           |    1 +
 dlls/scrrun/scrrun_private.h   |    1 +
 dlls/scrrun/tests/filesystem.c |   25 ++++++
 4 files changed, 203 insertions(+), 2 deletions(-)

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index 1254532..1d2beda 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -36,6 +36,11 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
 
+struct foldercollection {
+    IFolderCollection IFolderCollection_iface;
+    LONG ref;
+};
+
 struct folder {
     IFolder IFolder_iface;
     LONG ref;
@@ -76,6 +81,11 @@ static inline struct textstream *impl_from_ITextStream(ITextStream *iface)
     return CONTAINING_RECORD(iface, struct textstream, ITextStream_iface);
 }
 
+static inline struct foldercollection *impl_from_IFolderCollection(IFolderCollection *iface)
+{
+    return CONTAINING_RECORD(iface, struct foldercollection, IFolderCollection_iface);
+}
+
 static inline HRESULT create_error(DWORD err)
 {
     switch(err) {
@@ -337,6 +347,165 @@ static HRESULT create_textstream(IOMode mode, ITextStream **ret)
     return S_OK;
 }
 
+static HRESULT WINAPI foldercoll_QueryInterface(IFolderCollection *iface, REFIID riid, void **obj)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+
+    TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
+
+    *obj = NULL;
+
+    if (IsEqualIID( riid, &IID_IFolderCollection ) ||
+        IsEqualIID( riid, &IID_IDispatch ) ||
+        IsEqualIID( riid, &IID_IUnknown ))
+    {
+        *obj = iface;
+        IFolderCollection_AddRef(iface);
+    }
+    else
+        return E_NOINTERFACE;
+
+    return S_OK;
+}
+
+static ULONG WINAPI foldercoll_AddRef(IFolderCollection *iface)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+    TRACE("(%p)->(%d)\n", This, ref);
+    return ref;
+}
+
+static ULONG WINAPI foldercoll_Release(IFolderCollection *iface)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
+    TRACE("(%p)->(%d)\n", This, ref);
+
+    if (!ref)
+        heap_free(This);
+
+    return ref;
+}
+
+static HRESULT WINAPI foldercoll_GetTypeInfoCount(IFolderCollection *iface, UINT *pctinfo)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+    TRACE("(%p)->(%p)\n", This, pctinfo);
+    *pctinfo = 1;
+    return S_OK;
+}
+
+static HRESULT WINAPI foldercoll_GetTypeInfo(IFolderCollection *iface, UINT iTInfo,
+                                        LCID lcid, ITypeInfo **ppTInfo)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+    TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
+    return get_typeinfo(IFolderCollection_tid, ppTInfo);
+}
+
+static HRESULT WINAPI foldercoll_GetIDsOfNames(IFolderCollection *iface, REFIID riid,
+                                        LPOLESTR *rgszNames, UINT cNames,
+                                        LCID lcid, DISPID *rgDispId)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+    ITypeInfo *typeinfo;
+    HRESULT hr;
+
+    TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
+
+    hr = get_typeinfo(IFolderCollection_tid, &typeinfo);
+    if(SUCCEEDED(hr))
+    {
+        hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
+        ITypeInfo_Release(typeinfo);
+    }
+
+    return hr;
+}
+
+static HRESULT WINAPI foldercoll_Invoke(IFolderCollection *iface, DISPID dispIdMember,
+                                      REFIID riid, LCID lcid, WORD wFlags,
+                                      DISPPARAMS *pDispParams, VARIANT *pVarResult,
+                                      EXCEPINFO *pExcepInfo, UINT *puArgErr)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+    ITypeInfo *typeinfo;
+    HRESULT hr;
+
+    TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
+           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+
+    hr = get_typeinfo(IFolderCollection_tid, &typeinfo);
+    if(SUCCEEDED(hr))
+    {
+        hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags,
+                pDispParams, pVarResult, pExcepInfo, puArgErr);
+        ITypeInfo_Release(typeinfo);
+    }
+
+    return hr;
+}
+
+static HRESULT WINAPI foldercoll_Add(IFolderCollection *iface, BSTR name, IFolder **folder)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+    FIXME("(%p)->(%s %p): stub\n", This, debugstr_w(name), folder);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI foldercoll_get_Item(IFolderCollection *iface, VARIANT key, IFolder **folder)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+    FIXME("(%p)->(%p): stub\n", This, folder);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI foldercoll_get__NewEnum(IFolderCollection *iface, IUnknown **newenum)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+    FIXME("(%p)->(%p): stub\n", This, newenum);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI foldercoll_get_Count(IFolderCollection *iface, LONG *count)
+{
+    struct foldercollection *This = impl_from_IFolderCollection(iface);
+    FIXME("(%p)->(%p): stub\n", This, count);
+    return E_NOTIMPL;
+}
+
+static const IFolderCollectionVtbl foldercollvtbl = {
+    foldercoll_QueryInterface,
+    foldercoll_AddRef,
+    foldercoll_Release,
+    foldercoll_GetTypeInfoCount,
+    foldercoll_GetTypeInfo,
+    foldercoll_GetIDsOfNames,
+    foldercoll_Invoke,
+    foldercoll_Add,
+    foldercoll_get_Item,
+    foldercoll_get__NewEnum,
+    foldercoll_get_Count
+};
+
+static HRESULT create_foldercoll(IFolderCollection **folders)
+{
+    struct foldercollection *This;
+
+    *folders = NULL;
+
+    This = heap_alloc(sizeof(struct foldercollection));
+    if (!This) return E_OUTOFMEMORY;
+
+    This->IFolderCollection_iface.lpVtbl = &foldercollvtbl;
+    This->ref = 1;
+
+    *folders = &This->IFolderCollection_iface;
+
+    return S_OK;
+}
+
 static HRESULT WINAPI folder_QueryInterface(IFolder *iface, REFIID riid, void **obj)
 {
     struct folder *This = impl_from_IFolder(iface);
@@ -568,8 +737,13 @@ static HRESULT WINAPI folder_get_Size(IFolder *iface, VARIANT *size)
 static HRESULT WINAPI folder_get_SubFolders(IFolder *iface, IFolderCollection **folders)
 {
     struct folder *This = impl_from_IFolder(iface);
-    FIXME("(%p)->(%p): stub\n", This, folders);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, folders);
+
+    if(!folders)
+        return E_POINTER;
+
+    return create_foldercoll(folders);
 }
 
 static HRESULT WINAPI folder_get_Files(IFolder *iface, IFileCollection **files)
diff --git a/dlls/scrrun/scrrun.c b/dlls/scrrun/scrrun.c
index 3739e30..761e2d6 100644
--- a/dlls/scrrun/scrrun.c
+++ b/dlls/scrrun/scrrun.c
@@ -105,6 +105,7 @@ static REFIID tid_ids[] = {
     &IID_IDictionary,
     &IID_IFileSystem3,
     &IID_IFolder,
+    &IID_IFolderCollection,
     &IID_ITextStream,
     &IID_IFile
 };
diff --git a/dlls/scrrun/scrrun_private.h b/dlls/scrrun/scrrun_private.h
index aa24dde..2c6aba5 100644
--- a/dlls/scrrun/scrrun_private.h
+++ b/dlls/scrrun/scrrun_private.h
@@ -27,6 +27,7 @@ typedef enum tid_t
     IDictionary_tid,
     IFileSystem3_tid,
     IFolder_tid,
+    IFolderCollection_tid,
     ITextStream_tid,
     IFile_tid,
     LAST_tid
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index a6c5980..b5d2e1f 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -775,6 +775,30 @@ static void test_GetFolder(void)
     IFolder_Release(folder);
 }
 
+static void test_FolderCollection(void)
+{
+    IFolderCollection *folders;
+    WCHAR buffW[MAX_PATH];
+    IFolder *folder;
+    HRESULT hr;
+    BSTR str;
+
+    GetWindowsDirectoryW(buffW, MAX_PATH);
+    str = SysAllocString(buffW);
+    hr = IFileSystem3_GetFolder(fs3, str, &folder);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    SysFreeString(str);
+
+    hr = IFolder_get_SubFolders(folder, NULL);
+    ok(hr == E_POINTER, "got 0x%08x\n", hr);
+
+    hr = IFolder_get_SubFolders(folder, &folders);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    IFolderCollection_Release(folders);
+    IFolder_Release(folder);
+}
+
 START_TEST(filesystem)
 {
     HRESULT hr;
@@ -800,6 +824,7 @@ START_TEST(filesystem)
     test_CopyFolder();
     test_BuildPath();
     test_GetFolder();
+    test_FolderCollection();
 
     IFileSystem3_Release(fs3);
 




More information about the wine-cvs mailing list