> nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
> nsresult nsres=prefs->SetCharPref("network.proxy.socks", proxy.hostName());

I use this means too, no problem, but may be a little different, my
code:

nsCOMPtr<nsIPref> pref = do_GetService(NS_PREF_CONTRACTID);
if (pref)
{
        if (PROXY_ENABLED)
        {
                pref->SetIntPref("network.proxy.type", 1);
                pref->SetCharPref("network.proxy.http", PROXY_HOST);
                pref->SetIntPref("network.proxy.http_port", PROXY_PORT);
        }
}

The differences are:
1. you didn't specify network.proxy.type, whose default value is 0
meaning no proxy
2. you didn't give ght port number (for socks proxy, i don't know)


>   if (prefService) {
>     prefService->SavePrefFile(nsnull);
>     prefService->ResetPrefs();
>     prefService->ReadUserPrefs(nsnull);
>   }
>   does not help too
>
>  setting browser offline and then online by nsIIOService also doesnt seem to

I didn't use these two means.
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to