Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Chorus.Tests/UI/Misc/ServerSettingsDialogTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
using System.Threading;
using System.Windows.Forms;
using Chorus.Model;
using Chorus.UI.Misc;
using NUnit.Framework;

namespace Chorus.Tests.UI.Misc
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class ServerSettingsDialogTests
{
[SetUp]
public void Setup()
{
Application.EnableVisualStyles();
}

[Test, Ignore("Run by hand only")]
public void LaunchDialog_FullAddress()
{
Expand Down
12 changes: 6 additions & 6 deletions src/Chorus.Tests/UI/Sync/SyncDialogTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void ShowSyncDialog_InternetAndNetworkPaths_WindowsStyle()
{
setup.Repository.SetKnownRepositoryAddresses(new RepositoryAddress[]
{
RepositoryAddress.Create("language forge", "https://hg-public.languageforge.org"),
RepositoryAddress.Create("Lexbox", "https://hg-public.languageforge.org"),
RepositoryAddress.Create("joe's mac", "\\\\suzie-pc\\public\\chorusTest")
});

Expand All @@ -58,7 +58,7 @@ public void ShowSyncDialog_InternetAndNetworkPaths()
{
setup.Repository.SetKnownRepositoryAddresses(new RepositoryAddress[]
{
RepositoryAddress.Create("language forge", "https://hg-public.languageforge.org"),
RepositoryAddress.Create("Lexbox", "https://hg-public.languageforge.org"),
RepositoryAddress.Create("joe's mac", "//suzie-pc/public/chorusTest")
});

Expand All @@ -80,9 +80,9 @@ public void LaunchDialog_ExampleForBob()

setup.Repository.SetKnownRepositoryAddresses(new RepositoryAddress[]
{
RepositoryAddress.Create("language forge", "https://pedro:mypassword@hg-public.languageforge.org"),
RepositoryAddress.Create("Lexbox", "https://pedro:mypassword@hg-public.languageforge.org"),
});
setup.Repository.SetDefaultSyncRepositoryAliases(new[] {"language forge"});
setup.Repository.SetDefaultSyncRepositoryAliases(new[] {"Lexbox"});

using (var dlg = new SyncDialog(setup.ProjectFolderConfig,
SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished,
Expand All @@ -102,9 +102,9 @@ public void LaunchDialog_GoodForCancelTesting()

setup.Repository.SetKnownRepositoryAddresses(new RepositoryAddress[]
{
RepositoryAddress.Create("language forge", "https://automatedtest:testing@hg-public.languageforge.org/tpi"),
RepositoryAddress.Create("Lexbox", "https://automatedtest:testing@hg-public.languageforge.org/tpi"),
});
setup.Repository.SetDefaultSyncRepositoryAliases(new[] { "language forge" });
setup.Repository.SetDefaultSyncRepositoryAliases(new[] { "Lexbox" });

using (var dlg = new SyncDialog(setup.ProjectFolderConfig,
SyncUIDialogBehaviors.StartImmediately,
Expand Down
18 changes: 18 additions & 0 deletions src/Chorus/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static void Main(string[] args)
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

SetUpLocalization();
SetUpErrorHandling();

//Xpcom.Initialize(XULRunnerLocator.GetXULRunnerLocation());
Expand Down Expand Up @@ -66,6 +67,23 @@ static void Main(string[] args)
Application.Exit ();
}

private static void SetUpLocalization()
{
// Standalone Chorus.exe has no host app to initialize L10NSharp; use English defaults unless XLF files are deployed.
LocalizationManager.StrictInitializationMode = false;
var installedTranslations = Path.Combine(AppContext.BaseDirectory, "localizations");
if (Directory.Exists(Path.Combine(installedTranslations, "Chorus")))
{
// Pass the app's settings root; SetUpLocalization appends "Chorus" itself, so passing
// "SIL" (not "SIL\Chorus") avoids a redundant nested Chorus\Chorus directory.
var userTranslations = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"SIL");
Directory.CreateDirectory(userTranslations);
ChorusSystem.SetUpLocalization("en", installedTranslations, userTranslations);
}
}

private static void SetUpErrorHandling()
{
try
Expand Down
2 changes: 1 addition & 1 deletion src/Chorus/UI/Misc/ReadinessPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Chorus.UI.Misc
{
/// <summary>
/// Show this control somewhere in the setup UI of your application.
/// It will help people know if the project is ready to use LanguageDepot, and
/// It will help people know if the project is ready to use Lexbox, and
/// gives them a button to edit the relevant settings.
/// </summary>
public partial class ReadinessPanel : UserControl
Expand Down
7 changes: 3 additions & 4 deletions src/Chorus/UI/Misc/ServerSettingsControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/Chorus/UI/Misc/ServerSettingsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public ServerSettingsControl()
{
InitializeComponent();

// format the string with the server URL. We build our own URL because 'resumable' is not helpful here.
_serverLabel.Text = string.Format(_serverLabel.Text, $"{(ServerSettingsModel.IsPrivateServer ? "private" : "public")}{ServerSettingsModel.LanguageForgeServer}");

_bandwidth.Items.AddRange(ServerSettingsModel.Bandwidths);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Chorus/UI/Settings/SettingsView.resx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ suzie = \\SUZIE-PC\TokPisin
For an internet server, include your username and password like this:
online = https://JoeSmith:mypassword@hg-public.languageforge.org/tpi

For a free internet repository, visit https://public.languageforge.org</value>
For a free Lexbox internet repository, visit https://lexbox.org</value>
</data>
</root>
2 changes: 1 addition & 1 deletion src/LibChorus/Model/InternetCloneSettingsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public virtual bool SetRepositoryAddress()
}
else if (name.ToLower().EndsWith(@"languageforge.org"))
{
name = @"LanguageForge";
name = @"Lexbox";
}

var address = RepositoryAddress.Create(name, URL);
Expand Down
6 changes: 3 additions & 3 deletions src/LibChorus/Model/ServerSettingsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public string AliasName
return "custom";
}

return $"languageForge.org [{Bandwidth}]";
return $"Lexbox [{Bandwidth}]";
}
}

Expand Down Expand Up @@ -427,12 +427,12 @@ internal static string DecryptPassword(string decryptMe)
/// URL-encoded password to use for the current Send and Receive session. <see cref="PasswordForSession"/>
/// </summary>
/// <remarks>
/// UrlEncode encodes spaces as "+" and "+" as "%2b". LanguageDepot fails to decode plus-encoded spaces. Encode spaces as "%20"
/// UrlEncode encodes spaces as "+" and "+" as "%2b". Lexbox fails to decode plus-encoded spaces. Encode spaces as "%20"
/// </remarks>
public static string EncodedPasswordForSession => WebUtility.UrlEncode(PasswordForSession)?.Replace("+", "%20");

/// <summary>
/// URL-encoded language forge username
/// URL-encoded Lexbox username
/// </summary>
public static string EncodedLanguageForgeUser => WebUtility.UrlEncode(Settings.Default.LanguageForgeUser);

Expand Down
2 changes: 1 addition & 1 deletion src/LibChorus/VcsDrivers/Mercurial/HgExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override string Message
}
else if(_targetUri.ToLower().Contains("languageforge"))
{
return "Your computer could reach LanguageForge.org, but couldn't communicate with the Chorus server there. Possible causes:\r\n1) The Chorus server on LanguageForge might be temporarily out of order. If it is, try again later/tomorrow. \r\n2) A firewall on your machine or on your network is blocking the communication with LanguageForge.org.";
return "Your computer could reach Lexbox, but couldn't communicate with the Chorus server there. Possible causes:\r\n1) The Chorus server on Lexbox might be temporarily out of order. If it is, try again later/tomorrow. \r\n2) A firewall on your machine or on your network is blocking the communication with Lexbox.";
}
else
{
Expand Down
19 changes: 16 additions & 3 deletions src/LibChorus/VcsDrivers/Mercurial/HgRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ public void LogBasicInfo(IList<RepositoryAddress> potentialAddresses)
_progress.WriteVerbose($"Local User: {GetUserIdInUse()}");
if (potentialAddresses.Any(a => a is HttpRepositoryPath))
{
_progress.WriteVerbose($"LanguageForge User: {Settings.Default.LanguageForgeUser}");
_progress.WriteVerbose($"Lexbox User: {Settings.Default.LanguageForgeUser}");
}

_progress.WriteVerbose($"Repository URI: {string.Join(Environment.NewLine, potentialAddresses.Select(RepositoryURIForLog))}");
Expand Down Expand Up @@ -1498,6 +1498,19 @@ public void SetTheOnlyAddressOfThisType(RepositoryAddress address)
if(match!=null)
{
addresses.Remove(match);
// If the alias name changed (e.g. because the default server was rebranded), migrate the
// matching entry in [ChorusDefaultRepositories] as well. Default-sync membership is matched
// by alias name, so leaving the old name behind would silently drop this repository from
// default sync operations.
if (match.Name != address.Name)
{
var defaultSyncAliases = GetDefaultSyncAliases();
if (defaultSyncAliases.Remove(match.Name))
{
defaultSyncAliases.Add(address.Name);
SetDefaultSyncRepositoryAliases(defaultSyncAliases);
}
}
}
addresses.Add(address);
SetKnownRepositoryAddresses(addresses);
Expand All @@ -1519,7 +1532,7 @@ public void SetDefaultSyncRepositoryAliases(IEnumerable<string> aliases)
IniSection section = GetDefaultRepositoriesSection(doc);
foreach (var alias in aliases)
{
section.Set(alias, string.Empty); //so we'll have "LanguageForge =", which is weird, but it's the hgrc style
section.Set(alias, string.Empty); //so we'll have "Lexbox =", which is weird, but it's the hgrc style
}
doc.SaveAndGiveMessageIfCannot();

Expand Down Expand Up @@ -2095,7 +2108,7 @@ public string GetProxyConfigParameterString(string httpUrl)
public static string DoWorkOfDeterminingProxyConfigParameterString(string httpUrl, IProgress progress)
{
/* The hg url itself would be more robust for the theoretical possibility of different
* proxies for different destinations, but some hg servers (notably language depot) require a login.
* proxies for different destinations, but some hg servers (notably Lexbox) require a login.
* So we're ignoring what we were given, and just using a known address, for now.
*/
httpUrl = "http://proxycheck.palaso.org";
Expand Down
2 changes: 1 addition & 1 deletion src/LibChorus/VcsDrivers/RepositoryAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static RepositoryAddress Create(string name,string uri)
/// <summary>
/// Creates a new HttpRepositoryPath or DirectoryRepositorySource.
/// </summary>
/// <param name="name">examples: SIL Language Depot, My Machine, USB Key, Greg</param>
/// <param name="name">examples: Lexbox, My Machine, USB Key, Greg</param>
/// <param name="uri">
/// examples: https://sil.org/chorus, c:\work, UsbKey, //GregSmith/public/language projects
/// Note: does not work for ChorusHub
Expand Down
24 changes: 24 additions & 0 deletions src/LibChorusTests/VcsDrivers/Mercurial/HgRepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,29 @@ public void RemoveCredentialsFromIniIfNecessary_PreservesOtherData(string savedU
}
}
}

[Test]
public void SetTheOnlyAddressOfThisType_AliasRenamed_MigratesDefaultSyncEntry()
{
const string oldAlias = "languageForge.org [High bandwidth]";
const string newAlias = "Lexbox [High bandwidth]";
const string url = "https://hg-public.languageforge.org/tpi";

using (var tempDir = new TemporaryFolder("HgRepoDefaultSync"))
{
var repo = new HgRepository(tempDir.Path, _progress);
Directory.CreateDirectory(Path.GetDirectoryName(repo.GetPathToHgrc()));
repo.SetTheOnlyAddressOfThisType(new HttpRepositoryPath(oldAlias, url, false));
repo.SetDefaultSyncRepositoryAliases(new[] { oldAlias });

// SUT: rename the alias (same address type, e.g. server rebranding)
repo.SetTheOnlyAddressOfThisType(new HttpRepositoryPath(newAlias, url, false));

var defaultAliases = repo.GetDefaultSyncAliases();
Assert.That(defaultAliases, Does.Contain(newAlias), "default sync entry should follow the renamed alias");
Assert.That(defaultAliases, Does.Not.Contain(oldAlias), "stale default sync entry should be removed");
Assert.That(repo.GetRepositoryPathsInHgrc().Select(p => p.Name), Does.Contain(newAlias));
}
}
}
}
13 changes: 13 additions & 0 deletions src/SampleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.IO;
using System.Threading;
using System.Windows.Forms;
using Chorus;
using L10NSharp;

namespace SampleApp
{
Expand All @@ -13,6 +15,17 @@ static void Main()
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

LocalizationManager.StrictInitializationMode = false;
var installedTranslations = Path.Combine(AppContext.BaseDirectory, "localizations");
if (Directory.Exists(Path.Combine(installedTranslations, "Chorus")))
{
var userTranslations = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"SIL", "ChorusSampleApp");
Directory.CreateDirectory(userTranslations);
ChorusSystem.SetUpLocalization("en", installedTranslations, userTranslations);
}

string dataDirectory = Path.Combine(Path.GetTempPath(), "ChorusSampleApp");
if(Directory.Exists(dataDirectory ))
DeleteFolderThatMayBeInUse(dataDirectory);
Expand Down
Loading