mirror of
https://github.com/ckaczor/WorkIndicator.git
synced 2026-01-14 01:25:45 -05:00
Remove Skype detection
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Timers;
|
||||
using Common.Native;
|
||||
using SKYPE4COMLib;
|
||||
using WorkIndicator.Delcom;
|
||||
|
||||
namespace WorkIndicator
|
||||
@@ -23,8 +20,6 @@ namespace WorkIndicator
|
||||
private static StoplightIndicator _stoplightIndicator;
|
||||
private static bool _initialized;
|
||||
private static Status _status = Status.Auto;
|
||||
private static Timer _retryTimer;
|
||||
private static Timer _updateTimer;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
@@ -32,11 +27,6 @@ namespace WorkIndicator
|
||||
_stoplightIndicator.SetLight(StoplightIndicator.Light.Green, StoplightIndicator.LightState.On);
|
||||
|
||||
InitializeWindowDetection();
|
||||
InitializeSkypeDetection();
|
||||
|
||||
_updateTimer = new Timer(Properties.Settings.Default.UpdateInterval.TotalMilliseconds) { AutoReset = false };
|
||||
_updateTimer.Elapsed += HandleUpdateTimerElapsed;
|
||||
_updateTimer.Start();
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
@@ -46,11 +36,8 @@ namespace WorkIndicator
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
||||
_updateTimer.Dispose();
|
||||
|
||||
TerminateWindowDetection();
|
||||
TerminateSkypeDetection();
|
||||
|
||||
|
||||
_stoplightIndicator.SetLights(StoplightIndicator.LightState.Off, StoplightIndicator.LightState.Off, StoplightIndicator.LightState.Off);
|
||||
_stoplightIndicator.Dispose();
|
||||
|
||||
@@ -75,13 +62,7 @@ namespace WorkIndicator
|
||||
|
||||
if (_status == Status.Auto)
|
||||
{
|
||||
ISkype skype = _skype;
|
||||
|
||||
if (skype != null && skype.ActiveCalls.Count > 0)
|
||||
{
|
||||
red = skype.Mute ? StoplightIndicator.LightState.On : StoplightIndicator.LightState.Blink;
|
||||
}
|
||||
else if (WindowHandles.Count > 0)
|
||||
if (WindowHandles.Count > 0)
|
||||
{
|
||||
yellow = StoplightIndicator.LightState.On;
|
||||
}
|
||||
@@ -114,76 +95,6 @@ namespace WorkIndicator
|
||||
_stoplightIndicator.SetLights(red, yellow, green);
|
||||
}
|
||||
|
||||
#region Skype detection
|
||||
|
||||
private static Skype _skype;
|
||||
|
||||
public static void InitializeSkypeDetection()
|
||||
{
|
||||
try
|
||||
{
|
||||
_skype = new Skype();
|
||||
_skype.Attach();
|
||||
|
||||
var skype = (ISkype) _skype;
|
||||
skype.Mute = !skype.Mute;
|
||||
skype.Mute = !skype.Mute;
|
||||
|
||||
_ISkypeEvents_Event skypeEvents = _skype;
|
||||
|
||||
skypeEvents.CallStatus += HandleSkypeCallStatus;
|
||||
skypeEvents.Mute += HandleSkypeEventsMute;
|
||||
|
||||
UpdateLights();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (_retryTimer == null)
|
||||
{
|
||||
_retryTimer = new Timer(Properties.Settings.Default.RetryInterval.TotalMilliseconds) { AutoReset = false };
|
||||
_retryTimer.Elapsed += HandRetryTimerElapsed;
|
||||
}
|
||||
|
||||
_retryTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
static void HandRetryTimerElapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
InitializeSkypeDetection();
|
||||
}
|
||||
|
||||
private static void HandleUpdateTimerElapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
UpdateLights();
|
||||
|
||||
_updateTimer.Start();
|
||||
}
|
||||
|
||||
private static void HandleSkypeEventsMute(bool mute)
|
||||
{
|
||||
UpdateLights();
|
||||
}
|
||||
|
||||
private static void HandleSkypeCallStatus(Call call, TCallStatus status)
|
||||
{
|
||||
UpdateLights();
|
||||
}
|
||||
|
||||
public static void TerminateSkypeDetection()
|
||||
{
|
||||
_ISkypeEvents_Event skypeEvents = _skype;
|
||||
|
||||
skypeEvents.CallStatus -= HandleSkypeCallStatus;
|
||||
skypeEvents.Mute -= HandleSkypeEventsMute;
|
||||
|
||||
Marshal.ReleaseComObject(_skype);
|
||||
|
||||
_skype = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window detection
|
||||
|
||||
private static readonly WinEvent.WinEventDelegate ProcDelegate = WinEventProc;
|
||||
@@ -206,7 +117,7 @@ namespace WorkIndicator
|
||||
WindowEventHooks.Add(hook);
|
||||
}
|
||||
|
||||
public static void TerminateWindowDetection()
|
||||
private static void TerminateWindowDetection()
|
||||
{
|
||||
WindowEventHooks.ForEach(h => WinEvent.UnhookWinEvent(h));
|
||||
}
|
||||
@@ -239,10 +150,8 @@ namespace WorkIndicator
|
||||
|
||||
case WinEvent.Event.ObjectDestroy:
|
||||
if (WindowHandles.Contains(hwnd))
|
||||
WindowHandles.Remove(hwnd);
|
||||
|
||||
if (WindowMatchRegex.IsMatch(Functions.Window.GetText(hwnd)))
|
||||
{
|
||||
WindowHandles.Remove(hwnd);
|
||||
UpdateLights();
|
||||
}
|
||||
|
||||
|
||||
@@ -188,17 +188,6 @@
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\MainIcon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<COMReference Include="SKYPE4COMLib">
|
||||
<Guid>{03282B5D-B38F-469D-849A-09B0A7F4881B}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Reference in New Issue
Block a user