Skip to content

Commit

Permalink
Refactor/252 ICAccount info (#254)
Browse files Browse the repository at this point in the history
* Literally just merged ICAuthenticationInfo with ICServerInfo. Had to change constructors of course

* Reworked the endpoint login and connection system to work with the new AccountInfo Class. This caused a lot of change in the test code

* Fixed renaming issue

* Removed unused method

* Removed unused method

* Renamed ICAccountInfo contructor (legacy artifact)

* Review Requests on #254

* Recategorization and little code beautification

* name-attribut artifact replacement

* Made everything use anAccountINfo instead of Dictionary
Made everything use 'accountName' instead of 'name'

* Fixed "Account edit"

* Fixed Test Defaults
  • Loading branch information
timgarrels authored Jul 19, 2019
1 parent cd402f3 commit dbba65e
Show file tree
Hide file tree
Showing 162 changed files with 429 additions and 386 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
An ICAccountInfo is a dataobject holding information needed to connect to a server such as server address and user credentials. It also ensures basic IMAP datatype validity.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
initialAccountName

^ String empty
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
initialSsl

^ true
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
constants
initialPassword
invalidHost

^ String empty
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
constants
initialUsername
invalidPassword

^ String empty
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
constants
defaultPort
invalidPort

^ -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
invalidUsername

^ String empty
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
instance creation
newWith: aDataDictionary

^ self newWithAccountName: (aDataDictionary at: 'accountName')
host: (aDataDictionary at: 'address')
port: ((aDataDictionary at: 'port') asNumber)
username: (aDataDictionary at: 'username')
password: (aDataDictionary at: 'password')
ssl: (aDataDictionary at: 'ssl')
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
instance creation
newWithAccountName: aNameString host: aHostString port: aPortNumber username: aUsernameString password: aPasswordString ssl: aSSLBool

^ self new
accountName: aNameString;
host: aHostString;
port: aPortNumber;
username: aUsernameString;
password: aPasswordString;
ssl: aSSLBool
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
accountName: aString

accountName := aString
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
accountName

^ accountName ifNil: [accountName := self class initialAccountName]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
accessing
asDictionary

| dict |
dict := Dictionary new.
dict at: 'ssl' put: self ssl;
at: 'accountName' put: self accountName;
at: 'address' put: self host;
at: 'port' put: self port;
at: 'username' put: self username;
at: 'password' put: self password.

^ dict

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
validation
hasValidServerInfo

^ self host ~= self class invalidHost
and: [self port ~= self class invalidPort]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
validation
hasValidUserInfo

^ self username ~= self class invalidUsername
and: [self password ~= self class invalidPassword]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
host

^ host ifNil: [host := self class invalidHost]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
validation
isValid

^ self hasValidServerInfo and: self hasValidUserInfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
password

^ password ifNil: [password := self class invalidPassword]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
port

^ port ifNil: [port := self class invalidPort]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
printing
printOn: aStream

aStream nextPutAll: self accountName, ' ', self host, ' ', self port, ' ', self username, ' ', self password, ' ', self ssl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
ssl

^ ssl ifNil: [ssl := self class initialSsl]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
username

^ username ifNil: [username := self class invalidUsername].
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"class" : {
"initialAccountName" : "tg 7/10/2019 17:43",
"initialSsl" : "tg 7/10/2019 17:43",
"invalidHost" : "tg 7/10/2019 20:08",
"invalidPassword" : "tg 7/10/2019 20:10",
"invalidPort" : "tg 7/10/2019 20:09",
"invalidUsername" : "tg 7/10/2019 20:10",
"newWith:" : "tg 7/18/2019 23:08",
"newWithAccountName:host:port:username:password:ssl:" : "tg 7/18/2019 23:01" },
"instance" : {
"accountName" : "tg 7/10/2019 20:20",
"accountName:" : "tg 7/10/2019 17:35",
"asDictionary" : "tg 7/18/2019 23:07",
"canConvert:" : "tg 7/10/2019 17:18",
"hasValidServerInfo" : "tg 7/15/2019 12:08",
"hasValidUserInfo" : "tg 7/15/2019 12:08",
"host" : "tg 7/10/2019 20:06",
"host:" : "tg 7/10/2019 17:11",
"isValid" : "tg 7/15/2019 12:08",
"password" : "tg 7/15/2019 12:11",
"password:" : "tg 7/10/2019 17:18",
"passwordAsIMAPString" : "tg 7/10/2019 17:18",
"port" : "tg 7/10/2019 20:09",
"port:" : "tg 7/10/2019 17:11",
"printOn:" : "tg 7/10/2019 18:06",
"ssl" : "tg 7/10/2019 20:21",
"ssl:" : "tg 7/10/2019 17:34",
"username" : "tg 7/15/2019 12:11",
"username:" : "tg 7/10/2019 17:18",
"usernameAsIMAPString" : "tg 7/10/2019 17:18" } }
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
],
"classvars" : [
],
"commentStamp" : "tg 7/9/2019 14:40",
"commentStamp" : "tg 7/15/2019 12:14",
"instvars" : [
"accountName",
"host",
"port",
"username",
"password" ],
"name" : "ICAuthenticationInfo",
"password",
"ssl" ],
"name" : "ICAccountInfo",
"pools" : [
],
"super" : "Object",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ checkValidConfiguration: aDataDictionary
^ (aDataDictionary includesKey: 'username') and:
(aDataDictionary includesKey: 'port') and:
(aDataDictionary includesKey: 'address') and:
(aDataDictionary includesKey: 'name') and:
(aDataDictionary includesKey: 'accountName') and:
(aDataDictionary includesKey: 'ssl')
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
defaultStreamClass

^ SocketStream
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
constants
folderNameOfTrash

^ 'Trash'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
accountInfo: anICAccountInfo

accountInfo := anICAccountInfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
accountInfo

^ accountInfo ifNil: [accountInfo := ICAccountInfo new]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
asAccountInfoDictionary

^ self accountInfo asDictionary

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error handling
checkConnected

(self fatalErrorOccured)
ifTrue: [^ false].

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
connection
error handling
checkForParameterError

(self fatalErrorOccured)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ checkLoggedIn
(self fatalErrorOccured)
ifTrue: [^ false].

self isLoggedIn ifFalse: [
self loggedIn ifFalse: [
self fatalErrorOccured: true.
^ false].

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
login
connection
close

self stream close.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
connection
connect

self connectWith: self class defaultStreamClass
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
connection
connectAndLoginWith: anICAccountInfo

self accountInfo: anICAccountInfo.

[self
connect;
login]
valueWithin: 2 seconds
onTimeout: [
(self fatalErrorOccured)
ifFalse: [
UIManager default inform: 'Connection could not be established'.
self fatalErrorOccured: true]]

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit dbba65e

Please sign in to comment.