[EXAMPLES]

* NEW: The DBus Explorer example name is now "DBusExplorer".


git-svn-id: svn://localhost/gambas/trunk@2276 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2009-08-26 08:47:30 +00:00
parent 4e7d77b697
commit 54593a73cb
14 changed files with 612 additions and 0 deletions

View File

@ -0,0 +1,2 @@
[Desktop Entry]
Icon=./.icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -0,0 +1,14 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.0 (r2272)
Title=Gambas DBus Explorer
Startup=FVersiongbXML
Icon=dbus64.png
Version=0.0.1
Component=gb.gui
Component=gb.form
Component=gb.dbus
Component=gb.settings
Component=gb.form.mdi
Component=gb.xml
Authors="Fabien Bodard\nBenoît Minisini"
TabSize=2

View File

@ -0,0 +1,109 @@
[Breakpoints]
Count=0
[DebugWindow]
Count=0
[DebugWindow/$xmlMyDoc]
Geometry=[0,0,210,210]
[DebugWindow/$xmlMyDoc.Root]
Geometry=[350,29,210,210]
[DebugWindow/$xmlMyDoc.Root.Attributes]
Geometry=[364,43,210,210]
[DebugWindow/$xmlMyDoc.Root.Children]
Geometry=[702,60,210,210]
[DebugWindow/$xmlMyDoc.Root.Children[0]]
Geometry=[612,36,210,210]
[DebugWindow/$xmlMyDoc.Root.Children[0].Attributes]
Geometry=[730,88,210,210]
[DebugWindow/$xmlMyDoc.Root.Children[1]]
Geometry=[716,74,433,364]
[DebugWindow/$xmlMyDoc.Root.Children[1].Attributes]
Geometry=[730,88,229,225]
[DebugWindow/DBus[Last.current.text]]
Geometry=[0,0,322,306]
[DebugWindow/DBus[sApplication][sPath]]
Geometry=[0,0,210,210]
[DebugWindow/Split($Value, "]")]
Geometry=[0,0,494,210]
[DebugWindow/TreeView1]
ShowHidden=True
Geometry=[0,0,210,210]
[DebugWindow/aConCat]
Geometry=[0,0,210,210]
[DebugWindow/aa]
Geometry=[0,0,210,210]
[DebugWindow/ars]
Geometry=[72,235,210,210]
[DebugWindow/hApplication.Connection]
Geometry=[0,0,210,210]
[DebugWindow/hApplication.Connection.Applications]
Geometry=[10,0,210,210]
[DebugWindow/hInterface.Methods]
Geometry=[0,0,210,210]
[DebugWindow/hInterface.Methods[0]]
Geometry=[10,0,210,210]
[DebugWindow/hInterface.Properties]
Geometry=[0,0,210,210]
[DebugWindow/hInterface.Properties[0]]
Geometry=[10,0,210,210]
[DebugWindow/hInterface.Properties[0].Args]
Geometry=[228,185,210,210]
[DebugWindow/hInterface.Properties[0].Args[0]]
Geometry=[360,0,210,210]
[DebugWindow/hInterface.Signals]
Geometry=[0,0,210,210]
[DebugWindow/hInterface.Signals[0]]
Geometry=[10,0,210,210]
[DebugWindow/hInterface.Signals[2]]
Geometry=[10,0,210,210]
[DebugWindow/hNode.Children]
Geometry=[0,0,210,210]
[DebugWindow/tblV[0, 0]]
Geometry=[0,0,210,210]
[DebugWindow/xmlDoc]
Geometry=[0,0,210,210]
[FFind]
SearchIn="Module"
CaseSensitive=False
SearchWord=False
SearchComment=False
SearchString=True
[OpenFile]
File[1]="/home/benoit/gambas/3.0/link/share/gambas3/examples/Misc/DBusExplorer/.src/FVersiongbXML.form"
File[2]="/home/benoit/gambas/3.0/link/share/gambas3/examples/Misc/DBusExplorer/.src/FVersiongbXML.class:74.0"
Count=2
[Watches]
Count=0

View File

