• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ nsINIParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中nsINIParser的典型用法代码示例。如果您正苦于以下问题:C++ nsINIParser类的具体用法?C++ nsINIParser怎么用?C++ nsINIParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了nsINIParser类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:nikhilm,项目名称:v8monkey,代码行数:58,代码来源:nsOperaProfileMigrator.cpp


示例2: RegisterExtensionInterpositions

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);
}
开发者ID:ChaOSChriS,项目名称:gecko-dev,代码行数:25,代码来源:nsXREDirProvider.cpp


示例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;
}
开发者ID:nikhilm,项目名称:v8monkey,代码行数:33,代码来源:nsOperaProfileMigrator.cpp


示例4: LoadExtensionDirectories

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);
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:33,代码来源:nsXREDirProvider.cpp


示例5: PromiseFlatCString

NS_IMETHODIMP
nsINIParserImpl::GetString(const nsACString& aSection,
                           const nsACString& aKey,
                           nsACString& aResult)
{
  return mParser.GetString(PromiseFlatCString(aSection).get(),
                           PromiseFlatCString(aKey).get(),
                           aResult);
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:9,代码来源:nsINIParserImpl.cpp


示例6: ReadStrings

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;
  }
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:15,代码来源:CreateAppData.cpp


示例7:

NS_IMETHODIMP
nsINIParserImpl::GetSections(nsIUTF8StringEnumerator* *aResult)
{
  nsTArray<nsCString> *strings = new nsTArray<nsCString>;
  if (!strings)
    return NS_ERROR_OUT_OF_MEMORY;

  nsresult rv = mParser.GetSections(SectionCB, strings);
  if (NS_SUCCEEDED(rv))
    rv = NS_NewAdoptingUTF8StringEnumerator(aResult, strings);

  if (NS_FAILED(rv))
    delete strings;

  return rv;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:16,代码来源:nsINIParserImpl.cpp


示例8: ReadFlags

static void
ReadFlags(nsINIParser &parser, const ReadFlag *reads, uint32_t *buffer)
{
  nsresult rv;
  char buf[6]; // large enough to hold "false"

  while (reads->section) {
    rv = parser.GetString(reads->section, reads->key, buf, sizeof(buf));
    if (NS_SUCCEEDED(rv) || rv == NS_ERROR_LOSS_OF_SIGNIFICANT_DATA) {
      if (buf[0] == '1' || buf[0] == 't' || buf[0] == 'T') {
        *buffer |= reads->flag;
      }
      if (buf[0] == '0' || buf[0] == 'f' || buf[0] == 'F') {
        *buffer &= ~reads->flag;
      }
    }

    ++reads;
  }
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:20,代码来源:CreateAppData.cpp


示例9: LoadExtensionDirectories

static void
LoadExtensionDirectories(nsINIParser &parser,
                         const char *aSection,
                         nsCOMArray<nsIFile> &aDirectories,
                         NSLocationType aType)
{
  nsresult rv;
  int32_t i = 0;
  do {
    nsAutoCString buf("Extension");
    buf.AppendInt(i++);

    nsAutoCString path;
    rv = parser.GetString(aSection, buf.get(), path);
    if (NS_FAILED(rv))
      return;

    nsCOMPtr<nsIFile> 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);
    if (Substring(path, path.Length() - 4).EqualsLiteral(".xpi")) {
      XRE_AddJarManifestLocation(aType, dir);
    }
    else {
      nsCOMPtr<nsIFile> manifest =
        CloneAndAppend(dir, "chrome.manifest");
      XRE_AddManifestLocation(aType, manifest);
    }
  }
  while (true);
}
开发者ID:ChaOSChriS,项目名称:gecko-dev,代码行数:37,代码来源:nsXREDirProvider.cpp


示例10: 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);
  }
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:75,代码来源:webapprt.cpp



注:本文中的nsINIParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ nsIRDFService类代码示例发布时间:2022-05-31
下一篇:
C++ nsIImportAddressBooks类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap