예제 #1
0
BOOLEAN
ProcessKeyboardLayoutRegistry(
    PGENERIC_LIST List)
{
    PGENERIC_LIST_ENTRY Entry;
    PWCHAR LayoutId;
    const MUI_LAYOUTS * LayoutsList;
    MUI_LAYOUTS NewLayoutsList[20];
    ULONG uIndex;
    ULONG uOldPos = 0;

    Entry = GetCurrentListEntry(List);
    if (Entry == NULL)
        return FALSE;

    LayoutId = (PWCHAR)GetListEntryUserData(Entry);
    if (LayoutId == NULL)
        return FALSE;

    LayoutsList = MUIGetLayoutsList();

    if (_wcsicmp(LayoutsList[0].LayoutID, LayoutId) != 0)
    {
        for (uIndex = 1; LayoutsList[uIndex].LangID != NULL; uIndex++)
        {
            if (_wcsicmp(LayoutsList[uIndex].LayoutID, LayoutId) == 0)
            {
                uOldPos = uIndex;
                continue;
            }

            NewLayoutsList[uIndex].LangID   = LayoutsList[uIndex].LangID;
            NewLayoutsList[uIndex].LayoutID = LayoutsList[uIndex].LayoutID;
        }

        NewLayoutsList[uIndex].LangID    = NULL;
        NewLayoutsList[uIndex].LayoutID  = NULL;
        NewLayoutsList[uOldPos].LangID   = LayoutsList[0].LangID;
        NewLayoutsList[uOldPos].LayoutID = LayoutsList[0].LayoutID;
        NewLayoutsList[0].LangID         = LayoutsList[uOldPos].LangID;
        NewLayoutsList[0].LayoutID       = LayoutsList[uOldPos].LayoutID;

        return AddKbLayoutsToRegistry(NewLayoutsList);
    }

    return TRUE;
}
예제 #2
0
파일: settings.c 프로젝트: RareHare/reactos
PGENERIC_LIST
CreateKeyboardLayoutList(HINF InfFile, WCHAR * DefaultKBLayout)
{
    CHAR Buffer[128];
    PGENERIC_LIST List;
    INFCONTEXT Context;
    PWCHAR KeyName;
    PWCHAR KeyValue;
    PWCHAR UserData;
    const MUI_LAYOUTS * LayoutsList;
    ULONG uIndex = 0;
    BOOL KeyboardLayoutsFound = FALSE;

    /* Get default layout id */
    if (!SetupFindFirstLineW (InfFile, L"NLS", L"DefaultLayout", &Context))
        return NULL;

    if (!INF_GetData (&Context, NULL, &KeyValue))
        return NULL;

    wcscpy(DefaultKBLayout, KeyValue);

    List = CreateGenericList();
    if (List == NULL)
        return NULL;

    LayoutsList = MUIGetLayoutsList();

    do
    {
        if (!SetupFindFirstLineW(InfFile, L"KeyboardLayout", NULL, &Context))
        {
            DestroyGenericList(List, FALSE);
            return NULL;
        }

        do
        {
            if (!INF_GetData (&Context, &KeyName, &KeyValue))
            {
                /* FIXME: Handle error! */
                DPRINT("INF_GetData() failed\n");
                DestroyGenericList(List, FALSE);
                return NULL;
            }

            if (_wcsicmp(LayoutsList[uIndex].LayoutID, KeyName) == 0)
            {
                UserData = (WCHAR*) RtlAllocateHeap(ProcessHeap,
                                                0,
                                                (wcslen(KeyName) + 1) * sizeof(WCHAR));

                if (UserData == NULL)
                {
                    /* FIXME: Handle error! */
                    DPRINT("RtlAllocateHeap() failed\n");
                    DestroyGenericList(List, FALSE);
                    return NULL;
                }

                wcscpy(UserData, KeyName);

                sprintf(Buffer, "%S", KeyValue);
                AppendGenericListEntry(List,
                                       Buffer,
                                       UserData,
                                       _wcsicmp(KeyName, DefaultKBLayout) ? FALSE : TRUE);
                KeyboardLayoutsFound = TRUE;
            }

        } while (SetupFindNextLine(&Context, &Context));

        uIndex++;

    } while (LayoutsList[uIndex].LangID != NULL);

    /* FIXME: Handle this case */
    if (!KeyboardLayoutsFound)
    {
        DPRINT1("No keyboard layouts have been found\n");
        DestroyGenericList(List, FALSE);
        return NULL;
    }

    return List;
}