Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/252 ICAccount info #254

Merged
merged 12 commits into from
Jul 19, 2019
Empty file.
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: 'name')
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: name host: host port: port username: username password: password ssl: ssl
martintaraz marked this conversation as resolved.
Show resolved Hide resolved

^ self new
accountName: name;
host: host;
port: port;
username: username;
password: password;
ssl: ssl
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,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 host ~= self class invalidHost and: [self port ~= self class invalidPort]) and: (self username ~= self class invalidUsername and: [self password ~= self class invalidPassword])
martintaraz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
password

^ password ifNil: [self password: self class invalidPassword]
martintaraz marked this conversation as resolved.
Show resolved Hide resolved
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: [self username: self class invalidUsername].
martintaraz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"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/11/2019 10:07",
"newWithAccountName:host:port:username:password:ssl:" : "tg 7/10/2019 17:49" },
"instance" : {
"accountName" : "tg 7/10/2019 20:20",
"accountName:" : "tg 7/10/2019 17:35",
"canConvert:" : "tg 7/10/2019 17:18",
"host" : "tg 7/10/2019 20:06",
"host:" : "tg 7/10/2019 17:11",
"isValid" : "tg 7/10/2019 20:07",
"password" : "tg 7/10/2019 20: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/10/2019 20: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" : "",
"instvars" : [
"accountName",
"host",
"port",
"username",
"password" ],
"name" : "ICAuthenticationInfo",
"password",
"ssl" ],
"name" : "ICAccountInfo",
martintaraz marked this conversation as resolved.
Show resolved Hide resolved
"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
@@ -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
Expand Up @@ -7,11 +7,11 @@ asDictionary

dataDictionary := Dictionary new.

dataDictionary at: 'ssl' put: (self ssl).
dataDictionary at: 'name:' put: (self name).
dataDictionary at: 'address' put: (self serverInfo host).
dataDictionary at: 'port' put: (self serverInfo port).
dataDictionary at: 'username' put: (self authenticationInfo username).
dataDictionary at: 'password' put: (self authenticationInfo password).
dataDictionary at: 'ssl' put: (self accountInfo ssl).
martintaraz marked this conversation as resolved.
Show resolved Hide resolved
dataDictionary at: 'name:' put: (self accountInfo name).
dataDictionary at: 'address' put: (self accountInfo host).
dataDictionary at: 'port' put: (self accountInfo port).
dataDictionary at: 'username' put: (self accountInfo username).
dataDictionary at: 'password' put: (self accountInfo password).

^ dataDictionary

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
@@ -0,0 +1,4 @@
connection
connect

self connectWith: SocketStream

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
connection
connectWith: aStreamClass

self accountInfo isValid ifFalse: [^ Error signal: self class errorInvalidConnectionConfiguration].

[self stream
ssl: self useSSL;
martintaraz marked this conversation as resolved.
Show resolved Hide resolved
connectTo: self accountInfo host on: self accountInfo port with: aStreamClass;
nextResponse "skip server greetings"]
on: Error
do: [self fatalErrorOccured: true]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
accessing
fromAccountInfo: anICAccountInfo
martintaraz marked this conversation as resolved.
Show resolved Hide resolved

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.

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ login
UIManager default inform: 'Cant connect to the server'.
^ false].

(self authenticationInfo isValid) ifFalse: [
(self accountInfo isValid) ifFalse: [
self fatalErrorOccured: true.
^ false].

self sendCommand: (
{ self class loginCommand.
self authenticationInfo usernameAsIMAPString.
self authenticationInfo passwordAsIMAPString }
self accountInfo usernameAsIMAPString.
self accountInfo passwordAsIMAPString }
joinSeparatedBy: self class protocolBlank);
fetchNextResponse;
loggedIn: self commandSucceeded.
Expand Down

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,4 +4,4 @@ rootFolderName
"this accounts are saved with a hashed name, because we could otherwise get problems with
special tokens like @ or spaces in server-host or username"

^ ICHelper hashNameForAccount: (self serverInfo host) and: (self authenticationInfo username)
^ ICHelper hashNameForAccount: (self accountInfo host) and: (self accountInfo username)

This file was deleted.

Loading