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

Origin/develop #68

Merged
merged 3 commits into from
Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
accessing
maildirFileName
^ 'Maildir' ,
FileDirectory slash,
self folder endpoint serverInfo host asString,
FileDirectory slash,
self folder path copyReplaceAll: '.' with: '_'
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
accessing
saveInMaildir

ICFileReadWriter new
^ ICFileReadWriter new
write: self
in: ('Maildir' , FileDirectory slash , self folder endpoint serverInfo host asString , FileDirectory slash , self folder path copyReplaceAll: '.' with: '_')
in: self maildirFileName
as: self uid
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
"header:" : "js 6/14/2016 10:39",
"headerAsString" : "ms 7/28/2016 15:12",
"initialize" : "AR 6/10/2016 11:10",
"maildirFileName" : "js 8/4/2017 23:20",
"messageID" : "ms 7/10/2016 13:59",
"messageID:" : "ms 7/10/2016 13:59",
"minimalHeaderAsString" : "AR 7/28/2016 14:39",
"retrieveBody" : "dl 7/20/2017 12:44",
"saveInMaildir" : "MW 8/4/2017 22:08",
"saveInMaildir" : "js 8/4/2017 23:20",
"subject" : "ms 6/28/2016 10:08",
"subject:" : "AR 6/13/2016 17:25",
"to" : "AR 6/13/2016 17:27",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
commands
fetchHeaderCommand: messageId

^ {self protocolCommandStart . 'FETCH' . messageId . '(body[HEADER.FIELDS (from to subject date)])'} joinSeparatedBy: self protocolBlank
^ {self protocolCommandStart.
'FETCH'.
messageId.
'(body[HEADER.FIELDS (from to subject date)])'}
joinSeparatedBy: self protocolBlank
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
connection
createEmailsWith: maildir_directory andName: directory_name
| server_directory filereader existing_emails email folder |
server_directory := maildir_directory directoryNamed: directory_name.
filereader := ICFileReadWriter new.
(server_directory directoryNames) do:
[ :foldername |
existing_emails := OrderedCollection new.
folder := ((ICFolder new) name: foldername;
emails: existing_emails;
endpoint: self; yourself).
self rootFolder addFolder: folder.
(server_directory directoryNamed: foldername) fileNames do:
[ :filename |

Transcript show: 'folderName:' , (directory_name, FileDirectory slash, foldername); cr.
email := (filereader get: filename in: ('Maildir', FileDirectory slash, directory_name, FileDirectory slash, foldername)).
email folder: folder.
existing_emails add: email ]].

^ existing_emails.
Original file line number Diff line number Diff line change
@@ -1,42 +1,13 @@
fetching
fetchHeadersFrom: aBeginId to: anEndId

| uidSize start end filename files files2 currentMails |

| start end |
self getCurrentUIDs.
uidSize := uids size.

aBeginId > uidSize
aBeginId > (self uids size)
ifTrue: [ ^ OrderedCollection new ].

anEndId = '*'
ifTrue: [ start := uids first ]
ifFalse: [ anEndId > uidSize
ifTrue: [start := uids first ]
ifFalse: [start := uids at: uidSize - anEndId + 1 ] ].

end := uids at: uidSize - aBeginId + 1.
filename := 'Maildir' , FileDirectory slash, (self serverInfo host replaceAll: '.' with: '_') , FileDirectory slash , self currentFolderName.
Transcript show: filename;
cr.
Transcript show: end;
cr.
files := (FileDirectory uri: filename)
fileNamesMatching: end.
files2 := (FileDirectory uri: filename)
fileNamesMatching: start.
Transcript show: files;
cr;
show: files2;
cr.
files size > 0 & (files2 size > 0)
ifTrue: [Transcript show: 'Do nothing. Newest Mailrange already loaded'.
currentMails := rootFolder
childFolderNamed: self currentFolderName
ifAbsent: [OrderedCollection new].
currentMails := currentMails emails.
^ currentMails].
^ self
sendCommand: (self class fetchHeadersWithUIDRange: start to: end);
fetchNextResponse;
parseFetchHeaders: self lastResponse
ifTrue: [ start := self uids first ]
ifFalse: [ anEndId > (self uids size)
ifTrue: [start := self uids first ]
ifFalse: [start := self uids at: (self uids size) - anEndId + 1 ] ].
end := self uids at: (self uids size) - aBeginId + 1.
^ self maildirDiffFetchHeadersFrom: start to: end

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ fetching
fetchHeadersIn: aFolder for: aNumber
| selectResponse isNotEmpty|
selectResponse := self select: aFolder path.

isNotEmpty := true.
(self lastResponse do:
[:line | (line findString: '0 EXISTS') > 0
ifTrue: [isNotEmpty := false]]).

isNotEmpty
ifTrue: [^(self fetchHeadersFrom: 1 to: aNumber) collect: [ :email | email folder: aFolder ]]
ifFalse: [Transcript show: (aFolder name), ' is an empty folder!'. ^OrderedCollection new.].
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
fetching
fetchNextResponse

| multiLineResponse |
multiLineResponse := OrderedCollection new.
self stream nextResponse.
Expand All @@ -10,4 +9,4 @@ fetchNextResponse
multiLineResponse add: self stream lastResponse.
self stream nextResponse ].

