1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/XREAppData.h"
12 XREAppData
& XREAppData::operator=(const StaticXREAppData
& aOther
) {
13 vendor
= aOther
.vendor
;
15 remotingName
= aOther
.remotingName
;
16 version
= aOther
.version
;
17 buildID
= aOther
.buildID
;
19 copyright
= aOther
.copyright
;
21 minVersion
= aOther
.minVersion
;
22 maxVersion
= aOther
.maxVersion
;
23 crashReporterURL
= aOther
.crashReporterURL
;
24 profile
= aOther
.profile
;
25 UAName
= aOther
.UAName
;
26 sourceURL
= aOther
.sourceURL
;
27 updateURL
= aOther
.updateURL
;
32 XREAppData
& XREAppData::operator=(const XREAppData
& aOther
) = default;
34 void XREAppData::SanitizeNameForDBus(nsACString
& aName
) {
35 auto IsValidDBusNameChar
= [](char aChar
) {
36 return IsAsciiAlpha(aChar
) || IsAsciiDigit(aChar
) || aChar
== '_';
39 // D-Bus names can contain only [a-z][A-Z][0-9]_, so we replace all characters
40 // that aren't in that range with underscores.
41 char* cur
= aName
.BeginWriting();
42 char* end
= aName
.EndWriting();
43 for (; cur
!= end
; cur
++) {
44 if (!IsValidDBusNameChar(*cur
)) {
50 void XREAppData::GetDBusAppName(nsACString
& aName
) const {
51 const char* env
= getenv("MOZ_DBUS_APP_NAME");
55 aName
.Assign(remotingName
);
56 SanitizeNameForDBus(aName
);
60 } // namespace mozilla