more comcat.dll impl, swprintf fix, winerror.h additions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changelog:
John K. Hohm <jhohm@acm.org>

more comcat.dll impl, swprintf fix, winerror.h additions

Note that this includes the NTDLL_vsnwprintf patch I just sent to
wine-devel; it seems to be okay and fixed my problem.
Index: dlls/comcat/comcat.h
===================================================================
RCS file: /home/wine/wine/dlls/comcat/comcat.h,v
retrieving revision 1.1
diff -u -r1.1 comcat.h
--- dlls/comcat/comcat.h	14 May 2002 21:50:56 -0000	1.1
+++ dlls/comcat/comcat.h	18 May 2002 04:48:51 -0000
@@ -20,7 +20,9 @@
 
 #include "windef.h"
 #include "winbase.h"
+#include "winreg.h"
 #include "winerror.h"
+#include "ntddk.h"
 
 #include "ole2.h"
 #include "wine/obj_base.h"
Index: dlls/comcat/factory.c
===================================================================
RCS file: /home/wine/wine/dlls/comcat/factory.c,v
retrieving revision 1.1
diff -u -r1.1 factory.c
--- dlls/comcat/factory.c	14 May 2002 21:50:56 -0000	1.1
+++ dlls/comcat/factory.c	18 May 2002 04:48:51 -0000
@@ -63,7 +63,7 @@
     if (InterlockedIncrement(&This->ref) == 1) {
 	InterlockedIncrement(&dll_ref);
     }
-    return S_OK;
+    return This->ref;
 }
 
 /**********************************************************************
@@ -79,7 +79,7 @@
     if (InterlockedDecrement(&This->ref) == 0) {
 	InterlockedDecrement(&dll_ref);
     }
-    return S_OK;
+    return This->ref;;
 }
 
 /**********************************************************************
Index: dlls/comcat/information.c
===================================================================
RCS file: /home/wine/wine/dlls/comcat/information.c,v
retrieving revision 1.1
diff -u -r1.1 information.c
--- dlls/comcat/information.c	14 May 2002 21:50:56 -0000	1.1
+++ dlls/comcat/information.c	18 May 2002 04:48:51 -0000
@@ -18,12 +18,17 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <string.h>
 #include "comcat.h"
 
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ole);
 
+static LPENUMCATEGORYINFO COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid);
+static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc,
+				      ULONG buf_wchars);
+
 /**********************************************************************
  * COMCAT_ICatInformation_QueryInterface
  */
@@ -74,10 +79,15 @@
     LCID lcid,
     LPENUMCATEGORYINFO *ppenumCatInfo)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
-    FIXME("(): stub\n");
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
+    TRACE("\n");
 
-    return E_NOTIMPL;
+    if (iface == NULL || ppenumCatInfo == NULL) return E_POINTER;
+
+    *ppenumCatInfo = COMCAT_IEnumCATEGORYINFO_Construct(lcid);
+    if (*ppenumCatInfo == NULL) return E_OUTOFMEMORY;
+    IEnumCATEGORYINFO_AddRef(*ppenumCatInfo);
+    return S_OK;
 }
 
 /**********************************************************************
@@ -89,10 +99,38 @@
     LCID lcid,
     PWCHAR *ppszDesc)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
-    FIXME("(): stub\n");
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
+    WCHAR keyname[60] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n',
+			  't', ' ', 'C', 'a', 't', 'e', 'g', 'o',
+			  'r', 'i', 'e', 's', '\\', 0 };
+    HKEY key;
+    HRESULT res;
+
+    TRACE("\n\tCATID:\t%s\n\tLCID:\t%lX\n",debugstr_guid(rcatid), lcid);
+
+    if (rcatid == NULL || ppszDesc == NULL) return E_INVALIDARG;
+
+    /* Open the key for this category. */
+    if (!StringFromGUID2(rcatid, keyname + 21, 39)) return E_FAIL;
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &key);
+    if (res != ERROR_SUCCESS) return CAT_E_CATIDNOEXIST;
+
+    /* Allocate a sensible amount of memory for the description. */
+    *ppszDesc = (PWCHAR) CoTaskMemAlloc(128 * sizeof(WCHAR));
+    if (*ppszDesc == NULL) {
+	RegCloseKey(key);
+	return E_OUTOFMEMORY;
+    }
+
+    /* Get the description, and make sure it's null terminated. */
+    res = COMCAT_GetCategoryDesc(key, lcid, *ppszDesc, 128);
+    RegCloseKey(key);
+    if (FAILED(res)) {
+	CoTaskMemFree(*ppszDesc);
+	return res;
+    }
 
