コード例 #1
0
ファイル: settings.c プロジェクト: hoangduit/reactos
PGENERIC_LIST
CreateKeyboardDriverList(
    HINF InfFile)
{
    CHAR Buffer[128];
    PGENERIC_LIST List;
    INFCONTEXT Context;
    PWCHAR KeyName;
    PWCHAR KeyValue;
    PWCHAR UserData;

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

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

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

        UserData = (WCHAR*)RtlAllocateHeap(ProcessHeap,
                                           0,
                                           (wcslen(KeyName) + 1) * sizeof(WCHAR));
        if (UserData == NULL)
        {
            /* FIXME: Handle error! */
        }

        wcscpy(UserData, KeyName);

        sprintf(Buffer, "%S", KeyValue);
        AppendGenericListEntry(List, Buffer, UserData, FALSE);
    } while (SetupFindNextLine(&Context, &Context));

    return List;
}
コード例 #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;
}
コード例 #3
0
ファイル: settings.c プロジェクト: RareHare/reactos
PGENERIC_LIST
CreateLanguageList(HINF InfFile, WCHAR * DefaultLanguage) 
{
    CHAR Buffer[128];
    PGENERIC_LIST List;
    INFCONTEXT Context;
    PWCHAR KeyName;
    PWCHAR KeyValue;
    PWCHAR UserData = NULL;
    ULONG uIndex = 0;

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

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

    wcscpy(DefaultLanguage, KeyValue);

    SelectedLanguageId = KeyValue;

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

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

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

        if (IsLanguageAvailable(KeyName))
        {

            UserData = (WCHAR*) RtlAllocateHeap(ProcessHeap,
                                                0,
                                                (wcslen(KeyName) + 1) * sizeof(WCHAR));
            if (UserData == NULL)
            {
                /* FIXME: Handle error! */
            }

            wcscpy(UserData, KeyName);

            if (!_wcsicmp(KeyName, DefaultLanguage))
                DefaultLanguageIndex = uIndex;

            sprintf(Buffer, "%S", KeyValue);
            AppendGenericListEntry(List,
                                   Buffer,
                                   UserData,
                                   FALSE);
            uIndex++;
        }
    } while (SetupFindNextLine(&Context, &Context));

    /* Only one language available, make it the default one */
    if(uIndex == 1 && UserData != NULL)
    {
        DefaultLanguageIndex = 0;
        wcscpy(DefaultLanguage, UserData);
    }

    return List;
}
コード例 #4
0
ファイル: settings.c プロジェクト: RareHare/reactos
PGENERIC_LIST
CreateDisplayDriverList(HINF InfFile)
{
    CHAR Buffer[128];
    PGENERIC_LIST List;
    INFCONTEXT Context;
    PWCHAR KeyName;
    PWCHAR KeyValue;
    PWCHAR UserData;
    WCHAR DisplayIdentifier[128];
    WCHAR DisplayKey[32];

    /* Get the display identification */
    if (!GetDisplayIdentifier(DisplayIdentifier, 128))
    {
        DisplayIdentifier[0] = 0;
    }

    DPRINT("Display identifier: '%S'\n", DisplayIdentifier);

    /* Search for matching device identifier */
    if (!SetupFindFirstLineW(InfFile, L"Map.Display", NULL, &Context))
    {
        /* FIXME: error message */
        return NULL;
    }

    do
    {
        if (!INF_GetDataField(&Context, 1, &KeyValue))
        {
            /* FIXME: Handle error! */
            DPRINT("INF_GetDataField() failed\n");
            return NULL;
        }

        DPRINT("KeyValue: %S\n", KeyValue);
        if (wcsstr(DisplayIdentifier, KeyValue))
        {
            if (!INF_GetDataField(&Context, 0, &KeyName))
            {
                /* FIXME: Handle error! */
                DPRINT("INF_GetDataField() failed\n");
                return NULL;
            }

            DPRINT("Display key: %S\n", KeyName);
            wcscpy(DisplayKey, KeyName);
        }
    } while (SetupFindNextLine(&Context, &Context));

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

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

    do
    {
        if (!INF_GetDataField(&Context, 0, &KeyName))
        {
            DPRINT1("INF_GetDataField() failed\n");
            break;
        }

        if (!INF_GetDataField(&Context, 1, &KeyValue))
        {
            DPRINT1("INF_GetDataField() failed\n");
            break;
        }

        UserData = (WCHAR*) RtlAllocateHeap(ProcessHeap,
                                            0,
                                            (wcslen(KeyName) + 1) * sizeof(WCHAR));
        if (UserData == NULL)
        {
            DPRINT1("RtlAllocateHeap() failed\n");
            DestroyGenericList(List, TRUE);
            return NULL;
        }

        wcscpy(UserData, KeyName);

        sprintf(Buffer, "%S", KeyValue);
        AppendGenericListEntry(List,
                               Buffer,
                               UserData,
                               _wcsicmp(KeyName, DisplayKey) ? FALSE : TRUE);
    } while (SetupFindNextLine(&Context, &Context));

#if 0
    AppendGenericListEntry(List, "Other display driver", NULL, TRUE);
#endif

    return List;
}