Platforms to show: All Mac Windows Linux Cross-Platform

/MacCF/MacOSXProxySettings


Required plugins for this example: MBS MacCF Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/MacOSXProxySettings

This example is the version from Wed, 15th Feb 2022.

Project "MacOSXProxySettings.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu5 = ""
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu4 = ""
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = ""
End MenuBar
Class App Inherits Application
EventHandler 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 if m.HTTPSEnable then MsgBox "HTTP Proxy: "+m.HTTPSProxy+":"+str(m.HTTPSPort) else MsgBox "No HTTP Proxy." end if quit End EventHandler
End Class
Class MacOSXProxySettings
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 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
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
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 If cd <> Nil Then // get the network stuff in this dictionary o=cd.Value(NewCFStringMBS("Network")) if o isa CFDictionaryMBS then cd=CFDictionaryMBS(o) 'CFShowMBS cd If cd <> Nil Then // 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 If cd <> Nil Then 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 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 If cd <> Nil Then // 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 If cd <> Nil Then // get its proxy values o=cd.Value(s.kSCEntNetProxies) if o isa CFDictionaryMBS then cd=CFDictionaryMBS(o) If cd <> Nil Then 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 if end if end if End Sub
Property FTPEnable As boolean
Property FTPPassive As boolean
Property FTPPort As integer
Property FTPProxy As string
Property HTTPEnable As boolean
Property HTTPPort As integer
Property HTTPProxy As string
Property HTTPSEnable As boolean
Property HTTPSPort As integer
Property HTTPSProxy As string
End Class
End Project

The items on this page are in the following plugins: MBS MacCF Plugin.


The biggest plugin in space...