Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
added Pushbullet API
Browse files Browse the repository at this point in the history
  • Loading branch information
zekroTJA committed Jul 11, 2016
1 parent 5c67024 commit 8f92b56
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 22 deletions.
6 changes: 6 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<setting name="delayTime" serializeAs="String">
<value>0</value>
</setting>
<setting name="pbToken" serializeAs="String">
<value />
</setting>
<setting name="pbSend" serializeAs="String">
<value>False</value>
</setting>
</meautosd.Properties.Settings>
</userSettings>
</configuration>
17 changes: 17 additions & 0 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private void timer_Tick(object sender, EventArgs e)
lbStatus.ForeColor = Color.Red;
}


if (File.Exists(Settings.Default.finishLocation + "//" + Settings.Default.finishName) && status == 1)
{
status = 2;
Expand All @@ -117,6 +118,11 @@ private void timer_Tick(object sender, EventArgs e)
finished = true;
time = Settings.Default.delayTime * 60;

if (Settings.Default.pbSend && Settings.Default.pbToken != "")
{
cPush.send(Settings.Default.pbToken, "AME Auto Shutdown", "Your PC will shut down now.");
}

if (Settings.Default.writeLog)
{
StreamWriter writer = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "//Documents//ameautosd_logfile.txt");
Expand All @@ -136,6 +142,7 @@ private void timer_Tick(object sender, EventArgs e)
finished = true;
time = Settings.Default.delayTime * 60;
MessageBox.Show("Der PC wird in " + Settings.Default.delayTime * 60 + " Sekunden in den Standby gesetzt!", "Standby", MessageBoxButtons.OK, MessageBoxIcon.Information);

}

//HYBERNATE
Expand Down Expand Up @@ -211,6 +218,11 @@ private void timer1_Tick(object sender, EventArgs e)
writer.Close();
}

if (Settings.Default.pbSend && Settings.Default.pbToken != "")
{
cPush.send(Settings.Default.pbToken, "AME Auto Shutdown", "Your PC will set to standby now.");
}

Application.Exit();
}

Expand All @@ -226,6 +238,11 @@ private void timer1_Tick(object sender, EventArgs e)
writer.Close();
}

if (Settings.Default.pbSend && Settings.Default.pbToken != "")
{
cPush.send(Settings.Default.pbToken, "AME Auto Shutdown", "Your PC will set to hibernate now.");
}

Application.Exit();
}

Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("meautosd")]
[assembly: AssemblyTitle("Adobe Media Encoder Auto Shutdown")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
Expand All @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.4.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
24 changes: 24 additions & 0 deletions Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@
<Setting Name="delayTime" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="pbToken" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="pbSend" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
6 changes: 6 additions & 0 deletions bin/Debug/meautosd.exe.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<setting name="delayTime" serializeAs="String">
<value>0</value>
</setting>
<setting name="pbToken" serializeAs="String">
<value />
</setting>
<setting name="pbSend" serializeAs="String">
<value>False</value>
</setting>
</meautosd.Properties.Settings>
</userSettings>
</configuration>
Binary file modified bin/Debug/meautosd.pdb
Binary file not shown.
6 changes: 6 additions & 0 deletions bin/Debug/meautosd.vshost.exe.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<setting name="delayTime" serializeAs="String">
<value>0</value>
</setting>
<setting name="pbToken" serializeAs="String">
<value />
</setting>
<setting name="pbSend" serializeAs="String">
<value>False</value>
</setting>
</meautosd.Properties.Settings>
</userSettings>
</configuration>
36 changes: 36 additions & 0 deletions cPush.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace meautosd
{
static class cPush
{
public static void send(string token, string title, string body)
{
try
{
WebRequest request = WebRequest.Create("https://api.pushbullet.com/v2/pushes");
request.Method = "POST";
request.Headers.Add("Authorization", "Bearer " + token);
request.ContentType = "application/json; charset=UTF-8";
string postData =
"{\"type\": \"link\", \"title\": \"" + title + "\", \"body\": \"" + body + "\", \"url\": \"\"}";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
}
catch
{
MessageBox.Show("There accoured an error whilesending the push notification! Do you have entered a valid token?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
Loading

0 comments on commit 8f92b56

Please sign in to comment.