Skip to content

Commit

Permalink
Add Library Version Detection
Browse files Browse the repository at this point in the history
  • Loading branch information
eloaders committed Jul 28, 2014
1 parent e1a0fa7 commit c792138
Show file tree
Hide file tree
Showing 4 changed files with 311 additions and 8 deletions.
219 changes: 219 additions & 0 deletions I-Nex/i-nex/.src/FSystemInfo.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
' Gambas class file

Private $sInfo As String

Public Sub btnClose_Click()

Me.Close

End

Public Sub btnCopy_Click()

Clipboard.Copy($sInfo)

End

' Private Sub FindLibraryRec(sDir As String, sPattern As String) As String
'
' Dim sSubDir As String
' Dim sLib As String
' Dim aDir As String[]
'
' Try aDir = Dir(sDir, sPattern)
' If aDir And If aDir.Count = 1 Then Return aDir[0]
'
' Try aDir = Dir(sDir, "*", gb.Directory)
' If Not Error Then
' For Each sSubDir In aDir
' sLib = FindLibraryRec(sDir &/ sSubDir, sPattern)
' If sLib Then Return sLib
' Next
' Endif
'
' End

Private Sub ReadLsbRelease(sPath As String) As Collection

Dim cCol As New Collection
Dim sLine As String
Dim aLine As String[]

For Each sLine In Split(File.Load(sPath), "\n", "", True)

aLine = Scan(sLine, "*=*")
Try cCol[aLine[0]] = UnQuote(aLine[1])

Next

Return cCol

End

Private Sub GetDistribution() As String

Dim cDist As Collection = ["lsb-release": "/etc/lsb-release",
"vector": "/etc/vector-version",
"slackware": "/etc/slackware-version",
"debian": "/etc/debian_version",
"redhat": "/etc/redhat-release",
"arch": "/etc/arch-release",
"SuSE": "/etc/SuSE-release",
"gentoo": "/etc/gentoo-release",
"conectiva": "/etc/conectiva-release",
"mandriva": "/etc/mandriva-release",
"pardus": "/etc/pardus-release",
"kanotix": "/etc/kanotix-release"]
Dim sPath As String
Dim sDistro As String
Dim cData As Collection
Dim iPos As Integer

For Each sPath In cDist
sDistro = cDist.Key

If Not Exist(sPath) Then Continue

If sDistro = "lsb-release" Then
cData = ReadLsbRelease(sPath)
sDistro = cData["DISTRIB_DESCRIPTION"]
If sDistro Then Return sDistro
Return cData["DISTRIB_ID"] & " " & cData["DISTRIB_RELEASE"]
Else
Return sDistro & " " & Trim(File.Load(sPath))
Endif

Next

sDistro = File.Load("/etc/issue")
If sDistro Then
iPos = InStr(sDistro, "\\")
If iPos Then sDistro = Left(sDistro, iPos - 1)
Endif
Return Trim(sDistro)

End

Public Sub Form_Open()

Dim aText As New String[]
Dim aLib As New String[]
Dim sTemp As String
Dim sFile As String
Dim cSearch As Collection
Dim cFile As Collection
Dim sPattern As String
Dim sText As String
Dim I As Integer
Dim aLine As String[]
Dim sDir As String

Inc Application.Busy
'
' 'txtInfo.Font = Font[Settings["/ConsoleFont", Project.DEFAULT_FONT]]
'
' aText.Add("[System]")
' aText.Add("Gambas=" & System.FullVersion)
' aText.Add("OperatingSystem=" & System.Family)
'
' Exec ["uname", "-r"] To sTemp
' aText.Add("Kernel=" & Trim(sTemp))
'
' aText.Add("Architecture=" & System.Architecture)
' aText.Add("Distribution=" & GetDistribution())
' aText.Add("Desktop=" & Desktop.Type)
' aText.Add("Theme=" & Style.Name)
' aText.Add("Language=" & System.Language)
'
' If System.Family = "FreeBSD" Then
' Exec ["sysctl", "-n", "hw.physmem"] To sTemp
' sTemp = CStr(CInt(sTemp) \ 1024)
' Else
' Exec ["cat", "/proc/meminfo"] To sTemp
' Try sTemp = Scan(sTemp, "*MemTotal:*\n*")[1]
' If Error Then
' sTemp = ""
' Else
' While Not IsDigit(Right(sTemp))
' sTemp = Left(sTemp, -1)
' Wend
' sTemp = Trim(sTemp)
' Endif
' Endif
'
' If sTemp Then
' Try sTemp = Format(CInt(sTemp) / 1024, "0") & "M"
' If Not Error Then aText.Add("Memory=" & sTemp)
' Endif
If Settings["Window/X"] = Null Then
Me.Center
Else
Try Me.X = Settings["Window/X", Me.X]
Try Me.Y = Settings["Window/Y", Me.Y]
Endif
cSearch = ["Qt4": "libQtCore.so.*.*.*",
"Qt5": "libQt5Core.so.*.*.*",
"GTK2+": "libgtk-x11-2*.so.*.*.*",
"GTK3+": "libgtk-3.so.*.*.*",
"SDL": "libSDL-1.*.so.*.*.*",
"GStreamer": "libgstreamer-*.so.*.*.*",
"Poppler": "libpoppler.so.*.*.*",
"Curl": "libcurl.so.*.*.*",
"OpenGL": "libGL.so.*.*.*",
"Cairo": "libcairo.so.*.*.*",
"DBus": "libdbus-[0-9].so.*.*.*",
"Udev": "libudev.so.*.*.*",
"KDE Webkit": "libkdewebkit.so.*.*.*",
"Intel DRM": "libdrm_intel.so.*.*.*",
"Nouveau DRM": "libdrm_nouveau.so.*.*.*",
"Radeon DRM": "libdrm_radeon.so.*.*.*",
"Libdrm": "libdrm.so.*.*.*",
"PulseAudio": "libpulse.so.*.*.*"]
cFile = New Collection

aText.Add("[Libraries]")
For Each sDir In ["/lib", "/usr/lib"]
For Each sFile In RDir(sDir, "", gb.File, False).Sort(gb.IgnoreCase)
sFile = File.Name(sFile)
For Each sPattern In cSearch
If sFile Like sPattern And If Not cFile.Exist(sFile) Then
aLib.Add(cSearch.Key & "=" & sFile)
cFile[sFile] = True
Break
Endif
Next
Next
Next

aText.Insert(aLib.Sort())

gvwInfo.Rows.Count = aText.Count
gvwInfo.Columns.Count = 3
I = 0
For Each sText In aText
If Left(sText) = "[" Then
With gvwInfo[I, 0]
.Text = Mid$(sText, 2, -1)
.Font.Bold = True
.Font.Underline = True
.ColumnSpan = 3
.Padding = 4
End With
Else
aLine = Split(sText, "=")
gvwInfo[I, 0].Text = Space$(4) & Trim(aLine[0])
gvwInfo[I, 0].Padding = 4
gvwInfo[I, 2].Text = Trim(aLine[1])
gvwInfo[I, 2].Padding = 4
Endif
Inc I
Next

gvwInfo.Columns[0].Width = -1
gvwInfo.Columns[1].Width = Desktop.Scale * 2

$sInfo = aText.Join("\n")

Dec Application.Busy

End
66 changes: 66 additions & 0 deletions I-Nex/i-nex/.src/FSystemInfo.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Gambas Form File 3.0

