Git Product home page Git Product logo

Comments (10)

ocrickard avatar ocrickard commented on June 14, 2024

First off, let me say it's been fun to dive into this project! I'm doing a little investigation on which tools I want to use for a little project of mine, and thought I'd contribute a bit so I could cut my teeth on some of your code. I took a first pass at modifying your mac example to display messages on iOS for the example:

ocrickard@78ff578

from mailcore2.

dinhvh avatar dinhvh commented on June 14, 2024

That's great! Tried it. It's a good first pass.
There's an issue with email with images attachments. The images don't show. The Mac application will show them.

It looks like we cannot do like on the Mac where loading the images with cid: URL will trigger a webview callback.
We'll probably need to do some javascript magic to be able to load images.

from mailcore2.

ocrickard avatar ocrickard commented on June 14, 2024

Yeah, I just commented out a good portion of the jpeg code. I actually don't know much about email attachment formatting. Had a couple thoughts on it though, not sure if they're any use:

  1. Could we save the attachments to a local directory and then just change the reference for the UIWebView to point at a local file?
  2. What about encoding image attachments as base-64 data and displaying them as inline? Could use UIImageJPEGRepresentation to encode the data as a JPEG, then further encode to base-64... Reference: http://cluebucket.com/blog/2010/10/05/using-a-uiimage-directly-in-your-uiwebview/

from mailcore2.

ocrickard avatar ocrickard commented on June 14, 2024

Another crazy thought: What about specifying a NSURLCache in the Application Delegate? Messy, but can force the web view to go through an intermediary before trying to fetch the resources.

from mailcore2.

jwilling avatar jwilling commented on June 14, 2024

Yeah I've already apologized to Dinh and I might as well apologize to everyone. I agreed to making the iOS part of the demo and email renderer because I thought I'd have the time, but I haven't prioritized this project as much as I should have, and the little free time I have at college didn't give me enough time to work on this in addition to the both my classes and other personal projects. I've failed my part of the agreement and I'm very sorry.

Thanks for filling in for me, @ocrickard. After Tuesday I'll be completely free (finals are over), so if this needs more work done I'll definitely be able to do it.

from mailcore2.

dinhvh avatar dinhvh commented on June 14, 2024

Olivier, could you push a pull request for this change? That will be a first base code to implement it.

I don't get the idea about NSURLCache.

Ideally, we should not wait for the images to load before showing the content of the message.
We should be able to show the text of the message right away and update the view when the image are downloaded.
That could be done by parsing the HTML (NSXMLParser or libxml could help) to mark all the img tags and updating the HTML (through javascript) when the download is finished by replacing the src of the img tag with a local file reference.
base64 encoding might not be very efficient for that.

from mailcore2.

ocrickard avatar ocrickard commented on June 14, 2024

Just issued the pull request.

An NSURLCache can be used as the application's sharedURLCache on iOS, which then sits between all the pending NSURLRequests in the application and the larger web. The instance of NSURLCache has the opportunity to respond to the requests from the UIWebView, determine if they reference one of the x-mailcore-images, and if so, respond with a custom instance of NSCachedURLResponse which could read from a stream of input data from the MailCore system to construct the response when the web view attempts to load the data from the response. That's the short of it anyway. Here's a little background:

http://www.cocoawithlove.com/2010/09/substituting-local-data-for-remote.html

In my own application I'm going to be pulling out in-line images and displaying them as a list of native UIImageViews which can open up galleries. This isn't necessarily ideal, but I need control over how the images are displayed...

from mailcore2.

dinhvh avatar dinhvh commented on June 14, 2024

The trick could work for x-mailcore-images URLs but not for cid: URLs.
With IMAP, you can request download of attachments on demand and the attachment may not be here locally until you download it.
I'd like to use something that would work consistently for both.

from mailcore2.

ocrickard avatar ocrickard commented on June 14, 2024

OK, sounds good. I'll play with it in my free time over the next couple weeks and see what I can come up with.

from mailcore2.

ocrickard avatar ocrickard commented on June 14, 2024

Awesome.

from mailcore2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.