'From etoys4.0 of 9 October 2008 [latest update: #2314] on 16 September 2009 at 4:39:47 pm'! "Change Set: LoginNetworkErrorGuard-yo Date: 16 September 2009 Author: Yoshiki Ohshima More kinds of errors may happen. Guard against them."! !DAVClient methodsFor: 'public protocol' stamp: 'yo 9/16/2009 16:34'! openUrl: aUrl "self new openUrl: 'http://localhost/some/path.html' asUrl" | newPort | newPort := aUrl port ifNil: [self defaultPortNumber]. (aUrl authority = self hostName and: [newPort = self port]) ifFalse: [self close]. self url: aUrl. self openOnHost: ((NetNameResolver addressForName: aUrl authority timeout: 20) ifNil: [NetworkError signal]) port: newPort! ! !FileList2 methodsFor: 'private' stamp: 'yo 9/16/2009 16:36'! directoryNamesFor: item "item may be file directory or server directory" | entries | entries _ [item directoryNames] on: ProtocolClientError, NetworkError do: [:ex | (ex isKindOf: NetworkError) ifTrue: [self inform: 'Network Error'] ifFalse: [self loginHit]. ^ #()]. dirSelectionBlock ifNotNil:[entries _ entries select: dirSelectionBlock]. ^entries! ! !FileList2 methodsFor: 'private' stamp: 'yo 9/16/2009 16:31'! loginHit | s failed ret | loginDialog ifNotNil: [^ false]. s := ServerDirectory servers at: 'My Squeakland' ifAbsent: [^ false]. failed := [Utilities loggedIn: false. loginDialog := nil. s user: nil]. ret := true. loginDialog := EtoyDAVLoginMorph new. loginDialog loginAndDo: [:n :p | s ifNotNil: [ s user: n. s password: p. [s copy createPersonalDirectory: n] on: ProtocolClientError, NetworkError do: [:ex | "either directory already exists or could not create. Here, it is just eaten as the following test will tell us whether it can be read."]. [s entries] on: ProtocolClientError, NetworkError do: [:ex | failed value. self inform: 'Login failed.'. ret := false]. ret ifTrue: [Utilities authorName: n. Utilities loggedIn: true]]. self updateLoginButtonAppearance. Utilities loggedIn ifTrue: [ self directory: directory. brevityState := #FileList. "self addPath: path." self changed: #fileList. self changed: #contents. self changed: #currentDirectorySelected. EToyProjectDetailsMorph updateTripletsFromWebSiteInBackground. ]. loginDialog := nil. true. ] ifCanceled: failed. ! ! !FileList2 methodsFor: 'private' stamp: 'yo 9/16/2009 16:37'! setSelectedDirectoryTo: aFileDirectoryWrapper currentDirectorySelected _ aFileDirectoryWrapper. [self directory: aFileDirectoryWrapper withoutListWrapper] on: ProtocolClientError, NetworkError do: [:ex | (ex isKindOf: NetworkError) ifTrue: [self inform: 'Network Error'] ifFalse: [self loginHit]. ^ self]. brevityState := #FileList. "self addPath: path." self changed: #fileList. self changed: #contents. self changed: #currentDirectorySelected.! ! "Postscript: Leave the line above, and replace the rest of this comment by a useful one. Executable statements should follow this comment, and should be separated by periods, with no exclamation points (!!). Be sure to put any further comments in double-quotes, like this one." ReleaseBuilderSqueakland new setupServerDirectoryForSqueakland. !