Skip to content

Commit

Permalink
GitHub as update source added
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Wennergren committed Sep 21, 2017
1 parent 2f70ba5 commit 0ed0e5d
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 10 deletions.
22 changes: 22 additions & 0 deletions ATray/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using Activity;
Expand Down Expand Up @@ -205,5 +206,26 @@ private void OnMenuClickSettings(object sender, EventArgs e)
settingsForm = new SettingsForm();
settingsForm.Show();
}

protected override void WndProc(ref Message m)
{
// Detect closing/opening of lid
if (m.Msg == WindowsInternals.WM_POWERBROADCAST && m.WParam.ToInt32() == WindowsInternals.PBT_POWERSETTINGCHANGE)
{
var ps = (WindowsInternals.POWERBROADCAST_SETTING) Marshal.PtrToStructure(m.LParam, typeof(WindowsInternals.POWERBROADCAST_SETTING));
IntPtr pData = (IntPtr) (m.LParam.ToInt32() + Marshal.SizeOf(ps));
int iData = (int) Marshal.PtrToStructure(pData, typeof(int));
string monitorState;
switch (iData)
{
case 0: monitorState = "off"; break;
case 1: monitorState = "on"; break;
case 2: monitorState = "dimmed"; break;
default: monitorState = "unknown"; break;
}
Trace.TraceInformation("Monitor changed to " + monitorState);
}
base.WndProc(ref m);
}
}
}
7 changes: 4 additions & 3 deletions ATray/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ATray
namespace ATray
{
using System;
using System.Diagnostics;
Expand Down Expand Up @@ -60,9 +60,10 @@ private static async Task CheckForUpdates()
{
try
{
using (var mgr = new UpdateManager(@"E:\Projects\Misc\ATray\Releases"))
using (var mgr = UpdateManager.GitHubUpdateManager("https://github.com/jokedst/ATray"))
{
var up = await mgr.UpdateApp();
var manager = await mgr;
var up = await manager.UpdateApp();
Trace.TraceInformation("Update check " + up.Version);
}
}
Expand Down
4 changes: 2 additions & 2 deletions ATray/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
// 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("1.0.3.0")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyVersion("1.0.4.0")]
[assembly: AssemblyFileVersion("1.0.4.0")]
Binary file added ATray/Releases/ATray-1.0.4-delta.nupkg
Binary file not shown.
Binary file added ATray/Releases/ATray-1.0.4-full.nupkg
Binary file not shown.
4 changes: 3 additions & 1 deletion ATray/Releases/RELEASES
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
97A0CEF2AD751E261A99836BFE61B0BAB2CED20E ATray-1.0.2-delta.nupkg 2442545
33989062BE91B0E647F8CB0760FDEFDDFFF18930 ATray-1.0.2-full.nupkg 7106985
AB5648C57EF494015F21EA4F9FA1D0B247A9CAB3 ATray-1.0.3-delta.nupkg 25956
455290875BE4ADF1DBE1D4C455321CFA28AE5F0B ATray-1.0.3-full.nupkg 7106412
455290875BE4ADF1DBE1D4C455321CFA28AE5F0B ATray-1.0.3-full.nupkg 7106412
7179D5D3D1C4A28674846F914D4EE9AC167A04DA ATray-1.0.4-delta.nupkg 41397
046A4A3BD8C62128787C924621D8EAB3AAD80BC3 ATray-1.0.4-full.nupkg 7107646
Binary file modified ATray/Releases/Setup.exe
Binary file not shown.
Binary file modified ATray/Releases/Setup.msi
Binary file not shown.
31 changes: 27 additions & 4 deletions ATray/WindowsInternals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,35 @@
internal static class WindowsInternals
{
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
private static extern IntPtr GetForegroundWindow();

[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);

[DllImport("user32.dll", SetLastError = true)]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);

[DllImport("kernel32.dll", SetLastError = true)]
private static extern int GetModuleFileName(UIntPtr hModule, StringBuilder lpFilename, int nSize);

[DllImport("coredll.dll", SetLastError = true)]
static extern int GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, int nSize);
private static extern int GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, int nSize);

[DllImport("user32.dll")]
static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);

[DllImport(@"User32", SetLastError = true, EntryPoint = "RegisterPowerSettingNotification", CallingConvention = CallingConvention.StdCall)]
private static extern IntPtr RegisterPowerSettingNotification(IntPtr hRecipient, ref Guid PowerSettingGuid, int Flags);


private static Guid GUID_CONSOLE_DISPLAY_STATE = Guid.Parse("6fe69556-704a-47a0-8f24-c28d936fda47");
public const int WM_POWERBROADCAST = 0x0218;
public const int PBT_POWERSETTINGCHANGE = 0x8013;

private static void RegisterForPowerNotifications(IntPtr hwnd)
{
var hPowerSrc = RegisterPowerSettingNotification(hwnd, ref GUID_CONSOLE_DISPLAY_STATE, 0);
}

public static string GetForegroundWindowText()
{
Expand Down Expand Up @@ -108,5 +121,15 @@ public static uint GetIdleTime()

return (uint)Environment.TickCount - lastInPut.dwTime;
}