self lastResponse: multiLineResponse "if multiLineResponse is empty but no error was risen, all we got was a single line of response containing something like '. OK ...'"
self lastResponse: multiLineResponse
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
protocol parse
folderFromResponse: responseLine

| folderPath parent |
folderPath := self folderPathFrom: responseLine.
Transcript show: 'folderPath'; show: folderPath; cr.
parent := self rootFolder childFolderNamed: folderPath first
ifAbsent: [ ICFolder named: folderPath first in: self rootFolder with: self ].
Transcript show: 'parent'; show: parent; cr.

folderPath allButFirst do: [ :name | parent := parent childFolderNamed: name
ifAbsent: [ ICFolder named: name in: parent with: self ]].

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
fetching
getCurrentUIDs

self
sendCommand: self class getAllUIDs;
fetchNextResponse.

uids := ((self lastResponse at: 1) subStrings: ' ') asOrderedCollection
self uids: (((self lastResponse at: 1) subStrings: ' ') asOrderedCollection
removeFirst;
removeFirst;
yourself
yourself)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
accessing
hierarchyDelimiter: aSymbol

hierachyDelimiter := aSymbol
hierarchyDelimiter := aSymbol


Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
accessing
hierarchyDelimiter

^ hierachyDelimiter
^ hierarchyDelimiter

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
initialization
initialize

super initialize.
self
loggedIn: false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
message handling
listFoldersIn: root using: filter

self
checkConnected;
checkLoggedIn.

self stream sendCommand: ({ self class listCommand . self class asProtocolQuote: root . self class asProtocolQuote: filter } joinSeparatedBy: self class protocolBlank).

self stream sendCommand: (
{self class listCommand.
self class asProtocolQuote: root.
self class asProtocolQuote: filter}
joinSeparatedBy: self class protocolBlank).
^ self parseListResponse
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
login
loadEmailsFromMaildir

| directory_name server_directory filereader |

directory_name := (self serverInfo host) copyReplaceAll: '.' with: '_'.
(self maildirDirectory directoryExists: directory_name)
ifFalse: [
Transcript show: 'Maildir doesnt exist'.
^ (OrderedCollection new) ].

server_directory := self maildirDirectory directoryNamed: directory_name.

filereader := ICFileReadWriter new.
(server_directory directoryNames) do:
[ :foldername | self loadEmailsInFolder: foldername andDirectory: server_directory ]
loadEmailsFromMaildir
| directory_name maildir_directory default_directory |
default_directory := FileDirectory default.
(default_directory directoryExists: 'Maildir')
ifFalse: [default_directory createDirectory: 'Maildir'].
maildir_directory := default_directory directoryNamed: 'Maildir'.
directory_name := (self serverInfo host) copyReplaceAll: '.' with: '_'.
(maildir_directory directoryExists: directory_name)
ifFalse: [ Transcript show: 'Maildir doesnt exist'. ^ (OrderedCollection new) ].
^ self createEmailsWith: maildir_directory andName: directory_name.

This file was deleted.

23 changes: 11 additions & 12 deletions packages/IMAPClient-Core.package/ICEndPoint.class/instance/login.st
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
message handling
login

self checkConnected.
self authenticationInfo isValid ifFalse: [ ^ false ].
self
sendCommand: ({ self class loginCommand . self authenticationInfo username . self authenticationInfo password } joinSeparatedBy: self class protocolBlank);
fetchNextResponse;
loggedIn: self commandSucceeded;
checkLoggedIn.
self
loadEmailsFromMaildir.
^ true
self authenticationInfo isValid ifFalse: [ ^ false ].
self sendCommand: (
{ self class loginCommand.
self authenticationInfo username.
self authenticationInfo password }
joinSeparatedBy: self class protocolBlank);
fetchNextResponse;
loggedIn: self commandSucceeded;
checkLoggedIn.
self loadEmailsFromMaildir.
^ true
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
connection
maildirDiffFetchHeadersFrom: start to: end
| searchBegin searchEnd currentMails |
searchBegin := (FileDirectory uri: self maildirFileName)
fileNamesMatching: end.
searchEnd := (FileDirectory uri: self maildirFileName)
fileNamesMatching: start.

searchBegin size > 0 & (searchEnd size > 0)
ifTrue: [Transcript show: 'Do nothing. Newest Mailrange already loaded'.
currentMails := rootFolder
childFolderNamed: self currentFolderName
ifAbsent: [OrderedCollection new].
currentMails := currentMails emails.
^ currentMails].
^ self
sendCommand: (self class fetchHeadersWithUIDRange: start to: end);
fetchNextResponse;
parseFetchHeaders: self lastResponse

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
connection
maildirFileName
^ 'Maildir' ,
FileDirectory slash,
(self serverInfo host replaceAll: '.' with: '_'),
FileDirectory slash,
self currentFolderName.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
protocol parse
parseFetchHeader: headerLines withId: id

| email headerData headerChunk |

email := ICEmail new.
email messageID: id.
"(headerLines first subStrings: ' ') second."
headerData := headerLines subStrings: ((Character cr) asString) ." copyFrom: 2 to: headerLines size - 2.".
headerData := headerLines subStrings: ((Character cr) asString) .
headerChunk := OrderedCollection new.

headerData do: [ :line |
Expand Down
Loading