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/. */
6 #include "nsXULAppAPI.h"
7 #include "nsINIParser.h"
9 #include "mozilla/XREAppData.h"
11 // This include must appear early in the unified cpp file for toolkit/xre to
12 // make sure OSX APIs make use of the OSX TextRange before mozilla::TextRange is
13 // declared and made a global symbol by a "using namespace mozilla" declaration.
15 # include <Carbon/Carbon.h>
18 using namespace mozilla
;
20 static void ReadString(nsINIParser
& parser
, const char* section
,
21 const char* key
, XREAppData::CharPtr
& result
) {
23 nsresult rv
= parser
.GetString(section
, key
, str
);
24 if (NS_SUCCEEDED(rv
)) {
35 static void ReadFlag(nsINIParser
& parser
, const char* section
, const char* key
,
36 uint32_t flag
, uint32_t& result
) {
37 char buf
[6]; // large enough to hold "false"
38 nsresult rv
= parser
.GetString(section
, key
, buf
, sizeof(buf
));
39 if (NS_SUCCEEDED(rv
) || rv
== NS_ERROR_LOSS_OF_SIGNIFICANT_DATA
) {
40 if (buf
[0] == '1' || buf
[0] == 't' || buf
[0] == 'T') {
43 if (buf
[0] == '0' || buf
[0] == 'f' || buf
[0] == 'F') {
49 nsresult
XRE_ParseAppData(nsIFile
* aINIFile
, XREAppData
& aAppData
) {
50 NS_ENSURE_ARG(aINIFile
);
55 rv
= parser
.Init(aINIFile
);
56 if (NS_FAILED(rv
)) return rv
;
58 ReadString(parser
, "App", "Vendor", aAppData
.vendor
);
59 ReadString(parser
, "App", "Name", aAppData
.name
);
60 ReadString(parser
, "App", "RemotingName", aAppData
.remotingName
);
61 ReadString(parser
, "App", "Version", aAppData
.version
);
62 ReadString(parser
, "App", "BuildID", aAppData
.buildID
);
63 ReadString(parser
, "App", "ID", aAppData
.ID
);
64 ReadString(parser
, "App", "Copyright", aAppData
.copyright
);
65 ReadString(parser
, "App", "Profile", aAppData
.profile
);
66 ReadString(parser
, "Gecko", "MinVersion", aAppData
.minVersion
);
67 ReadString(parser
, "Gecko", "MaxVersion", aAppData
.maxVersion
);
68 ReadString(parser
, "Crash Reporter", "ServerURL", aAppData
.crashReporterURL
);
69 ReadString(parser
, "App", "UAName", aAppData
.UAName
);
70 ReadString(parser
, "AppUpdate", "URL", aAppData
.updateURL
);
71 ReadFlag(parser
, "XRE", "EnableProfileMigrator",
72 NS_XRE_ENABLE_PROFILE_MIGRATOR
, aAppData
.flags
);
73 ReadFlag(parser
, "Crash Reporter", "Enabled", NS_XRE_ENABLE_CRASH_REPORTER
,