Permalink
Browse files

disconnect after switching firmware

update font_remount
forgot to ensure online when switching firmware
add delays to Dns listener so it doesn't spam
try to make "less is more" debug messages when listeners react
  • Loading branch information...
daPhie79 committed Aug 5, 2018
1 parent 57171c5 commit 28edb36295df28de42f3d4fe15957fa4537b0dcf
@@ -2993,19 +2993,22 @@ private void switchRunningFirmwareToolStripMenuItem_Click(object sender, EventAr
{
try
{
if (hakchi.MinimalMemboot)
{
Tasks.MessageForm.Show(this, Resources.Warning, Resources.CannotProceedMinimalMemboot, Resources.sign_life_buoy);
return;
}
if (!hakchi.CanInteract)
{
Tasks.MessageForm.Show(this, Resources.Warning, Resources.CannotProceedCannotInteract, Resources.sign_ban);
return;
}
if (WaitingShellForm.WaitForDevice(this))
{
new SelectFirmwareDialog().ShowDialog();
if (hakchi.MinimalMemboot)
{
Tasks.MessageForm.Show(this, Resources.Warning, Resources.CannotProceedMinimalMemboot, Resources.sign_life_buoy);
return;
}
if (!hakchi.CanInteract)
{
Tasks.MessageForm.Show(this, Resources.Warning, Resources.CannotProceedCannotInteract, Resources.sign_ban);
return;
}
if (WaitingShellForm.WaitForDevice(this))
{
new SelectFirmwareDialog().ShowDialog();
}
}
}
catch (Exception ex)
@@ -33,6 +33,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.3.0.1")]
[assembly: AssemblyFileVersion("3.3.0.1")]
[assembly: AssemblyVersion("3.3.0.2")]
[assembly: AssemblyFileVersion("3.3.0.2")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
@@ -64,6 +64,7 @@ private void buttonOk_Click(object sender, EventArgs e)
hakchi.Shell.ExecuteSimple($"/bin/hsqs \"{firmwareFullPath}\"", 500, false);
}
catch { } // no-op
hakchi.Shell.Disconnect();
Tasks.MessageForm.Show(this, Resources.Firmware, string.Format(Resources.FirmwareSwitched, (string)listBoxFirmwares.SelectedItem), Resources.sign_check, new Tasks.MessageForm.Button[] { Tasks.MessageForm.Button.OK });
}
catch (Exception ex)
@@ -14,42 +14,62 @@ namespace com.clusterrr.ssh
{
public class DnsListener : IListener
{
public const int TTL = 60;
public const int TTR = 15;
public IList<Device> Available
{
get
{
Trace.WriteLine("Querying dns...");
IList<Device> devices = new List<Device>();
if (DateTime.Now.Subtract(lastChecked) > TimeSpan.FromSeconds(TTR))
{
lastChecked = DateTime.Now;
query();
}
return devices;
}
}
private string serviceName;
private List<Device> devices;
private DateTime lastUpdated;
private DateTime lastChecked;
private void query()
{
if (DateTime.Now.Subtract(lastUpdated) > TimeSpan.FromSeconds(TTL))
{
devices.Clear();
try
{
IPHostEntry ihe = Dns.GetHostEntry(serviceName);
if (ihe.AddressList != null && ihe.AddressList.Length > 0)
{
Trace.WriteLine($"Found {ihe.AddressList.Length} addresses...");
Trace.WriteLine($"DNS Resolution returned IPs: " + string.Join(", ", (IEnumerable<IPAddress>)ihe.AddressList));
lastUpdated = DateTime.Now;
foreach (var address in ihe.AddressList)
{
devices.Add(new Device() { Addresses = new List<IPAddress>() { address }, Port = SshClientWrapper.DEFAULT_SSH_PORT });
}
}
}
catch
{
Trace.WriteLine("No response!");
// no-op (dns resolution fail causes exception)
}
return devices;
}
}
private string serviceName;
public DnsListener(string name)
{
serviceName = name;
devices = new List<Device>();
lastUpdated = DateTime.Now.Subtract(TimeSpan.FromSeconds(TTL));
lastChecked = DateTime.Now;
}
public void Dispose()
{
devices.Clear();
devices = null;
}
}
}
@@ -46,7 +46,6 @@ public void Dispose()
private void debugAnnouncement(string header, ServiceAnnouncement a)
{
#if DEBUG
Trace.WriteLine(header);
Trace.Indent();
Trace.WriteLine("Instance: " + a.Instance);
@@ -55,7 +54,6 @@ private void debugAnnouncement(string header, ServiceAnnouncement a)
Trace.WriteLine("Port: " + a.Port);
Trace.WriteLine("Txt: " + string.Join(", ", a.Txt));
Trace.Unindent();
#endif
}
private void onServiceAdded(object sender, ServiceAnnouncementEventArgs e)
@@ -234,20 +234,19 @@ private void attemptConnect()
{
foreach (var dev in l.Available)
{
Trace.WriteLine("Device detected: " + string.Join(", ", dev.Addresses));
foreach (var a in dev.Addresses)
{
Trace.WriteLine($"Attempting to connect to {a}...");
IPAddress = a.ToString();
port = dev.Port;
if (ping(IPAddress) != -1)
Connect();
if (IsOnline)
{
Connect();
if (IsOnline)
{
Debug.WriteLine("Success!");
return;
}
Trace.WriteLine("Success!");
return;
}
else
Trace.WriteLine("Failure.");
}
}
}
@@ -48,13 +48,14 @@ fontFix(){
esac
repair_fonts "$rootfs$gamepath"
fontFix0 "$ui0" "$ui1" "s" "small"
fontFix0 "$ui0" "$ui1" "m" "medium"
fontFix0 "$ui0" "$ui1" "l" "large"
local font=""
fontFix0 "$ui0" "$ui1" title title
fontFix0 "$ui0" "$ui1" copyright copyright
fontFix0 "$ui0" "$ui1" s small
fontFix0 "$ui0" "$ui1" m medium
fontFix0 "$ui0" "$ui1" l large
fontFix0 "$ui0" "" debug debug
for font in title copyright s m l; do
fontFix0 "$ui0" "$ui1" "$font" "$font"
done
fontFix0 "$ui0" "" "debug" "debug"
}
repair_fonts(){
@@ -1,8 +1,12 @@
----------------------
---
Name: Font Remount
Creator: DanTheMan827
Category: System
----------------------
Category: UI
Version: 1.2.0
Packed on: Tue Mar 27 20:19:21 DST 2018
Git commit: b5217ca
---
This module will search **/media/hakchi/fonts** and **/var/lib/hakchi/fonts** for font files with the following names
- title.fnt
@@ -1,7 +1 @@
rm -rf "$rootfs/usr/fonts"
if [ "$sftype" == "nes" ]; then
find "$rootfs$gamepath" -type f -name "*.fnt" -exec rm {} \;
restore "$gamepath/title.fnt"
restore "$gamepath/copyright.fnt"
fi
[ "$sftype" = "nes" ] && find "$rootfs$gamepath" -type f -name "*.fnt" -exec rm -f {} \;

0 comments on commit 28edb36

Please sign in to comment.