Owen Rudge : shell32: Ensure the correct applet is loaded in multi-applet control panels.

Alexandre Julliard julliard at winehq.org
Tue Jun 24 06:45:32 CDT 2008


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

Author: Owen Rudge <owen at owenrudge.net>
Date:   Mon Jun 23 18:54:11 2008 +0100

shell32: Ensure the correct applet is loaded in multi-applet control panels.

---

 dlls/shell32/control.c |  105 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 76 insertions(+), 29 deletions(-)

diff --git a/dlls/shell32/control.c b/dlls/shell32/control.c
index 1f17016..7afe8e9 100644
--- a/dlls/shell32/control.c
+++ b/dlls/shell32/control.c
@@ -358,7 +358,8 @@ static	void	Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
     LPWSTR	end;
     WCHAR	ch;
     LPWSTR       ptr;
-    unsigned 	sp = 0;
+    signed 	sp = -1;
+    LPWSTR	extraPmtsBuf = NULL;
     LPWSTR	extraPmts = NULL;
     int        quoted = 0;
 
@@ -368,46 +369,92 @@ static	void	Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
     end = lstrcpyW(buffer, wszCmd);
 
     for (;;) {
-	ch = *end;
+        ch = *end;
         if (ch == '"') quoted = !quoted;
-	if (!quoted && (ch == ' ' || ch == ',' || ch == '\0')) {
-	    *end = '\0';
-	    if (beg) {
-	        if (*beg == '@') {
-		    sp = atoiW(beg + 1);
-		} else if (*beg == '\0') {
-		    sp = 0;
-		} else {
-		    extraPmts = beg;
-		}
-	    }
-	    if (ch == '\0') break;
-	    beg = end + 1;
-	    if (ch == ' ') while (end[1] == ' ') end++;
-	}
-	end++;
+        if (!quoted && (ch == ' ' || ch == ',' || ch == '\0')) {
+            *end = '\0';
+            if (beg) {
+                if (*beg == '@') {
+                    sp = atoiW(beg + 1);
+                } else if (*beg == '\0') {
+                    sp = -1;
+                } else {
+                    extraPmtsBuf = beg;
+                }
+            }
+            if (ch == '\0') break;
+            beg = end + 1;
+            if (ch == ' ') while (end[1] == ' ') end++;
+        }
+        end++;
     }
     while ((ptr = StrChrW(buffer, '"')))
 	memmove(ptr, ptr+1, lstrlenW(ptr)*sizeof(WCHAR));
 
+    /* now check for any quotes in extraPmtsBuf and remove */
+    if (extraPmtsBuf != NULL)
+    {
+        beg = end = extraPmtsBuf;
+        quoted = 0;
+
+        for (;;) {
+            ch = *end;
+            if (ch == '"') quoted = !quoted;
+            if (!quoted && (ch == ' ' || ch == ',' || ch == '\0')) {
+                *end = '\0';
+                if (beg) {
+                    if (*beg != '\0') {
+                        extraPmts = beg;
+                    }
+                }
+                if (ch == '\0') break;
+		    beg = end + 1;
+                if (ch == ' ') while (end[1] == ' ') end++;
+            }
+            end++;
+        }
+
+        while ((ptr = StrChrW(extraPmts, '"')))
+            memmove(ptr, ptr+1, lstrlenW(ptr)*sizeof(WCHAR));
+
+        if (extraPmts == NULL)
+            extraPmts = extraPmtsBuf;
+    }
+
     TRACE("cmd %s, extra %s, sp %d\n", debugstr_w(buffer), debugstr_w(extraPmts), sp);
 
     Control_LoadApplet(hWnd, buffer, panel);
 
     if (panel->first) {
-       CPlApplet* applet = panel->first;
+        CPlApplet* applet = panel->first;
 
-       assert(applet && applet->next == NULL);
-       if (sp >= applet->count) {
-	  WARN("Out of bounds (%u >= %u), setting to 0\n", sp, applet->count);
-	  sp = 0;
-       }
-       if (applet->info[sp].dwSize) {
-	  if (!applet->proc(applet->hWnd, CPL_STARTWPARMSA, sp, (LPARAM)extraPmts))
-	     applet->proc(applet->hWnd, CPL_DBLCLK, sp, applet->info[sp].lData);
-       }
-       Control_UnloadApplet(applet);
+        assert(applet && applet->next == NULL);
+
+        /* we've been given a textual parameter (or none at all) */
+        if (sp == -1) {
+            while ((++sp) != applet->count) {
+                if (applet->info[sp].dwSize) {
+                    TRACE("sp %d, name %s\n", sp, debugstr_w(applet->info[sp].szName));
+
+                    if (StrCmpIW(extraPmts, applet->info[sp].szName) == 0)
+                        break;
+                }
+            }
+        }
+
+        if (sp >= applet->count) {
+            WARN("Out of bounds (%u >= %u), setting to 0\n", sp, applet->count);
+            sp = 0;
+        }
+
+        if (applet->info[sp].dwSize) {
+            if (!applet->proc(applet->hWnd, CPL_STARTWPARMSA, sp, (LPARAM)extraPmts))
+                applet->proc(applet->hWnd, CPL_DBLCLK, sp, applet->info[sp].lData);
+        }
+
+        Control_UnloadApplet(applet);
     }
+
     HeapFree(GetProcessHeap(), 0, buffer);
 }
 




More information about the wine-cvs mailing list