Skip to content

Commit 2b89328

Browse files
committed
Version 1.0.3 hotfix. Support for Google Drive, better error handling and a lot of bugfixes
1 parent 02b1ce2 commit 2b89328

36 files changed

+661
-182
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ publish/
177177
# in these scripts will be unencrypted
178178
PublishScripts/
179179

180+
AssistantComputerControl/AnalyticsSettings.cs
181+
180182
# NuGet Packages
181183
*.nupkg
182184
# The packages folder can be ignored because of Package Restore
-192 KB
Binary file not shown.
-192 KB
Binary file not shown.
-32 Bytes
Binary file not shown.

Advanced Installer/Advanced Installer.aip

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<DOCUMENT Type="Advanced Installer" CreateVersion="15.0.1" version="15.0.1" PreviousModules="simple" Modules="professional" RootPath="." Language="en" Id="{878E7B14-C44F-4C1C-AB0B-4449D443B80D}">
2+
<DOCUMENT Type="Advanced Installer" CreateVersion="15.0.1" version="15.1" PreviousModules="simple" Modules="professional" RootPath="." Language="en" Id="{878E7B14-C44F-4C1C-AB0B-4449D443B80D}">
33
<COMPONENT cid="caphyon.advinst.msicomp.ProjectOptionsComponent">
44
<ROW Name="HiddenItems" Value="AppXAppDetailsComponent;AppXCapabilitiesComponent;AppXDependenciesComponent;AppXProductDetailsComponent;AppXVisualAssetsComponent;AppXAppDeclarationsComponent;AppXUriRulesComponent"/>
55
</COMPONENT>
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\Debug"/>
10-
<ROW Property="AI_PROPPATH_DIR_PERBUILD_AssistantComputerControl.exe.config" Value="..\AssistantComputerControl\bin\Debug"/>
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"/>
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"/>
@@ -27,10 +27,10 @@
2727
<ROW Property="BannerBitmap" Value="banner" MultiBuildValue="DefaultBuild:banner.png" Type="1" MsiKey="BannerBitmap"/>
2828
<ROW Property="DialogBitmap" Value="dialog" MultiBuildValue="DefaultBuild:dialogbitmap.png" Type="1" MsiKey="DialogBitmap"/>
2929
<ROW Property="Manufacturer" Value="Albert MN."/>
30-
<ROW Property="ProductCode" Value="1033:{E9B0F51D-E725-4C20-899F-70CA1538FA43} " Type="16"/>
30+
<ROW Property="ProductCode" Value="1033:{7CE46ADC-D2D6-408E-9F03-6067331DC76D} " Type="16"/>
3131
<ROW Property="ProductLanguage" Value="1033"/>
3232
<ROW Property="ProductName" Value="AssistantComputerControl"/>
33-
<ROW Property="ProductVersion" Value="1.0.2" Type="32"/>
33+
<ROW Property="ProductVersion" Value="1.0.3" Type="32"/>
3434
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND;AI_SETUPEXEPATH;SETUPEXEDIR"/>
3535
<ROW Property="UpgradeCode" Value="{8E6F4399-B513-420B-8E11-36837A8550EE}"/>
3636
<ROW Property="WindowsType9X" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/>

Advanced Installer/Advanced Installer.back (1).aip

Lines changed: 244 additions & 0 deletions
Large diffs are not rendered by default.

