Skip to content

Commit

Permalink
version 2.0.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
briandunnington committed Sep 21, 2011
1 parent 3ee1234 commit 74f27c9
Show file tree
Hide file tree
Showing 63 changed files with 15,346 additions and 1,310 deletions.
Binary file modified Growl Connectors/NET/libraries/Growl.Connector.dll
Binary file not shown.
Binary file modified Growl Connectors/NET/libraries/Growl.CoreLibrary.dll
Binary file not shown.
Binary file modified Growl Extras/Growl Display SDK/libraries/Growl.CoreLibrary.dll
Binary file not shown.
Binary file modified Growl Extras/Growl Display SDK/libraries/Growl.DisplayStyle.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GrowlTray", "GrowlTray\GrowlTray.csproj", "{E75F4755-B9C7-426B-9070-A2BDADBC71DF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GrowlTrayPluginTester", "GrowlTrayPluginTester\GrowlTrayPluginTester.csproj", "{2927B682-21A3-4CF8-A6F9-E055D5A01E92}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -31,12 +29,6 @@ Global
{E75F4755-B9C7-426B-9070-A2BDADBC71DF}.Release32|Any CPU.Build.0 = Release|Any CPU
{E75F4755-B9C7-426B-9070-A2BDADBC71DF}.Release64|Any CPU.ActiveCfg = Release64|Any CPU
{E75F4755-B9C7-426B-9070-A2BDADBC71DF}.Release64|Any CPU.Build.0 = Release64|Any CPU
{2927B682-21A3-4CF8-A6F9-E055D5A01E92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2927B682-21A3-4CF8-A6F9-E055D5A01E92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2927B682-21A3-4CF8-A6F9-E055D5A01E92}.Release32|Any CPU.ActiveCfg = Release|Any CPU
{2927B682-21A3-4CF8-A6F9-E055D5A01E92}.Release32|Any CPU.Build.0 = Release|Any CPU
{2927B682-21A3-4CF8-A6F9-E055D5A01E92}.Release64|Any CPU.ActiveCfg = Release64|Any CPU
{2927B682-21A3-4CF8-A6F9-E055D5A01E92}.Release64|Any CPU.Build.0 = Release64|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class GrowlTrayAppContext : ApplicationContext
bool GROWL = true;
#endif

const string CALLBACK_DATA_SEPARATOR = ":";

const uint MSG_STOP = Win32.WM_USER + 100;

bool restoreBalloonRegistryOnQuit = false;
Expand Down Expand Up @@ -51,13 +53,31 @@ public GrowlTrayAppContext()

this.growl = new GrowlConnector();
this.growl.EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText;
this.growl.NotificationCallback += new GrowlConnector.CallbackEventHandler(growl_NotificationCallback);
if(GROWL) this.growl.Register(app, types);

timer = new Timer();
timer.Interval = 5 * 1000;
timer.Tick += new EventHandler(timer_Tick);
}

void growl_NotificationCallback(Response response, CallbackData callbackData, object state)
{
if (callbackData != null)
{
if (callbackData.Result == Growl.CoreLibrary.CallbackResult.CLICK)
{
string[] data = callbackData.Data.Split(CALLBACK_DATA_SEPARATOR.ToCharArray());
IntPtr hWnd = new IntPtr(Convert.ToInt32(data[0]));
uint msg = Convert.ToUInt32(data[1]);
IntPtr wparam = new IntPtr(Convert.ToInt32(data[2]));
IntPtr lparam = new IntPtr(Convert.ToInt32(data[3]));

Win32.SendMessage(hWnd, msg, wparam, lparam);
}
}
}

void timer_Tick(object sender, EventArgs e)
{
try
Expand Down Expand Up @@ -93,7 +113,14 @@ private void WndProc(ref Message m)
{
Win32.COPYDATASTRUCT cds = new Win32.COPYDATASTRUCT();
cds = (Win32.COPYDATASTRUCT)m.GetLParam(typeof(Win32.COPYDATASTRUCT));
HandleCopyData(m.HWnd, m.WParam, cds);
try
{
HandleCopyData(m.HWnd, m.WParam, cds);
}
catch (Exception ex)
{
Log(ex.ToString());
}
}
}