-    return E_NOTIMPL;
+    return S_OK;
 }
 
 /**********************************************************************
@@ -106,7 +144,7 @@
     CATID *rgcatidReq,
     LPENUMCLSID *ppenumCLSID)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
     FIXME("(): stub\n");
 
     return E_NOTIMPL;
@@ -123,7 +161,7 @@
     ULONG cRequired,
     CATID *rgcatidReq)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
     FIXME("(): stub\n");
 
     return E_NOTIMPL;
@@ -137,7 +175,7 @@
     REFCLSID rclsid,
     LPENUMCATID *ppenumCATID)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
     FIXME("(): stub\n");
 
     return E_NOTIMPL;
@@ -151,7 +189,7 @@
     REFCLSID rclsid,
     LPENUMCATID *ppenumCATID)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
     FIXME("(): stub\n");
 
     return E_NOTIMPL;
@@ -173,3 +211,188 @@
     COMCAT_ICatInformation_EnumImplCategoriesOfClass,
     COMCAT_ICatInformation_EnumReqCategoriesOfClass
 };
+
+/**********************************************************************
+ * IEnumCATEGORYINFO implementation
+ *
+ * This implementation is not thread-safe.  The manager itself is, but
+ * I can't imagine a valid use of an enumerator in several threads.
+ */
+typedef struct
+{
+    ICOM_VFIELD(IEnumCATEGORYINFO);
+    DWORD ref;
+    LCID  lcid;
+    HKEY  key;
+    DWORD next_index;
+} IEnumCATEGORYINFOImpl;
+
+static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_AddRef(LPENUMCATEGORYINFO iface)
+{
+    ICOM_THIS(IEnumCATEGORYINFOImpl, iface);
+    TRACE("\n");
+
+    if (This == NULL) return E_POINTER;
+
+    return ++(This->ref);
+}
+
+static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_QueryInterface(
+    LPENUMCATEGORYINFO iface,
+    REFIID riid,
+    LPVOID *ppvObj)
+{
+    ICOM_THIS(IEnumCATEGORYINFOImpl, iface);
+    TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
+
+    if (This == NULL || ppvObj == NULL) return E_POINTER;
+
+    if (IsEqualGUID(riid, &IID_IUnknown) ||
+	IsEqualGUID(riid, &IID_IEnumCATEGORYINFO))
+    {
+	*ppvObj = (LPVOID)iface;
+	COMCAT_IEnumCATEGORYINFO_AddRef(iface);
+	return S_OK;
+    }
+
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_Release(LPENUMCATEGORYINFO iface)
+{
+    ICOM_THIS(IEnumCATEGORYINFOImpl, iface);
+    TRACE("\n");
+
+    if (This == NULL) return E_POINTER;
+
+    if (--(This->ref) == 0) {
+	if (This->key) RegCloseKey(This->key);
+	HeapFree(GetProcessHeap(), 0, This);
+	return 0;
+    }
+    return This->ref;
+}
+
+static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Next(
+    LPENUMCATEGORYINFO iface,
+    ULONG celt,
+    CATEGORYINFO *rgelt,
+    ULONG *pceltFetched)
+{
+    ICOM_THIS(IEnumCATEGORYINFOImpl, iface);
+    ULONG fetched = 0;
+
+    TRACE("\n");
+
+    if (This == NULL || rgelt == NULL) return E_POINTER;
+
+    if (This->key) while (fetched < celt) {
+	HRESULT res;
+	WCHAR catid[39];
+	DWORD cName = 39;
+	HKEY subkey;
+
+	res = RegEnumKeyExW(This->key, This->next_index, catid, &cName,
+			    NULL, NULL, NULL, NULL);
+	if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break;
+	++(This->next_index);
+
+	res = CLSIDFromString(catid, &rgelt->catid);
+	if (FAILED(res)) continue;
+
+	res = RegOpenKeyExW(This->key, catid, 0, KEY_READ, &subkey);
+	if (res != ERROR_SUCCESS) continue;
+
+	res = COMCAT_GetCategoryDesc(subkey, This->lcid,
+				     rgelt->szDescription, 128);
+	RegCloseKey(subkey);
+	if (FAILED(res)) continue;
+
+	rgelt->lcid = This->lcid;
+	++fetched;
+	++rgelt;
+    }
+
+    if (pceltFetched) *pceltFetched = fetched;
+    return fetched == celt ? S_OK : S_FALSE;
+}
+
+static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Skip(
+    LPENUMCATEGORYINFO iface,
+    ULONG celt)
+{
+/*     ICOM_THIS(IEnumCATEGORYINFOImpl, iface); */
+    FIXME("(): stub\n");
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Reset(LPENUMCATEGORYINFO iface)
+{
+/*     ICOM_THIS(IEnumCATEGORYINFOImpl, iface); */
+    FIXME("(): stub\n");
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Clone(
+    LPENUMCATEGORYINFO iface,
+    IEnumCATEGORYINFO **ppenum)
+{
+/*     ICOM_THIS(IEnumCATEGORYINFOImpl, iface); */
+    FIXME("(): stub\n");
+
+    return E_NOTIMPL;
+}
+
+ICOM_VTABLE(IEnumCATEGORYINFO) COMCAT_IEnumCATEGORYINFO_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+    COMCAT_IEnumCATEGORYINFO_QueryInterface,
+    COMCAT_IEnumCATEGORYINFO_AddRef,
+    COMCAT_IEnumCATEGORYINFO_Release,
+    COMCAT_IEnumCATEGORYINFO_Next,
+    COMCAT_IEnumCATEGORYINFO_Skip,
+    COMCAT_IEnumCATEGORYINFO_Reset,
+    COMCAT_IEnumCATEGORYINFO_Clone
+};
+
+static LPENUMCATEGORYINFO COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid)
+{
+    IEnumCATEGORYINFOImpl *This;
+
+    This = (IEnumCATEGORYINFOImpl *) HeapAlloc(
+	GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumCATEGORYINFOImpl));
+    if (This) {
+	WCHAR keyname[21] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n',
+			      't', ' ', 'C', 'a', 't', 'e', 'g', 'o',
+			      'r', 'i', 'e', 's', 0 };
+
+	ICOM_VTBL(This) = &COMCAT_IEnumCATEGORYINFO_Vtbl;
+	This->lcid = lcid;
+	RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &This->key);
+    }
+    return (LPENUMCATEGORYINFO)This;
+}
+
+/**********************************************************************
+ * COMCAT_GetCategoryDesc
+ */
+static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc,
+				      ULONG buf_wchars)
+{
+    WCHAR fmt[4] = { '%', 'l', 'X', 0 };
+    WCHAR valname[5];
+    HRESULT res;
+    DWORD type, size = (buf_wchars - 1) * sizeof(WCHAR);
+
+    if (pszDesc == NULL) return E_INVALIDARG;
+
+    /* FIXME: lcid comparisons are more complex than this! */
+    swprintf(valname, fmt, lcid);
+    res = RegQueryValueExW(key, valname, 0, &type, (LPBYTE)pszDesc, &size);
+    if (res != ERROR_SUCCESS || type != REG_SZ) return CAT_E_NODESCRIPTION;
+    pszDesc[size / sizeof(WCHAR)] = (WCHAR)0;
+
+    return S_OK;
+}
Index: dlls/comcat/manager.c
===================================================================
RCS file: /home/wine/wine/dlls/comcat/manager.c,v
retrieving revision 1.1
diff -u -r1.1 manager.c
--- dlls/comcat/manager.c	14 May 2002 21:50:56 -0000	1.1
+++ dlls/comcat/manager.c	18 May 2002 04:48:51 -0000
@@ -73,7 +73,7 @@
     if (InterlockedIncrement(&This->ref) == 1) {
 	InterlockedIncrement(&dll_ref);
     }