@ -0,0 +1,230 @@
' Gambas class file
Private $ColArgs As New Collection
Private $colTypes As New Collection
Public Sub _new()
$colTypes["i"] = "Interger"
$colTypes["u"] = "Interger"
$colTypes["s"] = "Interger"
$colTypes["b"] = "Boolean"
$colTypes["y"] = "Byte"
$colTypes["ay"] = "Byte[]"
$colTypes["ai"] = "Integer[]"
$colTypes["as"] = "String[]"
$colTypes["v"] = "Variant"
$colTypes["av"] = "Variant[]"
End
Public Sub Form_Open()
Me.Raise
btnRefresh_Click
End
Public Sub ShowPathContent(sPath As String, sBus As String, sApplication As String)
Dim xmlDoc As New XmlDocument
Dim sInterface, sFullDbusPath, s, sAppPath As String
Dim hattr, hattr2, hNode, hNode2 As XmlNode
Dim i, j, k As Integer
Dim aArgs As New String[]
Dim sArgs As String
'Dim haArgs As New Object[]
Try xmlDoc.FromString(DBus[sBus & sApplication]._introspect(sPath))
If Error Then Return
For i = 0 To xmlDoc.Root.Children.Count - 1
hNode = xmlDoc.Root.Children[i]
If hNode.Name = "interface" Then
For Each hattr In hNode.Attributes
sFullDbusPath = [sBus, sApplication, sPath, CStr(hattr.Value)].Join("|")
If Not tvDbus.Exist(sBus & "|" & sApplication & "|" & sPath) Then
tvDbus.Add(sFullDbusPath, hattr.Value)
Else
tvDbus.Add(sFullDbusPath, hattr.Value,, sBus & "|" & sApplication & "|" & sPath)
Endif
For j = 0 To hNode.Children.Count - 1
hNode2 = hNode.Children[j]
If hNode2.Name = "method" Or hNode2.Name = "property" Or hNode2.Name = "signal" Then
For Each hattr In hNode2.Attributes
Break
Next
Try tvDbus.Add(sFullDbusPath & "|" & hattr.Value, hattr.Value, Picture[hNode2.Name & ".png"], sFullDbusPath)
If Error Then Continue
For k = 0 To hNode2.Children.Count - 1
If hNode2.Children[k].Name = "arg" Then
For Each hattr2 In hNode2.Children[k].Attributes
aArgs.Add(hattr2.Name & "=" & hattr2.Value)
Next
$ColArgs[sFullDbusPath & "|" & hattr.Value] &= aArgs.Join()
If k < hNode2.Children.Count - 2 Then $ColArgs[sFullDbusPath & "|" & hattr.Value] &= "|"
aArgs.Clear
Endif
Next
Endif
Next
Next
Endif
Next
For Each s In DBus[sApplication][sPath].Children
sAppPath = [sBus, sApplication, sPath].join("|")
If tvDbus.Exist(sAppPath) Then
tvDbus.Add(sAppPath &/ s, s,, sAppPath)
Else
tvDbus.Add(sAppPath &/ s, s)
Endif
tvDbus.Add(sAppPath &/ s & "|child", "child",, sAppPath &/ s)
tvDbus[sAppPath &/ s].Picture = Picture["icon:/medium/directory"]
Next
Catch
Print Error.Text
End
Public Sub lstb_activate()
tvDbus.Clear
$ColArgs.Clear
ShowPathContent("/", Last.Tag & "://", Last.current.text)
End
Public Sub tvDbus_Expand()
Dim ars As String[]
If Not tvDbus.Exist(tvDbus.item.Key & "|" & "child") Then Return
tvDbus.Remove(tvDbus.item.Key & "|" & "child")
ars = Split(tvDbus.Item.Key, "|")
ShowPathContent(ars[2], ars[0], ars[1])
End
Public Sub btnRefresh_Click()
lstbSystem.Clear
lstbSession.Clear
$ColArgs.Clear
tvDbus.Clear
lstbSession.List = DBus.Session.Applications
lstbSystem.List = DBus.System.Applications
End
Public Sub lstb_DblClick()
Try Print DBus[Last.current.text]._Introspect("/")
End
Public Function MakeSignature(sKey As String) As String
Dim ars As String[]
Dim ars2 As New String[]
Dim sValue, s, t, sOut As String
ars = Split(skey, "|")
If Not $ColArgs.Exist(skey) Then Return
For Each s In Split($ColArgs[sKey], "|")
If InStr(s, "=in") Then
sValue &= "Value As "
For Each t In Split(s)
If Scan(t, "*=*")[0] = "type" Then
s = Scan(t, "*=*")[1]
If $colTypes.Exist(s) Then
sValue &= $colTypes[s]
Else
sValue &= s
Endif
Endif
Next
ars2.Add(sValue)
sValue = ""
Else
For Each t In Split(s)
If Scan(t, "*=*")[0] = "type" Then
s = Scan(t, "*=*")[1]
If $colTypes.Exist(s) Then
sOut &= $colTypes[s]
Else
sOut &= s
Endif
Endif
Next
sOut = " As " & sOut
Endif
Next
sValue = ars[ars.Max] & "(" & ars2.Join(", ") & ")" & sOut
Return sValue
End
Public Sub tvDbus_Select()
MakeSignature(Last.item.key)
End
Public Sub tvDbus_MouseMove()
Dim s As String
Dim ix, iy As Integer
Dim hcont As Object
If Not tvDbus.Find(Mouse.x, Mouse.y) Then
s = MakeSignature(tvDbus.item.key)
If IsNull(s) Then
lblsignature.Visible = False
Return
Endif
hcont = tvDbus.Parent
ix = tvDbus.Item.X + tvDbus.Item.w / 2
iy = tvDbus.Item.Y
lblsignature.Text = s
lblsignature.Left = Min(iX, tvDbus.Width - lblsignature.Width)
lblsignature.Y = iY
lblsignature.Visible = True
lblsignature.Refresh
Else
lblsignature.Visible = False
Endif
End
Public Sub tvDbus_Leave()
lblsignature.Visible = False
End

