Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/iphone
diff options
context:
space:
mode:
authorKirill Zhdanovich <kzhdanovich@gmail.com>2013-01-25 19:26:02 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:49:25 +0300
commit536980d502f7fc02569c1e31c86d54296ea9985b (patch)
tree005d172200fcfb85ba2b74e540e20c6534031940 /iphone
parent641ad0061fcb7527a8241aa9ef45f88f8b120156 (diff)
[ios]sending kHz via mail
Diffstat (limited to 'iphone')
-rw-r--r--iphone/Maps/Bookmarks/BookmarksVC.mm37
1 files changed, 27 insertions, 10 deletions
diff --git a/iphone/Maps/Bookmarks/BookmarksVC.mm b/iphone/Maps/Bookmarks/BookmarksVC.mm
index 2b2dd8e120..755830fc70 100644
--- a/iphone/Maps/Bookmarks/BookmarksVC.mm
+++ b/iphone/Maps/Bookmarks/BookmarksVC.mm
@@ -9,6 +9,8 @@
#include "Framework.h"
#include "../../../geometry/distance_on_sphere.hpp"
+#include "../../../coding/zip_creator.hpp"
+#include "../../../coding/internal/file_data.hpp"
#define TEXTFIELD_TAG 999
@@ -232,17 +234,21 @@
BookmarkCategory const * cat = GetFramework().GetBmCategory(m_categoryIndex);
if (cat)
{
- MFMailComposeViewController * mailVC = [[[MFMailComposeViewController alloc] init] autorelease];
- mailVC.mailComposeDelegate = self;
-
- [mailVC setSubject:NSLocalizedString(@"share_bookmarks_email_subject", nil)];
-
NSString * filePath = [NSString stringWithUTF8String:cat->GetFileName().c_str()];
- NSData * myData = [[[NSData alloc] initWithContentsOfFile:filePath] autorelease];
- NSString * catName = [NSString stringWithUTF8String:cat->GetName().c_str()];
- [mailVC addAttachmentData:myData mimeType:@"application/vnd.google-earth.kml+xml" fileName:[NSString stringWithFormat:@"%@.kml", catName]];
- [mailVC setMessageBody:[NSString stringWithFormat:NSLocalizedString(@"share_bookmarks_email_body", nil), catName] isHTML:NO];
- [self presentModalViewController:mailVC animated:YES];
+ NSMutableString * catName = [NSMutableString stringWithUTF8String:cat->GetName().c_str()];
+ if (![catName length])
+ [catName setString:@"MapsWithMe"];
+ NSMutableString * kmzFile = [NSMutableString stringWithString:filePath];
+ [kmzFile replaceCharactersInRange:NSMakeRange([filePath length] - 1, 1) withString:@"z"];
+ if (createZipFromPathDeflatedAndDefaultCompression([filePath UTF8String], [kmzFile UTF8String]))
+ {
+ [self sendBookmarksWithExtension:@".kmz" andType:@"application/vnd.google-earth.kmz" andFile:kmzFile andCategory:catName];
+ }
+ else
+ {
+ [self sendBookmarksWithExtension:@".kml" andType:@"application/vnd.google-earth.kml+xml" andFile:filePath andCategory:catName];
+ }
+ my::DeleteFileX([kmzFile UTF8String]);
}
}
break;
@@ -409,4 +415,15 @@
return NO;
}
+- (void) sendBookmarksWithExtension:(NSString *) fileExtension andType:(NSString *)mimeType andFile:(NSString *)filePath andCategory:(NSString *)catName
+{
+ MFMailComposeViewController * mailVC = [[[MFMailComposeViewController alloc] init] autorelease];
+ mailVC.mailComposeDelegate = self;
+ [mailVC setSubject:NSLocalizedString(@"share_bookmarks_email_subject", nil)];
+ NSData * myData = [[[NSData alloc] initWithContentsOfFile:filePath] autorelease];
+ [mailVC addAttachmentData:myData mimeType:mimeType fileName:[NSString stringWithFormat:@"%@%@", catName, fileExtension]];
+ [mailVC setMessageBody:[NSString stringWithFormat:NSLocalizedString(@"share_bookmarks_email_body", nil), catName] isHTML:NO];
+ [self presentModalViewController:mailVC animated:YES];
+}
+
@end