Skip to content

Commit

Permalink
Merge pull request #67 from HPI-SWA-Teaching/origin/develop2
Browse files Browse the repository at this point in the history
Origin/develop2
  • Loading branch information
Melvin Witte authored Aug 4, 2017
2 parents d140d96 + 988e04c commit a4a92e1
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"messageID:" : "ms 7/10/2016 13:59",
"minimalHeaderAsString" : "AR 7/28/2016 14:39",
"retrieveBody" : "dl 7/20/2017 12:44",
"saveInMaildir" : "dl 7/20/2017 12:20",
"saveInMaildir" : "MW 8/4/2017 22:08",
"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,29 +1,16 @@
login
loadEmailsFromMaildir

| directory_name maildir_directory default_directory server_directory existing_emails filereader folder email |
default_directory := FileDirectory default.
| directory_name server_directory filereader |

(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) ].
server_directory := maildir_directory directoryNamed: directory_name.
(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 |
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 |
email := (filereader get: filename in: (directory_name, FileDirectory slash, foldername)).
email folder: folder.
existing_emails add: email ]].

^ existing_emails
[ :foldername | self loadEmailsInFolder: foldername andDirectory: server_directory ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
login
loadEmailsInFolder: aFolder andDirectory: aDirectory

| existing_emails filereader folder email |

filereader := ICFileReadWriter new.
existing_emails := OrderedCollection new.
folder := ((ICFolder new) name: aFolder;
emails: existing_emails;
endpoint: self; yourself).
self rootFolder addFolder: folder.
((aDirectory directoryNamed: aFolder) fileNames do:
[ :filename |
email := (filereader get: filename in: (aDirectory, FileDirectory slash, aFolder)).
email folder: folder.
existing_emails add: email ]).
^ existing_emails
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
maildir
maildirDirectory

(FileDirectory default directoryExists: 'Maildir')
ifFalse: [FileDirectory default createDirectory: 'MailDir'].

^ FileDirectory default directoryNamed: 'Maildir'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
protocol parse
parseFetchHeaders: headerLines

| parser folder|
| parser folder |
parser := (ICFetchResponseParser new) endpoint: self.

headerLines do: [:x | x do: [:i | parser read: i]. parser read: (Character cr) ].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"currentFolderName:" : "js 7/9/2017 21:13",
"fetchAllHeadersOfSelectedFolder" : "js 6/4/2017 16:46",
"fetchBody:" : "AR 6/13/2016 16:23",
"fetchHeadersFrom:to:" : "dl 7/20/2017 12:24",
"fetchHeadersFrom:to:" : "MW 8/4/2017 21:36",
"fetchHeadersIn:" : "js 6/12/2017 10:58",
"fetchHeadersIn:for:" : "dl 6/23/2017 13:37",
"fetchHeadersOfSelectedFolderFor:" : "dl 6/23/2017 13:30",
"fetchNextResponse" : "jwe 7/28/2016 10:57",
"fetchNextResponse" : "MW 8/4/2017 22:05",
"fillBodyFor:" : "ms 7/10/2016 14:09",
"fillBodyFor:with:" : "AR 6/15/2016 11:30",
"folderFromResponse:" : "js 7/9/2017 18:31",
Expand All @@ -65,20 +65,22 @@
"lastResponse:" : "js 6/14/2016 10:41",
"listAllFolders" : "js 6/14/2016 12:31",
"listFoldersIn:using:" : "js 6/14/2016 10:41",
"loadEmailsFromMaildir" : "MW 8/4/2017 15:25",
"loadEmailsFromMaildir" : "MW 8/4/2017 20:56",
"loadEmailsInFolder:andDirectory:" : "MW 8/4/2017 20:54",
"loggedIn" : "js 5/15/2016 13:09",
"loggedIn:" : "js 5/15/2016 13:09",
"login" : "js 7/9/2017 23:45",
"login:using:" : "js 5/15/2016 16:33",
"loginUsing:" : "jwe 7/12/2016 10:19",
"logout" : "js 6/14/2016 16:59",
"maildirDirectory" : "MW 8/4/2017 20:59",
"parseFetchBody" : "jwe 7/28/2016 11:39",
"parseFetchHeader:withId:" : "dl 7/31/2017 18:21",
"parseFetchHeaderDate:for:" : "AR 6/27/2016 20:58",
"parseFetchHeaderReceiver:for:" : "AR 6/29/2016 21:48",
"parseFetchHeaderSender:for:" : "al 6/28/2016 11:10",
"parseFetchHeaderSubject:for:" : "MD 7/9/2017 22:57",
"parseFetchHeaders:" : "dl 8/1/2017 16:16",
"parseFetchHeaders:" : "MW 8/4/2017 22:08",
"parseHeaderChunk:for:" : "js 6/4/2017 17:39",
"parseListResponse" : "ms 7/9/2016 17:43",
"parseMethods" : "AR 6/27/2016 20:47",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
write file
createPathIfNotExisting: aPath

| current_directory |
current_directory := FileDirectory default.
(aPath subStrings: (FileDirectory slash)) reverseDo:
[ :path |
(current_directory directoryExists: path) ifFalse: [current_directory createDirectory: path].
current_directory := current_directory directoryNamed: path.].
^ current_directory
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
write file
write: anICEmail in: aFolder as: aString

| jsonFile renderedJson fileDirectory subDir |
jsonFile := JsonObject newFrom: {
| json_object rendered_json directory |
json_object := JsonObject newFrom: {
'header' -> (self createJsonHeaderFrom: anICEmail header).
'body' -> anICEmail body.
'messageID' -> anICEmail messageID.
'uid' -> anICEmail uid}.

fileDirectory := (FileDirectory startUp; default).
subDir := ((aFolder subStrings: (FileDirectory slash)) allButLast) joinSeparatedBy: (FileDirectory slash).

(fileDirectory directoryExists: subDir)
ifFalse: [ fileDirectory createDirectory: subDir ].
(fileDirectory directoryExists: aFolder)
ifFalse: [ fileDirectory createDirectory: aFolder ].

renderedJson := Json render: jsonFile.
FileStream forceNewFileNamed: (aFolder, FileDirectory slash, aString) do:
directory := self createPathIfNotExisting: aFolder.


rendered_json := Json render: json_object.
(FileStream forceNewFileNamed: (directory fullNameFor: aString)) do:
[ :stream | stream
nextPutAll: renderedJson;
nextPutAll: rendered_json;
flush;
close ]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"instance" : {
"createHeaderFrom:" : "dl 6/29/2017 20:54",
"createJsonHeaderFrom:" : "dl 7/20/2017 09:54",
"createPathIfNotExisting:" : "MW 8/4/2017 22:57",
"get:in:" : "js 7/16/2017 18:36",
"getRecipientsFrom:" : "dl 7/20/2017 09:54",
"write:in:as:" : "dl 7/20/2017 09:53" } }
"write:in:as:" : "MW 8/4/2017 22:54" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
get emails
chooseNumberOfMails

| numberOfMails |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
get emails
fetchHeaderProcess

selectedFolder fetchHeadersFor: self numberOfHeadersToFetch.
Expand Down

0 comments on commit a4a92e1

Please sign in to comment.