Ignore:
Timestamp:
Feb 13, 2003, 4:29:57 PM (23 years ago)
Author:
sandervl
Message:

Wine resync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/control.c

    r6709 r9799  
    1 /* Control Panel management */
    2 /* Eric Pouech 2001 */
     1/* Control Panel management
     2 *
     3 * Copyright 2001 Eric Pouech
     4 *
     5 * This library is free software; you can redistribute it and/or
     6 * modify it under the terms of the GNU Lesser General Public
     7 * License as published by the Free Software Foundation; either
     8 * version 2.1 of the License, or (at your option) any later version.
     9 *
     10 * This library is distributed in the hope that it will be useful,
     11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13 * Lesser General Public License for more details.
     14 *
     15 * You should have received a copy of the GNU Lesser General Public
     16 * License along with this library; if not, write to the Free Software
     17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     18 */
    319
    420#include <assert.h>
     
    1026#include "wingdi.h"
    1127#include "winuser.h"
    12 #include "debugtools.h"
     28#include "wine/debug.h"
    1329#include "cpl.h"
    14 
    15 DEFAULT_DEBUG_CHANNEL(shlctrl);
     30#include "wine/unicode.h"
     31
     32#define NO_SHLWAPI_REG
     33#include "shlwapi.h"
     34
     35WINE_DEFAULT_DEBUG_CHANNEL(shlctrl);
    1636
    1737typedef struct CPlApplet {
     
    2141    HMODULE             hModule;        /* module of loaded applet */
    2242    APPLET_PROC         proc;           /* entry point address */
    23     NEWCPLINFOA         info[1];        /* array of count information.
     43    NEWCPLINFOW         info[1];        /* array of count information.
    2444                                         * dwSize field is 0 if entry is invalid */
    2545} CPlApplet;
     
    4969}
    5070
    51 static CPlApplet*       Control_LoadApplet(HWND hWnd, LPCSTR cmd, CPanel* panel)
     71static CPlApplet*       Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
    5272{
    5373    CPlApplet*  applet;
    5474    unsigned    i;
    5575    CPLINFO     info;
     76    NEWCPLINFOW newinfo;
    5677
    5778    if (!(applet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*applet))))
     
    6081    applet->hWnd = hWnd;
    6182
    62     if (!(applet->hModule = LoadLibraryA(cmd))) {
    63         WARN("Cannot load control panel applet %s\n", cmd);
     83    if (!(applet->hModule = LoadLibraryW(cmd))) {
     84        WARN("Cannot load control panel applet %s\n", debugstr_w(cmd));
    6485        goto theError;
    6586    }
    6687    if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule, "CPlApplet"))) {
    67         WARN("Not a valid control panel applet %s\n", cmd);
     88        WARN("Not a valid control panel applet %s\n", debugstr_w(cmd));
    6889        goto theError;
    6990    }
     
    7798    }
    7899
    79     applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet, 
    80                          sizeof(*applet) + (applet->count - 1) * sizeof(NEWCPLINFOA));
    81    
     100    applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet,
     101                         sizeof(*applet) + (applet->count - 1) * sizeof(NEWCPLINFOW));
     102
    82103    for (i = 0; i < applet->count; i++) {
    83        applet->info[i].dwSize = sizeof(NEWCPLINFOA);
     104       ZeroMemory(&newinfo, sizeof(newinfo));
     105       newinfo.dwSize = sizeof(NEWCPLINFOA);
     106       applet->info[i].dwSize = sizeof(NEWCPLINFOW);
    84107       /* proc is supposed to return a null value upon success for
    85108        * CPL_INQUIRE and CPL_NEWINQUIRE
     
    87110        * So, use introspection rather than return value
    88111        */
    89        applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&applet->info[i]);
    90        if (applet->info[i].hIcon == 0) {
     112       applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo);
     113       if (newinfo.hIcon == 0) {
    91114           applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info);
    92115           if (info.idIcon == 0 || info.idName == 0) {
     
    98121               applet->info[i].dwHelpContext = 0;
    99122               applet->info[i].lData = info.lData;
    100                applet->info[i].hIcon = LoadIconA(applet->hModule,
    101                                                  MAKEINTRESOURCEA(info.idIcon));
    102                LoadStringA(applet->hModule, info.idName,
    103                            applet->info[i].szName, sizeof(applet->info[i].szName));
    104                LoadStringA(applet->hModule, info.idInfo,
    105                            applet->info[i].szInfo, sizeof(applet->info[i].szInfo));
     123               applet->info[i].hIcon = LoadIconW(applet->hModule,
     124                                                 MAKEINTRESOURCEW(info.idIcon));
     125               LoadStringW(applet->hModule, info.idName,
     126                           applet->info[i].szName, sizeof(applet->info[i].szName) / sizeof(WCHAR));
     127               LoadStringW(applet->hModule, info.idInfo,
     128                           applet->info[i].szInfo, sizeof(applet->info[i].szInfo) / sizeof(WCHAR));
    106129               applet->info[i].szHelpFile[0] = '\0';
    107130           }
     131       }
     132       else
     133       {
     134           CopyMemory(&applet->info[i], &newinfo, newinfo.dwSize);
     135           if (newinfo.dwSize != sizeof(NEWCPLINFOW))
     136           {
     137               applet->info[i].dwSize = sizeof(NEWCPLINFOW);
     138               MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szName,
     139                                   sizeof(((LPNEWCPLINFOA)&newinfo)->szName) / sizeof(CHAR),
     140                                   applet->info[i].szName,
     141                                   sizeof(applet->info[i].szName) / sizeof(WCHAR));
     142               MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szInfo,
     143                                   sizeof(((LPNEWCPLINFOA)&newinfo)->szInfo) / sizeof(CHAR),
     144                                   applet->info[i].szInfo,
     145                                   sizeof(applet->info[i].szInfo) / sizeof(WCHAR));
     146               MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szHelpFile,
     147                                   sizeof(((LPNEWCPLINFOA)&newinfo)->szHelpFile) / sizeof(CHAR),
     148                                   applet->info[i].szHelpFile,
     149                                   sizeof(applet->info[i].szHelpFile) / sizeof(WCHAR));
     150           }
    108151       }
    109152    }
     
    139182    CPlApplet*  applet;
    140183    RECT        rc;
    141    
     184
    142185    GetClientRect(panel->hWnd, &rc);
    143186    for (applet = panel->first; applet; applet = applet = applet->next) {
     
    183226            txtRect.top = y + YICON;
    184227            txtRect.bottom = y + YSTEP;
    185             DrawTextA(hdc, applet->info[i].szName, -1, &txtRect,
     228            DrawTextW(hdc, applet->info[i].szName, -1, &txtRect,
    186229                      DT_CENTER | DT_VCENTER);
    187230            x += XSTEP;
     
    197240    unsigned    i;
    198241    CPlApplet*  applet;
    199    
     242
    200243    if (Control_Localize(panel, LOWORD(lParam), HIWORD(lParam), &applet, &i)) {
    201244       if (up) {
     
    211254}
    212255
    213 static LRESULT WINAPI   Control_WndProc(HWND hWnd, UINT wMsg, 
     256static LRESULT WINAPI   Control_WndProc(HWND hWnd, UINT wMsg,
    214257                                        WPARAM lParam1, LPARAM lParam2)
    215258{
     
    256299    if (!RegisterClassA(&wc)) return;
    257300
    258     CreateWindowExA(0, wc.lpszClassName, "Wine Control Panel", 
    259                     WS_OVERLAPPEDWINDOW | WS_VISIBLE, 
    260                     CW_USEDEFAULT, CW_USEDEFAULT, 
    261                     CW_USEDEFAULT, CW_USEDEFAULT, 
    262                     hWnd, (HMENU)0, hInst, panel);
     301    CreateWindowExA(0, wc.lpszClassName, "Wine Control Panel",
     302                    WS_OVERLAPPEDWINDOW | WS_VISIBLE,
     303                    CW_USEDEFAULT, CW_USEDEFAULT,
     304                    CW_USEDEFAULT, CW_USEDEFAULT,
     305                    hWnd, NULL, hInst, panel);
    263306    if (!panel->hWnd) return;
    264307    while (GetMessageA(&msg, panel->hWnd, 0, 0)) {
     
    272315{
    273316    HANDLE              h;
    274     WIN32_FIND_DATAA    fd;
    275     char                buffer[MAX_PATH];
    276 
    277     /* FIXME: should grab path somewhere from configuration */
    278     if ((h = FindFirstFileA("c:\\windows\\system\\*.cpl", &fd)) != 0) {
     317    WIN32_FIND_DATAW    fd;
     318    WCHAR               buffer[MAX_PATH];
     319    static const WCHAR wszAllCpl[] = {'*','.','c','p','l',0};
     320    WCHAR *p;
     321
     322    GetSystemDirectoryW( buffer, MAX_PATH );
     323    p = buffer + strlenW(buffer);
     324    *p++ = '\\';
     325    lstrcpyW(p, wszAllCpl);
     326
     327    if ((h = FindFirstFileW(buffer, &fd)) != 0) {
    279328        do {
    280            sprintf(buffer, "c:\\windows\\system\\%s", fd.cFileName);
     329           lstrcpyW(p, fd.cFileName);
    281330           Control_LoadApplet(hWnd, buffer, panel);
    282         } while (FindNextFileA(h, &fd));
     331        } while (FindNextFileW(h, &fd));
    283332        FindClose(h);
    284333    }
     
    287336}
    288337
    289 static  void    Control_DoLaunch(CPanel* panel, HWND hWnd, LPCSTR cmd)
     338static  void    Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
    290339   /* forms to parse:
    291340    *   foo.cpl,@sp,str
     
    294343    *   foo.cpl @sp
    295344    *   foo.cpl str
     345    *   "a path\foo.cpl"
    296346    */
    297347{
    298     char*       buffer;
    299     char*       beg = NULL;
    300     char*       end;
    301     char        ch;
     348    LPWSTR      buffer;
     349    LPWSTR      beg = NULL;
     350    LPWSTR      end;
     351    WCHAR       ch;
     352    LPWSTR       ptr;
    302353    unsigned    sp = 0;
    303     char*       extraPmts = NULL;
    304 
    305     buffer = HeapAlloc(GetProcessHeap(), 0, strlen(cmd) + 1);
     354    LPWSTR      extraPmts = NULL;
     355    int        quoted = 0;
     356
     357    buffer = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(wszCmd) + 1) * sizeof(*wszCmd));
    306358    if (!buffer) return;
    307359
    308     end = strcpy(buffer, cmd);
     360    end = lstrcpyW(buffer, wszCmd);
    309361
    310362    for (;;) {
    311363        ch = *end;
    312         if (ch == ' ' || ch == ',' || ch == '\0') {
     364        if (ch == '"') quoted = !quoted;
     365        if (!quoted && (ch == ' ' || ch == ',' || ch == '\0')) {
    313366            *end = '\0';
    314367            if (beg) {
    315368                if (*beg == '@') {
    316                     sp = atoi(beg + 1);
     369                    sp = atoiW(beg + 1);
    317370                } else if (*beg == '\0') {
    318371                    sp = 0;
     
    327380        end++;
    328381    }
     382    while ((ptr = StrChrW(buffer, '"')))
     383        memmove(ptr, ptr+1, lstrlenW(ptr));
     384
     385    TRACE("cmd %s, extra %s, sp %d\n", debugstr_w(buffer), debugstr_w(extraPmts), sp);
     386
    329387    Control_LoadApplet(hWnd, buffer, panel);
    330388
     
    347405
    348406/*************************************************************************
    349  * Control_RunDLL                       [SHELL32.12]
    350  *
    351  */
    352 void WINAPI Control_RunDLL(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
     407 * Control_RunDLLW                      [SHELL32.@]
     408 *
     409 */
     410void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow)
    353411{
    354412    CPanel      panel;
    355413
    356     TRACE("(0x%08x, 0x%08lx, %s, 0x%08lx)\n",
    357           hWnd, (DWORD)hInst, debugstr_a(cmd), nCmdShow);
     414    TRACE("(%p, %p, %s, 0x%08lx)\n",
     415          hWnd, hInst, debugstr_w(cmd), nCmdShow);
    358416
    359417    memset(&panel, 0, sizeof(panel));
     
    367425
    368426/*************************************************************************
    369  * Control_FillCache_RunDLL                     [SHELL32.8]
     427 * Control_RunDLLA                      [SHELL32.@]
     428 *
     429 */
     430void WINAPI Control_RunDLLA(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
     431{
     432    DWORD len = MultiByteToWideChar(CP_ACP, 0, cmd, -1, NULL, 0 );
     433    LPWSTR wszCmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
     434    if (wszCmd && MultiByteToWideChar(CP_ACP, 0, cmd, -1, wszCmd, len ))
     435    {
     436        Control_RunDLLW(hWnd, hInst, wszCmd, nCmdShow);
     437    }
     438    HeapFree(GetProcessHeap(), 0, wszCmd);
     439}
     440
     441/*************************************************************************
     442 * Control_FillCache_RunDLL                     [SHELL32.@]
    370443 *
    371444 */
    372445HRESULT WINAPI Control_FillCache_RunDLL(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
    373446{
    374     FIXME("0x%04x 0x%04x 0x%04lx 0x%04lx stub\n",hWnd, hModule, w, x);
     447    FIXME("%p %p 0x%04lx 0x%04lx stub\n", hWnd, hModule, w, x);
    375448    return 0;
    376449}
     
    378451/*************************************************************************
    379452 * RunDLL_CallEntry16                           [SHELL32.122]
    380  * the name is propably wrong
     453 * the name is probably wrong
    381454 */
    382455HRESULT WINAPI RunDLL_CallEntry16(DWORD v, DWORD w, DWORD x, DWORD y, DWORD z)
     
    385458    return 0;
    386459}
     460
     461/*************************************************************************
     462 * CallCPLEntry16                               [SHELL32.166]
     463 *
     464 * called by desk.cpl on "Advanced" with:
     465 * hMod("DeskCp16.Dll"), pFunc("CplApplet"), 0, 1, 0xc, 0
     466 *
     467 */
     468DWORD WINAPI CallCPLEntry16(HMODULE hMod, FARPROC pFunc, DWORD dw3, DWORD dw4, DWORD dw5, DWORD dw6)
     469{
     470    FIXME("(%p, %p, %08lx, %08lx, %08lx, %08lx): stub.\n", hMod, pFunc, dw3, dw4, dw5, dw6);
     471    return 0x0deadbee;
     472}
Note: See TracChangeset for help on using the changeset viewer.