Skip to content

Commit

Permalink
Add CTRE license
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Dec 14, 2024
1 parent 8076e46 commit 4959c4e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 33 deletions.
2 changes: 1 addition & 1 deletion docsSite/docs/getting-started/manage-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Image2 from './img/open-file-2.png';
- **RLOG (.rlog)** - Legacy, produced by AdvantageKit 2022.

:::info
Hoot log files can only be opened after agreeing to CTRE's [terms and conditions](https://PLACEHOLDER). AdvantageScope displays a prompt to confirm agreement to these terms when opening a Hoot log file for the first time.
Hoot log files can only be opened after agreeing to CTRE's [end user license agreement](https://raw.githubusercontent.com/CrossTheRoadElec/Phoenix-Releases/refs/heads/master/CTRE_LICENSE.txt). AdvantageScope displays a prompt to confirm agreement to these terms when opening a Hoot log file for the first time.
:::

## Opening Logs
Expand Down
5 changes: 0 additions & 5 deletions src/hub/dataSources/HistoricalDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ export class HistoricalDataSource {
this.refreshCallback = refreshCallback;

// Post message to start reading
if (path.endsWith(".hoot") && window.platform === "win32" && window.platformArch !== "x64") {
this.customError = "CTRE does not support Hoot file decoding on Windows for ARM.";
this.setStatus(HistoricalDataSourceStatus.Error);
return;
}
if (this.path.endsWith(".dsevents")) {
this.path = this.path.slice(0, -8) + "dslog";
}
Expand Down
76 changes: 49 additions & 27 deletions src/main/main.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { hex } from "color-convert";
import {
app,
BrowserWindow,
BrowserWindowConstructorOptions,
clipboard,
dialog,
FileFilter,
Menu,
MenuItem,
MessageChannelMain,
MessagePortMain,
TitleBarOverlay,
TouchBar,
TouchBarSlider,
app,
clipboard,
dialog,
nativeImage,
nativeTheme,
powerMonitor,
shell
shell,
TitleBarOverlay,
TouchBar,
TouchBarSlider
} from "electron";
import fs from "fs";
import jsonfile from "jsonfile";
Expand Down Expand Up @@ -81,7 +81,7 @@ import {
shouldPromptBetaSurvey
} from "./betaUtil";
import { getOwletDownloadStatus, startOwletDownloadLoop } from "./owletDownloadLoop";
import { checkHootIsPro, convertHoot } from "./owletInterface";
import { checkHootIsPro, convertHoot, CTRE_LICENSE_URL } from "./owletInterface";

// Global variables
let hubWindows: BrowserWindow[] = []; // Ordered by last focus time (recent first)
Expand All @@ -93,6 +93,7 @@ let satelliteWindows: { [id: string]: BrowserWindow[] } = {};
let windowPorts: { [id: number]: MessagePortMain } = {};
let hubTouchBarSliders: { [id: number]: TouchBarSlider } = {};
let hubExportingIds: Set<number> = new Set();
let ctreLicensePrompt: Promise<void> | null = null;

let stateTracker = new StateTracker();
let updateChecker = new UpdateChecker();
Expand Down Expand Up @@ -326,29 +327,50 @@ async function handleHubMessage(window: BrowserWindow, message: NamedMessage) {
} else if (path.endsWith(".hoot")) {
// Hoot, convert to WPILOG
targetCount += 1;

// Prompt for CTRE license if not accepted
let prefs: Preferences = jsonfile.readFileSync(PREFS_FILENAME);
if (!prefs.ctreLicenseAccepted) {
let response = await new Promise<Electron.MessageBoxReturnValue>((resolve) =>
dialog
.showMessageBox(window, {
type: "info",
title: "Alert",
message: "CTRE Terms & Conditions",
detail:
"Hoot log file decoding requires agreement to CTRE's terms and conditions. Please navigate to the address below to view the full license agreement.\n\n<PLACEHOLDER>",
checkboxLabel: "I Agree",
icon: WINDOW_ICON
})
.then((response) => resolve(response))
);
// if (response.checkboxChecked) {
// prefs.ctreLicenseAccepted = true;
// jsonfile.writeFileSync(PREFS_FILENAME, prefs);
// sendAllPreferences();
// }
if (ctreLicensePrompt === null) {
ctreLicensePrompt = new Promise(async (resolve) => {
while (true) {
let response = await new Promise<Electron.MessageBoxReturnValue>((resolve) =>
dialog
.showMessageBox(window, {
type: "question",
title: "Alert",
message: "CTRE License Agreement",
detail:
"Hoot log file decoding requires agreement to CTRE's end user license agreement. Please click the button below to view the full license agreement, then check the box if you agree to the terms.",
checkboxLabel: "I Agree",
buttons: ["View License", "OK"],
defaultId: 1,
icon: WINDOW_ICON
})
.then((response) => resolve(response))
);
if (response.response === 1) {
if (response.checkboxChecked) {
prefs.ctreLicenseAccepted = true;
jsonfile.writeFileSync(PREFS_FILENAME, prefs);
sendAllPreferences();
}
resolve();
break;
} else {
shell.openExternal(CTRE_LICENSE_URL);
}
}
});
}
await ctreLicensePrompt;
ctreLicensePrompt = null;
}

// Check for license and open file
prefs = jsonfile.readFileSync(PREFS_FILENAME);
if (!prefs.ctreLicenseAccepted) {
errorMessage = "Hoot log files cannot be decoded without agreeing to CTRE's terms and conditions.";
errorMessage = "Hoot log files cannot be decoded without agreeing to CTRE's end user license agreement.";
completedCount++;
sendIfReady();
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/main/owletInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import path from "path";
import { createUUID } from "../shared/util";
import { OWLET_STORAGE } from "./owletDownloadLoop";

export const CTRE_LICENSE_URL =
"https://raw.githubusercontent.com/CrossTheRoadElec/Phoenix-Releases/refs/heads/master/CTRE_LICENSE.txt";

/**
* Converts a Hoot log to WPILOG
*
Expand Down

0 comments on commit 4959c4e

Please sign in to comment.