Workaround for Skype API events no longer working

This commit is contained in:
2015-03-31 14:26:43 -04:00
parent 7308654b60
commit fc4368af87
5 changed files with 41 additions and 3 deletions

View File

@@ -71,6 +71,9 @@ namespace WorkIndicator.Delcom
public void SetLights(LightState red, LightState yellow, LightState green)
{
if (_red == red && _yellow == yellow && _green == green)
return;
int port1 = 0;
_red = red;

View File

@@ -24,6 +24,7 @@ namespace WorkIndicator
private static bool _initialized;
private static Status _status = Status.Auto;
private static Timer _retryTimer;
private static Timer _updateTimer;
public static void Initialize()
{
@@ -33,6 +34,10 @@ namespace WorkIndicator
InitializeWindowDetection();
InitializeSkypeDetection();
_updateTimer = new Timer(Properties.Settings.Default.UpdateInterval.TotalMilliseconds) { AutoReset = false };
_updateTimer.Elapsed += HandleUpdateTimerElapsed;
_updateTimer.Start();
_initialized = true;
}
@@ -41,6 +46,8 @@ namespace WorkIndicator
if (!_initialized)
return;
_updateTimer.Dispose();
TerminateWindowDetection();
TerminateSkypeDetection();
@@ -118,10 +125,16 @@ namespace WorkIndicator
_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)
{
@@ -140,12 +153,19 @@ namespace WorkIndicator
InitializeSkypeDetection();
}
static void HandleSkypeEventsMute(bool mute)
private static void HandleUpdateTimerElapsed(object sender, ElapsedEventArgs e)
{
UpdateLights();
_updateTimer.Start();
}
private static void HandleSkypeEventsMute(bool mute)
{
UpdateLights();
}
static void HandleSkypeCallStatus(Call call, TCallStatus status)
private static void HandleSkypeCallStatus(Call call, TCallStatus status)
{
UpdateLights();
}

View File

@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
// Runtime Version:4.0.30319.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -55,5 +55,14 @@ namespace WorkIndicator.Properties {
return ((global::System.TimeSpan)(this["RetryInterval"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("00:00:00.5000000")]
public global::System.TimeSpan UpdateInterval {
get {
return ((global::System.TimeSpan)(this["UpdateInterval"]));
}
}
}
}

View File

@@ -11,5 +11,8 @@
<Setting Name="RetryInterval" Type="System.TimeSpan" Scope="Application">
<Value Profile="(Default)">00:00:10</Value>
</Setting>
<Setting Name="UpdateInterval" Type="System.TimeSpan" Scope="Application">
<Value Profile="(Default)">00:00:00.5000000</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -23,6 +23,9 @@
<setting name="RetryInterval" serializeAs="String">
<value>00:00:10</value>
</setting>
<setting name="UpdateInterval" serializeAs="String">
<value>00:00:00.5000000</value>
</setting>
</WorkIndicator.Properties.Settings>
</applicationSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/></startup></configuration>