View File

@ -0,0 +1,105 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,107,84)
Text = ("Gambas DBus Explorer - gb.xml version")
Icon = Picture["dbus64.png"]
Arrangement = Arrange.Vertical
{ Panel1 Panel
MoveScaled(3,0,83,4)
Arrangement = Arrange.Horizontal
{ btnRefresh ToolButton
MoveScaled(0,0,4,4)
AutoResize = True
Text = ("Refresh")
Picture = Picture["icon:/small/refresh"]
}
{ HBox1 HBox
MoveScaled(11,0,52,3)
{ Separator1 Separator
MoveScaled(2,0,2,3)
}
{ Label4 Label
MoveScaled(7,0,9,3)
Text = ("Legend:")
}
{ PictureBox1 PictureBox
MoveScaled(11,0,3,3)
Picture = Picture["method.png"]
Alignment = Align.Center
}
{ Label1 Label
MoveScaled(14,0,9,3)
Text = ("Method")
}
{ PictureBox2 PictureBox
MoveScaled(23,0,3,3)
Picture = Picture["property.png"]
Alignment = Align.Center
}
{ Label2 Label
MoveScaled(28,0,10,3)
Text = ("Property")
}
{ PictureBox3 PictureBox
MoveScaled(37,0,3,3)
Picture = Picture["signal.png"]
Alignment = Align.Center
}
{ Label3 Label
MoveScaled(41,0,6,3)
Text = ("Signal")
}
}
}
{ Separator2 Separator
MoveScaled(20,5,18,0)
}
{ HSplit1 HSplit
MoveScaled(0,8,102,74)
Expand = True
{ TabStrip3 TabStrip
MoveScaled(2,8,39,57)
Arrangement = Arrange.Fill
Count = 2
Index = 0
Text = ("Session")
{ lstbSession ListBox lstb
Name = "lstbSession"
MoveScaled(2,1,30,51)
Tag = "session"
Expand = True
}
Index = 1
Text = ("System")
{ lstbSystem ListBox lstb
Name = "lstbSystem"
MoveScaled(3,1,30,50)
Tag = "system"
Expand = True
}
Index = 0
}
{ VBox1 HBox
MoveScaled(43,5,54,65)
Expand = True
{ Separator3 Separator
MoveScaled(2,19,0,5)
}
{ tvDbus TreeView
MoveScaled(5,6,45,53)
Expand = True
Border = False
}
{ lblsignature Label
MoveScaled(0,0,22,3)
Visible = False
Background = Color.LightBackground
Ignore = True
AutoResize = True
Text = ("Label5")
Border = Border.Plain
}
}
}
}

View File

@ -0,0 +1,13 @@
FVersiongbXML
Gambas DBus Explorer
0
0
0.0.1
gb.gui
gb.form
gb.dbus
gb.settings
gb.form.mdi
gb.xml

View File

