From 9fa56d3e4f2cee4c2a8cf551d9fd768a1ea77ca2 Mon Sep 17 00:00:00 2001 From: Wade Mergenthal Date: Mon, 25 Aug 2025 16:54:52 -0400 Subject: [PATCH 1/7] HT now sends 'sync_interrupted' when a sync is cancelled before completing The substantive changes will only be a few lines. This is a safety commit after the first time both normal and cancel scenarios work. The extra debug output code is still in place and will be removed next, prior to pull_request. --- src/HearThis/Communication/AndroidLink.cs | 11 +++++++++- .../Communication/AndroidSynchronization.cs | 22 ++++++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/HearThis/Communication/AndroidLink.cs b/src/HearThis/Communication/AndroidLink.cs index 67a6da41..a707a924 100644 --- a/src/HearThis/Communication/AndroidLink.cs +++ b/src/HearThis/Communication/AndroidLink.cs @@ -7,7 +7,9 @@ // #endregion // -------------------------------------------------------------------------------------------- +using Paratext.Data.DBLServices; using System; +using System.Diagnostics; using System.IO; using System.Net; using System.Text; @@ -26,6 +28,7 @@ public AndroidLink(string ipAddress, Func retryOnTim { AndroidAddress = ipAddress; _address = "http://" + AndroidAddress + ":8087"; + Debug.WriteLine("AndroidLink, remote URI = " + _address); RetryOnTimeout = retryOnTimeout ?? ((ex, path) => false); } @@ -34,7 +37,10 @@ public AndroidLink(string ipAddress, Func retryOnTim public string GetDeviceName() { WebClient myClient = new WebClient(); - return GetString(myClient, _address); + //return GetString(myClient, _address); + string name = GetString(myClient, _address); + Debug.WriteLine("AndroidLink, device name = " + name); + return name; } private static string GetString(WebClient myClient, string address) @@ -63,6 +69,7 @@ protected override WebRequest GetWebRequest(Uri uri) public bool GetFile(string androidPath, string destPath) { + Debug.WriteLine("AndroidLink, GetFile, androidPath=" + androidPath + ", destPath=" + destPath); var myClient = new FileRetrievalWebClient(); bool retry = false; do @@ -130,12 +137,14 @@ public bool PutFile(string androidPath, byte[] data) { WebClient myClient = new WebClient(); myClient.UploadData(_address + "/putfile?path=" + Uri.EscapeDataString(androidPath), data); + //Debug.WriteLine("AndroidLink, PutFile, called"); return true; } public bool SendNotification(string message) { WebClient myClient = new WebClient(); + Debug.WriteLine("AndroidLink, SendNotification: " + message); myClient.UploadData(_address + "/notify?message=" + Uri.EscapeDataString(message), new byte[] {0}); return true; } diff --git a/src/HearThis/Communication/AndroidSynchronization.cs b/src/HearThis/Communication/AndroidSynchronization.cs index 4e25bc2b..05a4e20f 100644 --- a/src/HearThis/Communication/AndroidSynchronization.cs +++ b/src/HearThis/Communication/AndroidSynchronization.cs @@ -7,19 +7,20 @@ // #endregion // -------------------------------------------------------------------------------------------- +using DesktopAnalytics; +using HearThis.Script; +using HearThis.UI; +using L10NSharp; +using SIL.IO; using System; +using System.Diagnostics; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading.Tasks; using System.Windows.Forms; -using DesktopAnalytics; -using HearThis.Script; -using HearThis.UI; -using L10NSharp; -using SIL.IO; -using static System.String; using static HearThis.Communication.PreferredNetworkInterfaceResolver; +using static System.String; namespace HearThis.Communication { @@ -105,6 +106,8 @@ bool RetryOnTimeout(WebException ex, string path) var theirLink = new AndroidLink(AndroidSyncDialog.AndroidIpAddress, RetryOnTimeout); var ourLink = new WindowsLink(Program.ApplicationDataBaseFolder); + Debug.WriteLine("AndroidSynchronization, theirLink = " + theirLink); + Debug.WriteLine("AndroidSynchronization, ourLink = " + ourLink); var merger = new RepoMerger(project, ourLink, theirLink); var progressMsgFmt = LocalizationManager.GetString( @@ -121,11 +124,14 @@ bool RetryOnTimeout(WebException ex, string path) // up in a corrupt state following cancellation. //Update info.txt on Android var infoFilePath = project.GetProjectRecordingStatusInfoFilePath(); + Debug.WriteLine("AndroidSynchronization, infoFilePath = " + infoFilePath); RobustFile.WriteAllText(infoFilePath, project.GetProjectRecordingStatusInfoFileContent()); var theirInfoTxtPath = project.Name + "/" + Project.InfoTxtFileName; + Debug.WriteLine("AndroidSynchronization, theirInfoTxtPath = " + theirInfoTxtPath); theirLink.PutFile(theirInfoTxtPath, File.ReadAllBytes(infoFilePath)); if (mergeCompleted) { + Debug.WriteLine("AndroidSynchronization, mergeCompleted = TRUE, sending sync_success"); theirLink.SendNotification("sync_success"); dlg.ProgressBox.WriteMessage(LocalizationManager.GetString( "AndroidSynchronization.Progress.Completed", @@ -135,8 +141,8 @@ bool RetryOnTimeout(WebException ex, string path) { // TODO (HT-508): Send a specific notification so HTA knows the sync was // interrupted. - // theirLink.SendNotification("sync_interrupted"); - theirLink.SendNotification("sync_success"); + Debug.WriteLine("AndroidSynchronization, mergeCompleted = FALSE, sending sync_interrupted"); + theirLink.SendNotification("sync_interrupted"); dlg.ProgressBox.WriteMessage(LocalizationManager.GetString( "AndroidSynchronization.Progress.Canceled", "Sync was canceled by the user.")); From 3e83c01b603375bbb87627cee9edfdc864e179ef Mon Sep 17 00:00:00 2001 From: Wade Mergenthal Date: Wed, 27 Aug 2025 17:15:19 -0400 Subject: [PATCH 2/7] PR preparation: remove unneeded diffs For clarity in assessing the imminent pull request, put back as much as possible of the original code. This will help the actual changes stand out better. --- src/HearThis/Communication/AndroidLink.cs | 9 +++------ .../Communication/AndroidSynchronization.cs | 15 ++++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/HearThis/Communication/AndroidLink.cs b/src/HearThis/Communication/AndroidLink.cs index a707a924..09b163b0 100644 --- a/src/HearThis/Communication/AndroidLink.cs +++ b/src/HearThis/Communication/AndroidLink.cs @@ -7,12 +7,11 @@ // #endregion // -------------------------------------------------------------------------------------------- -using Paratext.Data.DBLServices; using System; -using System.Diagnostics; using System.IO; using System.Net; using System.Text; +using System.Diagnostics; namespace HearThis.Communication { @@ -37,10 +36,8 @@ public AndroidLink(string ipAddress, Func retryOnTim public string GetDeviceName() { WebClient myClient = new WebClient(); - //return GetString(myClient, _address); - string name = GetString(myClient, _address); - Debug.WriteLine("AndroidLink, device name = " + name); - return name; + Debug.WriteLine("AndroidLink, device name = " + GetString(myClient, _address)); + return GetString(myClient, _address); } private static string GetString(WebClient myClient, string address) diff --git a/src/HearThis/Communication/AndroidSynchronization.cs b/src/HearThis/Communication/AndroidSynchronization.cs index 05a4e20f..813c2f4a 100644 --- a/src/HearThis/Communication/AndroidSynchronization.cs +++ b/src/HearThis/Communication/AndroidSynchronization.cs @@ -7,20 +7,20 @@ // #endregion // -------------------------------------------------------------------------------------------- -using DesktopAnalytics; -using HearThis.Script; -using HearThis.UI; -using L10NSharp; -using SIL.IO; using System; -using System.Diagnostics; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading.Tasks; using System.Windows.Forms; -using static HearThis.Communication.PreferredNetworkInterfaceResolver; +using System.Diagnostics; +using DesktopAnalytics; +using HearThis.Script; +using HearThis.UI; +using L10NSharp; +using SIL.IO; using static System.String; +using static HearThis.Communication.PreferredNetworkInterfaceResolver; namespace HearThis.Communication { @@ -141,6 +141,7 @@ bool RetryOnTimeout(WebException ex, string path) { // TODO (HT-508): Send a specific notification so HTA knows the sync was // interrupted. + // theirLink.SendNotification("sync_interrupted"); Debug.WriteLine("AndroidSynchronization, mergeCompleted = FALSE, sending sync_interrupted"); theirLink.SendNotification("sync_interrupted"); dlg.ProgressBox.WriteMessage(LocalizationManager.GetString( From d0c0115466bcf4be96c1572701d72616855f58a6 Mon Sep 17 00:00:00 2001 From: Wade Mergenthal Date: Thu, 28 Aug 2025 16:53:51 -0400 Subject: [PATCH 3/7] HT-508: finish HT-side implementation of sync-interrupted scenario Formerly HT sent HTA "sync_success" regardless of whether 'mergeCompleted' was True. Now the False case leads to "sync_interrupted" being sent to HTA so the user can know that sync did not complete successfully. --- src/HearThis/Communication/AndroidLink.cs | 6 ------ src/HearThis/Communication/AndroidSynchronization.cs | 10 +--------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/HearThis/Communication/AndroidLink.cs b/src/HearThis/Communication/AndroidLink.cs index 09b163b0..67a6da41 100644 --- a/src/HearThis/Communication/AndroidLink.cs +++ b/src/HearThis/Communication/AndroidLink.cs @@ -11,7 +11,6 @@ using System.IO; using System.Net; using System.Text; -using System.Diagnostics; namespace HearThis.Communication { @@ -27,7 +26,6 @@ public AndroidLink(string ipAddress, Func retryOnTim { AndroidAddress = ipAddress; _address = "http://" + AndroidAddress + ":8087"; - Debug.WriteLine("AndroidLink, remote URI = " + _address); RetryOnTimeout = retryOnTimeout ?? ((ex, path) => false); } @@ -36,7 +34,6 @@ public AndroidLink(string ipAddress, Func retryOnTim public string GetDeviceName() { WebClient myClient = new WebClient(); - Debug.WriteLine("AndroidLink, device name = " + GetString(myClient, _address)); return GetString(myClient, _address); } @@ -66,7 +63,6 @@ protected override WebRequest GetWebRequest(Uri uri) public bool GetFile(string androidPath, string destPath) { - Debug.WriteLine("AndroidLink, GetFile, androidPath=" + androidPath + ", destPath=" + destPath); var myClient = new FileRetrievalWebClient(); bool retry = false; do @@ -134,14 +130,12 @@ public bool PutFile(string androidPath, byte[] data) { WebClient myClient = new WebClient(); myClient.UploadData(_address + "/putfile?path=" + Uri.EscapeDataString(androidPath), data); - //Debug.WriteLine("AndroidLink, PutFile, called"); return true; } public bool SendNotification(string message) { WebClient myClient = new WebClient(); - Debug.WriteLine("AndroidLink, SendNotification: " + message); myClient.UploadData(_address + "/notify?message=" + Uri.EscapeDataString(message), new byte[] {0}); return true; } diff --git a/src/HearThis/Communication/AndroidSynchronization.cs b/src/HearThis/Communication/AndroidSynchronization.cs index 813c2f4a..fa7d6070 100644 --- a/src/HearThis/Communication/AndroidSynchronization.cs +++ b/src/HearThis/Communication/AndroidSynchronization.cs @@ -13,7 +13,6 @@ using System.Net.Sockets; using System.Threading.Tasks; using System.Windows.Forms; -using System.Diagnostics; using DesktopAnalytics; using HearThis.Script; using HearThis.UI; @@ -106,8 +105,6 @@ bool RetryOnTimeout(WebException ex, string path) var theirLink = new AndroidLink(AndroidSyncDialog.AndroidIpAddress, RetryOnTimeout); var ourLink = new WindowsLink(Program.ApplicationDataBaseFolder); - Debug.WriteLine("AndroidSynchronization, theirLink = " + theirLink); - Debug.WriteLine("AndroidSynchronization, ourLink = " + ourLink); var merger = new RepoMerger(project, ourLink, theirLink); var progressMsgFmt = LocalizationManager.GetString( @@ -124,14 +121,11 @@ bool RetryOnTimeout(WebException ex, string path) // up in a corrupt state following cancellation. //Update info.txt on Android var infoFilePath = project.GetProjectRecordingStatusInfoFilePath(); - Debug.WriteLine("AndroidSynchronization, infoFilePath = " + infoFilePath); RobustFile.WriteAllText(infoFilePath, project.GetProjectRecordingStatusInfoFileContent()); var theirInfoTxtPath = project.Name + "/" + Project.InfoTxtFileName; - Debug.WriteLine("AndroidSynchronization, theirInfoTxtPath = " + theirInfoTxtPath); theirLink.PutFile(theirInfoTxtPath, File.ReadAllBytes(infoFilePath)); if (mergeCompleted) { - Debug.WriteLine("AndroidSynchronization, mergeCompleted = TRUE, sending sync_success"); theirLink.SendNotification("sync_success"); dlg.ProgressBox.WriteMessage(LocalizationManager.GetString( "AndroidSynchronization.Progress.Completed", @@ -139,10 +133,8 @@ bool RetryOnTimeout(WebException ex, string path) } else { - // TODO (HT-508): Send a specific notification so HTA knows the sync was + // HT-508: Send a specific notification so HTA knows the sync was // interrupted. - // theirLink.SendNotification("sync_interrupted"); - Debug.WriteLine("AndroidSynchronization, mergeCompleted = FALSE, sending sync_interrupted"); theirLink.SendNotification("sync_interrupted"); dlg.ProgressBox.WriteMessage(LocalizationManager.GetString( "AndroidSynchronization.Progress.Canceled", From 163fd96d4a971c74cd3bb136f103ad7423165faf Mon Sep 17 00:00:00 2001 From: Wade Mergenthal Date: Tue, 30 Sep 2025 22:02:34 -0400 Subject: [PATCH 4/7] Add minHtaVersion First cut with addition of minimum HTA version needed for a successful sync. Not yet fully tested. --- src/HearThis/Communication/AndroidLink.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/HearThis/Communication/AndroidLink.cs b/src/HearThis/Communication/AndroidLink.cs index 67a6da41..6960065d 100644 --- a/src/HearThis/Communication/AndroidLink.cs +++ b/src/HearThis/Communication/AndroidLink.cs @@ -8,6 +8,7 @@ #endregion // -------------------------------------------------------------------------------------------- using System; +using System.Diagnostics; using System.IO; using System.Net; using System.Text; @@ -57,6 +58,7 @@ protected override WebRequest GetWebRequest(Uri uri) { var w = base.GetWebRequest(uri); w.Timeout = (int) Math.Round(TimeSpan.FromSeconds(TimeoutInSeconds).TotalMilliseconds); + Debug.WriteLine($"SYNC, AndroidLink...WebRequest, timeout set: {TimeoutInSeconds} secs"); // TEMPORARY return w; } } @@ -93,6 +95,7 @@ public bool GetFile(string androidPath, string destPath) // success. Presumably, if they retry more than a couple times, // they will just give up. FileRetrievalWebClient.TimeoutInSeconds += 100; + Debug.WriteLine($"SYNC, AndroidLink.GetFile, timeout set: {FileRetrievalWebClient.TimeoutInSeconds} secs"); // TEMPORARY continue; } @@ -133,10 +136,20 @@ public bool PutFile(string androidPath, byte[] data) return true; } - public bool SendNotification(string message) + public bool SendNotification(string status) { + // Protocol change for communicating sync status to Android. + // As of September 2025 HT sends *two* notifications, in this order: + // - minimum HTA version that implements this revised protocol + // - final sync status WebClient myClient = new WebClient(); - myClient.UploadData(_address + "/notify?message=" + Uri.EscapeDataString(message), new byte[] {0}); + + // TODO: replace hardcoded "1.0" version number with a variable. + myClient.UploadData(_address + "/notify?minHtaVersion=" + Uri.EscapeDataString("1.0"), new byte[] {0}); + + // WM, to test Android's timeout behavior: comment out the next line, causing PC to never finish sync. + myClient.UploadData(_address + "/notify?status=" + Uri.EscapeDataString(status), new byte[] {0}); + return true; } From e441ef57e69199669fa01462787cff595edf79cc Mon Sep 17 00:00:00 2001 From: Wade Mergenthal Date: Wed, 1 Oct 2025 11:41:44 -0400 Subject: [PATCH 5/7] Safety commit: watchdog works, debug info shows sync activities No substantive changes. Just captures debug stmts producing the output captured in 20251001_02_HT_sync_watchdog_all_ok.log, where watchdog is seen to work correctly for both success and fail scenarios. --- .../Communication/AndroidSynchronization.cs | 22 ++++++++++++++----- src/HearThis/Script/Project.cs | 20 ++++++++++------- src/HearThis/UI/AndroidSyncDialog.cs | 12 +++++----- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/HearThis/Communication/AndroidSynchronization.cs b/src/HearThis/Communication/AndroidSynchronization.cs index fa7d6070..30f088a6 100644 --- a/src/HearThis/Communication/AndroidSynchronization.cs +++ b/src/HearThis/Communication/AndroidSynchronization.cs @@ -7,19 +7,20 @@ // #endregion // -------------------------------------------------------------------------------------------- +using DesktopAnalytics; +using HearThis.Script; +using HearThis.UI; +using L10NSharp; +using SIL.IO; using System; +using System.Diagnostics; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading.Tasks; using System.Windows.Forms; -using DesktopAnalytics; -using HearThis.Script; -using HearThis.UI; -using L10NSharp; -using SIL.IO; -using static System.String; using static HearThis.Communication.PreferredNetworkInterfaceResolver; +using static System.String; namespace HearThis.Communication { @@ -67,6 +68,7 @@ public static void DoAndroidSync(Project project, Form parent) MessageBox.Show(parent, msg, Program.kProduct); return; } + Debug.WriteLine("SYNC, got localIp = " + localIp); // WM, TEMPORARY var dlg = new AndroidSyncDialog(); @@ -104,7 +106,9 @@ bool RetryOnTimeout(WebException ex, string path) Analytics.Track("Sync with Android"); var theirLink = new AndroidLink(AndroidSyncDialog.AndroidIpAddress, RetryOnTimeout); + Debug.WriteLine("SYNC, got theirLink"); // WM, TEMPORARY var ourLink = new WindowsLink(Program.ApplicationDataBaseFolder); + Debug.WriteLine("SYNC, got ourLink"); // WM, TEMPORARY var merger = new RepoMerger(project, ourLink, theirLink); var progressMsgFmt = LocalizationManager.GetString( @@ -112,20 +116,25 @@ bool RetryOnTimeout(WebException ex, string path) "Syncing {0}, chapter {1}", "Param 0: Scripture book name; Param 1: chapter number"); + Debug.WriteLine("SYNC, starting merge"); // WM, TEMPORARY // Run the merge off the UI thread var mergeCompleted = await Task.Run(() => merger.Merge( project.StylesToSkipByDefault, dlg.ProgressBox, progressMsgFmt)); + Debug.WriteLine("SYNC, merge done"); // WM, TEMPORARY // REVIEW: Should we check for cancellation here and not even attempt to write // the project info file? That could be what's causing the Android app to end // up in a corrupt state following cancellation. //Update info.txt on Android var infoFilePath = project.GetProjectRecordingStatusInfoFilePath(); + Debug.WriteLine($"SYNC, calling RobustFile.WriteAllText, GPRSIFC(), infoFilePath = {infoFilePath}"); // WM, TEMPORARY RobustFile.WriteAllText(infoFilePath, project.GetProjectRecordingStatusInfoFileContent()); + Debug.WriteLine("SYNC, returned from RobustFile.WriteAllText"); // WM, TEMPORARY var theirInfoTxtPath = project.Name + "/" + Project.InfoTxtFileName; theirLink.PutFile(theirInfoTxtPath, File.ReadAllBytes(infoFilePath)); if (mergeCompleted) { + Debug.WriteLine("SYNC, sending sync_success"); // WM, TEMPORARY theirLink.SendNotification("sync_success"); dlg.ProgressBox.WriteMessage(LocalizationManager.GetString( "AndroidSynchronization.Progress.Completed", @@ -135,6 +144,7 @@ bool RetryOnTimeout(WebException ex, string path) { // HT-508: Send a specific notification so HTA knows the sync was // interrupted. + Debug.WriteLine("SYNC, sending sync_interrupted"); // WM, TEMPORARY theirLink.SendNotification("sync_interrupted"); dlg.ProgressBox.WriteMessage(LocalizationManager.GetString( "AndroidSynchronization.Progress.Canceled", diff --git a/src/HearThis/Script/Project.cs b/src/HearThis/Script/Project.cs index 09aa188a..8db3f769 100644 --- a/src/HearThis/Script/Project.cs +++ b/src/HearThis/Script/Project.cs @@ -7,22 +7,23 @@ // #endregion // -------------------------------------------------------------------------------------------- -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; using DesktopAnalytics; using HearThis.Properties; using HearThis.Publishing; using L10NSharp; using SIL.IO; using SIL.Reporting; -using static HearThis.Script.BibleStatsBase; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; using static HearThis.Program; -using static System.String; using static HearThis.SafeSettings; +using static HearThis.Script.BibleStatsBase; +using static System.String; namespace HearThis.Script { @@ -186,7 +187,10 @@ internal string GetProjectRecordingStatusInfoFileContent() // chap.GetScriptLine(iLine).Text); } sb.AppendLine(""); + Debug.WriteLine($"SYNC, GPRSIFC(), iBook={iBook}, book {bookName}:"); // WM, TEMPORARY + //Debug.WriteLine(sb.ToString()); // WM, TEMPORARY - this is a lot of text! } + Debug.WriteLine("SYNC, GPRSIFC(), done, returning"); // WM, TEMPORARY return sb.ToString(); } diff --git a/src/HearThis/UI/AndroidSyncDialog.cs b/src/HearThis/UI/AndroidSyncDialog.cs index b3a67f48..acdcd438 100644 --- a/src/HearThis/UI/AndroidSyncDialog.cs +++ b/src/HearThis/UI/AndroidSyncDialog.cs @@ -7,8 +7,13 @@ // #endregion // -------------------------------------------------------------------------------------------- +using L10NSharp; +using SIL.Reporting; +using SIL.Windows.Forms.Extensions; +using SIL.Windows.Forms.Progress; using System; using System.ComponentModel; +using System.Diagnostics; using System.Drawing; using System.Net; using System.Net.Sockets; @@ -16,14 +21,10 @@ using System.Text.RegularExpressions; using System.Threading; using System.Windows.Forms; -using L10NSharp; -using SIL.Reporting; -using SIL.Windows.Forms.Extensions; -using SIL.Windows.Forms.Progress; using ZXing; +using static SIL.Windows.Forms.Extensions.ControlExtensions.ErrorHandlingAction; using static System.String; using static System.Windows.Forms.MessageBoxButtons; -using static SIL.Windows.Forms.Extensions.ControlExtensions.ErrorHandlingAction; namespace HearThis.UI { @@ -286,6 +287,7 @@ private void ListenForUDPPackages() { try { + Debug.WriteLine("SYNC, UDPListener, getting UdpClient on port " + kPortToListen); // WM, TEMPORARY _udpClient = new UdpClient(kPortToListen); } catch (SocketException se) From 4cc6b7a57da96c4dc022bd993f00d0b574190680 Mon Sep 17 00:00:00 2001 From: Wade Mergenthal Date: Fri, 6 Feb 2026 21:25:51 -0500 Subject: [PATCH 6/7] Cleanup to enable PR acceptance Remove all debug output statements and the secondary notification of the value of 'minHtaVersion'. Improve some text that gets shown to the user, along with some code comments. Change the final status 'sync_interrupted' to 'sync_cancelled'. As discussed on 22 Jan, we plan to have a second pull request following this one. It will include at least one, and hopefully both, of the following: - minHtaVersion implementation - robust recovery from sync aborted by Wi-Fi going down --- src/HearThis/Communication/AndroidLink.cs | 15 ++++----------- .../Communication/AndroidSynchronization.cs | 15 +++------------ .../PreferredNetworkInterfaceResolver.cs | 2 +- src/HearThis/Script/Project.cs | 3 --- src/HearThis/UI/AndroidSyncDialog.cs | 5 ++--- 5 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/HearThis/Communication/AndroidLink.cs b/src/HearThis/Communication/AndroidLink.cs index 6960065d..8968078c 100644 --- a/src/HearThis/Communication/AndroidLink.cs +++ b/src/HearThis/Communication/AndroidLink.cs @@ -58,7 +58,6 @@ protected override WebRequest GetWebRequest(Uri uri) { var w = base.GetWebRequest(uri); w.Timeout = (int) Math.Round(TimeSpan.FromSeconds(TimeoutInSeconds).TotalMilliseconds); - Debug.WriteLine($"SYNC, AndroidLink...WebRequest, timeout set: {TimeoutInSeconds} secs"); // TEMPORARY return w; } } @@ -95,7 +94,6 @@ public bool GetFile(string androidPath, string destPath) // success. Presumably, if they retry more than a couple times, // they will just give up. FileRetrievalWebClient.TimeoutInSeconds += 100; - Debug.WriteLine($"SYNC, AndroidLink.GetFile, timeout set: {FileRetrievalWebClient.TimeoutInSeconds} secs"); // TEMPORARY continue; } @@ -138,16 +136,11 @@ public bool PutFile(string androidPath, byte[] data) public bool SendNotification(string status) { - // Protocol change for communicating sync status to Android. - // As of September 2025 HT sends *two* notifications, in this order: - // - minimum HTA version that implements this revised protocol - // - final sync status + // Send sync status to Android. + // Note: commenting out the UploadData() call here causes HearThis to never + // finish the sync in progress. This is a convenient way to provoke and measure + // a timeout on the Android. WebClient myClient = new WebClient(); - - // TODO: replace hardcoded "1.0" version number with a variable. - myClient.UploadData(_address + "/notify?minHtaVersion=" + Uri.EscapeDataString("1.0"), new byte[] {0}); - - // WM, to test Android's timeout behavior: comment out the next line, causing PC to never finish sync. myClient.UploadData(_address + "/notify?status=" + Uri.EscapeDataString(status), new byte[] {0}); return true; diff --git a/src/HearThis/Communication/AndroidSynchronization.cs b/src/HearThis/Communication/AndroidSynchronization.cs index 48f0ca8f..b465d4df 100644 --- a/src/HearThis/Communication/AndroidSynchronization.cs +++ b/src/HearThis/Communication/AndroidSynchronization.cs @@ -68,7 +68,6 @@ public static void DoAndroidSync(Project project, Form parent) MessageBox.Show(parent, msg, Program.kProduct); return; } - Debug.WriteLine("SYNC, got localIp = " + localIp); // WM, TEMPORARY var dlg = new AndroidSyncDialog(); @@ -110,9 +109,7 @@ bool RetryOnTimeout(WebException ex, string path) Analytics.Track("Sync with Android"); var theirLink = new AndroidLink(AndroidSyncDialog.AndroidIpAddress, RetryOnTimeout); - Debug.WriteLine("SYNC, got theirLink"); // WM, TEMPORARY var ourLink = new WindowsLink(Program.ApplicationDataBaseFolder); - Debug.WriteLine("SYNC, got ourLink"); // WM, TEMPORARY var merger = new RepoMerger(project, ourLink, theirLink); var progressMsgFmt = LocalizationManager.GetString( @@ -120,25 +117,20 @@ bool RetryOnTimeout(WebException ex, string path) "Syncing {0}, chapter {1}", "Param 0: Scripture book name; Param 1: chapter number"); - Debug.WriteLine("SYNC, starting merge"); // WM, TEMPORARY // Run the merge off the UI thread var mergeCompleted = await Task.Run(() => merger.Merge( project.StylesToSkipByDefault, dlg.ProgressBox, progressMsgFmt)); - Debug.WriteLine("SYNC, merge done"); // WM, TEMPORARY // REVIEW: Should we check for cancellation here and not even attempt to write // the project info file? That could be what's causing the Android app to end // up in a corrupt state following cancellation. //Update info.txt on Android var infoFilePath = project.GetProjectRecordingStatusInfoFilePath(); - Debug.WriteLine($"SYNC, calling RobustFile.WriteAllText, GPRSIFC(), infoFilePath = {infoFilePath}"); // WM, TEMPORARY RobustFile.WriteAllText(infoFilePath, project.GetProjectRecordingStatusInfoFileContent()); - Debug.WriteLine("SYNC, returned from RobustFile.WriteAllText"); // WM, TEMPORARY var theirInfoTxtPath = project.Name + "/" + Project.InfoTxtFileName; theirLink.PutFile(theirInfoTxtPath, File.ReadAllBytes(infoFilePath)); if (mergeCompleted) { - Debug.WriteLine("SYNC, sending sync_success"); // WM, TEMPORARY theirLink.SendNotification("sync_success"); dlg.ProgressBox.WriteMessage(LocalizationManager.GetString( "AndroidSynchronization.Progress.Completed", @@ -148,11 +140,10 @@ bool RetryOnTimeout(WebException ex, string path) { // HT-508: Send a specific notification so HTA knows the sync was // interrupted. - Debug.WriteLine("SYNC, sending sync_interrupted"); // WM, TEMPORARY - theirLink.SendNotification("sync_interrupted"); + theirLink.SendNotification("sync_cancelled"); dlg.ProgressBox.WriteMessage(LocalizationManager.GetString( - "AndroidSynchronization.Progress.Canceled", - "Sync was canceled by the user.")); + "AndroidSynchronization.Progress.Cancelled", + "Sync was cancelled by the user.")); } } catch (WebException ex) diff --git a/src/HearThis/Communication/PreferredNetworkInterfaceResolver.cs b/src/HearThis/Communication/PreferredNetworkInterfaceResolver.cs index 388f9e1e..1e2702aa 100644 --- a/src/HearThis/Communication/PreferredNetworkInterfaceResolver.cs +++ b/src/HearThis/Communication/PreferredNetworkInterfaceResolver.cs @@ -111,7 +111,7 @@ public IPAddress GetBestActiveInterface(out FailureReason failureReason) // Of these, we care only about Wi-Fi and Ethernet. if (ni.Type == Wireless80211) { - // We always assume that wireless is better than wired, so once we get a + // We always assume that wireless is preferred over wired, so once we get a // Wi-Fi candidate, we ignore any subsequent Ethernet candidates. RememberBestInterface(ref wifiInterface, ni, ip, interfaceIndex); } diff --git a/src/HearThis/Script/Project.cs b/src/HearThis/Script/Project.cs index 8db3f769..96846a99 100644 --- a/src/HearThis/Script/Project.cs +++ b/src/HearThis/Script/Project.cs @@ -187,10 +187,7 @@ internal string GetProjectRecordingStatusInfoFileContent() // chap.GetScriptLine(iLine).Text); } sb.AppendLine(""); - Debug.WriteLine($"SYNC, GPRSIFC(), iBook={iBook}, book {bookName}:"); // WM, TEMPORARY - //Debug.WriteLine(sb.ToString()); // WM, TEMPORARY - this is a lot of text! } - Debug.WriteLine("SYNC, GPRSIFC(), done, returning"); // WM, TEMPORARY return sb.ToString(); } diff --git a/src/HearThis/UI/AndroidSyncDialog.cs b/src/HearThis/UI/AndroidSyncDialog.cs index acdcd438..482bdcdc 100644 --- a/src/HearThis/UI/AndroidSyncDialog.cs +++ b/src/HearThis/UI/AndroidSyncDialog.cs @@ -231,8 +231,8 @@ protected override void OnFormClosing(FormClosingEventArgs e) ProgressBox.CancelRequested = true; ProgressBox.WriteMessageWithColor(AppPalette.Red, LocalizationManager.GetString( - "AndroidSynchronization.Progress.Canceling", - "Sync is being canceled.")); + "AndroidSynchronization.Progress.Cancelling", + "Sync is being cancelled.")); // The LogBox should handle this itself, but currently it doesn't. _logBox.Update(); } @@ -287,7 +287,6 @@ private void ListenForUDPPackages() { try { - Debug.WriteLine("SYNC, UDPListener, getting UdpClient on port " + kPortToListen); // WM, TEMPORARY _udpClient = new UdpClient(kPortToListen); } catch (SocketException se) From 96b4481fa3a06e107d5669b0b2c82665783b31c9 Mon Sep 17 00:00:00 2001 From: Wade Mergenthal Date: Mon, 9 Feb 2026 12:56:34 -0500 Subject: [PATCH 7/7] Revert some added 'l' chars, update copyright dates Responding to change requests in PR #338 - Revert changes made in previous commit to 'canceled' and 'canceling' (had added an 'l') to avoid the need for corresponding localization changes. - Update copyright data, when present, at top of files modified in previous commit. --- src/HearThis/Communication/AndroidLink.cs | 6 +++--- src/HearThis/Communication/AndroidSynchronization.cs | 12 ++++++------ src/HearThis/Script/Project.cs | 6 +++--- src/HearThis/UI/AndroidSyncDialog.cs | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/HearThis/Communication/AndroidLink.cs b/src/HearThis/Communication/AndroidLink.cs index 8968078c..957dbff5 100644 --- a/src/HearThis/Communication/AndroidLink.cs +++ b/src/HearThis/Communication/AndroidLink.cs @@ -1,7 +1,7 @@ // -------------------------------------------------------------------------------------------- -#region // Copyright (c) 2014-2025, SIL Global. -// -// Copyright (c) 2014-2025, SIL Global. +#region // Copyright (c) 2014-2026, SIL Global. +// +// Copyright (c) 2014-2026, SIL Global. // // Distributable under the terms of the MIT License (https://sil.mit-license.org/) // diff --git a/src/HearThis/Communication/AndroidSynchronization.cs b/src/HearThis/Communication/AndroidSynchronization.cs index b465d4df..408518e2 100644 --- a/src/HearThis/Communication/AndroidSynchronization.cs +++ b/src/HearThis/Communication/AndroidSynchronization.cs @@ -1,7 +1,7 @@ // -------------------------------------------------------------------------------------------- -#region // Copyright (c) 2016-2025, SIL Global. -// -// Copyright (c) 2016-2025, SIL Global. +#region // Copyright (c) 2016-2026, SIL Global. +// +// Copyright (c) 2016-2026, SIL Global. // // Distributable under the terms of the MIT License (https://sil.mit-license.org/) // @@ -140,10 +140,10 @@ bool RetryOnTimeout(WebException ex, string path) { // HT-508: Send a specific notification so HTA knows the sync was // interrupted. - theirLink.SendNotification("sync_cancelled"); + theirLink.SendNotification("sync_canceled"); dlg.ProgressBox.WriteMessage(LocalizationManager.GetString( - "AndroidSynchronization.Progress.Cancelled", - "Sync was cancelled by the user.")); + "AndroidSynchronization.Progress.Canceled", + "Sync was canceled by the user.")); } } catch (WebException ex) diff --git a/src/HearThis/Script/Project.cs b/src/HearThis/Script/Project.cs index 96846a99..1774eb4c 100644 --- a/src/HearThis/Script/Project.cs +++ b/src/HearThis/Script/Project.cs @@ -1,7 +1,7 @@ // -------------------------------------------------------------------------------------------- -#region // Copyright (c) 2011-2025, SIL Global. -// -// Copyright (c) 2011-2025, SIL Global. +#region // Copyright (c) 2011-2026, SIL Global. +// +// Copyright (c) 2011-2026, SIL Global. // // Distributable under the terms of the MIT License (https://sil.mit-license.org/) // diff --git a/src/HearThis/UI/AndroidSyncDialog.cs b/src/HearThis/UI/AndroidSyncDialog.cs index 482bdcdc..587a3a36 100644 --- a/src/HearThis/UI/AndroidSyncDialog.cs +++ b/src/HearThis/UI/AndroidSyncDialog.cs @@ -1,7 +1,7 @@ // -------------------------------------------------------------------------------------------- -#region // Copyright (c) 2015-2025, SIL Global. -// -// Copyright (c) 2015-2025, SIL Global. +#region // Copyright (c) 2015-2026, SIL Global. +// +// Copyright (c) 2015-2026, SIL Global. // // Distributable under the terms of the MIT License (https://sil.mit-license.org/) // @@ -231,8 +231,8 @@ protected override void OnFormClosing(FormClosingEventArgs e) ProgressBox.CancelRequested = true; ProgressBox.WriteMessageWithColor(AppPalette.Red, LocalizationManager.GetString( - "AndroidSynchronization.Progress.Cancelling", - "Sync is being cancelled.")); + "AndroidSynchronization.Progress.Canceling", + "Sync is being canceled.")); // The LogBox should handle this itself, but currently it doesn't. _logBox.Update(); }