summaryrefslogtreecommitdiff
path: root/CyteKit/WebViewController.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-03-04 15:56:31 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-07 02:41:36 -0800
commit2b2a4e33d2693923b46834ca3072b69d7348f790 (patch)
tree0abeccedc137e511e7b3870fe712154e5142c14a /CyteKit/WebViewController.mm
parent8ea7249140d2c49f8008e60ef8dd287d23d29124 (diff)
When possible, use MFMailComposeViewController for _openMailToURL:.
Diffstat (limited to 'CyteKit/WebViewController.mm')
-rw-r--r--CyteKit/WebViewController.mm24
1 files changed, 23 insertions, 1 deletions
diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm
index e6f7e45..78da1c5 100644
--- a/CyteKit/WebViewController.mm
+++ b/CyteKit/WebViewController.mm
@@ -1,6 +1,8 @@
#include "CyteKit/UCPlatform.h"
+#include "CyteKit/WebViewController.h"
+
+#include "CyteKit/MFMailComposeViewController-MailToURL.h"
-#include <UIKit/UIKit.h>
#include "iPhonePrivate.h"
#include "CyteKit/Localize.h"
@@ -31,6 +33,9 @@ extern NSString * const kCAFilterNearest;
#define lprintf(args...) fprintf(stderr, args)
+// XXX: centralize these special class things to some file or mechanism?
+static Class $MFMailComposeViewController;
+
template <typename Type_>
static inline void CYRelease(Type_ &value) {
if (value != nil) {
@@ -126,6 +131,9 @@ float CYScrollViewDecelerationRateNormal;
+ (void) _initialize {
[WebPreferences _setInitialDefaultTextEncodingToSystemEncoding];
+ dlopen("/System/Library/Frameworks/MessageUI.framework/MessageUI", RTLD_GLOBAL | RTLD_LAZY);
+ $MFMailComposeViewController = objc_getClass("MFMailComposeViewController");
+
if (float *_UIScrollViewDecelerationRateNormal = reinterpret_cast<float *>(dlsym(RTLD_DEFAULT, "UIScrollViewDecelerationRateNormal")))
CYScrollViewDecelerationRateNormal = *_UIScrollViewDecelerationRateNormal;
else // XXX: this actually might be fast on some older systems: we should look into this
@@ -285,7 +293,21 @@ float CYScrollViewDecelerationRateNormal;
[self _setViewportWidth];
}
+- (void) mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
+ [self dismissModalViewControllerAnimated:YES];
+}
+
- (void) _openMailToURL:(NSURL *)url {
+ if ($MFMailComposeViewController != nil && [$MFMailComposeViewController canSendMail]) {
+ MFMailComposeViewController *controller([[[$MFMailComposeViewController alloc] init] autorelease]);
+ [controller setMailComposeDelegate:self];
+
+ [controller setMailToURL:url];
+
+ [self presentModalViewController:controller animated:YES];
+ return;
+ }
+
UIApplication *app([UIApplication sharedApplication]);
if ([app respondsToSelector:@selector(openURL:asPanel:)])
[app openURL:url asPanel:YES];