LCOV - code coverage report
Current view: top level - toolkit/xre - CreateAppData.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 37 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include "nsXULAppAPI.h"
       7             : #include "nsINIParser.h"
       8             : #include "nsIFile.h"
       9             : #include "nsAutoPtr.h"
      10             : #include "mozilla/XREAppData.h"
      11             : 
      12             : using namespace mozilla;
      13             : 
      14             : static void
      15           0 : ReadString(nsINIParser &parser, const char* section,
      16             :            const char* key, XREAppData::CharPtr& result)
      17             : {
      18           0 :   nsCString str;
      19           0 :   nsresult rv = parser.GetString(section, key, str);
      20           0 :   if (NS_SUCCEEDED(rv)) {
      21           0 :     result = str.get();
      22             :   }
      23           0 : }
      24             : 
      25             : struct ReadFlag {
      26             :   const char *section;
      27             :   const char *key;
      28             :   uint32_t flag;
      29             : };
      30             : 
      31             : static void
      32           0 : ReadFlag(nsINIParser &parser, const char* section,
      33             :          const char* key, uint32_t flag, uint32_t& result)
      34             : {
      35             :   char buf[6]; // large enough to hold "false"
      36           0 :   nsresult rv = parser.GetString(section, key, buf, sizeof(buf));
      37           0 :   if (NS_SUCCEEDED(rv) || rv == NS_ERROR_LOSS_OF_SIGNIFICANT_DATA) {
      38           0 :     if (buf[0] == '1' || buf[0] == 't' || buf[0] == 'T') {
      39           0 :       result |= flag;
      40             :     }
      41           0 :     if (buf[0] == '0' || buf[0] == 'f' || buf[0] == 'F') {
      42           0 :       result &= ~flag;
      43             :     }
      44             :   }
      45           0 : }
      46             : 
      47             : nsresult
      48           0 : XRE_ParseAppData(nsIFile* aINIFile, XREAppData& aAppData)
      49             : {
      50           0 :   NS_ENSURE_ARG(aINIFile);
      51             : 
      52             :   nsresult rv;
      53             : 
      54           0 :   nsINIParser parser;
      55           0 :   rv = parser.Init(aINIFile);
      56           0 :   if (NS_FAILED(rv))
      57           0 :     return rv;
      58             : 
      59           0 :   ReadString(parser, "App", "Vendor", aAppData.vendor);
      60           0 :   ReadString(parser, "App", "Name", aAppData.name);
      61           0 :   ReadString(parser, "App", "RemotingName", aAppData.remotingName);
      62           0 :   ReadString(parser, "App", "Version", aAppData.version);
      63           0 :   ReadString(parser, "App", "BuildID", aAppData.buildID);
      64           0 :   ReadString(parser, "App", "ID", aAppData.ID);
      65           0 :   ReadString(parser, "App", "Copyright", aAppData.copyright);
      66           0 :   ReadString(parser, "App", "Profile", aAppData.profile);
      67           0 :   ReadString(parser, "Gecko", "MinVersion", aAppData.minVersion);
      68           0 :   ReadString(parser, "Gecko", "MaxVersion", aAppData.maxVersion);
      69           0 :   ReadString(parser, "Crash Reporter", "ServerURL", aAppData.crashReporterURL);
      70           0 :   ReadString(parser, "App", "UAName", aAppData.UAName);
      71           0 :   ReadFlag(parser, "XRE", "EnableProfileMigrator",
      72           0 :            NS_XRE_ENABLE_PROFILE_MIGRATOR, aAppData.flags);
      73           0 :   ReadFlag(parser, "Crash Reporter", "Enabled",
      74           0 :            NS_XRE_ENABLE_CRASH_REPORTER, aAppData.flags);
      75             : 
      76           0 :   return NS_OK;
      77             : }

Generated by: LCOV version 1.13