Skip to content

Commit 8109ad4

Browse files
author
Albert Møller Nielsen
committed
Hotfix 1.0.2: Bugfixes
1 parent 30e2cf3 commit 8109ad4

13 files changed

+105
-33
lines changed

Advanced Installer/Advanced Installer.aip

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<COMPONENT cid="caphyon.advinst.msicomp.MsiPropsComponent">
77
<ROW Property="AI_BITMAP_DISPLAY_MODE" Value="0"/>
88
<ROW Property="AI_FINDEXE_TITLE" Value="Select the installation package for [|ProductName]" ValueLocId="AI.Property.FindExeTitle"/>
9-
<ROW Property="AI_PROPPATH_DIR_PERBUILD_AssistantComputerControl.exe" Value="..\AssistantComputerControl\bin\Release"/>
10-
<ROW Property="AI_PROPPATH_DIR_PERBUILD_AssistantComputerControl.exe.config" Value="..\AssistantComputerControl\bin\Release"/>
9+
<ROW Property="AI_PROPPATH_DIR_PERBUILD_AssistantComputerControl.exe" Value="..\AssistantComputerControl\bin\Debug"/>
10+
<ROW Property="AI_PROPPATH_DIR_PERBUILD_AssistantComputerControl.exe.config" Value="..\AssistantComputerControl\bin\Debug"/>
1111
<ROW Property="AI_PROPPATH_DIR_PERBUILD_Microsoft.WindowsAPICodePack.Shell.dll" Value="..\packages\Microsoft.WindowsAPICodePack.Shell.1.1.0\lib"/>
1212
<ROW Property="AI_PROPPATH_DIR_PERBUILD_Microsoft.WindowsAPICodePack.dll" Value="..\packages\Microsoft.WindowsAPICodePack.Core.1.1.0\lib"/>
1313
<ROW Property="AI_PROPPATH_DIR_PERBUILD_Newtonsoft.Json.dll" Value="..\packages\Newtonsoft.Json.11.0.2\lib\net45"/>
@@ -18,17 +18,19 @@
1818
<ROW Property="AI_PROPPATH_FILENAME_PERBUILD_Newtonsoft.Json.dll" Value="Newtonsoft.Json.dll"/>
1919
<ROW Property="AI_ThemeStyle" Value="aero" MsiKey="AI_ThemeStyle"/>
2020
<ROW Property="ALLUSERS" Value="1"/>
21-
<ROW Property="ARPCOMMENTS" Value="This installer database contains the logic and data required to install [|ProductName]." ValueLocId="*"/>
21+
<ROW Property="ARPCOMMENTS" Value="The software that lets you control your computer using your assistants (Amazon Alexa or Google Assistant)" ValueLocId="*"/>
22+
<ROW Property="ARPCONTACT" Value="https://twitter.com/ACC_HomeAlexa"/>
23+
<ROW Property="ARPHELPLINK" Value="https://github.com/AlbertMN/AssistantComputerControl/issues"/>
2224
<ROW Property="ARPNOMODIFY" MultiBuildValue="DefaultBuild:1"/>
2325
<ROW Property="ARPNOREPAIR" Value="1" MultiBuildValue="DefaultBuild:1"/>
2426
<ROW Property="ARPPRODUCTICON" Value="logoico.exe" Type="8"/>
2527
<ROW Property="BannerBitmap" Value="banner" MultiBuildValue="DefaultBuild:banner.png" Type="1" MsiKey="BannerBitmap"/>
2628
<ROW Property="DialogBitmap" Value="dialog" MultiBuildValue="DefaultBuild:dialogbitmap.png" Type="1" MsiKey="DialogBitmap"/>
2729
<ROW Property="Manufacturer" Value="Albert MN."/>
28-
<ROW Property="ProductCode" Value="1033:{7DF2BB2F-E945-4D1D-8D0A-5D3DC10FBC70} " Type="16"/>
30+
<ROW Property="ProductCode" Value="1033:{E9B0F51D-E725-4C20-899F-70CA1538FA43} " Type="16"/>
2931
<ROW Property="ProductLanguage" Value="1033"/>
3032
<ROW Property="ProductName" Value="AssistantComputerControl"/>
31-
<ROW Property="ProductVersion" Value="1.0.1" Type="32"/>
33+
<ROW Property="ProductVersion" Value="1.0.2" Type="32"/>
3234
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND;AI_SETUPEXEPATH;SETUPEXEDIR"/>
3335
<ROW Property="UpgradeCode" Value="{8E6F4399-B513-420B-8E11-36837A8550EE}"/>
3436
<ROW Property="WindowsType9X" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/>

