Platforms to show: All Mac Windows Linux Cross-Platform

/MacBase/NSURLDownload/NSURLDownload test


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

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacBase/NSURLDownload/NSURLDownload test

This example is the version from Sun, 17th Mar 2012.

Project "NSURLDownload test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
Control iURL Inherits TextField
ControlInstance iURL Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StartButton Inherits PushButton
ControlInstance StartButton Inherits PushButton
EventHandler Sub Action() dim r as new NSURLRequestMBS(iURL.text) dim m as new MyNSURLDownloadMBS(r) m.list = Listbox1 downloaders.Append m End EventHandler
End Control
Property downloaders() As Variant
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyNSURLDownloadMBS Inherits NSURLDownloadMBS
EventHandler Function canAuthenticateAgainstProtectionSpace(protectionSpace as NSURLProtectionSpaceMBS) As boolean List.AddRow CurrentMethodName End EventHandler
EventHandler Sub decideDestinationWithSuggestedFilename(filename as string) List.AddRow CurrentMethodName dim file as FolderItem = SpecialFolder.Desktop.Child(filename) me.setDestination file, false End EventHandler
EventHandler Sub didBegin() List.AddRow CurrentMethodName End EventHandler
EventHandler Sub didCancelAuthenticationChallenge(challenge as NSURLAuthenticationChallengeMBS) List.AddRow CurrentMethodName End EventHandler
EventHandler Sub didCreateDestination(path as string, file as folderitem) List.AddRow CurrentMethodName List.AddRow "path: "+path End EventHandler
EventHandler Sub didFailWithError(error as NSErrorMBS) List.AddRow CurrentMethodName List.AddRow "Error: "+error.localizedDescription End EventHandler
EventHandler Sub didFinish() List.AddRow CurrentMethodName End EventHandler
EventHandler Sub didReceiveAuthenticationChallenge(challenge as NSURLAuthenticationChallengeMBS) List.AddRow CurrentMethodName End EventHandler
EventHandler Sub didReceiveDataOfLength(length as UInt64) List.AddRow CurrentMethodName List.AddRow "length: "+str(length) End EventHandler
EventHandler Sub didReceiveResponse(response as NSURLResponseMBS) List.AddRow CurrentMethodName List.AddRow "expectedContentLength: "+str(response.expectedContentLength) List.AddRow "suggestedFilename: "+response.suggestedFilename List.AddRow "MIMEType: "+response.MIMEType List.AddRow "statusCode: "+str(response.statusCode) End EventHandler
EventHandler Function shouldDecodeSourceDataOfMIMEType(encodingType as string) As boolean List.AddRow CurrentMethodName End EventHandler
EventHandler Function shouldUseCredentialStorage() As boolean List.AddRow CurrentMethodName End EventHandler
EventHandler Sub willResumeWithResponse(response as NSURLResponseMBS, startingByte as Int64) List.AddRow CurrentMethodName End EventHandler
EventHandler Function willSendRequest(request as NSURLRequestMBS, redirectResponse as NSURLResponseMBS) As NSURLRequestMBS List.AddRow CurrentMethodName List.AddRow "URL: "+request.URL // we don't modify it Return request End EventHandler
Property list As listbox
End Class
End Project

See also:

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


The biggest plugin in space...