Expand Down Expand Up @@ -121,6 +148,8 @@ private bool Start(IntPtr hWnd)
Log("className: " + className);
bool is64bit = Win32.Is64BitOperatingSystem();
Log("64-bit: " + is64bit.ToString());
Log("OS: " + Environment.OSVersion.VersionString);
Log("XP: " + isXP.ToString());
bool res;
if (is64bit) res = SetTrayHook64(className);
else res = SetTrayHook(className);
Expand Down Expand Up @@ -219,12 +248,15 @@ private void HandleCopyData(IntPtr hWnd, IntPtr WParam, Win32.COPYDATASTRUCT cds
uint CustomBalloonIconHandle;
Image image = null;

CallbackContext callback = null;

if (isXP)
{
Win32.TRAYINFO ti = (Win32.TRAYINFO)Marshal.PtrToStructure(cds.lpData, typeof(Win32.TRAYINFO));
Win32.NOTIFYICONDATA data = ti.nid;
if (!IsFlagSet((int)ti.nid.Flags, (int)Win32.IconDataMembers.Info)) return;
if (data.szInfo == "") return; //ignore dummy notification

szTitle = data.szInfoTitle;
szText = data.szInfo;
info = data.dwInfoFlags;
Expand All @@ -233,8 +265,11 @@ private void HandleCopyData(IntPtr hWnd, IntPtr WParam, Win32.COPYDATASTRUCT cds
Win32.GetWindowThreadProcessId((IntPtr)data.hWnd, out szPid);
CustomBalloonIconHandle = 0;



// handle custom icons
if (IsFlagSet((int)ti.nid.dwInfoFlags, (int)Win32.BalloonFlags.USER) && (IntPtr)ti.nid.hIcon != IntPtr.Zero)
{
if ((IntPtr)ti.nid.hIcon != IntPtr.Zero)
{
System.Drawing.Icon icon = System.Drawing.Icon.FromHandle((IntPtr)ti.nid.hIcon);
Expand All @@ -243,6 +278,28 @@ private void HandleCopyData(IntPtr hWnd, IntPtr WParam, Win32.COPYDATASTRUCT cds
image = icon.ToBitmap();
}
}
}

// handle callbacks - format: hwnd:msg:wparam:lparam
if (ti.nid.uCallbackMsg > 0)
{
string hwnd = handle.ToString();
string msg = ti.nid.uCallbackMsg.ToString();
string wparam = null;
string lparam = null;
if (ti.nid.uTimeoutOrVersion == 4)
{
wparam = MakeLParam(LoWord(0), HiWord(0)).ToString();
lparam = MakeLParam(LoWord(0x405), HiWord(Convert.ToInt32(ti.nid.uID))).ToString();
}
else
{
wparam = ti.nid.uID.ToString();
lparam = 0x405.ToString();
}
string d = String.Join(CALLBACK_DATA_SEPARATOR, new string[] { hwnd, msg, wparam, lparam });
callback = new CallbackContext(d, "balloonclick");
}
}
else
{
Expand All @@ -268,6 +325,27 @@ private void HandleCopyData(IntPtr hWnd, IntPtr WParam, Win32.COPYDATASTRUCT cds
image = icon.ToBitmap();
}
}

// handle callbacks - format: hwnd:msg:wparam:lparam
if (ti.nid.uCallbackMsg > 0)
{
string hwnd = handle.ToString();
string msg = ti.nid.uCallbackMsg.ToString();
string wparam = null;
string lparam = null;
if(ti.nid.uTimeoutOrVersion == 4)
{
wparam = MakeLParam(LoWord(0), HiWord(0)).ToString();
lparam = MakeLParam(LoWord(0x405), HiWord(Convert.ToInt32(ti.nid.uID))).ToString();
}
else
{
wparam = ti.nid.uID.ToString();
lparam = 0x405.ToString();
}
string d = String.Join(CALLBACK_DATA_SEPARATOR, new string[] { hwnd, msg, wparam, lparam });
callback = new CallbackContext(d, "balloonclick");
}
}

switch (info)
Expand Down Expand Up @@ -341,7 +419,7 @@ private void HandleCopyData(IntPtr hWnd, IntPtr WParam, Win32.COPYDATASTRUCT cds
// TODO: NOTIFY
Notification n = new Notification(appName, ntNameOther, String.Empty, szTitle, szText);
n.Icon = image;
if (GROWL) growl.Notify(n);
if (GROWL) growl.Notify(n, callback);
}

[DllImport("gTraySpy.dll")]
Expand All @@ -364,23 +442,27 @@ protected string GetCurrentClassName()

static bool isXPOS()
{
System.IO.FileInfo shell32 = new System.IO.FileInfo(System.IO.Path.Combine(System.Environment.SystemDirectory, "shell32.dll"));
if (shell32.Exists)
{
System.Diagnostics.FileVersionInfo theVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(shell32.FullName);
int i = theVersion.FileVersion.IndexOf('.');
if (i > 0)
{
try
{
int ver = int.Parse(theVersion.FileVersion.Substring(0, i));
if (ver >= 6) return false;
else return true;
}
catch { }
}
}
return false;
// Ex: Microsoft Windows NT 5.2.3790 Service Pack 2

if (Environment.OSVersion.Version.Major >= 6) return false;
else return true;
}

static int MakeLong(int LoWord, int HiWord)
{
return (HiWord << 16) | (LoWord & 0xffff);
}
static IntPtr MakeLParam(int LoWord, int HiWord)
{
return (IntPtr)((HiWord << 16) | (LoWord & 0xffff));
}
static int HiWord(int Number)
{
return (Number >> 16) & 0xffff;
}
static int LoWord(int Number)
{
return Number & 0xffff;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ static extern IntPtr GetProcAddress(IntPtr hModule,
public const uint TTS_ALWAYSTIP = 0x01;
public const uint TTM_POP = WM_USER + 28;

public const uint NOTIFYICON_VERSION = 3;
public const uint NOTIFYICON_VERSION_4 = 4;


[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int command);

Expand Down
3 changes: 2 additions & 1 deletion Growl/Growl.Connector/MessageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Growl.CoreLibrary;

namespace Growl.Connector
{
Expand Down Expand Up @@ -80,7 +81,7 @@ private Response Parse(string message, out HeaderCollection headers)
System.IO.MemoryStream stream = new System.IO.MemoryStream(bytes);
using (stream)
{
System.IO.StreamReader reader = new System.IO.StreamReader(stream);
GNTPStreamReader reader = new GNTPStreamReader(stream);
using (reader)
{
bool isError = false;
Expand Down
4 changes: 2 additions & 2 deletions Growl/Growl.Connector/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.6.1")]
[assembly: AssemblyInformationalVersion("2.0.6")]
[assembly: AssemblyFileVersion("2.0.7.2")]
[assembly: AssemblyInformationalVersion("2.0.7")]
96 changes: 96 additions & 0 deletions Growl/Growl.CoreLibrary/ByteBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Growl.CoreLibrary
{
/// <summary>
/// Helper class for converting basic data types to a byte array.
/// This class is similar to the <see cref="StringBuilder"/> class.
/// </summary>
public class ByteBuilder
{
protected List<byte> byteList = new List<byte>();
protected bool isLittleEndian = BitConverter.IsLittleEndian;

/// <summary>
/// Appends a single byte to the array
/// </summary>
/// <param name="val">The byte to append</param>
public void Append(byte val)
{
this.byteList.Add(val);
}

/// <summary>
/// Appends an array of bytes to the array
/// </summary>
/// <param name="val">The bytes to append</param>
public void Append(byte[] val)
{
this.byteList.AddRange(val);
}

/// <summary>
/// Appends a string as an array of UTF8-encoded bytes
/// </summary>
/// <param name="val">The string to append</param>
public void Append(string val)
{
if (val != null)
this.byteList.AddRange(Encoding.UTF8.GetBytes(val));
}

/// <summary>
/// Appends an <see cref="int"/> as a 4-byte array using Big Endian encoding
/// </summary>
/// <param name="val">The number to append</param>
public void Append(int val)
{
byte[] b = BitConverter.GetBytes(val);
if (this.isLittleEndian) Array.Reverse(b);
this.byteList.AddRange(b);
}

/// <summary>
/// Appends a <see cref="short"/> as a 2-byte array using Big Endian encoding
/// </summary>
/// <param name="val">The number to append</param>
public void Append(short val)
{
byte[] b = BitConverter.GetBytes(val);
if(this.isLittleEndian) Array.Reverse(b);
this.byteList.AddRange(b);
}

/// <summary>
/// Appends a <see cref="long"/> as a 8-byte array using Big Endian encoding
/// </summary>
/// <param name="val">The number to append</param>
public void Append(long val)
{
byte[] b = BitConverter.GetBytes(val);
if (this.isLittleEndian) Array.Reverse(b);
this.byteList.AddRange(b);
}

/// <summary>
/// Returns all of the bytes as an array
/// </summary>
/// <returns>Array of <see cref="byte"/>s</returns>
public byte[] GetBytes()
{
return this.byteList.ToArray();
}

/// <summary>
/// Returns the number of bytes making up the string
/// </summary>
/// <param name="val">The string whose length you want</param>
/// <returns>The number of bytes making up the string (NOT the number of characters, since some characters will require 2 bytes)</returns>
public static short GetStringLengthAsShort(string val)
{
return (short) Encoding.UTF8.GetBytes(val).Length;
}
}
}
Loading

0 comments on commit 74f27c9

Please sign in to comment.