AssistantComputerControl/AdvancedSettings.Designer.cs

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AssistantComputerControl/AdvancedSettings.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public partial class AdvancedSettings : Form {
1313
public AdvancedSettings() {
1414
InitializeComponent();
1515

16-
actionFolderPath.KeyDown += new KeyEventHandler(FreakingStopDingSound);
16+
actionFolderPath.KeyDown += new KeyEventHandler(FreakingStopDingSoundNoHandle);
1717
actionFileExtension.KeyDown += new KeyEventHandler(FreakingStopDingSound);
1818

1919
void FreakingStopDingSound(Object o, KeyEventArgs e) {
@@ -23,18 +23,23 @@ void FreakingStopDingSound(Object o, KeyEventArgs e) {
2323
}
2424
}
2525

26-
actionFolderPath.KeyDown += delegate { pathChanged(); };
27-
actionFolderPath.KeyUp += delegate { pathChanged(); };
26+
void FreakingStopDingSoundNoHandle(Object o, KeyEventArgs e) {
27+
if (e.KeyCode == Keys.Enter) {
28+
e.SuppressKeyPress = true;
29+
e.Handled = true;
2830

29-
void pathChanged() {
30-
if (Directory.Exists(actionFolderPath.Text)) {
3131
MainProgram.SetCheckFolder(actionFolderPath.Text);
32-
} else {
33-
MessageBox.Show("Folder does not exist");
34-
actionFolderPath.Text = MainProgram.CheckPath();
3532
}
3633
}
3734

35+
//actionFolderPath.KeyDown += delegate { pathChanged(); };
36+
//actionFolderPath.KeyUp += delegate { pathChanged(); };
37+
38+
/*void pathChanged() {
39+
MainProgram.SetCheckFolder(actionFolderPath.Text);
40+
actionFolderPath.Text = MainProgram.CheckPath();
41+
}*/
42+
3843
actionFileExtension.KeyDown += delegate { MainProgram.SetCheckExtension(actionFileExtension.Text); };
3944
actionFileExtension.KeyUp += delegate { MainProgram.SetCheckExtension(actionFileExtension.Text); };
4045

@@ -47,16 +52,12 @@ void pathChanged() {
4752

4853
private void pickFolderBtn_Click(object sender, EventArgs e) {
4954
CommonOpenFileDialog dialog = new CommonOpenFileDialog() {
50-
InitialDirectory = Directory.Exists(MainProgram.CheckPath()) ? MainProgram.CheckPath() : Assembly.GetEntryAssembly().Location,
55+
InitialDirectory = MainProgram.CheckPath(),
5156
IsFolderPicker = true
5257
};
5358
if (dialog.ShowDialog() == CommonFileDialogResult.Ok) {
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);
59+
MainProgram.SetCheckFolder(dialog.FileName);
60+
actionFolderPath.Text = MainProgram.CheckPath();
6061
}
6162
}
6263

AssistantComputerControl/AnalyticsSettings.cs

Lines changed: 77 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
using System.Collections.Specialized;
55
using System.Linq;
66
using System.Net;
7+
using System.Net.Http;
8+
using System.Net.Http.Headers;
79
using System.Text;
810

911
namespace AssistantComputerControl {
1012
class AnalyticsSettings {
1113
//private static string requestKey = null; // < version 1.1
1214
const string getKeyUrl = "https://acc.albe.pw/functions/ReceiveAnalyticsData.php";
1315
const string sendDataUrl = "https://acc.albe.pw/functions/ReceiveAnalyticsData.php";
16+
private static readonly HttpClient client = new HttpClient();
1417

15-
public static readonly string[] actions = new String[12] { //No changing this order!
18+
public static readonly string[] actions = new String[13] { //No changing this order!
1619
"shutdown", //0
1720
"restart", //1
1821
"open", //2
@@ -24,37 +27,69 @@ class AnalyticsSettings {
2427
"previous_song", //8
2528
"play_pause", //9
2629
"next_song", //10
27-
"die" //11
30+
"die", //11
31+
"hibernate", //12
32+
};
33+
34+
public static readonly string[] assistants = new String[4] { //No changing this order!
35+
"google",
36+
"alexa",
37+
"cortana",
38+
"unknown",
2839
};
2940

3041
class KeyHandler {
3142
public bool Status { get; set; }
3243
public string Message { get; set; }
3344
public string Key { get; set; }
3445
}
35-
46+
3647
public static void SetupAnalyticsAsync() {
48+
//Unique user-ID
49+
if (Properties.Settings.Default.UID == "" || Properties.Settings.Default.UID == null) {
50+
string newUID = Guid.NewGuid().ToString("N");
51+
Properties.Settings.Default.UID = newUID;
52+
Properties.Settings.Default.Save();
53+
54+
MainProgram.DoDebug("Set UID to " + newUID);
55+
} else {
56+
MainProgram.DoDebug("UID; " + Properties.Settings.Default.UID);
57+
}
58+
3759
if (Properties.Settings.Default.SendAnonymousAnalytics) {
60+
MainProgram.DoDebug("Setting up annonymous analytics...");
61+
//Execution amounts
3862
if (Properties.Settings.Default.TotalActionsExecuted == null) {
3963
Properties.Settings.Default.TotalActionsExecuted = new int[actions.Length - 1];
4064
Properties.Settings.Default.Save();
4165
}
4266

43-
MainProgram.DoDebug("Annonymous analytics setup...");
67+
int[] actionsExecuted = Properties.Settings.Default.TotalActionsExecuted;
68+
if (actions.Length != actionsExecuted.Length) {
69+
MainProgram.DoDebug(actions.Length + "!= " + actionsExecuted.Length);
4470

45-
//Request analytics-key < For version 1.1
46-
//RequestKey();
71+
//New action most likely added
72+
int[] oldSettings = actionsExecuted
73+
, newSettings = new int[actions.Length];
4774

48-
//Setup array
49-
int[] actionsExecuted = Properties.Settings.Default.TotalActionsExecuted;
50-
if (actionsExecuted.Length != actions.Length) {
51-
int i = actionsExecuted.Length - 1;
52-
while (i < actions.Length - 1) {
53-
actionsExecuted[i] = 0;
75+
//Populate new analytics array with old values
76+
int i = 0;
77+
foreach(int ac in oldSettings) {
78+
newSettings[i] = ac;
5479
i++;
5580
}
81+
82+
Properties.Settings.Default.TotalActionsExecuted = newSettings;
83+
Properties.Settings.Default.Save();
84+
}
85+
86+
//Assistant type
87+
if (Properties.Settings.Default.AssistantType == null) {
88+
Properties.Settings.Default.AssistantType = new int[actions.Length - 1];
5689
Properties.Settings.Default.Save();
5790
}
91+
92+
MainProgram.DoDebug("Annonymous analytics setup done");
5893
} else {
5994
MainProgram.DoDebug("Annonymous analytics are not being shared");
6095
}
@@ -65,7 +100,7 @@ public static void PrintAnalytics() {
65100
, totalCount = 0;
66101
if (Properties.Settings.Default.TotalActionsExecuted != null) {
67102
foreach (int count in Properties.Settings.Default.TotalActionsExecuted) {
68-
MainProgram.DoDebug(actions[i] + ": executed " + count + " times");
103+
MainProgram.DoDebug(i + ". " + actions[i] + ": executed " + count + " times");
69104
i++;
70105

71106
totalCount += count;
@@ -75,7 +110,8 @@ public static void PrintAnalytics() {
75110
MainProgram.DoDebug("\nTotal executions; " + totalCount);
76111
}
77112

78-
public static void AddCount(string action) {
113+
public static void AddCount(string action, string type) {
114+
AddTypeCount(type);
79115
int pos = Array.IndexOf(actions, action);
80116
if (pos > -1) {
81117
Properties.Settings.Default.TotalActionsExecuted[pos]++;
@@ -84,7 +120,8 @@ public static void AddCount(string action) {
84120
MainProgram.DoDebug("Could not find action \"" + action + "\" in action-array (analytics)");
85121
}
86122
}
87-
public static void AddCount(int action) {
123+
public static void AddCount(int action, string type) {
124+
AddTypeCount(type);
88125
if (actions[action] != null) {
89126
Properties.Settings.Default.TotalActionsExecuted[action]++;
90127
Properties.Settings.Default.Save();
@@ -93,48 +130,36 @@ public static void AddCount(int action) {
93130
}
94131
}
95132

96-
/*private static void RequestKey() {
97-
using (var wb = new WebClient()) {
98-
string actionsExecutedString = string.Join(",", Properties.Settings.Default.TotalActionsExecuted);
99-
100-
var data = new NameValueCollection {
101-
["key"] = requestKey,
102-
["actions_executed"] = actionsExecutedString
103-
};
104-
105-
var response = wb.UploadValues(getKeyUrl, "POST", data);
106-
KeyHandler jsonResponse = JsonConvert.DeserializeObject<KeyHandler>(Encoding.UTF8.GetString(response));
107-
if (jsonResponse.Status) {
108-
requestKey = jsonResponse.Key;
109-
MainProgram.DoDebug("Successfully requested analytics key. Got \"" + requestKey + "\"");
133+
private static void AddTypeCount(string type) {
134+
if (type == null) {
135+
Properties.Settings.Default.AssistantType[3]++;
136+
Properties.Settings.Default.Save();
137+
} else {
138+
int pos = Array.IndexOf(assistants, type);
139+
if (pos > -1) {
140+
Properties.Settings.Default.AssistantType[pos]++;
141+
Properties.Settings.Default.Save();
110142
} else {
111-
MainProgram.DoDebug("Failed to get analytics key; " + jsonResponse.Message);
143+
MainProgram.DoDebug("Assistant type \"" + type + "\" doesn't exist in assistant-array (analytics)");
112144
}
113145
}
114-
}*/
146+
}
115147

116-
/*public static void SendData() { // < for version 1.1
117-
if (requestKey != null) {
118-
if (ACC_Updater.RemoteFileExists(sendDataUrl)) {
119-
using (var wb = new WebClient()) {
120-
string actionsExecutedString = string.Join(",", Properties.Settings.Default.TotalActionsExecuted);
121-
122-
var data = new NameValueCollection {
123-
["key"] = requestKey,
124-
["actions_executed"] = actionsExecutedString
125-
};
126-
127-
var response = wb.UploadValues(sendDataUrl, "POST", data);
128-
string responseInString = Encoding.UTF8.GetString(response);
129-
130-
... deserialize json
131-
}
132-
}
133-
} else {
134-
MainProgram.DoDebug("Attempted to send analytics data, but the key was null, trying to request new");
135-
RequestKey();
148+
/*public static async System.Threading.Tasks.Task SendDataAsync() { // < for version 1.1
149+
if (ACC_Updater.RemoteFileExists(sendDataUrl)) {
150+
using (var wb = new WebClient()) {
136151
137-
...
152+
var values = new Dictionary<string, string> {
153+
{ "actions_executed", JsonConvert.SerializeObject(Properties.Settings.Default.TotalActionsExecuted) },
154+
{ "thing2", "world" }
155+
};
156+
var content = new FormUrlEncodedContent(values);
157+
var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);
158+
159+
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Your Oauth token");
160+
161+
var responseString = await response.Content.ReadAsStringAsync();
162+
}
138163
}
139164
}*/
140165
}

AssistantComputerControl/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
<setting name="SendAnonymousAnalytics" serializeAs="String">
5757
<value>True</value>
5858
</setting>
59+
<setting name="UID" serializeAs="String">
60+
<value />
61+
</setting>
5962
</AssistantComputerControl.Properties.Settings>
6063
</userSettings>
6164
</configuration>

0 commit comments

Comments
 (0)