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

@@ -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();
}