Merge branch 'DBusExplorerUpdate' into 'master'

Updated DBus Explorer to work with Latest XML returned by introspect call

See merge request gambas/gambas!257
This commit is contained in:
Benoît Minisini 2022-01-29 00:31:49 +00:00
commit e4dcb05c53
3 changed files with 76 additions and 35 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -1,19 +1,19 @@
# Gambas Project File 3.0 # Gambas Project File 3.0
# Compiled with Gambas 3.10.90
Title=Gambas DBus Explorer Title=Gambas DBus Explorer
Startup=FVersiongbXML Startup=FVersiongbXML
Icon=dbus64.png Icon=dbus64.png
Version=1.0.0 Version=1.0.1
Component=gb.image Component=gb.image
Component=gb.gui Component=gb.gui
Component=gb.dbus Component=gb.dbus
Component=gb.settings Component=gb.settings
Component=gb.libxml Component=gb.libxml
Description="DBus explorer.\n\nThis example allows to explore all applications connected to both DBus system and application buses. You can see all exported interfaces, methods, properties and events, with their signature. But you cannot use them." Description="DBus explorer.\n\nThis example allows to explore all applications connected to both DBus system and application buses. You can see all exported interfaces, methods, properties and events, with their signature. But you cannot use them.\n\nUpdated to Correctly report property Names, Looks for Name attribute now \n Was expecting to be first in List, but now randomly located\nUpdated to display Property direction read or read/write\nUpdated to correctly report full details of signal handling"
Authors="Fabien Bodard\nBenoît Minisini" Authors="Fabien Bodard\nBenoît Minisini"
TabSize=2 TabSize=2
Translate=1
Language=en_US
Vendor=Example Vendor=Example
Packager=1 Packager=1
Tags=Example,Utility Tags=Example,Utility
CreateMenu=1 CreateMenu=1
Translate=1

View file