@ -0,0 +1,88 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="data" direction="out" type="s"/>
</method>
</interface>
<interface name="org.freedesktop.DBus">
<method name="Hello">
<arg direction="out" type="s"/>
</method>
<method name="RequestName">
<arg direction="in" type="s"/>
<arg direction="in" type="u"/>
<arg direction="out" type="u"/>
</method>
<method name="ReleaseName">
<arg direction="in" type="s"/>
<arg direction="out" type="u"/>
</method>
<method name="StartServiceByName">
<arg direction="in" type="s"/>
<arg direction="in" type="u"/>
<arg direction="out" type="u"/>
</method>
<method name="UpdateActivationEnvironment">
<arg direction="in" type="a{ss}"/>
</method>
<method name="NameHasOwner">
<arg direction="in" type="s"/>
<arg direction="out" type="b"/>
</method>
<method name="ListNames">
<arg direction="out" type="as"/>
</method>
<method name="ListActivatableNames">
<arg direction="out" type="as"/>
</method>
<method name="AddMatch">
<arg direction="in" type="s"/>
</method>
<method name="RemoveMatch">
<arg direction="in" type="s"/>
</method>
<method name="GetNameOwner">
<arg direction="in" type="s"/>
<arg direction="out" type="s"/>
</method>
<method name="ListQueuedOwners">
<arg direction="in" type="s"/>
<arg direction="out" type="as"/>
</method>
<method name="GetConnectionUnixUser">
<arg direction="in" type="s"/>
<arg direction="out" type="u"/>
</method>
<method name="GetConnectionUnixProcessID">
<arg direction="in" type="s"/>
<arg direction="out" type="u"/>
</method>
<method name="GetAdtAuditSessionData">
<arg direction="in" type="s"/>
<arg direction="out" type="ay"/>
</method>
<method name="GetConnectionSELinuxSecurityContext">
<arg direction="in" type="s"/>
<arg direction="out" type="ay"/>
</method>
<method name="ReloadConfig">
</method>
<method name="GetId">
<arg direction="out" type="s"/>
</method>
<signal name="NameOwnerChanged">
<arg type="s"/>
<arg type="s"/>
<arg type="s"/>
</signal>
<signal name="NameLost">
<arg type="s"/>
</signal>
<signal name="NameAcquired">
<arg type="s"/>
</signal>
</interface>
</node>

View File

@ -0,0 +1,51 @@
Connected to D-Bus.
Received reply from :1.2
Arguments: "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> <interface name="org.kde.network"> <method name="deviceData"> <arg type="(ssi)" direction="out"/> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="Mollet::NetDevice"/> <arg name="hostName" type="s" direction="in"/> </method> <method name="serviceData"> <arg type="(ssss)" direction="out"/> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="Mollet::NetService"/> <arg name="hostName" type="s" direction="in"/> <arg name="serviceName" type="s" direction="in"/> <arg name="serviceType" type="s" direction="in"/> </method> <method name="deviceDataList"> <arg type="a(ssi)" direction="out"/> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="Mollet::NetDeviceList"/> </method> <method name="serviceDataList"> <arg type="a(ssss)" direction="out"/> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="Mollet::NetServiceList"/> <arg name="hostName" type="s" direction="in"/> </method> </interface> <interface name="org.freedesktop.DBus.Properties"> <method name="Get"> <arg name="interface_name" type="s" direction="in"/> <arg name="property_name" type="s" direction="in"/> <arg name="value" type="v" direction="out"/> </method> <method name="Set"> <arg name="interface_name" type="s" direction="in"/> <arg name="property_name" type="s" direction="in"/> <arg name="value" type="v" direction="in"/> </method> <method name="GetAll"> <arg name="interface_name" type="s" direction="in"/> <arg name="values" type="a{sv}" direction="out"/> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> </method> </interface> <interface name="org.freedesktop.DBus.Introspectable"> <method name="Introspect"> <arg name="xml_data" type="s" direction="out"/> </method> </interface> <node name="KDebug"/> <node name="MainApplication"/> <node name="NotificationItemWatcher"/> <node name="kbuildsycoca"/> <node name="kded"/> <node name="modules"/> <node name="org"/> </node> "
Connected to D-Bus.
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.network">
<method name="deviceData">
<arg type="(ssi)" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="Mollet::NetDevice"/>
<arg name="hostName" type="s" direction="in"/>
</method> <method name="serviceData">
<arg type="(ssss)" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="Mollet::NetService"/>
<arg name="hostName" type="s" direction="in"/>
<arg name="serviceName" type="s" direction="in"/>
<arg name="serviceType" type="s" direction="in"/>
</method>
<method name="deviceDataList">
<arg type="a(ssi)" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="Mollet::NetDeviceList"/>
</method> <method name="serviceDataList">
<arg type="a(ssss)" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="Mollet::NetServiceList"/>
<arg name="hostName" type="s" direction="in"/> </method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="out"/>
</method> <method name="Set">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method> <method name="GetAll">
<arg name="interface_name" type="s" direction="in"/>
<arg name="values" type="a{sv}" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
</method> </interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="xml_data" type="s" direction="out"/> </method> </interface>
<node name="KDebug"/> <node name="MainApplication"/>
<node name="NotificationItemWatcher"/>
<node name="kbuildsycoca"/>
<node name="kded"/>
<node name="modules"/>
<node name="org"/> </node> "

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B