// This structure is sent when the PBT_POWERSETTINGSCHANGE message is sent.
// It describes the power setting that has changed and contains data about the change
[StructLayout(LayoutKind.Sequential, Pack = 4)]
internal struct POWERBROADCAST_SETTING
{
public Guid PowerSetting;
public uint DataLength;
//public byte Data;
}
}
}
46 changes: 46 additions & 0 deletions packages/squirrel.windows.1.7.8/tools/SquirrelSetup.log
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,49 @@ File name: 'bin\Release\ATray.1.0.6448.nupkg'
2017-09-11 22:01:38> DeltaPackageBuilder: \lib\net45\lib\win32\x64\git2-a5cf255.dll hasn't changed, writing dummy file
2017-09-11 22:01:38> DeltaPackageBuilder: \lib\net45\lib\win32\x86\git2-a5cf255.dll hasn't changed, writing dummy file
2017-09-11 22:01:38> Program: Building embedded zip file for Setup.exe
2017-09-21 15:00:02> Program: Starting Squirrel Updater: --releasify bin\Release\ATray.1.0.4.nupkg
2017-09-21 15:00:02> Program: Bootstrapper EXE found at:C:\Projects\Misc\ATray\packages\squirrel.windows.1.7.8\tools\Setup.exe
2017-09-21 15:00:02> Program: Creating release package: C:\Projects\Misc\ATray\ATray\Releases\ATray.1.0.4.nupkg
2017-09-21 15:00:02> ReleasePackage: Creating release package: C:\Projects\Misc\ATray\ATray\Releases\ATray.1.0.4.nupkg => C:\Projects\Misc\ATray\ATray\Releases\ATray-1.0.4-full.nupkg
2017-09-21 15:00:02> ReleasePackage: Extracting dependent packages: []
2017-09-21 15:00:02> ReleasePackage: Removing unnecessary data
2017-09-21 15:00:02> ReleasePackage: No release notes found in C:\Users\joawen\AppData\Local\SquirrelTemp\tempa\ATray.nuspec
2017-09-21 15:00:03> DeltaPackageBuilder: Extracting .\Releases\ATray-1.0.3-full.nupkg and C:\Projects\Misc\ATray\ATray\Releases\ATray-1.0.4-full.nupkg into C:\Users\joawen\AppData\Local\SquirrelTemp\tempb
2017-09-21 15:00:04> DeltaPackageBuilder: Delta patching C:\Users\joawen\AppData\Local\SquirrelTemp\tempa\lib\net45\ATray.application => C:\Users\joawen\AppData\Local\SquirrelTemp\tempb\lib\net45\ATray.application
2017-09-21 15:00:04> DeltaPackageBuilder: We really couldn't create a delta for ATray.application: System.DivideByZeroException: Attempted to divide by zero.
at Squirrel.Bsdiff.BinaryPatchUtility.Create(Byte[] oldData, Byte[] newData, Stream output)
at Squirrel.DeltaPackageBuilder.createDeltaForSingleFile(FileInfo targetFile, DirectoryInfo workingDirectory, Dictionary`2 baseFileListing)
2017-09-21 15:00:04> DeltaPackageBuilder: Delta patching C:\Users\joawen\AppData\Local\SquirrelTemp\tempa\lib\net45\ATray.exe => C:\Users\joawen\AppData\Local\SquirrelTemp\tempb\lib\net45\ATray.exe
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\ATray.exe.config hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: Delta patching C:\Users\joawen\AppData\Local\SquirrelTemp\tempa\lib\net45\ATray.exe.manifest => C:\Users\joawen\AppData\Local\SquirrelTemp\tempb\lib\net45\ATray.exe.manifest
2017-09-21 15:00:04> DeltaPackageBuilder: We really couldn't create a delta for ATray.exe.manifest: System.DivideByZeroException: Attempted to divide by zero.
at Squirrel.Bsdiff.BinaryPatchUtility.Create(Byte[] oldData, Byte[] newData, Stream output)
at Squirrel.DeltaPackageBuilder.createDeltaForSingleFile(FileInfo targetFile, DirectoryInfo workingDirectory, Dictionary`2 baseFileListing)
2017-09-21 15:00:04> DeltaPackageBuilder: Delta patching C:\Users\joawen\AppData\Local\SquirrelTemp\tempa\lib\net45\ATray_ExecutionStub.exe => C:\Users\joawen\AppData\Local\SquirrelTemp\tempb\lib\net45\ATray_ExecutionStub.exe
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\CredentialManagement.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\DeltaCompressionDotNet.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\DeltaCompressionDotNet.MsDelta.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\DeltaCompressionDotNet.PatchApi.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\LibGit2Sharp.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\LibGit2Sharp.dll.config hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\Microsoft.Alm.Authentication.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\Microsoft.Alm.Git.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\Mono.Cecil.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\Mono.Cecil.Mdb.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\Mono.Cecil.Pdb.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\Mono.Cecil.Rocks.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\Newtonsoft.Json.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\NuGet.Squirrel.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\Ookii.Dialogs.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: Delta patching C:\Users\joawen\AppData\Local\SquirrelTemp\tempa\lib\net45\RepositoryManager.dll => C:\Users\joawen\AppData\Local\SquirrelTemp\tempb\lib\net45\RepositoryManager.dll
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\SharpCompress.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\SharpPlink-x64.svnExe hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\SharpSvn.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\Splat.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\Squirrel.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: Delta patching C:\Users\joawen\AppData\Local\SquirrelTemp\tempa\lib\net45\app.publish\ATray.exe => C:\Users\joawen\AppData\Local\SquirrelTemp\tempb\lib\net45\app.publish\ATray.exe
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\lib\linux\x86_64\libgit2-a5cf255.so hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\lib\osx\libgit2-a5cf255.dylib hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\lib\win32\x64\git2-a5cf255.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> DeltaPackageBuilder: \lib\net45\lib\win32\x86\git2-a5cf255.dll hasn't changed, writing dummy file
2017-09-21 15:00:04> Program: Building embedded zip file for Setup.exe

0 comments on commit 0ed0e5d

Please sign in to comment.