Skip to content

Commit 2e4e036

Browse files
committed
v0.3 commit
0 parents  commit 2e4e036

File tree

91 files changed

+2736
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2736
-0
lines changed

.vs/ACC/v14/-DESKTOP-M1UNSJM.suo

50.5 KB
Binary file not shown.

.vs/ACC/v14/.suo

101 KB
Binary file not shown.
16 KB
Binary file not shown.

ACC.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssistantComputerControl", "AssistantComputerControl\AssistantComputerControl.csproj", "{404B42F4-E135-4D2F-8FD0-20A590814930}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{404B42F4-E135-4D2F-8FD0-20A590814930}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{404B42F4-E135-4D2F-8FD0-20A590814930}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{404B42F4-E135-4D2F-8FD0-20A590814930}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{404B42F4-E135-4D2F-8FD0-20A590814930}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System.IO;
2+
using System.Windows.Forms;
3+
using System.Net;
4+
using System.Diagnostics;
5+
6+
namespace AssistantComputerControl {
7+
class ACC_Updater {
8+
public void check() {
9+
string latest_version;
10+
using (WebClient client = new WebClient()) {
11+
latest_version = client.DownloadString("https://gh.albe.pw/acc/releases/latest/version.txt");
12+
}
13+
if (latest_version != MainProgram.softwareVersion) {
14+
//New version available
15+
MainProgram.doDebug("New software version found");
16+
DialogResult dialogResult = MessageBox.Show("A new version of " + MainProgram.messageBoxTitle + " is available (v" + latest_version + "), do you wish to install it?", "New update found | " + MainProgram.messageBoxTitle, MessageBoxButtons.YesNo);
17+
if (dialogResult == DialogResult.Yes) {
18+
MainProgram.doDebug("User chose \"yes\" to install update");
19+
install();
20+
} else if(dialogResult == DialogResult.No) {
21+
MainProgram.doDebug("User did not want to install update");
22+
}
23+
} else {
24+
MainProgram.doDebug("Software up to date");
25+
}
26+
if (File.Exists(Path.Combine(MainProgram.dataFolderLocation, "updated.txt"))) {
27+
File.Delete("updated.txt");
28+
}
29+
}
30+
31+
public void install() {
32+
MainProgram.doDebug("Installing...");
33+
//Create file for the updater, containing the name (and full path) of the ACC-exe which is being updated
34+
if (File.Exists(Path.Combine(MainProgram.dataFolderLocation, "updated.txt"))) {
35+
File.Delete("updated.txt");
36+
}
37+
if (File.Exists(Path.Combine(MainProgram.dataFolderLocation, "acc_location.txt"))) {
38+
File.WriteAllText(Path.Combine(MainProgram.dataFolderLocation, "acc_location.txt"), string.Empty);
39+
}
40+
using (var tw = new StreamWriter(Path.Combine(MainProgram.dataFolderLocation, "acc_location.txt"), true)) {
41+
tw.WriteLine(MainProgram.currentLocationFull);
42+
tw.Close();
43+
}
44+
string downloadLocation = Path.Combine(MainProgram.currentLocation, "ACC_installer.exe");
45+
using (var client = new WebClient()) {
46+
client.DownloadFile("https://gh.albe.pw/acc/installer/ACC_installer.exe", downloadLocation);
47+
}
48+
Process.Start(downloadLocation);
49+
MainProgram.exit();
50+
}
51+
}
52+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<configSections>
4+
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
5+
<section name="HomeComputerControl.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
6+
</sectionGroup>
7+
</configSections>
8+
<appSettings>
9+
<!-- DO NOT CHANGE THIS VALUE -->
10+
<add key="config_version" value="0.3" />
11+
<!-- [SETTINGS]
12+
You may edit the values within this tag
13+
To reset the config you can simply delete it, and it will auto-generate
14+
Only change the content of the "value" tags.
15+
Config Wiki: https://github.com/AlbertMN/AssistantComputerControl/wiki/Config -->
16+
17+
<!-- Automatically check for updates? -->
18+
<add key="CheckForUpdates" value="true" />
19+
20+
<!-- Path of the generated Computer Action file (filename & extension required) -->
21+
<add key="ActionFilePath" value="computerAction.txt" />
22+
<!-- The max last-edited datetime of the action-file in *seconds*.
23+
Fx. 30 means the file can be no more than 30 seconds old to make sure we're not using an old file. -->
24+
<add key="FileEditedMargin" value="30" />
25+
26+
<!-- Whether the PC should be unmuted when the volume is changed (via. Google Assistant, up or down)
27+
Accepted values: "true" or "false" -->
28+
<add key="UnmuteOnVolumeChange" value="true" />
29+
</appSettings>
30+
</configuration>
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{404B42F4-E135-4D2F-8FD0-20A590814930}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>AssistantComputerControl</RootNamespace>
11+
<AssemblyName>AssistantComputerControl</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
17+
<PublishUrl>publish\</PublishUrl>
18+
<Install>true</Install>
19+
<InstallFrom>Disk</InstallFrom>
20+
<UpdateEnabled>false</UpdateEnabled>
21+
<UpdateMode>Foreground</UpdateMode>
22+
<UpdateInterval>7</UpdateInterval>
23+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
24+
<UpdatePeriodically>false</UpdatePeriodically>
25+
<UpdateRequired>false</UpdateRequired>
26+
<MapFileExtensions>true</MapFileExtensions>
27+
<ApplicationRevision>0</ApplicationRevision>
28+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
29+
<IsWebBootstrapper>false</IsWebBootstrapper>
30+
<UseApplicationTrust>false</UseApplicationTrust>
31+
<BootstrapperEnabled>true</BootstrapperEnabled>
32+
</PropertyGroup>
33+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
34+
<PlatformTarget>AnyCPU</PlatformTarget>
35+
<DebugSymbols>true</DebugSymbols>
36+
<DebugType>full</DebugType>
37+
<Optimize>false</Optimize>
38+
<OutputPath>bin\Debug\</OutputPath>
39+
<DefineConstants>DEBUG;TRACE</DefineConstants>
40+
<ErrorReport>prompt</ErrorReport>
41+
<WarningLevel>4</WarningLevel>
42+
<UseVSHostingProcess>false</UseVSHostingProcess>
43+
</PropertyGroup>
44+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
45+
<PlatformTarget>AnyCPU</PlatformTarget>
46+
<DebugType>pdbonly</DebugType>
47+
<Optimize>true</Optimize>
48+
<OutputPath>bin\Release\</OutputPath>
49+
<DefineConstants>TRACE</DefineConstants>
50+
<ErrorReport>prompt</ErrorReport>
51+
<WarningLevel>4</WarningLevel>
52+
</PropertyGroup>
53+
<PropertyGroup>
54+
<StartupObject>AssistantComputerControl.MainProgram</StartupObject>
55+
</PropertyGroup>
56+
<PropertyGroup>
57+
<ApplicationIcon>Resources\ACC_icon.ico</ApplicationIcon>
58+
</PropertyGroup>
59+
<PropertyGroup>
60+
<SignManifests>false</SignManifests>
61+
</PropertyGroup>
62+
<ItemGroup>
63+
<Reference Include="AudioSwitcher.AudioApi, Version=3.0.0.209, Culture=neutral, PublicKeyToken=fda5729e2db3a64f, processorArchitecture=MSIL">
64+
<HintPath>..\packages\AudioSwitcher.AudioApi.3.0.0\lib\net40\AudioSwitcher.AudioApi.dll</HintPath>
65+
<Private>True</Private>
66+
</Reference>
67+
<Reference Include="AudioSwitcher.AudioApi.CoreAudio, Version=3.0.0.209, Culture=neutral, PublicKeyToken=fda5729e2db3a64f, processorArchitecture=MSIL">
68+
<HintPath>..\packages\AudioSwitcher.AudioApi.CoreAudio.3.0.0.1\lib\net40\AudioSwitcher.AudioApi.CoreAudio.dll</HintPath>
69+
<Private>True</Private>
70+
</Reference>
71+
<Reference Include="Costura, Version=1.6.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
72+
<HintPath>..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll</HintPath>
73+
<Private>False</Private>
74+
</Reference>
75+
<Reference Include="PresentationFramework" />
76+
<Reference Include="System" />
77+
<Reference Include="System.configuration" />
78+
<Reference Include="System.Core" />
79+
<Reference Include="System.Drawing" />
80+
<Reference Include="System.Web.Extensions" />
81+
<Reference Include="System.Windows.Forms" />
82+
<Reference Include="System.Xml.Linq" />
83+
<Reference Include="System.Data.DataSetExtensions" />
84+
<Reference Include="Microsoft.CSharp" />
85+
<Reference Include="System.Data" />
86+
<Reference Include="System.Net.Http" />
87+
<Reference Include="System.Xml" />
88+
</ItemGroup>
89+
<ItemGroup>
90+
<Compile Include="ACC_Updater.cs" />
91+
<Compile Include="actionChecker.cs" />
92+
<Compile Include="configValidator.cs" />
93+
<Compile Include="MainProgram.cs" />
94+
<Compile Include="Properties\AssemblyInfo.cs" />
95+
<Compile Include="Properties\Resources.Designer.cs">
96+
<AutoGen>True</AutoGen>
97+
<DesignTime>True</DesignTime>
98+
<DependentUpon>Resources.resx</DependentUpon>
99+
</Compile>
100+
<Compile Include="SysTrayIcon.cs" />
101+
</ItemGroup>
102+
<ItemGroup>
103+
<None Include="App.config" />
104+
</ItemGroup>
105+
<ItemGroup>
106+
<None Include="FodyWeavers.xml" />
107+
</ItemGroup>
108+
<ItemGroup>
109+
<Content Include="logo ico.ico" />
110+
<None Include="Resources\ACC_icon.ico" />
111+
</ItemGroup>
112+
<ItemGroup>
113+
<EmbeddedResource Include="Properties\Resources.resx">
114+
<Generator>ResXFileCodeGenerator</Generator>
115+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
116+
</EmbeddedResource>
117+
</ItemGroup>
118+
<ItemGroup>
119+
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
120+
<Visible>False</Visible>
121+
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
122+
<Install>true</Install>
123+
</BootstrapperPackage>
124+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
125+
<Visible>False</Visible>
126+
<ProductName>.NET Framework 3.5 SP1</ProductName>
127+
<Install>false</Install>
128+
</BootstrapperPackage>
129+
</ItemGroup>
130+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
131+
<Import Project="..\packages\Fody.2.0.0\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.2.0.0\build\dotnet\Fody.targets')" />
132+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
133+
<PropertyGroup>
134+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
135+
</PropertyGroup>
136+
<Error Condition="!Exists('..\packages\Fody.2.0.0\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.0.0\build\dotnet\Fody.targets'))" />
137+
<Error Condition="!Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets'))" />
138+
</Target>
139+
<Import Project="..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" />
140+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
141+
Other similar extension points exist, see Microsoft.Common.targets.
142+
<Target Name="BeforeBuild">
143+
</Target>
144+
<Target Name="AfterBuild">
145+
</Target>
146+
-->
147+
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<PublishUrlHistory>publish\</PublishUrlHistory>
5+
<InstallUrlHistory />
6+
<SupportUrlHistory />
7+
<UpdateUrlHistory />
8+
<BootstrapperUrlHistory />
9+
<ErrorReportUrlHistory />
10+
<FallbackCulture>en-US</FallbackCulture>
11+
<VerifyUploadedFiles>false</VerifyUploadedFiles>
12+
</PropertyGroup>
13+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Weavers>
3+
<Costura />
4+
</Weavers>
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows.Forms;
7+
using System.IO;
8+
using System.Diagnostics;
9+
using System.Runtime.InteropServices;
10+
using System.ComponentModel;
11+
using System.Threading;
12+
using System.Reflection;
13+
using System.Net;
14+
15+
using YamlDotNet;
16+
using YamlDotNet.Serialization;
17+
using YamlDotNet.Serialization.NamingConventions;
18+
using YamlDotNet.RepresentationModel;
19+
20+
namespace HomeComputerControl {
21+
class MainProgram {
22+
static public bool debug = true;
23+
24+
static actionChecker checker = new actionChecker();
25+
static public string currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location),
26+
actionFilePath = @currentLocation + "/computerAction.txt",
27+
configFilePath = @currentLocation + "/hcc_config.yml",
28+
error_message = "";
29+
static public int fileEditedSecondMargin = 30;
30+
31+
public static void doDebug(string str = null) {
32+
if(str != null) {
33+
if (debug) {
34+
Console.WriteLine(str);
35+
}
36+
} else {
37+
if (debug)
38+
Console.WriteLine("Debug string is null");
39+
}
40+
}
41+
42+
private static void configSetup() {
43+
doDebug("Checking if config exists...");
44+
45+
if (!File.Exists(configFilePath)) {
46+
doDebug("Config doesn't exist - creating config...");
47+
//Creating config file & adding content
48+
setConfigContent();
49+
50+
if (!File.Exists(configFilePath)) {
51+
//If the file was somehow not created...
52+
doDebug("ERROR: The file config file was not created");
53+
}
54+
} else {
55+
doDebug("Config exists (" + configFilePath + ")");
56+
57+
if (new FileInfo(configFilePath).Length == 0) {
58+
doDebug("Config file is empty. Setting content...");
59+
setConfigContent();
60+
}
61+
}
62+
63+
//Setting variables to config values...
64+
//ehh....
65+
}
66+
67+
private static void setConfigContent() {
68+
string textFromFile = (new WebClient()).DownloadString("http://albe.pw/test.yml");
69+
70+
using (StreamWriter sw = File.CreateText(configFilePath)) {
71+
sw.Write(textFromFile);
72+
}
73+
}
74+
75+
static public void clearFile() {
76+
if (File.Exists(actionFilePath)) {
77+
doDebug("Action-file exists, deleting...");
78+
File.Delete(actionFilePath);
79+
doDebug("Action-file deleted");
80+
} else {
81+
doDebug("Action-file doesn't exist, nothing to delete");
82+
}
83+
}
84+
85+
static void Main(string[] args) {
86+
doDebug("[HomeComputerControl] starting up...\nCurrent location: " + currentLocation + "\naction file location: " + actionFilePath + "\n");
87+
88+
configSetup();
89+
clearFile();
90+
91+
checker.check();
92+
if (debug) {
93+
doDebug("Done checking, program finished (somehow...)");
94+
Console.ReadKey();
95+
}
96+
}
97+
98+
}
99+
}

0 commit comments

Comments
 (0)