diff --git a/packages/IMAPClient-Core.package/ICEmail.class/methodProperties.json b/packages/IMAPClient-Core.package/ICEmail.class/methodProperties.json index 30b999ca..fa0e833a 100644 --- a/packages/IMAPClient-Core.package/ICEmail.class/methodProperties.json +++ b/packages/IMAPClient-Core.package/ICEmail.class/methodProperties.json @@ -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", diff --git a/packages/IMAPClient-Core.package/ICEndPoint.class/instance/loadEmailsFromMaildir.st b/packages/IMAPClient-Core.package/ICEndPoint.class/instance/loadEmailsFromMaildir.st index f12bc7eb..3eddfac2 100644 --- a/packages/IMAPClient-Core.package/ICEndPoint.class/instance/loadEmailsFromMaildir.st +++ b/packages/IMAPClient-Core.package/ICEndPoint.class/instance/loadEmailsFromMaildir.st @@ -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 \ No newline at end of file + [ :foldername | self loadEmailsInFolder: foldername andDirectory: server_directory ] \ No newline at end of file diff --git a/packages/IMAPClient-Core.package/ICEndPoint.class/instance/loadEmailsInFolder.andDirectory..st b/packages/IMAPClient-Core.package/ICEndPoint.class/instance/loadEmailsInFolder.andDirectory..st new file mode 100644 index 00000000..1f78b6df --- /dev/null +++ b/packages/IMAPClient-Core.package/ICEndPoint.class/instance/loadEmailsInFolder.andDirectory..st @@ -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 \ No newline at end of file diff --git a/packages/IMAPClient-Core.package/ICEndPoint.class/instance/maildirDirectory.st b/packages/IMAPClient-Core.package/ICEndPoint.class/instance/maildirDirectory.st new file mode 100644 index 00000000..e4aa5165 --- /dev/null +++ b/packages/IMAPClient-Core.package/ICEndPoint.class/instance/maildirDirectory.st @@ -0,0 +1,7 @@ +maildir +maildirDirectory + + (FileDirectory default directoryExists: 'Maildir') + ifFalse: [FileDirectory default createDirectory: 'MailDir']. + + ^ FileDirectory default directoryNamed: 'Maildir' \ No newline at end of file diff --git a/packages/IMAPClient-Core.package/ICEndPoint.class/instance/parseFetchHeaders..st b/packages/IMAPClient-Core.package/ICEndPoint.class/instance/parseFetchHeaders..st index bfbed77b..c5b9dbb9 100644 --- a/packages/IMAPClient-Core.package/ICEndPoint.class/instance/parseFetchHeaders..st +++ b/packages/IMAPClient-Core.package/ICEndPoint.class/instance/parseFetchHeaders..st @@ -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) ]. diff --git a/packages/IMAPClient-Core.package/ICEndPoint.class/methodProperties.json b/packages/IMAPClient-Core.package/ICEndPoint.class/methodProperties.json index 6d30a817..98f40687 100644 --- a/packages/IMAPClient-Core.package/ICEndPoint.class/methodProperties.json +++ b/packages/IMAPClient-Core.package/ICEndPoint.class/methodProperties.json @@ -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", @@ -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", diff --git a/packages/IMAPClient-Core.package/ICFileReadWriter.class/instance/createPathIfNotExisting..st b/packages/IMAPClient-Core.package/ICFileReadWriter.class/instance/createPathIfNotExisting..st new file mode 100644 index 00000000..0f973f8d --- /dev/null +++ b/packages/IMAPClient-Core.package/ICFileReadWriter.class/instance/createPathIfNotExisting..st @@ -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 \ No newline at end of file diff --git a/packages/IMAPClient-Core.package/ICFileReadWriter.class/instance/write.in.as..st b/packages/IMAPClient-Core.package/ICFileReadWriter.class/instance/write.in.as..st index ddaaf2c3..d6119a54 100644 --- a/packages/IMAPClient-Core.package/ICFileReadWriter.class/instance/write.in.as..st +++ b/packages/IMAPClient-Core.package/ICFileReadWriter.class/instance/write.in.as..st @@ -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 ] \ No newline at end of file diff --git a/packages/IMAPClient-Core.package/ICFileReadWriter.class/methodProperties.json b/packages/IMAPClient-Core.package/ICFileReadWriter.class/methodProperties.json index 97a74a27..6f4359d7 100644 --- a/packages/IMAPClient-Core.package/ICFileReadWriter.class/methodProperties.json +++ b/packages/IMAPClient-Core.package/ICFileReadWriter.class/methodProperties.json @@ -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" } } diff --git a/packages/IMAPClient-UI.package/ICFolderDialog.class/instance/chooseNumberOfMails.st b/packages/IMAPClient-UI.package/ICFolderDialog.class/instance/chooseNumberOfMails.st index 22c7ba1b..2795f038 100644 --- a/packages/IMAPClient-UI.package/ICFolderDialog.class/instance/chooseNumberOfMails.st +++ b/packages/IMAPClient-UI.package/ICFolderDialog.class/instance/chooseNumberOfMails.st @@ -1,4 +1,4 @@ -accessing +get emails chooseNumberOfMails | numberOfMails | diff --git a/packages/IMAPClient-UI.package/ICFolderDialog.class/instance/fetchHeaderProcess.st b/packages/IMAPClient-UI.package/ICFolderDialog.class/instance/fetchHeaderProcess.st index 37efbe99..29470e27 100644 --- a/packages/IMAPClient-UI.package/ICFolderDialog.class/instance/fetchHeaderProcess.st +++ b/packages/IMAPClient-UI.package/ICFolderDialog.class/instance/fetchHeaderProcess.st @@ -1,4 +1,4 @@ -accessing +get emails fetchHeaderProcess selectedFolder fetchHeadersFor: self numberOfHeadersToFetch.