Skip to content
Snippets Groups Projects
Commit d151dfe0 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

added ability to clear result files + email model files

parent 37790676
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
2901F1211BB0086C004C328B /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 2901F1201BB0086C004C328B /* libz.tbd */; };
2907CCEC193DE6560011341A /* icon_onelab.png in Resources */ = {isa = PBXBuildFile; fileRef = 2907CCEB193DE6560011341A /* icon_onelab.png */; };
295056611D9AF3D200B9D9C4 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 295056601D9AF3D200B9D9C4 /* MessageUI.framework */; };
2988FF1E18E59558001435B6 /* libf2cblas.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2988FF1C18E59558001435B6 /* libf2cblas.a */; };
2988FF1F18E59558001435B6 /* libf2clapack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2988FF1D18E59558001435B6 /* libf2clapack.a */; };
29A4AC80193CE6DA0007B5A5 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 29A4AC7F193CE6DA0007B5A5 /* Images.xcassets */; };
......@@ -54,6 +55,7 @@
/* Begin PBXFileReference section */
2901F1201BB0086C004C328B /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-tbd-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
2907CCEB193DE6560011341A /* icon_onelab.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon_onelab.png; sourceTree = "<group>"; };
295056601D9AF3D200B9D9C4 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; };
2988FF1C18E59558001435B6 /* libf2cblas.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libf2cblas.a; path = ../../frameworks_ios/libf2cblas.a; sourceTree = "<group>"; };
2988FF1D18E59558001435B6 /* libf2clapack.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libf2clapack.a; path = ../../frameworks_ios/libf2clapack.a; sourceTree = "<group>"; };
29A4AC7F193CE6DA0007B5A5 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
......@@ -132,6 +134,7 @@
9C96083D1712C16300E1D4A0 /* Foundation.framework in Frameworks */,
9C96083F1712C16300E1D4A0 /* CoreGraphics.framework in Frameworks */,
9CE2773B17E197F50076E728 /* Social.framework in Frameworks */,
295056611D9AF3D200B9D9C4 /* MessageUI.framework in Frameworks */,
9CE08E10178AEB1600A83B4B /* GetDP.framework in Frameworks */,
9CE08E11178AEB1600A83B4B /* Gmsh.framework in Frameworks */,
9CE08E12178AEB1600A83B4B /* petsc.framework in Frameworks */,
......@@ -172,6 +175,7 @@
9C9608391712C16300E1D4A0 /* Frameworks */ = {
isa = PBXGroup;
children = (
295056601D9AF3D200B9D9C4 /* MessageUI.framework */,
2901F1201BB0086C004C328B /* libz.tbd */,
9C1B9911194F4E0400507EFD /* slepc.framework */,
2988FF1C18E59558001435B6 /* libf2cblas.a */,
......
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import "EAGLView.h"
@interface ModelListController : UITableViewController <NSXMLParserDelegate, UIActionSheetDelegate>
@interface ModelListController : UITableViewController <NSXMLParserDelegate, UIActionSheetDelegate, MFMailComposeViewControllerDelegate>
{
@private
NSMutableArray *models;
......
......@@ -129,9 +129,9 @@
if(indexPath == nil) return;
UIActionSheet *actionSheet;
if([[models objectAtIndex:indexPath.row] getUrl])
actionSheet = [[UIActionSheet alloc] initWithTitle:[[models objectAtIndex:indexPath.row] getName] delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: @"Open model", @"Remove model", @"View model website", nil];
actionSheet = [[UIActionSheet alloc] initWithTitle:[[models objectAtIndex:indexPath.row] getName] delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: @"Open", @"Remove", @"Clear results", @"Email model files", @"Visit model website", nil];
else
actionSheet = [[UIActionSheet alloc] initWithTitle:[[models objectAtIndex:indexPath.row] getName] delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: @"Open model", @"Remove model", nil];
actionSheet = [[UIActionSheet alloc] initWithTitle:[[models objectAtIndex:indexPath.row] getName] delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: @"Open", @"Remove", @"Clear results", @"Email model files", nil];
actionSheet.tag = indexPath.row;
[actionSheet showInView:self.view];
}
......@@ -139,9 +139,36 @@
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case 2:
case 4:
[[UIApplication sharedApplication] openURL:[[models objectAtIndex:actionSheet.tag] getUrl]];
break;
case 3:
{
NSString *modelFile = [[models objectAtIndex:actionSheet.tag] getFile];
NSString *modelPath = [modelFile stringByDeletingLastPathComponent];
NSArray *modelFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:modelPath error:NULL];
// TODO: would probably be better to email a zip archive? (this ignores subdirectories)
[self attachFilesToEmail:modelFiles filePath:modelPath];
}
break;
case 2:
{
NSString *modelFile = [[models objectAtIndex:actionSheet.tag] getFile];
NSString *modelPath = [modelFile stringByDeletingLastPathComponent];
NSArray *modelFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:modelPath error:NULL];
for (NSString *obj in modelFiles){
NSString *extension = [obj pathExtension];
if([extension isEqualToString:@"msh"] ||
[extension isEqualToString:@"pre"] ||
[extension isEqualToString:@"res"] ||
[extension isEqualToString:@"pos"]){
NSString *file = [[modelPath stringByAppendingString:@"/"] stringByAppendingString:obj];
NSLog(@"Removing file %@", file);
[[NSFileManager defaultManager] removeItemAtPath:file error:nil];
}
}
}
break;
case 1:
{
NSString *file = [[models objectAtIndex:actionSheet.tag] getFile];
......@@ -156,6 +183,66 @@
}
}
- (void)attachFilesToEmail:(NSArray*)files filePath:(NSString*)path
{
if([MFMailComposeViewController canSendMail] == NO) return;
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:@"My ONELAB model"];
// Add attachments
for (NSString *file in files){
NSString *extension = [file pathExtension];
NSString *filePath = [[path stringByAppendingString:@"/"] stringByAppendingString:file];
NSData *fileData = [NSData dataWithContentsOfFile:filePath];
if(fileData){
NSString *mimeType;
if ([extension isEqualToString:@"jpg"]) {
mimeType = @"image/jpeg";
}
else if([extension isEqualToString:@"png"]) {
mimeType = @"image/png";
}
else if([extension isEqualToString:@"doc"]) {
mimeType = @"application/msword";
}
else if([extension isEqualToString:@"ppt"]) {
mimeType = @"application/vnd.ms-powerpoint";
}
else if([extension isEqualToString:@"html"]) {
mimeType = @"text/html";
}
else if([extension isEqualToString:@"pdf"]) {
mimeType = @"application/pdf";
}
else{
mimeType = @"text/plain";
}
[mc addAttachmentData:fileData mimeType:@"" fileName:file];
}
}
// Present mail view controller on screen
[self presentViewController:mc animated:YES completion:NULL];
}
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result){
case MFMailComposeResultCancelled: NSLog(@"Mail cancelled"); break;
case MFMailComposeResultSaved: NSLog(@"Mail saved"); break;
case MFMailComposeResultSent: NSLog(@"Mail sent"); break;
case MFMailComposeResultFailed: NSLog(@"Mail sent failure: %@", [error localizedDescription]); break;
default: break;
}
// Close the Mail Interface
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (BOOL) parseInfosFile:(NSString *)file
{
NSData *xmlFile = [[NSFileManager defaultManager] contentsAtPath:file];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment