Platforms to show: All Mac Windows Linux Cross-Platform
/MacOSX/SystemConfiguration/MacOSXProxySettings
Feedback.
Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /MacOSX/SystemConfiguration/MacOSXProxySettings
This example is the version from Fri, 28th Jan 2010.
Notes: Last modified: Fri, 28th Jan 2010
Feedback.
Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /MacOSX/SystemConfiguration/MacOSXProxySettings
This example is the version from Fri, 28th Jan 2010.
Notes: Last modified: Fri, 28th Jan 2010
Class App
Inherits Application
// Event implementations
Sub Open()
dim m as MacOSXProxySettings
m=new MacOSXProxySettings
if m.HTTPEnable then
MsgBox "HTTP Proxy: "+m.HTTPProxy+":"+str(m.HTTPPort)
else
MsgBox "No HTTP Proxy."
end if
quit
End Sub
End Class
Class MacOSXProxySettings
// Properties
Dim HTTPPort As integer
Dim HTTPProxy As string
Dim HTTPEnable As boolean
Dim FTPEnable As boolean
Dim FTPPort As integer
Dim FTPProxy As string
Dim FTPPassive As boolean
Dim HTTPSEnable As boolean
Dim HTTPSPort As integer
Dim HTTPSProxy As string
// Methods
Sub Constructor()
FindProxy
End Sub
Protected Sub FindProxy()
dim ca as CFArrayMBS
dim co as CFObjectMBS
dim i,c as integer
dim cs as CFStringMBS
dim s as SystemConfigurationMBS
dim p as SCPreferencesMBS
dim o as CFObjectMBS
dim cd as CFDictionaryMBS
dim currentset as CFStringMBS
dim cdl as CFDictionaryListMBS
s=new SystemConfigurationMBS
p=new SCPreferencesMBS
if p.Create(NewCFStringMBS("TestRB"),nil) then
// currentset is a CFString
// and can be used as key in the Network Services.
o=p.GetValue(s.kSCPrefCurrentSet)
currentset=CFStringMBS(o)
'CFShowMBS currentset
// Find the value for this path and get the dictionary
cd=p.GetPathValue(currentset)
'CFShowMBS cd
// get the network stuff in this dictionary
o=cd.Value(NewCFStringMBS("Network"))
if o isa CFDictionaryMBS then
cd=CFDictionaryMBS(o)
'CFShowMBS cd
// get the list of services
o=cd.Value(NewCFStringMBS("Service"))
if o isa CFDictionaryMBS then
cd=CFDictionaryMBS(o)
'CFShowMBS cd
// now we try each of them
cdl=cd.List
c=cdl.Count-1
for i=0 to c
FindProxyInNetworkService(cdl.Value(i),s,p)
next
end if
end if
end if
End Sub
Protected Sub FindProxyInNetworkService(dico as CFObjectMBS, s as SystemConfigurationMBS, p as SCPreferencesMBS)
dim cd as CFDictionaryMBS
dim cs as CFStringMBS
dim o as CFObjectMBS
if dico isa CFDictionaryMBS then
cd=CFDictionaryMBS(dico)
'CFShowMBS cd
// get the link path
o=cd.Value(s.kSCResvLink)
if o isa CFStringMBS then
cs=CFStringMBS(o)
// search the Network Services linked
cd=p.GetPathValue(cs)
'CFShowMBS cd
// get its proxy values
o=cd.Value(s.kSCEntNetProxies)
if o isa CFDictionaryMBS then
cd=CFDictionaryMBS(o)
CheckBoolean(cd, s.kSCPropNetProxiesHTTPEnable,HTTPEnable)
CheckInteger(cd, s.kSCPropNetProxiesHTTPPort, HTTPPort)
CheckString (cd, s.kSCPropNetProxiesHTTPProxy, HTTPProxy)
CheckBoolean(cd, s.kSCPropNetProxiesHTTPSEnable,HTTPSEnable)
CheckInteger(cd, s.kSCPropNetProxiesHTTPSPort, HTTPSPort)
CheckString (cd, s.kSCPropNetProxiesHTTPSProxy, HTTPSProxy)
CheckBoolean(cd, s.kSCPropNetProxiesFTPEnable, FTPEnable)
CheckBoolean(cd, s.kSCPropNetProxiesFTPPassive,FTPPassive)
CheckInteger(cd, s.kSCPropNetProxiesFTPPort, FTPPort)
CheckString (cd, s.kSCPropNetProxiesFTPProxy, FTPProxy)
end if
end if
end if
End Sub
Protected Sub CheckBoolean(cd as CFDIctionaryMBS, s as CFStringMBS, byref result as boolean)
dim o as CFObjectMBS
dim b as CFBooleanMBS
dim n as CFNumberMBS
// Check if a Boolean is there and return it's value
// false on not found.
o=cd.Value(s)
if o isa CFBooleanMBS then
b=CFBooleanMBS(o)
result=b.Value
end if
// for unknown reason it is a CFNumber for the proxy settings!?
if o isa CFNumberMBS then
n=CFNumberMBS(o)
result= n.integerValue=1
end if
End Sub
Protected Sub CheckString(cd as CFDIctionaryMBS, s as CFStringMBS, byref result as string)
dim o as CFObjectMBS
dim b as CFStringMBS
// Check if a String is there and return it's value
// false on not found.
o=cd.Value(s)
if o isa CFStringMBS then
b=CFStringMBS(o)
Result=b.Str
end if
End Sub
Protected Sub CheckInteger(cd as CFDIctionaryMBS, s as CFStringMBS, byref result as integer)
dim o as CFObjectMBS
dim b as CFNumberMBS
// Check if a Boolean is there and return it's value
// false on not found.
o=cd.Value(s)
if o isa CFNumberMBS then
b=CFNumberMBS(o)
result=b.integerValue
end if
End Sub
End Class