AssistantComputerControl/ACC_Updater.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ namespace AssistantComputerControl {
1010
class ACC_Updater {
1111
private const string releaseJsonUrl = "http://acc.albe.pw/versions/latest_version.php?type=release";
1212
private const string betaJsonUrl = "http://acc.albe.pw/versions/latest_version.php?type=beta";
13-
13+
1414
public bool Check() {
15+
if (MainProgram.isCheckingForUpdate)
16+
return false;
17+
18+
MainProgram.isCheckingForUpdate = true;
1519
MainProgram.DoDebug("Checking for updates...");
1620

1721
string latestReleaseJson = null;

AssistantComputerControl/AdvancedSettings.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Microsoft.WindowsAPICodePack.Dialogs;
22
using System;
33
using System.Diagnostics;
4+
using System.IO;
5+
using System.Reflection;
46
using System.Windows.Forms;
57

68
namespace AssistantComputerControl {
@@ -21,13 +23,21 @@ void FreakingStopDingSound(Object o, KeyEventArgs e) {
2123
}
2224
}
2325

24-
actionFolderPath.KeyDown += delegate { MainProgram.SetCheckFolder(actionFolderPath.Text); };
25-
actionFolderPath.KeyUp += delegate { MainProgram.SetCheckFolder(actionFolderPath.Text); };
26+
actionFolderPath.KeyDown += delegate { pathChanged(); };
27+
actionFolderPath.KeyUp += delegate { pathChanged(); };
28+
29+
void pathChanged() {
30+
if (Directory.Exists(actionFolderPath.Text)) {
31+
MainProgram.SetCheckFolder(actionFolderPath.Text);
32+
} else {
33+
MessageBox.Show("Folder does not exist");
34+
actionFolderPath.Text = MainProgram.CheckPath();
35+
}
36+
}
2637

2738
actionFileExtension.KeyDown += delegate { MainProgram.SetCheckExtension(actionFileExtension.Text); };
2839
actionFileExtension.KeyUp += delegate { MainProgram.SetCheckExtension(actionFileExtension.Text); };
2940

30-
3141
actionFolderPath.Text = MainProgram.CheckPath();
3242
actionFileExtension.Text = Properties.Settings.Default.ActionFileExtension;
3343

@@ -37,11 +47,16 @@ void FreakingStopDingSound(Object o, KeyEventArgs e) {
3747

3848
private void pickFolderBtn_Click(object sender, EventArgs e) {
3949
CommonOpenFileDialog dialog = new CommonOpenFileDialog() {
40-
InitialDirectory = MainProgram.CheckPath(),
50+
InitialDirectory = Directory.Exists(MainProgram.CheckPath()) ? MainProgram.CheckPath() : Assembly.GetEntryAssembly().Location,
4151
IsFolderPicker = true
4252
};
4353
if (dialog.ShowDialog() == CommonFileDialogResult.Ok) {
44-
actionFolderPath.Text = dialog.FileName;
54+
if (Directory.Exists(dialog.FileName)) {
55+
actionFolderPath.Text = dialog.FileName;
56+
} else {
57+
MessageBox.Show("Folder does not exist");
58+
}
59+
MainProgram.SetCheckFolder(actionFolderPath.Text);
4560
}
4661
}
4762

AssistantComputerControl/AssistantComputerControl.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
77
<ProjectGuid>{404B42F4-E135-4D2F-8FD0-20A590814930}</ProjectGuid>
8-
<OutputType>WinExe</OutputType>
8+
<OutputType>Exe</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>AssistantComputerControl</RootNamespace>
1111
<AssemblyName>AssistantComputerControl</AssemblyName>

AssistantComputerControl/GettingStarted.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
using System.Data;
66
using System.Diagnostics;
77
using System.Drawing;
8+
using System.IO;
89
using System.Linq;
10+
using System.Reflection;
911
using System.Text;
1012
using System.Text.RegularExpressions;
1113
using System.Threading;
@@ -103,7 +105,7 @@ void FreakingStopDingSound(Object o, KeyEventArgs e) {
103105
}
104106
}
105107

106-
actionFolderPath.Text = MainProgram.CheckPath();
108+
actionFolderPath.Text = Directory.Exists(MainProgram.CheckPath()) ? MainProgram.CheckPath() : Assembly.GetEntryAssembly().Location;
107109
actionFileExtension.Text = Properties.Settings.Default.ActionFileExtension;
108110

109111
actionFolderPath.KeyDown += delegate { MainProgram.SetCheckFolder(actionFolderPath.Text); };
@@ -280,7 +282,7 @@ private void finalOptionButton_Click(object sender, EventArgs e) {
280282

281283
private void pickFolderBtn_Click(object sender, EventArgs e) {
282284
CommonOpenFileDialog dialog = new CommonOpenFileDialog() {
283-
InitialDirectory = MainProgram.CheckPath(),
285+
InitialDirectory = Directory.Exists(MainProgram.CheckPath()) ? MainProgram.CheckPath() : Assembly.GetEntryAssembly().Location,
284286
IsFolderPicker = true
285287
};
286288
if (dialog.ShowDialog() == CommonFileDialogResult.Ok) {

AssistantComputerControl/MainProgram.cs

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99
using System.Net;
1010
using Newtonsoft.Json;
1111
using System.Linq;
12+
using System.Threading;
1213

1314
namespace AssistantComputerControl {
1415
class MainProgram {
15-
public const string softwareVersion = "1.0.1",
16-
releaseDate = "2018-07-20 16:59",
16+
public const string softwareVersion = "1.0.2",
17+
releaseDate = "2018-07-21 21:19",
1718
appName = "AssistantComputerControl";
1819
static public bool debug = true,
1920
unmuteVolumeChange = true,
2021
isPerformingAction = false,
22+
isCheckingForUpdate = false,
2123

2224
testingAction = false;
2325

@@ -28,6 +30,8 @@ public enum TestStatus {
2830
ongoing
2931
}
3032

33+
private static FileSystemWatcher watcher;
34+
3135
static public string currentLocationFull = Assembly.GetEntryAssembly().Location,
3236
defaultActionFolder = CheckPath(),
3337

@@ -47,9 +51,13 @@ public enum TestStatus {
4751
[STAThread]
4852
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
4953
static void Main(string[] args) {
54+
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
55+
5056
SetupDataFolder();
5157
if (File.Exists(logFilePath))
5258
File.WriteAllText(logFilePath, string.Empty);
59+
else
60+
CreateLogFile();
5361

5462
//Check if software already runs, if so kill this instance
5563
if (Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Length > 1) {
@@ -63,12 +71,15 @@ static void Main(string[] args) {
6371

6472
if (Properties.Settings.Default.CheckForUpdates) {
6573
if (HasInternet()) {
66-
new ACC_Updater().Check();
74+
new Thread(() => {
75+
new ACC_Updater().Check();
76+
}).Start();
6777
} else {
6878
DoDebug("Couldn't check for new update as PC does not have access to the internet");
6979
}
7080
}
71-
if(File.Exists(Path.Combine(dataFolderLocation, "updated.txt"))) {
81+
82+
if (File.Exists(Path.Combine(dataFolderLocation, "updated.txt"))) {
7283
File.Delete(Path.Combine(dataFolderLocation, "updated.txt"));
7384
new AboutVersion().Show();
7485
}
@@ -94,20 +105,13 @@ static void Main(string[] args) {
94105
}
95106

96107
//Delete all old action files
97-
foreach (string file in Directory.GetFiles(CheckPath(), "*." + Properties.Settings.Default.ActionFileExtension)) {
98-
ClearFile(file);
108+
if (Directory.Exists(CheckPath())) {
109+
foreach (string file in Directory.GetFiles(CheckPath(), "*." + Properties.Settings.Default.ActionFileExtension)) {
110+
ClearFile(file);
111+
}
99112
}
100-
101-
//WATCHER
102-
FileSystemWatcher watcher = new FileSystemWatcher() {
103-
Path = CheckPath(),
104-
NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
105-
| NotifyFilters.FileName | NotifyFilters.DirectoryName,
106-
Filter = "*." + Properties.Settings.Default.ActionFileExtension,
107-
EnableRaisingEvents = true
108-
};
109-
watcher.Changed += new FileSystemEventHandler(ActionChecker.FileFound);
110-
//END WATCHER
113+
114+
SetupListener();
111115

112116
DoDebug("\n[" + messageBoxTitle + "] Initiated. \nListening in: \"" + CheckPath() + "\" for \"." + Properties.Settings.Default.ActionFileExtension + "\" extensions");
113117

@@ -138,11 +142,51 @@ static void Main(string[] args) {
138142
Application.Run();
139143
}
140144

145+
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args) {
146+
Exception e = (Exception)args.ExceptionObject;
147+
string errorLogLoc = Path.Combine(dataFolderLocation, "error_log.txt");
148+
149+
if (!File.Exists(errorLogLoc)) {
150+
using (var tw = new StreamWriter(errorLogLoc, true)) {
151+
tw.WriteLine(e);
152+
tw.Close();
153+
}
154+
}
155+
156+
File.AppendAllText(errorLogLoc, DateTime.Now.ToString() + ": " + e + Environment.NewLine);
157+
if (debug) {
158+
Console.WriteLine(e);
159+
}
160+
MessageBox.Show("An unhandled critical error occurred. Please contact the developer (https://github.com/AlbertMN/AssistantComputerControl/issues)");
161+
}
162+
163+
private static void CreateLogFile() {
164+
using (var tw = new StreamWriter(logFilePath, true)) {
165+
tw.WriteLine(string.Empty);
166+
tw.Close();
167+
}
168+
}
169+
170+
public static void SetupListener() {
171+
if (Directory.Exists(CheckPath())) {
172+
watcher = new FileSystemWatcher() {
173+
Path = CheckPath(),
174+
NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
175+
| NotifyFilters.FileName | NotifyFilters.DirectoryName,
176+
Filter = "*." + Properties.Settings.Default.ActionFileExtension,
177+
EnableRaisingEvents = true
178+
};
179+
watcher.Changed += new FileSystemEventHandler(ActionChecker.FileFound);
180+
}
181+
}
182+
141183
public static void SetCheckFolder(string setTo) {
142184
SetRegKey("ActionFolder", setTo);
143185

144186
Properties.Settings.Default.ActionFilePath = setTo;
145187
Properties.Settings.Default.Save();
188+
189+
SetupListener();
146190
}
147191
public static void SetCheckExtension(string setTo) {
148192
SetRegKey("ActionExtension", setTo);
@@ -151,7 +195,7 @@ public static void SetCheckExtension(string setTo) {
151195
Properties.Settings.Default.Save();
152196
}
153197

154-
private static void SetRegKey(string theKey, string setTo) {
198+
public static void SetRegKey(string theKey, string setTo) {
155199
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true);
156200
if (Registry.GetValue(key.Name + "\\AssistantComputerControl", theKey, null) == null) {
157201
key.CreateSubKey("AssistantComputerControl");
@@ -292,11 +336,16 @@ public static string CheckPath() {
292336
}
293337

294338
public static void DoDebug(string str) {
295-
if (str != null && File.Exists(logFilePath)) {
339+
try {
340+
if (!File.Exists(logFilePath)) {
341+
CreateLogFile();
342+
}
296343
File.AppendAllText(logFilePath, DateTime.Now.ToString() + ": " + str + Environment.NewLine);
297344
if (debug) {
298345
Console.WriteLine(str);
299346
}
347+
} catch (Exception e) {
348+
Console.WriteLine("Failed to write to log, exception; " + e);
300349
}
301350
}
302351

Binary file not shown.
1.5 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)