Reading default preferences in C++ - Mozilla

This is a discussion on Reading default preferences in C++ - Mozilla ; When I attempt to read a default preference via nsIPrefBranch::GetCharPref, I'm getting what I think is a chrome URI instead of the pref I see when I load about :config. Considering the following: nsresult rv; nsCOMPtr prefBranch; char *pszHomePage; rv ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Reading default preferences in C++

  1. Reading default preferences in C++

    When I attempt to read a default preference via
    nsIPrefBranch::GetCharPref, I'm getting what I think is a chrome URI
    instead of the pref I see when I load about:config.

    Considering the following:
    nsresult rv;
    nsCOMPtr prefBranch;
    char *pszHomePage;

    rv = prefService->GetBranch("", getter_AddRefs(prefBranch));
    rv = prefBranch->GetCharPref("browser.startup.homepage",
    &pszHomePage);


    When my home page is user set I can retrieve it. However, when it is
    the default ("http://www.google.com/firefox?client=firefox-
    a&rls=org.mozilla:en-USfficial"), I'm receiving "resource:/
    browserconfig.properties"

    I'd like to get the actual URL (the google one), not the file that
    contains the value. Anyone know what I'm doing wrong?

    Thanks,
    Dave


  2. Re: Reading default preferences in C++

    test1033@gmail.com wrote:

    >When I attempt to read a default preference via nsIPrefBranch::GetCharPref, I'm getting what I think is a chrome URI instead of the pref I see when I load about:config.
    >
    >

    That's because it's a localised pref, so you need to call
    GetComplexValue to retrieve the actual URL:

    nsCOMPtr urlString;
    prefBranch->GetComplexValue("browser.startup.homepage",
    NS_GET_IID(nsIPrefLocalisedString), getter_AddRefs(urlString));
    if (urlString) {
    nsXPIDLString data;
    urlString->GetData(getter_Copies(data));
    }

    --
    Warning: May contain traces of nuts.

  3. Re: Reading default preferences in C++

    Sir, I owe you a beer.

    Thanks!
    Dave


+ Reply to Thread