msi: iterate RegisterFonts

Aric Stewart aric at codeweavers.com
Tue Jun 21 09:18:08 CDT 2005


rework RegisterFonts to use MSI_IterateRecords
-------------- next part --------------
Index: dlls/msi/action.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/action.c,v
retrieving revision 1.152
diff -u -r1.152 action.c
--- dlls/msi/action.c	20 Jun 2005 15:33:10 -0000	1.152
+++ dlls/msi/action.c	21 Jun 2005 13:56:20 -0000
@@ -4163,14 +4043,13 @@
     return ret;
 }
 
-static UINT ACTION_RegisterFonts(MSIPACKAGE *package)
+static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param)
 {
-    UINT rc;
-    MSIQUERY * view;
-    MSIRECORD * row = 0;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','F','o','n','t','`',0};
+    MSIPACKAGE *package = (MSIPACKAGE*)param;
+    LPWSTR name;
+    LPCWSTR file;
+    UINT index;
+    DWORD size;
     static const WCHAR regfont1[] =
         {'S','o','f','t','w','a','r','e','\\',
          'M','i','c','r','o','s','o','f','t','\\',
@@ -4186,85 +4065,64 @@
     HKEY hkey1;
     HKEY hkey2;
 
-    TRACE("%p\n", package);
-
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
-    if (rc != ERROR_SUCCESS)
+    file = MSI_RecordGetString(row,1);
+    index = get_loaded_file(package,file);
+    if (index < 0)
     {
-        TRACE("MSI_DatabaseOpenViewW failed: %d\n", rc);
+        ERR("Unable to load file\n");
         return ERROR_SUCCESS;
     }
 
-    rc = MSI_ViewExecute(view, 0);
-    if (rc != ERROR_SUCCESS)
+    /* check to make sure that component is installed */
+    if (!ACTION_VerifyComponentForAction(package, 
+                package->files[index].ComponentIndex, INSTALLSTATE_LOCAL))
     {
-        MSI_ViewClose(view);
-        msiobj_release(&view->hdr);
-        TRACE("MSI_ViewExecute returned %d\n", rc);
+        TRACE("Skipping: Component not scheduled for install\n");
         return ERROR_SUCCESS;
     }
 
     RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont1,&hkey1);
     RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont2,&hkey2);
-    
-    while (1)
-    {
-        LPWSTR name;
-        LPCWSTR file;
-        UINT index;
-        DWORD size;
-
-        rc = MSI_ViewFetch(view,&row);
-        if (rc != ERROR_SUCCESS)
-        {
-            rc = ERROR_SUCCESS;
-            break;
-        }
-
-        file = MSI_RecordGetString(row,1);
-        index = get_loaded_file(package,file);
-        if (index < 0)
-        {
-            ERR("Unable to load file\n");
-            continue;
-        }
 
-        /* check to make sure that component is installed */
-        if (!ACTION_VerifyComponentForAction(package, 
-                package->files[index].ComponentIndex, INSTALLSTATE_LOCAL))
-        {
-            TRACE("Skipping: Component not scheduled for install\n");
+    if (MSI_RecordIsNull(row,2))
+        name = load_ttfname_from(package->files[index].TargetPath);
+    else
+        name = load_dynamic_stringW(row,2);
 
-            msiobj_release(&row->hdr);
+    if (name)
+    {
+        size = strlenW(package->files[index].FileName) * sizeof(WCHAR);
+        RegSetValueExW(hkey1,name,0,REG_SZ,
+                    (LPBYTE)package->files[index].FileName,size);
+        RegSetValueExW(hkey2,name,0,REG_SZ,
+                    (LPBYTE)package->files[index].FileName,size);
+    }
 
-            continue;
-        }
+    HeapFree(GetProcessHeap(),0,name);
+    RegCloseKey(hkey1);
+    RegCloseKey(hkey2);
+    return ERROR_SUCCESS;
+}
 
-        if (MSI_RecordIsNull(row,2))
-            name = load_ttfname_from(package->files[index].TargetPath);
-        else
-            name = load_dynamic_stringW(row,2);
+static UINT ACTION_RegisterFonts(MSIPACKAGE *package)
+{
+    UINT rc;
+    MSIQUERY * view;
+    static const WCHAR ExecSeqQuery[] =
+        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+         '`','F','o','n','t','`',0};
 
-        if (name)
-        {
-            size = strlenW(package->files[index].FileName) * sizeof(WCHAR);
-            RegSetValueExW(hkey1,name,0,REG_SZ,
-                        (LPBYTE)package->files[index].FileName,size);
-            RegSetValueExW(hkey2,name,0,REG_SZ,
-                        (LPBYTE)package->files[index].FileName,size);
-        }
-        
-        HeapFree(GetProcessHeap(),0,name);
-        msiobj_release(&row->hdr);
+    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    if (rc != ERROR_SUCCESS)
+    {
+        TRACE("MSI_DatabaseOpenViewW failed: %d\n", rc);
+        return ERROR_SUCCESS;
     }
-    MSI_ViewClose(view);
-    msiobj_release(&view->hdr);
 
-    RegCloseKey(hkey1);
-    RegCloseKey(hkey2);
+    MSI_IterateRecords(view, NULL, ITERATE_RegisterFonts, package);
+    msiobj_release(&view->hdr);
 
-    TRACE("returning %d\n", rc);
-    return rc;
+    return ERROR_SUCCESS;
 }
 
 static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param)


More information about the wine-patches mailing list