Skip to content

Commit

Permalink
Built EventLogging Into System
Browse files Browse the repository at this point in the history
  • Loading branch information
skavan committed Jul 16, 2014
1 parent 162c4d5 commit 7db4ffb
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 40 deletions.
41 changes: 24 additions & 17 deletions vbDeviceSpy/frmDeviceFinderClean.Designer.vb

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

4 changes: 2 additions & 2 deletions vbDeviceSpy/frmDeviceFinderClean.resx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABE
FwAAAk1TRnQBSQFMAgEBCAEAAVABAQFQAQEBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
FwAAAk1TRnQBSQFMAgEBCAEAAWABAQFgAQEBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
AwABMAMAAQEBAAEYBgABJP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AB4A//8n/wPnAc4CxgHnAt4B/wL3
If8E1gHOAcYB7wLnAf8C9y3/Aa0BpQKtAZQCrQGUAq0BlAKtAZQCrQGUAq0BlAGtA9YM/wMQIZQDIQz/
AfcC/wFrAb0B1gExAYwBrQFKAXsBlAFrAYQBjAGUApwBvQK1Ad4C1gH3Au8S/wHGAecB9wFaAa0BxgE5
Expand Down Expand Up @@ -311,7 +311,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAg
OQAAAk1TRnQBSQFMAgEBBQEAAdABAAHQAQABIAEAASABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAGA
OQAAAk1TRnQBSQFMAgEBBQEAAeABAAHgAQABIAEAASABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAGA
AwABQAMAAQEBAAEYBgABYP8A/wD/AP8A/wD/AP8A/wD/ACEAUZMDj/8AKgADmAPiA/5I/wP9A90Dlf8A
JwADkwP+A/AD7QPsA+sG6gPpA+gD5wPmA+UG5APjA+ID4QPgA98G3g/dA+AD/QOT/wAnAAOTA/8D7wN7
A+4DrwOwA6UDqgPEA6QDrgO8A9IDrgO3A5sDnQPHA6cDjQOXA7oDnwOcA90DcgPdA/8Dk/8AJwADkwP/
Expand Down
48 changes: 31 additions & 17 deletions vbDeviceSpy/frmDeviceFinderClean.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Imports OpenSource.UPnP
Imports OpenSource.Utilities

Public Class frmDeviceFinderClean

Expand Down Expand Up @@ -48,7 +49,7 @@ Public Class frmDeviceFinderClean
#Region "Initialization & Cleanup"

Private Sub Init()

Categories.Add("urn:schemas-upnp-org:device:MediaRenderer:1", "Media Renderers")
Categories.Add("urn:schemas-upnp-org:device:MediaServer:1", "Media Servers")
Categories.Add("OTHER", "Other")
Expand All @@ -72,27 +73,28 @@ Public Class frmDeviceFinderClean
ManagedRootNodes.Add(item.Key, root)
Me.ManagedTree.Nodes.Add(root)
Next
If My.Settings.SavedDevices IsNot Nothing Then
If My.Settings.SavedDevices.Count = 0 Then
disc.BeginNetworkScan()
'Else
' disc.LoadSettings()
End If
'Else

End If
disc.BeginNetworkScan()


InstanceTracker.Enabled = True
InstanceTracker.Display()

EventLogger.ShowAll = True

GuiResizing()
End Sub

Private Sub CleanUp()
InstanceTracker.Enabled = False
InstanceTracker.ActiveForm.Close()
player = Nothing
Debug.Print("Exiting.....")
disc.SaveSettings()
disc.CleanUp()


disc = Nothing


End Sub


Expand All @@ -101,13 +103,15 @@ Public Class frmDeviceFinderClean
#Region "Callbacks"

Private Sub disc_deviceDiscoveryEvent(device As UPnPDevice, deviceChangeEvent As discovery.eDeviceDiscoveryEvent) Handles disc.deviceDiscoveryEvent