-    return S_OK;
+    return This->ref;
 }
 
 /**********************************************************************
@@ -89,7 +89,7 @@
     if (InterlockedDecrement(&This->ref) == 0) {
 	InterlockedDecrement(&dll_ref);
     }
-    return S_OK;
+    return This->ref;
 }
 
 /**********************************************************************
Index: dlls/comcat/register.c
===================================================================
RCS file: /home/wine/wine/dlls/comcat/register.c,v
retrieving revision 1.1
diff -u -r1.1 register.c
--- dlls/comcat/register.c	14 May 2002 21:50:56 -0000	1.1
+++ dlls/comcat/register.c	18 May 2002 04:48:51 -0000
@@ -74,7 +74,7 @@
     ULONG cCategories,
     CATEGORYINFO *rgCategoryInfo)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
     FIXME("(): stub\n");
 
     return E_NOTIMPL;
@@ -88,7 +88,7 @@
     ULONG cCategories,
     CATID *rgcatid)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
     FIXME("(): stub\n");
 
     return E_NOTIMPL;
@@ -103,7 +103,7 @@
     ULONG cCategories,
     CATID *rgcatid)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
     FIXME("(): stub\n");
 
     return E_NOTIMPL;
@@ -118,7 +118,7 @@
     ULONG cCategories,
     CATID *rgcatid)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
     FIXME("(): stub\n");
 
     return E_NOTIMPL;
@@ -133,7 +133,7 @@
     ULONG cCategories,
     CATID *rgcatid)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
     FIXME("(): stub\n");
 
     return E_NOTIMPL;
@@ -148,7 +148,7 @@
     ULONG cCategories,
     CATID *rgcatid)
 {
-    ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
+/*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
     FIXME("(): stub\n");
 
     return E_NOTIMPL;
Index: dlls/ntdll/wcstring.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/wcstring.c,v
retrieving revision 1.15
diff -u -r1.15 wcstring.c
--- dlls/ntdll/wcstring.c	16 May 2002 18:58:47 -0000	1.15
+++ dlls/ntdll/wcstring.c	18 May 2002 04:48:51 -0000
@@ -451,10 +451,7 @@
       }
       if (*iter == (WCHAR)L'h' ||
           *iter == (WCHAR)L'l')
-      {
           *fmta++ = *iter++;
-          *fmta++ = *iter++;
-      }
 
       switch (*iter)
       {
Index: include/winerror.h
===================================================================
RCS file: /home/wine/wine/include/winerror.h,v
retrieving revision 1.41
diff -u -r1.41 winerror.h
--- include/winerror.h	16 May 2002 23:09:29 -0000	1.41
+++ include/winerror.h	18 May 2002 04:48:53 -0000
@@ -1749,6 +1749,11 @@
 #define REGDB_E_IIDNOTREG                                  0x80040155L
 #define REGDB_E_LAST                                       0x8004015FL
 
+#define CAT_E_FIRST                                        0x80040160L
+#define CAT_E_CATIDNOEXIST                                 0x80040160L
+#define CAT_E_NODESCRIPTION                                0x80040161L
+#define CAT_E_LAST                                         0x80040161L
+
 #define CACHE_S_FIRST                                      0x00040170L
 #define CACHE_S_FORMATETC_NOTSUPPORTED                     0x00040170L
 #define CACHE_S_SAMECACHE                                  0x00040171L

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux