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

New message rendering methods on IMAP #155

Merged
merged 79 commits into from
Jul 12, 2013

Conversation

paulyoung
Copy link
Contributor

I'm creating a pull request so it's easier to discuss and track changes as opposed to in the issues themselves.

As discussed in #112 and #111, this is a first pass at defining the interface. Currently only includes IMAP. RFC 822 to come.

I need to look further into the implementation and how the existing IMAPMessage::htmlRendering and HTMLRenderer::htmlForIMAPMessage methods work. It's unclear to me at this point if these new methods need to take additional parameters for the callbacks or if callbacks will be created within their implementation.

@paulyoung
Copy link
Contributor Author

For the asynchronous methods, what would the return type be?

@dinhvh
Copy link
Member

dinhvh commented Jun 27, 2013

It would be void but and a callback would be provided.

class IMAPMessageRenderingCallback {
fetchFinished(IMAPAsyncSession *session, IMAPMessage, ErrorCode error, String * result);
};

The asynchronous method has no return type (void) and will return immediately.
The callback will be called when the result is ready.

@paulyoung
Copy link
Contributor Author

Where would the callback class live? Is it OK to put it in MCIMAPAsyncSession or should it have it's own file? (I'm not sure of your conventions)

@dinhvh
Copy link
Member

dinhvh commented Jun 27, 2013

I just though about cancellation.
-> Think about fast scrolling in a UITableView.
The message content would load but would not be valid when the callback is called.

Maybe we should not be providing an Operation. That would make it less simple to use but would cover that case properly.

@paulyoung
Copy link
Contributor Author

Maybe we should not be providing an Operation.

What would the alternative be?

@dinhvh
Copy link
Member

dinhvh commented Jun 27, 2013

I meant "we should be providing an operation".
I though about making simpler but does not solve the cancel issue. We might have similar issue with objc.

Hoa V. Dinh

On Wednesday, June 26, 2013 at 10:15 PM, Paul Young wrote:

Maybe we should not be providing an Operation.

What would the alternative be?


Reply to this email directly or view it on GitHub (#155 (comment)).

@paulyoung
Copy link
Contributor Author

So mailcore::IMAPHTMLRenderingOperation for example?

@dinhvh
Copy link
Member

dinhvh commented Jun 27, 2013

IMAPMessageRenderingOperation. Create 4 methods but one operation class that change its behavior using flags.

@paulyoung
Copy link
Contributor Author

Nice.

* Revert commit 22b05c3.
* Revert commit 35d29ed.
* Revert commit db2671b.
* Revert commit af57027.
@paulyoung
Copy link
Contributor Author

What should the targets for the new file be? (For the build settings)

@dinhvh
Copy link
Member

dinhvh commented Jun 27, 2013

"static mailcore2 ios" and "static mailcore2 osx".

@paulyoung
Copy link
Contributor Author

Hopefully this is a start. I tried to understand how other operations work and what they're doing.

A nudge in the right direction from here would be good.

@dinhvh
Copy link
Member

dinhvh commented Jun 27, 2013

The start would be to implement the synchronous methods in IMAPSession.
By using It should be fairly easy by using:
class IMAPMessage {
virtual String * htmlRendering(String * folder,
HTMLRendererIMAPCallback * dataCallback,
HTMLRendererTemplateCallback * htmlCallback = NULL);
}

You have to create an object that implements HTMLRendererIMAPCallback and make the call to IMAPSession when in the callbacks.

* Added rendering enumerated type.
* Added result string.
* Removed data.
* Moved rendering methods from IMAP message rendering operation to
  IMAP session.
@paulyoung
Copy link
Contributor Author

By using It should be fairly easy by using:

class IMAPMessage {
virtual String * htmlRendering(String * folder,
HTMLRendererIMAPCallback * dataCallback,
HTMLRendererTemplateCallback * htmlCallback = NULL);
}

I don't follow exactly what you mean by this. I think you're saying make a call to this method, since it appears to already exist.

@dinhvh
Copy link
Member

dinhvh commented Jun 27, 2013

Yes, you should make a call to htmlRendering(). It perform all the work for you.

* Passing message ivar to methods in `main()`.
* Created a generic message renderer helper class.
* Renamed "msg" to "message" in session rendering methods.
@paulyoung
Copy link
Contributor Author

Would appreciate some guidance on this. I'm a little unclear on how to actually implement the callback methods. I'm guessing I'll need more than one of each in order to return just the body when necessary.

@dinhvh
Copy link
Member

dinhvh commented Jun 29, 2013

You should just override the templateformainheader method to return an empty string.

Hoa V. Dinh

On Friday, June 28, 2013 at 9:30 PM, Paul Young wrote:

Would appreciate some guidance on this. I'm a little unclear on how to actually implement the callback methods. I'm guessing I'll need more than one of each in order to return just the body when necessary.


Reply to this email directly or view it on GitHub (#155 (comment)).

@paulyoung
Copy link
Contributor Author

You should just override the templateformainheader method to return an empty string.

But I only want to return an empty string when only the body is requested. Not sure if you're suggesting having a separate (sub)class for rendering only the body, or using a single class and putting a conditional inside that method.

@dinhvh
Copy link
Member

dinhvh commented Jul 11, 2013

From master (https://github.com/MailCore/mailcore2), by using those instructions, I got a conflict in the xcodeproj file:

git checkout -b paulyoung-message-rendering-with-session master
git pull https://github.com/paulyoung/mailcore2.git message-rendering-with-session

@paulyoung
Copy link
Contributor Author

Do you have local changes on master that haven't been pushed?

@paulyoung
Copy link
Contributor Author

I don't mean unstaged changes, I mean commits. Is your local branch ahead of the remote?

@dinhvh
Copy link
Member

dinhvh commented Jul 11, 2013

I'm locally in sync with github.
Did you try the commands I described?

Hoà V. Dinh

On Thursday, July 11, 2013 at 10:11 AM, Paul Young wrote:

I don't mean unstaged changes, I mean commits. Is your local branch ahead of the remote?


Reply to this email directly or view it on GitHub (#155 (comment)).

@paulyoung
Copy link
Contributor Author

Yeah, it was a fast-forward merge with no conflicts.

@paulyoung
Copy link
Contributor Author

I'm getting the following error when trying to implement in the examples.

Receiver type 'MCOIMAPMessageRenderingOperation' for instance message is a forward declaration.

How can I make sure that the class is available?

@dinhvh
Copy link
Member

dinhvh commented Jul 12, 2013

Include it in MCOIMAP.h and in targets "static mailcore osx" and "static mailcore ios", add this file to "copy files" phase.

@paulyoung
Copy link
Contributor Author

I think this means I have too many calls "release" (I'm assuming MC_SAFE_RELEASE).

2013-07-11 21:41:56.968 [49285:4303] MCIMAPSession.cc:2293: had error : 0
2013-07-11 21:41:56.975 [49285:4303] MCObject.cc:63: release too much 0x7d73f30 mailcore::String
/Users/Paul/git/mailcore2/build-mac/../src/core/basetypes/MCObject.cc:64: assert 0

@dinhvh
Copy link
Member

dinhvh commented Jul 12, 2013

What's the crash stack trace?

@paulyoung
Copy link
Contributor Author

screen shot 2013-07-11 at 21 51 41

Let me know if you need more info.

}
else if (mRenderingType == IMAPMessageRenderingTypePlainTextBody) {
mResult = session()->session()->plainTextBodyRendering(mMessage, folder(), &error);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mResult is not retained. It might be the cause.

@paulyoung
Copy link
Contributor Author

This works end to end now. I'm happy to make any further changes/optimizations.

I'd need to understand how testing works to add those.

@dinhvh
Copy link
Member

dinhvh commented Jul 12, 2013

We can merge this first part for now.
Whenever you feel confident, remove the "NOT READY TO MERGE" at the top, then, we're good to go.

@paulyoung
Copy link
Contributor Author

I'm going to sync with master before we merge.

…-with-session

Conflicts:
	build-mac/mailcore2.xcodeproj/project.pbxproj
@paulyoung
Copy link
Contributor Author

Good to merge. 👍

dinhvh added a commit that referenced this pull request Jul 12, 2013
Simple message rendering methods on IMAP.
@dinhvh dinhvh merged commit df96333 into MailCore:master Jul 12, 2013
@paulyoung paulyoung deleted the message-rendering-with-session branch July 12, 2013 04:49
@pushkarsingh
Copy link
Contributor

  • (MCOIMAPMessageRenderingOperation *) plainTextRenderingOperationWithMessage:(MCOIMAPMessage *)message
    folder:(NSString *)folder;

How do we construct MCOIMAPMessage from the data we have saved? I might have only uid,subject, headers etc from the previous fetch of messages, I could not find a easy way to construct MCOIMAPMessage from that.

@dinhvh
Copy link
Member

dinhvh commented Jul 21, 2013

For 0.3, I plan to make MCOIMAPMessage serializable.
For now, if you just have the UID, you can fetch it using:

 MCOIMAPFetchMessagesOperation * op = [session fetchMessagesByUIDOperationWithFolder:@"INBOX"
                                                                         requestKind:MCOIMAPMessagesRequestKindHeaders | MCOIMAPMessagesRequestKindStructure
                                                                                uids:MCORangeMake(uid, uid)];
 [op start:^(NSError * error, NSArray * messages, MCOIndexSet * vanishedMessages) {
    // messages array will contain 0 or 1 MCOIMAPMessage.
 }];

proforov added a commit to proforov/mailcore2_deprecated that referenced this pull request Aug 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants