@@ -92,32 +92,114 @@ Inherits Application
9292 End Function
9393 #tag EndMethod
9494
95+ #tag Method, Flags = &h21
96+ Private Function GetLinuxLibrary(psName As String ) As FolderItem
97+ # If TargetLinux Then
98+ Dim systemLibs_Folders() As String
99+ Dim systemLibs_Filenames() As String
100+
101+ systemLibs_Filenames.Append(psName + ".so.1.1" )
102+ systemLibs_Filenames.Append(psName + ".so.1.0.2" )
103+ systemLibs_Filenames.Append(psName + ".so.1.0.0" )
104+ systemLibs_Filenames.Append(psName + ".so.0.9.8" )
105+ systemLibs_Filenames.Append(psName + ".so" ) 'is usually a symlink, but might point to non supported version by CubeSQLPlugin
106+
107+ # If Target32Bit Then
108+ # If TargetARM Then
109+ systemLibs_Folders.Append( "/lib/arm-linux-gnueabihf/" )
110+ systemLibs_Folders.Append( "/usr/lib/arm-linux-gnueabihf/" )
111+ # EndIf
112+ systemLibs_Folders.Append( "/lib/i386-linux-gnu/" )
113+ systemLibs_Folders.Append( "/usr/lib/i386-linux-gnu/" )
114+ systemLibs_Folders.Append( "/lib32/" )
115+ systemLibs_Folders.Append( "/usr/lib32/" )
116+ # EndIf
117+ # If Target64Bit Then
118+ # If TargetARM Then
119+ #Pragma Error "SSL Library locations has not been implemented yet for this BuildTarget"
120+ # EndIf
121+ systemLibs_Folders.Append( "/lib/x86_64-linux-gnu/" )
122+ systemLibs_Folders.Append( "/usr/lib/x86_64-linux-gnu/" )
123+ systemLibs_Folders.Append( "/lib64/" )
124+ systemLibs_Folders.Append( "/usr/lib64/" )
125+ # EndIf
126+
127+ systemLibs_Folders.Append( "/lib/" )
128+ systemLibs_Folders.Append( "/usr/lib/" )
129+
130+ Dim oFile As FolderItem
131+ For Each sSystemLibsFolder As String In systemLibs_Folders
132+ For Each sSystemLibsFilename As String In systemLibs_Filenames
133+ oFile = GetFolderItem(sSystemLibsFolder + sSystemLibsFilename, FolderItem.PathTypeShell)
134+ If (oFile <> Nil) And ( Not oFile.Directory) And oFile.Exists Then Return oFile
135+ Next
136+ Next
137+
138+ # EndIf
139+
140+ Return Nil
141+
142+ End Function
143+ #tag EndMethod
144+
95145 #tag Method, Flags = &h21
96146 Private Sub SSLStartupCheck()
97- Dim f As FolderItem = Prefs.SSLAdminPath
98- if (f = nil) then return
147+ Dim SSLLibFile As FolderItem
148+ Dim CryptoLibFile As FolderItem
99149
100- Dim SSLLib As String
101- Dim CryptoLib As String
150+ # If TargetMacOS Then
151+ 'SSL Library is included in CubeSQLPlugin
152+ return
153+
154+ # ElseIf TargetWindows Then
155+ 'Try to locate the SSL Library in these folders
156+ Dim locateSSLLibsInFolders() As FolderItem = Array(Prefs.SSLAdminPath)
157+ locateSSLLibsInFolders.Append(App.ExecutableFile.Parent)
158+
159+ Dim libsFoldername As String = App.ExecutableFile.Name 'remove .exe
160+ libsFoldername = Left(libsFoldername, Len(libsFoldername) - 4 ) + " Libs"
161+ locateSSLLibsInFolders.Append(App.ExecutableFile.Parent.Child(libsFoldername))
162+ locateSSLLibsInFolders.Append(App.ExecutableFile.Parent.Child( "Libs" ))
163+
164+ Dim SSLLib As String
165+ Dim CryptoLib As String
166+
167+ # If Target64Bit Then
168+ SSLLib = "libssl-1_1-x64.dll"
169+ CryptoLib = "libcrypto-1_1-x64.dll"
170+ # Else
171+ SSLLib = "libssl-1_1.dll"
172+ CryptoLib = "libcrypto-1_1.dll"
173+ # EndIf
174+
175+ For Each folder As FolderItem In locateSSLLibsInFolders
176+ If (folder = Nil) Or ( Not folder.Exists) Or ( Not folder.Directory) Then Continue
177+
178+ SSLLibFile = folder.Child(SSLLib)
179+ CryptoLibFile = folder.Child(CryptoLib)
180+
181+ If (SSLLibFile = Nil) Or (CryptoLibFile = Nil) Then Continue
182+ If ( Not SSLLibFile.Exists) Or ( Not CryptoLibFile.Exists) Then Continue
183+
184+ 'Libs found
185+ Exit 'Loop
186+ Next
187+
188+ # ElseIf TargetLinux Then
189+ SSLLibFile = Me .GetLinuxLibrary( "libssl" )
190+ CryptoLibFile = Me .GetLinuxLibrary( "libcrypto" )
191+
192+ # Else
193+ #Pragma Error "SSL Library locations has not been implemented yet for this BuildTarget"
194+ # EndIf
102195
103- # if TargetMacOS
104- SSLLib = "libssl.dylib"
105- CryptoLib = "libcrypto.dylib"
106- # elseif TargetWindows
107- SSLLib = "libssl32.dll"
108- CryptoLib = "libeay32.dll"
109- # else
110- SSLLib = "libssl.so"
111- CryptoLib = "libcrypto.so"
112- # endif
196+ If (SSLLibFile = Nil) Or (CryptoLibFile = Nil) Then Return
197+ If ( Not SSLLibFile.Exists) Or ( Not CryptoLibFile.Exists) Then Return
113198
114- Dim SSLLibPath As FolderItem = f.Child(SSLLib)
115- Dim CryptoLibPath As FolderItem = f.Child(CryptoLib)
116- if (SSLLibPath = nil) or (CryptoLibPath = nil) then return
117- if (SSLLibPath.Exists = false ) or (CryptoLibPath.Exists = False ) then return
199+ 'set SSL Library for CubeSQLPlugin
200+ CubeSQLPlugin.SSLLibrary = SSLLibFile
201+ CubeSQLPlugin.CryptoLibrary = CryptoLibFile
118202
119- CubeSQLPlugin.SSLLibrary = SSLLibPath
120- CubeSQLPlugin.CryptoLibrary = CryptoLibPath
121203 End Sub
122204 #tag EndMethod
123205
0 commit comments