Select Case deviceChangeEvent
Case discovery.eDeviceDiscoveryEvent.deviceAdded
MyBase.Invoke(New DeviceChangeHandler(AddressOf AddDeviceToTree), {device, False})
'Me.AddDeviceToTree(device)
Case discovery.eDeviceDiscoveryEvent.deviceRemoved
MyBase.Invoke(New DeviceChangeHandler(AddressOf Me.RemovedDeviceFromTree), New Object() {device, False})
Case discovery.eDeviceDiscoveryEvent.managedDeviceAdded
EventLogger.Log(Me, EventLogEntryType.Error, device.FriendlyName & " " & deviceChangeEvent.ToString)
MyBase.Invoke(New DeviceChangeHandler(AddressOf AddDeviceToTree), {device, True})
Case discovery.eDeviceDiscoveryEvent.managedDeviceRemoved
MyBase.Invoke(New DeviceChangeHandler(AddressOf Me.RemovedDeviceFromTree), {device, True})
Expand Down Expand Up @@ -297,6 +301,7 @@ Public Class frmDeviceFinderClean
Me.listInfo.Items.AddRange(CType(Items.ToArray(GetType(ListViewItem)), ListViewItem()))
End Sub

'// on exit
Private Sub frmDeviceFinderClean_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
CleanUp()
End Sub
Expand All @@ -306,12 +311,6 @@ Public Class frmDeviceFinderClean
Init()
End Sub

'// on exit
Private Sub Form1_HandleDestroyed(sender As Object, e As EventArgs) Handles Me.HandleDestroyed
'Me.deviceTree.Nodes.Add(Me.UPnpRoot)

End Sub

'// on GUI resize
Private Sub ToolStrip1_SizeChanged(sender As Object, e As EventArgs) Handles ToolStrip1.SizeChanged
GuiResizing()
Expand Down Expand Up @@ -689,4 +688,19 @@ Public Class frmDeviceFinderClean
Private Sub btnPause_Click(sender As Object, e As EventArgs) Handles btnPause.Click
player.Pause()
End Sub


Private Sub mnuGo_Click(sender As Object, e As EventArgs) Handles mnuGo.Click
If My.Settings.SavedDevices IsNot Nothing Then
If My.Settings.SavedDevices.Count = 0 Then
'disc.BeginNetworkScan()
'Else
' disc.LoadSettings()
End If
'Else
Else

End If
disc.BeginNetworkScan()
End Sub
End Class
18 changes: 14 additions & 4 deletions vbDeviceSpy/player.vb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

Imports OpenSource.UPnP
Imports OpenSource.Utilities
Imports System.Collections.Generic
Imports System.Linq
Imports System.Threading
Expand Down Expand Up @@ -53,7 +54,10 @@ Public Class Player
Protected Overrides Sub Finalize()

If positionTimer IsNot Nothing Then positionTimer.Dispose()
AVTransport.UnSubscribe(Nothing)
If AVTransport IsNot Nothing Then
AVTransport.UnSubscribe(Nothing)
End If

MyBase.Finalize()
End Sub

Expand All @@ -71,7 +75,8 @@ Public Class Player

'Console.WriteLine("LastChange from {0}", UUID);
Dim newState As String = sender.Value
Debug.Print("AVTRANSPORT CALLBACK" & newState)
'Debug.Print("AVTRANSPORT CALLBACK" & newState)
EventLogger.Log(Me, EventLogEntryType.Error, "Incoming Event: " & sender.Name & " | " & newState)
'Console.WriteLine(newState);
ParseChangeXML(newState)
End Sub
Expand Down Expand Up @@ -126,7 +131,11 @@ Public Class Player
Case "PLAYING"
StartPolling()
Case "PAUSED_PLAYBACK", "PAUSED", "STOPPED"
positionTimer.Change(0, Timeout.Infinite)
If positionTimer IsNot Nothing Then
'// suspend timer if its running
positionTimer.Change(0, Timeout.Infinite)
End If

End Select
Debug.Print("RAISING EVENT 2")
' every time we have got a state change, do a PositionInfo
Expand Down Expand Up @@ -171,7 +180,7 @@ Public Class Player
End Try

CurrentState.LastStateChange = DateTime.Now

EventLogger.Log(Me, EventLogEntryType.Error, "Event Processed.")
RaiseEvent StateChanged(Me)

End Sub
Expand Down Expand Up @@ -643,6 +652,7 @@ Public Class SonosItem
Public Overridable Property DIDL() As SonosDIDL

Public Shared Function Parse(xmlString As String) As IList(Of SonosItem)

Dim xml = XElement.Parse(xmlString)
Dim ns As XNamespace = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
Dim dc As XNamespace = "http://purl.org/dc/elements/1.1/"
Expand Down

0 comments on commit 7db4ffb

Please sign in to comment.