{ Form Form
MoveScaled(0,0,68,77)
Background = Color.TextBackground
Text = ("I-Nex Library")
Icon = Picture["i-nex.png"]
Resizable = False
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
{ HBox2 HBox
MoveScaled(1,0,58,7)
Background = Color.TextBackground
AutoResize = True
Spacing = True
{ PictureBox1 PictureBox
MoveScaled(0,0,7,7)
Picture = Picture["icon:/large/system"]
AutoResize = True
Alignment = Align.Center
}
{ TextLabel1 TextLabel
MoveScaled(12,0,46,5)
Font = Font["Bold"]
Expand = True
Text = ("Library Informations")
Alignment = Align.Normal
}
}
{ Panel3 Panel
MoveScaled(1,11,63,27)
Expand = True
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
Border = Border.Plain
{ gvwInfo GridView
MoveScaled(3,4,49,22)
Expand = True
Border = False
Grid = False
ScrollBar = Scroll.Vertical
}
}
{ HBox1 HBox
MoveScaled(0,59,66,4)
Spacing = True
{ Panel1 Panel
MoveScaled(4,0,4,4)
Expand = True
}
{ btnCopy Button
MoveScaled(23,0,18,4)
Text = ("&Copy")
Picture = Picture["icon:/small/copy"]
}
{ btnClose Button
MoveScaled(48,0,18,4)
Text = ("Close")
Picture = Picture["icon:/16/close"]
Default = True
Cancel = True
}
}
}
27 changes: 20 additions & 7 deletions I-Nex/i-nex/.src/Finfosys.class
Original file line number Diff line number Diff line change
Expand Up @@ -801,15 +801,18 @@ Public Sub Button10_Click()
End

Public Sub ComboBox3_Click()
Inc Application.Busy
Disk_Drives.get_informations()
refreshing()
Dec Application.Busy
End

Public Sub ComboBox4_Click()

Inc Application.Busy
Disk_Drives._init_2()
Disk_Drives.get_informations()
refreshing()
Dec Application.Busy
End

Public Sub refreshing()
Expand Down Expand Up @@ -879,21 +882,21 @@ Label134.Text = "Rq affinity: " & Disk_Drives.rq_affinity & "" ' rq_affinity
End

Public Sub ComboBox5_Click()

Inc Application.Busy
USB_Drives.get_informations()

Dec Application.Busy
End

Public Sub ComboBox6_Click()

Inc Application.Busy
Asound_Drives._get_informations()

Dec Application.Busy
End

Public Sub ComboBox7_Click()

Inc Application.Busy
Input_Devices._get_informations()

Dec Application.Busy
End

Public Sub Button12_Click()
Expand Down Expand Up @@ -927,10 +930,12 @@ Public Sub Button6_Click()
End

Public Sub ComboBox2_Click()
Inc Application.Busy
Network.get_informations_about_net_interface()
TextBox56.Text = Network.subsystem_device
TextBox57.Text = Network.subsystem_vendor
TextArea4.Text = Network.lspci
Dec Application.Busy
End

Public Sub Button8_Click()
Expand Down Expand Up @@ -1130,9 +1135,11 @@ End
Public Sub MenuButton1_Click()

Dim URL As String
Inc Application.Busy
VALIDATE._inits()
URL = VALIDATE.SendReportToServer(User.Home & "/.i-nex/VALID", "Validate", "http://i-nex.pl/", Settings["Cerbero/USERNAME"], Settings["Cerbero/API"])
FCopyUrl.TextBox1.Text = URL
Dec Application.Busy
FCopyUrl.Show

End
Expand All @@ -1155,3 +1162,9 @@ Public Sub Button17_Click()
Desktop.Open("https://www.google.com/maps/search/" & Label237.Text & "")

End

Public Sub Button18_Click()

FSystemInfo.Show

End
7 changes: 6 additions & 1 deletion I-Nex/i-nex/.src/Finfosys.form
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@
ReadOnly = True
}
{ TextLabel21 TextLabel
Move(84,413,378,28)
Move(84,413,301,28)
#Translate = False
Font = Font["Bold,8"]
Padding = 3
Expand Down Expand Up @@ -1609,6 +1609,11 @@
Padding = 3
Border = Border.Raised
}
{ Button18 Button
Move(392,413,70,28)
Font = Font["Bold,8"]
Text = ("Library")
}
Index = 6
Text = "Kernel"
{ TextLabel18 TextLabel
Expand Down

0 comments on commit c792138

Please sign in to comment.