本文整理汇总了C++中nsINIParser::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ nsINIParser::GetString方法的具体用法?C++ nsINIParser::GetString怎么用?C++ nsINIParser::GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsINIParser
的用法示例。
在下文中一共展示了nsINIParser::GetString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sprintf
nsresult
nsOperaProfileMigrator::CopyProxySettings(nsINIParser &aParser,
nsIPrefBranch* aBranch)
{
nsresult rv;
PRInt32 networkProxyType = 0;
const char* protocols[] = { "HTTP", "HTTPS", "FTP" };
const char* protocols_l[] = { "http", "https", "ftp" };
char toggleBuf[15], serverBuf[20], serverPrefBuf[20],
serverPortPrefBuf[25];
PRInt32 enabled;
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(protocols); ++i) {
sprintf(toggleBuf, "Use %s", protocols[i]);
GetInteger(aParser, "Proxy", toggleBuf, &enabled);
if (enabled) {
// Enable the "manual configuration" setting if we have at least
// one protocol using a Proxy.
networkProxyType = 1;
}
sprintf(serverBuf, "%s Server", protocols[i]);
nsCAutoString proxyServer;
rv = aParser.GetString("Proxy", serverBuf, proxyServer);
if (NS_FAILED(rv))
continue;
sprintf(serverPrefBuf, "network.proxy.%s", protocols_l[i]);
sprintf(serverPortPrefBuf, "network.proxy.%s_port", protocols_l[i]);
// strings in Opera pref. file are in UTF-8
SetProxyPref(NS_ConvertUTF8toUTF16(proxyServer),
serverPrefBuf, serverPortPrefBuf, aBranch);
}
GetInteger(aParser, "Proxy", "Use Automatic Proxy Configuration", &enabled);
if (enabled)
networkProxyType = 2;
nsCAutoString configURL;
rv = aParser.GetString("Proxy", "Automatic Proxy Configuration URL",
configURL);
if (NS_SUCCEEDED(rv))
aBranch->SetCharPref("network.proxy.autoconfig_url", configURL.get());
GetInteger(aParser, "Proxy", "No Proxy Servers Check", &enabled);
if (enabled) {
nsCAutoString servers;
rv = aParser.GetString("Proxy", "No Proxy Servers", servers);
if (NS_SUCCEEDED(rv))
// strings in Opera pref. file are in UTF-8
ParseOverrideServers(NS_ConvertUTF8toUTF16(servers), aBranch);
}
aBranch->SetIntPref("network.proxy.type", networkProxyType);
return NS_OK;
}
示例2: buf
static void
RegisterExtensionInterpositions(nsINIParser &parser)
{
if (!mozilla::Preferences::GetBool("extensions.interposition.enabled", false))
return;
nsCOMPtr<nsIAddonInterposition> interposition =
do_GetService("@mozilla.org/addons/multiprocess-shims;1");
nsresult rv;
int32_t i = 0;
do {
nsAutoCString buf("Extension");
buf.AppendInt(i++);
nsAutoCString addonId;
rv = parser.GetString("MultiprocessIncompatibleExtensions", buf.get(), addonId);
if (NS_FAILED(rv))
return;
if (!xpc::SetAddonInterposition(addonId, interposition))
continue;
}
while (true);
}
示例3:
nsresult
nsOperaProfileMigrator::CopyUserContentSheet(nsINIParser &aParser)
{
nsresult rv;
nsCAutoString userContentCSS;
rv = aParser.GetString("User Prefs", "Local CSS File", userContentCSS);
if (NS_FAILED(rv) || userContentCSS.Length() == 0)
return NS_OK;
// Copy the file
nsCOMPtr<nsILocalFile> userContentCSSFile;
rv = NS_NewNativeLocalFile(userContentCSS, PR_TRUE,
getter_AddRefs(userContentCSSFile));
if (NS_FAILED(rv))
return NS_OK;
PRBool exists;
rv = userContentCSSFile->Exists(&exists);
if (NS_FAILED(rv) || !exists)
return NS_OK;
nsCOMPtr<nsIFile> profileChromeDir;
NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR,
getter_AddRefs(profileChromeDir));
if (!profileChromeDir)
return NS_OK;
userContentCSSFile->CopyToNative(profileChromeDir,
NS_LITERAL_CSTRING("userContent.css"));
return NS_OK;
}
示例4: buf
static void
LoadExtensionDirectories(nsINIParser &parser,
const char *aSection,
nsCOMArray<nsIFile> &aDirectories,
NSLocationType aType)
{
nsresult rv;
PRInt32 i = 0;
do {
nsCAutoString buf("Extension");
buf.AppendInt(i++);
nsCAutoString path;
rv = parser.GetString(aSection, buf.get(), path);
if (NS_FAILED(rv))
return;
nsCOMPtr<nsILocalFile> dir = do_CreateInstance("@mozilla.org/file/local;1", &rv);
if (NS_FAILED(rv))
continue;
rv = dir->SetPersistentDescriptor(path);
if (NS_FAILED(rv))
continue;
aDirectories.AppendObject(dir);
nsCOMPtr<nsILocalFile> manifest =
CloneAndAppend(dir, "chrome.manifest");
XRE_AddManifestLocation(aType, manifest);
}
while (PR_TRUE);
}
示例5: PromiseFlatCString
NS_IMETHODIMP
nsINIParserImpl::GetString(const nsACString& aSection,
const nsACString& aKey,
nsACString& aResult)
{
return mParser.GetString(PromiseFlatCString(aSection).get(),
PromiseFlatCString(aKey).get(),
aResult);
}
示例6: while
static void
ReadStrings(nsINIParser &parser, const ReadString *reads)
{
nsresult rv;
nsCString str;
while (reads->section) {
rv = parser.GetString(reads->section, reads->key, str);
if (NS_SUCCEEDED(rv)) {
SetAllocatedString(*reads->buffer, str);
}
++reads;
}
}
示例7: RemoveApplication
void RemoveApplication(nsINIParser& parser, const char* curExeDir, const char* profile) {
if (!isProfileOverridden) {
// Remove the desktop entry file.
char desktopEntryFilePath[MAXPATHLEN];
char* dataDir = getenv("XDG_DATA_HOME");
if (dataDir && *dataDir) {
snprintf(desktopEntryFilePath, MAXPATHLEN, "%s/applications/owa-%s.desktop", dataDir, profile);
} else {
char* home = getenv("HOME");
snprintf(desktopEntryFilePath, MAXPATHLEN, "%s/.local/share/applications/owa-%s.desktop", home, profile);
}
unlink(desktopEntryFilePath);
}
// Remove the files from the installation directory.
char webAppIniPath[MAXPATHLEN];
snprintf(webAppIniPath, MAXPATHLEN, "%s/%s", curExeDir, kWEBAPP_INI);
unlink(webAppIniPath);
char curExePath[MAXPATHLEN];
snprintf(curExePath, MAXPATHLEN, "%s/%s", curExeDir, kAPP_RT);
unlink(curExePath);
char webAppJsonPath[MAXPATHLEN];
snprintf(webAppJsonPath, MAXPATHLEN, "%s/%s", curExeDir, kWEBAPP_JSON);
unlink(webAppJsonPath);
char iconPath[MAXPATHLEN];
snprintf(iconPath, MAXPATHLEN, "%s/icon.png", curExeDir);
unlink(iconPath);
char appName[MAXPATHLEN];
if (NS_FAILED(parser.GetString("Webapp", "Name", appName, MAXPATHLEN))) {
strcpy(appName, profile);
}
char uninstallMsg[MAXPATHLEN];
if (NS_SUCCEEDED(parser.GetString("Webapp", "UninstallMsg", uninstallMsg, MAXPATHLEN))) {
/**
* The only difference between libnotify.so.4 and libnotify.so.1 for these symbols
* is that notify_notification_new takes three arguments in libnotify.so.4 and
* four in libnotify.so.1.
* Passing the fourth argument as NULL is binary compatible.
*/
typedef void (*notify_init_t)(const char*);
typedef void* (*notify_notification_new_t)(const char*, const char*, const char*, const char*);
typedef void (*notify_notification_show_t)(void*, void**);
void *handle = dlopen("libnotify.so.4", RTLD_LAZY);
if (!handle) {
handle = dlopen("libnotify.so.1", RTLD_LAZY);
if (!handle)
return;
}
notify_init_t nn_init = (notify_init_t)(uintptr_t)dlsym(handle, "notify_init");
notify_notification_new_t nn_new = (notify_notification_new_t)(uintptr_t)dlsym(handle, "notify_notification_new");
notify_notification_show_t nn_show = (notify_notification_show_t)(uintptr_t)dlsym(handle, "notify_notification_show");
if (!nn_init || !nn_new || !nn_show) {
dlclose(handle);
return;
}
nn_init(appName);
void* n = nn_new(uninstallMsg, NULL, "dialog-information", NULL);
nn_show(n, NULL);
dlclose(handle);
}
}