@ -61,28 +61,42 @@ Public Sub ShowPathContent(sPath As String, sBus As String, sApplication As Stri
hNode2 = hNode.Children[j] hNode2 = hNode.Children[j]
If hNode2.Name = "method" Or hNode2.Name = "property" Or hNode2.Name = "signal" Then If hNode2.Name = "method" Or hNode2.Name = "property" Or hNode2.Name = "signal" Then
For Each hattr In hNode2.Attributes For Each hattr In hNode2.Attributes
Break If hattr.name = "name" Then Break
Next Next
Try tvDbus.Add(sFullDbusPath & "|" & hattr.Value, hattr.Value, Picture[hNode2.Name & ".png"], sFullDbusPath) Try tvDbus.Add(sFullDbusPath & "|" & hattr.Value, hattr.Value, Picture[hNode2.Name & ".png"], sFullDbusPath)
If Error Then Continue If Error Then Continue
For k = 0 To hNode2.Children.Count - 1 $cArgs[sFullDbusPath & "|" & hattr.Value] &= "ref=" & hNode2.Name
If hNode2.Children[k].Name = "arg" Then
For Each hattr2 In hNode2.Children[k].Attributes If hNode2.name = "property" Then
aArgs.Add(hattr2.Name & "=" & hattr2.Value) For Each hattr2 In hNode2.Attributes
If hattr2.name = "name" Then Continue
aArgs.Add(hattr2.Name & "=" & hattr2.Value)
Next
Next $cArgs[sFullDbusPath & "|" & hattr.Value] &= "|" & aArgs.Join()
aArgs.Clear
$cArgs[sFullDbusPath & "|" & hattr.Value] &= aArgs.Join() Else
If k < hNode2.Children.Count - 2 Then $cArgs[sFullDbusPath & "|" & hattr.Value] &= "|" For k = 0 To hNode2.Children.Count - 1
aArgs.Clear If hNode2.Children[k].Name = "arg" Then
Endif
Next
For Each hattr2 In hNode2.Children[k].Attributes
aArgs.Add(hattr2.Name & "=" & hattr2.Value)
Next
$cArgs[sFullDbusPath & "|" & hattr.Value] &= "|" & aArgs.Join()
'If k < hNode2.Children.Count - 2 Then $cArgs[sFullDbusPath & "|" & hattr.Value] &= "|"
aArgs.Clear
Endif
Next
Endif
Endif Endif
Next Next
Next Next
Endif Endif
@ -180,8 +194,12 @@ Public Function MakeSignature(sKey As String) As String
Dim s, t As String Dim s, t As String
Dim aArg As String[] Dim aArg As String[]
Dim sName, sType As String Dim sName, sType As String
Dim iArg As Integer Dim sDirection As String
Dim sRef As String
Dim iArg As Integer = 1
Dim aOut As New String[] Dim aOut As New String[]
Dim sAccess As String = ""
Dim bHasAccess As Boolean = False
ars = Split(skey, "|") ars = Split(skey, "|")
If Not $cArgs.Exist(skey) Then If Not $cArgs.Exist(skey) Then
@ -192,40 +210,63 @@ Public Function MakeSignature(sKey As String) As String
Endif Endif
Endif Endif
For Each s In Split($cArgs[sKey], "|") Dim sParameters As String[] = Split($cArgs[sKey], "|")
For Each s In sParameters
Inc iArg sName = "Arg" '
sDirection = ""
sName = "Arg" & CStr(iArg) sType = ""
For Each t In Split(s) For Each t In Split(s)
aArg = Scan(t, "*=*") aArg = Scan(t, "*=*")
Select Case aArg[0] Select Case aArg[0]
Case "ref"
sRef = aArg[1]
Case "direction"
sDirection = aArg[1]
Case "type" Case "type"
sType = GetType(aArg[1]) sType = GetType(aArg[1])
Case "name" Case "name"
sName = aArg[1] sName = aArg[1]
Case "access"
sAccess = aArg[1]
bHasAccess = True
End Select End Select
Next Next
If InStr(s, "=out") Then If sDirection == "in" Then
If sName = "Arg" Then
aOut.Add(sName & " As " & sType) sName &= CStr(iArg)
Inc iArg
Else Endif
aIn.Add(sName & " As " & sType) aIn.Add(sName & " As " & sType)
Else
If sName = "Arg" Then
If stype <> "" Then aOut.Add(sType)
Else
aOut.Add(sName & " As " & sType)
Endif
Endif Endif
Next Next
s = ars[ars.Max] & "(" & aIn.Join(", ") & ")" If sRef = "property" Then
If aOut.Count Then s = ars[ars.max] & " AS " & aOut.last & " For " & sAccess
s &= " As " Else
If aOut.Count = 1 Then If sRef = "method" Then
s &= Scan(aOut[0], "* As *")[1] s = ars[ars.Max] & "(" & aIn.Join(", ") & ")"
Else If sRef = "signal" Then
s = ars[ars.Max]
Endif
If aOut.Count Then
s &= IIf(sRef = "signal", " Sends ", " As ")
If aOut.Count = 1 Then
s &= aOut.last
Else
s &= "[" & aOut.Join(", ") & "] as variant[]"
Endif
Else Else
s &= "[" & aOut.Join(", ") & "]" If sRef = "signal" Then s &= " Sends Nothing"
Endif Endif
Endif Endif
@ -248,7 +289,7 @@ Public Sub tvDbus_MouseMove()
If Not tvDbus.FindAt(Mouse.x, Mouse.y) Then If Not tvDbus.FindAt(Mouse.x, Mouse.y) Then
s = MakeSignature(tvDbus.item.key) s = MakeSignature(tvDbus.item.key)
hcont = tvDbus.Parent hcont = tvDbus.Parent
ix = tvDbus.Item.X + tvDbus.Item.w / 2 ix = tvDbus.Item.X + tvDbus.Item.w / 2
iy = tvDbus.Item.Y iy = tvDbus.Item.Y