├── .DS_Store ├── README.md ├── TabBarController.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── TabBarController.xccheckout │ └── xcuserdata │ │ ├── gtcc.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── luochuanlu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── gtcc.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── TabBarController.xcscheme │ │ └── xcschememanagement.plist │ └── luochuanlu.xcuserdatad │ └── xcschemes │ ├── TabBarController.xcscheme │ └── xcschememanagement.plist ├── TabBarController ├── .DS_Store ├── AVPlayerViewController.h ├── AVPlayerViewController.m ├── AdjustSpeedView.h ├── AdjustSpeedView.m ├── BIDAppDelegate.h ├── BIDAppDelegate.m ├── BIDSecondViewController.h ├── BIDSecondViewController.m ├── Base.lproj │ ├── Main_iPad.storyboard │ └── Main_iPhone.storyboard ├── Classes │ ├── AsyncSocket.h │ ├── AsyncSocket.m │ ├── DDData.h │ ├── DDData.m │ ├── DDNumber.h │ ├── DDNumber.m │ ├── DDRange.h │ ├── DDRange.m │ ├── FtpConnection.h │ ├── FtpConnection.m │ ├── FtpDataConnection.h │ ├── FtpDataConnection.m │ ├── FtpDefines.h │ ├── FtpServer.h │ ├── FtpServer.m │ ├── HTTPAuthenticationRequest.h │ ├── HTTPAuthenticationRequest.m │ ├── HTTPConnection.h │ ├── HTTPConnection.m │ ├── HTTPResponse.h │ ├── HTTPResponse.m │ ├── HTTPServer.h │ ├── HTTPServer.m │ ├── MyHTTPConnection.h │ ├── MyHTTPConnection.m │ ├── NetworkController.h │ ├── NetworkController.m │ ├── iPhoneHTTPServerAppDelegate.h │ ├── iPhoneHTTPServerAppDelegate.m │ ├── list.h │ ├── list.m │ ├── localhostAddresses.h │ └── localhostAddresses.m ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── LaunchImage.launchimage │ │ └── Contents.json │ ├── second.imageset │ │ ├── Contents.json │ │ ├── second.png │ │ └── second@2x.png │ └── video.imageset │ │ ├── Contents.json │ │ ├── first.png │ │ └── first@2x.png ├── MovieInfosViewController.h ├── MovieInfosViewController.mm ├── TabBarController-Info.plist ├── TabBarController-Prefix.pch ├── UIAlertView+Blocks.h ├── UIAlertView+Blocks.m ├── VideoEffectView.h ├── VideoEffectView.m ├── avplayer.bundle │ ├── audioTrackIcon.png │ ├── audioTrackIcon@2x.png │ ├── hudbackground_ipad.png │ ├── hudbackground_ipad@2x.png │ ├── hudbackground_iphone.png │ ├── hudbackground_iphone@2x.png │ ├── music_icon.png │ ├── music_icon@2x.png │ ├── playback_ff.png │ ├── playback_ff@2x.png │ ├── playback_pause.png │ ├── playback_pause@2x.png │ ├── playback_play.png │ ├── playback_play@2x.png │ ├── playback_prev.png │ ├── playback_prev@2x.png │ ├── speedIcon.png │ ├── speedIcon@2x.png │ ├── subtitleIcon.png │ ├── subtitleIcon@2x.png │ ├── videoEffectsIcon.png │ ├── videoEffectsIcon@2x.png │ ├── zoomin.png │ ├── zoomin@2x.png │ ├── zoomout.png │ └── zoomout@2x.png ├── en.lproj │ └── InfoPlist.strings └── main.m ├── TabBarControllerTests ├── TabBarControllerTests-Info.plist ├── TabBarControllerTests.m └── en.lproj │ └── InfoPlist.strings ├── VideoListTableViewController.h ├── VideoListTableViewController.m ├── ftp_commands.plist └── trail.AVPTFramework.framework ├── Headers ├── Resources ├── Versions ├── A │ ├── Headers │ │ ├── AVParser.h │ │ └── AVPlayerController.h │ ├── Resources │ │ ├── Info.plist │ │ └── en.lproj │ │ │ └── InfoPlist.strings │ └── trail.AVPTFramework └── Current └── trail.AVPTFramework /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WifiTransfer 2 | ============ 3 | 4 | WifiTransfer can transfer file by Wifi without cable. 5 | -------------------------------------------------------------------------------- /TabBarController.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TabBarController.xcodeproj/project.xcworkspace/xcshareddata/TabBarController.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | D06A270E-2353-4B41-AAC7-810C853EBB1E 9 | IDESourceControlProjectName 10 | TabBarController 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 6538607DEEF80FFA68FBF22FDA4BC4AE62278E1F 14 | https://github.com/nekaso/WifiTransfer.git 15 | 16 | IDESourceControlProjectPath 17 | TabBarController.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 6538607DEEF80FFA68FBF22FDA4BC4AE62278E1F 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/nekaso/WifiTransfer.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 6538607DEEF80FFA68FBF22FDA4BC4AE62278E1F 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 6538607DEEF80FFA68FBF22FDA4BC4AE62278E1F 36 | IDESourceControlWCCName 37 | WifiTransfer 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /TabBarController.xcodeproj/project.xcworkspace/xcuserdata/gtcc.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController.xcodeproj/project.xcworkspace/xcuserdata/gtcc.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /TabBarController.xcodeproj/project.xcworkspace/xcuserdata/luochuanlu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController.xcodeproj/project.xcworkspace/xcuserdata/luochuanlu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /TabBarController.xcodeproj/xcuserdata/gtcc.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 56 | 68 | 69 | 70 | 72 | 84 | 85 | 86 | 88 | 100 | 101 | 102 | 104 | 116 | 117 | 118 | 120 | 132 | 133 | 134 | 136 | 148 | 149 | 150 | 152 | 164 | 165 | 166 | 168 | 180 | 181 | 182 | 184 | 196 | 197 | 198 | 200 | 212 | 213 | 214 | 216 | 228 | 229 | 230 | 232 | 244 | 245 | 246 | 248 | 260 | 261 | 262 | 263 | 264 | -------------------------------------------------------------------------------- /TabBarController.xcodeproj/xcuserdata/gtcc.xcuserdatad/xcschemes/TabBarController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /TabBarController.xcodeproj/xcuserdata/gtcc.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | TabBarController.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 6D99E15418B4CB11003D187A 16 | 17 | primary 18 | 19 | 20 | 6D99E17B18B4CB11003D187A 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /TabBarController.xcodeproj/xcuserdata/luochuanlu.xcuserdatad/xcschemes/TabBarController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 75 | 76 | 77 | 78 | 84 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /TabBarController.xcodeproj/xcuserdata/luochuanlu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | TabBarController.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 6D99E15418B4CB11003D187A 16 | 17 | primary 18 | 19 | 20 | 6D99E17B18B4CB11003D187A 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /TabBarController/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/.DS_Store -------------------------------------------------------------------------------- /TabBarController/AVPlayerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVPlayerViewController.h 3 | // AVPlayer 4 | // 5 | // Created by apple on 13-5-22. 6 | // Copyright (c) 2013年 iMoreApp Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface AVPlayerViewController : UIViewController 13 | 14 | // audio or video file path (local or network file path) 15 | @property (nonatomic, strong) NSString *mediaPath; 16 | 17 | // did load video successfully callback. 18 | @property (nonatomic, copy) void (^didLoadVideo)(AVPlayerController *player); 19 | 20 | // get start playback time (>= 0 and <= media duration). 21 | // if the property is nil, player will start playback from begining. 22 | // the callback returns a float number value or nil. 23 | @property (nonatomic, copy) NSNumber* (^getStartTime)(AVPlayerController *player, NSString *path); 24 | 25 | // required saving progress info, you can save progress here. 26 | @property (nonatomic, copy) void (^saveProgress)(AVPlayerController *player); 27 | 28 | // on video playback did finish. 29 | @property (nonatomic, copy) void (^didFinishPlayback)(AVPlayerController *player); 30 | 31 | // on video player controller will be dismissed. 32 | @property (nonatomic, copy) void (^willDismiss)(void); 33 | 34 | // Start playback at special time position 35 | - (void)startPlaybackAt:(NSNumber *)startTimePosition; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /TabBarController/AdjustSpeedView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AdjustSpeedView.h 3 | // AVPlayerDemo 4 | // 5 | // Created by apple on 3/4/14. 6 | // Copyright (c) 2014 apple. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AdjustSpeedView : UIView 12 | @property (weak, nonatomic) IBOutlet UILabel *speedLabel; 13 | @property (weak, nonatomic) IBOutlet UIStepper *speedStepper; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TabBarController/AdjustSpeedView.m: -------------------------------------------------------------------------------- 1 | // 2 | // AdjustSpeedView.m 3 | // AVPlayerDemo 4 | // 5 | // Created by apple on 3/4/14. 6 | // Copyright (c) 2014 apple. All rights reserved. 7 | // 8 | 9 | #import "AdjustSpeedView.h" 10 | 11 | @implementation AdjustSpeedView 12 | 13 | - (id)initWithFrame:(CGRect)frame 14 | { 15 | self = [super initWithFrame:frame]; 16 | if (self) { 17 | // Initialization code 18 | } 19 | return self; 20 | } 21 | 22 | /* 23 | // Only override drawRect: if you perform custom drawing. 24 | // An empty implementation adversely affects performance during animation. 25 | - (void)drawRect:(CGRect)rect 26 | { 27 | // Drawing code 28 | } 29 | */ 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /TabBarController/BIDAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // BIDAppDelegate.h 3 | // TabBarController 4 | // 5 | // Created by gtcc on 2/19/14. 6 | // Copyright (c) 2014 xc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BIDAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TabBarController/BIDAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // BIDAppDelegate.m 3 | // TabBarController 4 | // 5 | // Created by gtcc on 2/19/14. 6 | // Copyright (c) 2014 xc. All rights reserved. 7 | // 8 | 9 | #import "BIDAppDelegate.h" 10 | 11 | @implementation BIDAppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /TabBarController/BIDSecondViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BIDSecondViewController.h 3 | // TabBarController 4 | // 5 | // Created by gtcc on 2/19/14. 6 | // Copyright (c) 2014 xc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NetworkController.h" 11 | 12 | @class FtpServer; 13 | @class HTTPServer; 14 | 15 | @interface BIDSecondViewController : UIViewController { 16 | FtpServer *theServer; 17 | HTTPServer *theHTTPServer; 18 | NSDictionary *addresses; 19 | NSString *baseDir; 20 | } 21 | 22 | @property (nonatomic, retain) FtpServer *theServer; 23 | @property (nonatomic, copy) NSString *baseDir; 24 | @property (retain, nonatomic) IBOutlet UITextView *ServerInfoView; 25 | @property (retain, nonatomic) IBOutlet UILabel *ServerTitleLabel; 26 | @property (retain, nonatomic) IBOutlet UILabel *ftpLabel; 27 | @property (retain, nonatomic) IBOutlet UIButton *btnControlServer; 28 | 29 | @property (nonatomic, retain) HTTPServer *theHTTPServer; 30 | 31 | @property (retain, nonatomic) IBOutlet UIButton *btnControlHTTPServer; 32 | @property (retain, nonatomic) IBOutlet UILabel *httpLabel; 33 | 34 | @property (retain, nonatomic) IBOutlet UILabel *httpURL; 35 | 36 | -(void)didReceiveFileListChanged; 37 | - (void)stopFtpServer; 38 | - (void)startHTTPServer; 39 | - (void)stopHTTPServer; 40 | 41 | @end -------------------------------------------------------------------------------- /TabBarController/BIDSecondViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BIDSecondViewController.m 3 | // TabBarController 4 | // 5 | // Created by gtcc on 2/19/14. 6 | // Copyright (c) 2014 xc. All rights reserved. 7 | // 8 | 9 | #import "BIDSecondViewController.h" 10 | #import "FtpServer.h" 11 | #import "HTTPServer.h" 12 | #import "MyHTTPConnection.h" 13 | #import "localhostAddresses.h" 14 | 15 | 16 | #define FTP_PORT 20000 17 | @interface BIDSecondViewController () 18 | @property BOOL isServerRunning; 19 | @end 20 | 21 | @implementation BIDSecondViewController 22 | @synthesize theServer, theHTTPServer, baseDir,ServerInfoView, ServerTitleLabel,btnControlServer,isServerRunning; 23 | 24 | - (void)viewDidLoad 25 | { 26 | [super viewDidLoad]; 27 | // Do any additional setup after loading the view, typically from a nib. 28 | 29 | [self startServer]; 30 | } 31 | 32 | - (void)didReceiveMemoryWarning 33 | { 34 | [super didReceiveMemoryWarning]; 35 | // Dispose of any resources that can be recreated. 36 | } 37 | 38 | - (void) startServer 39 | { 40 | NSString *localIPAddress = [ NetworkController localWifiIPAddress ]; 41 | 42 | NSArray *docFolders = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES ); 43 | self.baseDir = [docFolders lastObject]; 44 | 45 | 46 | FtpServer *aServer = [[ FtpServer alloc ] initWithPort:20000 withDir:baseDir notifyObject:self ]; 47 | self.theServer = aServer; 48 | //[aServer release]; 49 | 50 | 51 | theHTTPServer = [HTTPServer new]; 52 | [theHTTPServer setType:@"_http._tcp."]; 53 | [theHTTPServer setConnectionClass:[MyHTTPConnection class]]; 54 | [theHTTPServer setDocumentRoot:[NSURL fileURLWithPath:self.baseDir]]; 55 | 56 | NSError *error; 57 | if(![theHTTPServer start:&error]) 58 | { 59 | NSLog(@"Error starting HTTP Server: %@", error); 60 | } 61 | 62 | self.ServerTitleLabel.text = [NSString stringWithFormat:@"%@ %@ %@", 63 | @"ftp://",localIPAddress, @": 20000"]; 64 | 65 | UInt16 theHTTPServerPort = [theHTTPServer port]; 66 | 67 | self.httpURL.text =[NSString stringWithFormat:@"%@ %@ %@ %d", 68 | @"http://",localIPAddress, @":", theHTTPServerPort]; 69 | 70 | self.ServerInfoView.text = @"The FTP/HTTP Server have been enabled, please use FTP client software or Web Browser to transfer any files to this device.\nPress the \"Stop Server\" button once all data transfers have been completed."; 71 | 72 | self.theServer = aServer; 73 | //[aServer release]; 74 | 75 | self.isServerRunning = TRUE; 76 | [self.btnControlServer setTitle:@"Stop Server" forState:UIControlStateNormal] ; 77 | 78 | self.ServerTitleLabel.hidden = false; 79 | self.ServerInfoView.hidden = false; 80 | 81 | self.httpLabel.hidden = false; 82 | self.httpURL.hidden = false; 83 | self.ftpLabel.hidden = false; 84 | 85 | } 86 | 87 | - (void) startHTTPServer 88 | { 89 | /* 90 | /// NSString *localIPAddress = [ NetworkController localIPAddress ]; 91 | NSString *localIPAddress = [ NetworkController localWifiIPAddress ]; 92 | 93 | self.ServerTitleLabel.text = [NSString stringWithFormat:@"%@ %@ %@", @"Connect to", localIPAddress, @"port 20000"]; 94 | self.ServerTitleLabel.hidden = false; 95 | 96 | self.ServerInfoView.text = @"The FTP Server has been enabled, please use FTP client software to transfer any import/export data to or from this device.\nPress the \"Stop Server\" button once all data transfers have been completed."; 97 | self.ServerInfoView.hidden = false; 98 | 99 | NSArray *docFolders = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES ); 100 | self.baseDir = [docFolders lastObject]; 101 | 102 | 103 | FtpServer *aServer = [[ FtpServer alloc ] initWithPort:20000 withDir:baseDir notifyObject:self ]; 104 | self.theServer = aServer; 105 | [aServer release]; 106 | 107 | self.isServerRunning = TRUE; 108 | [self.btnControlServer setTitle:@"Stop Server" forState:UIControlStateNormal] ; 109 | */ 110 | 111 | NSString *root = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0]; 112 | 113 | theHTTPServer = [HTTPServer new]; 114 | [theHTTPServer setType:@"_http._tcp."]; 115 | [theHTTPServer setConnectionClass:[MyHTTPConnection class]]; 116 | [theHTTPServer setDocumentRoot:[NSURL fileURLWithPath:root]]; 117 | 118 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(displayInfoUpdate:) name:@"LocalhostAdressesResolved" object:nil]; 119 | [localhostAddresses performSelectorInBackground:@selector(list) withObject:nil]; 120 | } 121 | 122 | - (void)displayInfoUpdate:(NSNotification *) notification 123 | { 124 | NSLog(@"displayInfoUpdate:"); 125 | 126 | if(notification) 127 | { 128 | [addresses release]; 129 | addresses = [[notification object] copy]; 130 | NSLog(@"addresses: %@", addresses); 131 | } 132 | 133 | if(addresses == nil) 134 | { 135 | return; 136 | } 137 | 138 | NSString *info; 139 | //UInt16 port = [theHTTPServer port]; 140 | 141 | NSString *localIP = nil; 142 | 143 | localIP = [addresses objectForKey:@"en0"]; 144 | 145 | if (!localIP) 146 | { 147 | localIP = [addresses objectForKey:@"en1"]; 148 | } 149 | 150 | if (!localIP) 151 | info = @"Wifi: No Connection!\n"; 152 | } 153 | 154 | 155 | // ---------------------------------------------------------------------------------------------------------- 156 | - (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex { 157 | // ---------------------------------------------------------------------------------------------------------- 158 | if (buttonIndex == 0) { 159 | [alert dismissWithClickedButtonIndex:0 animated:YES]; 160 | [self stopFtpServer]; 161 | } 162 | } 163 | 164 | // This is a method that will shut down the server cleanly, it calles the stopFtpServer method of FtpServer class. 165 | // ---------------------------------------------------------------------------------------------------------- 166 | - (void)stopFtpServer { 167 | // ---------------------------------------------------------------------------------------------------------- 168 | NSLog(@"Stopping the FTP server"); 169 | 170 | self.isServerRunning = FALSE; 171 | [self.btnControlServer setTitle:@"Start Server" forState:UIControlStateNormal] ; 172 | self.ServerTitleLabel.hidden = true; 173 | self.ServerInfoView.hidden = true; 174 | self.ftpLabel.hidden = true; 175 | 176 | self.httpLabel.hidden = true; 177 | self.httpURL.hidden = true; 178 | 179 | 180 | if(theHTTPServer) 181 | { 182 | [theHTTPServer stop]; 183 | [theHTTPServer release]; 184 | theHTTPServer=nil; 185 | } 186 | 187 | if(theServer) 188 | { 189 | [theServer stopFtpServer]; 190 | [theServer release]; 191 | theServer=nil; 192 | } 193 | } 194 | 195 | - (void)stopHTTPServer { 196 | // ---------------------------------------------------------------------------------------------------------- 197 | /*NSLog(@"Stopping the FTP server"); 198 | 199 | self.isServerRunning = FALSE; 200 | [self.btnControlHTTPServer setTitle:@"Start HTTP Server" forState:UIControlStateNormal] ; 201 | [self.ServerTitleLabel setText:@"HTTP is stopped!"]; 202 | self.ServerInfoView.hidden = true; 203 | 204 | if(theServer) 205 | { 206 | [theServer stopFtpServer]; 207 | [theServer release]; 208 | theServer=nil; 209 | } 210 | */ 211 | } 212 | 213 | -(void)didReceiveFileListChanged 214 | // ---------------------------------------------------------------------------------------------------------- 215 | { 216 | NSLog(@"didReceiveFileListChanged"); 217 | } 218 | 219 | - (void)dealloc { 220 | [self.ServerInfoView release]; 221 | [self.ServerTitleLabel release]; 222 | [self.btnControlServer release]; 223 | [_btnControlHTTPServer release]; 224 | [_httpURL release]; 225 | [_ftpLabel release]; 226 | [super dealloc]; 227 | } 228 | - (IBAction)ToggleServer:(id)sender { 229 | if(self.isServerRunning) 230 | { 231 | [self stopFtpServer]; 232 | }else 233 | { 234 | [self startServer]; 235 | } 236 | } 237 | 238 | @end 239 | -------------------------------------------------------------------------------- /TabBarController/Base.lproj/Main_iPad.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 78 | 88 | 93 | 98 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /TabBarController/Base.lproj/Main_iPhone.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 65 | 75 | 80 | 85 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /TabBarController/Classes/DDData.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSData (DDData) 4 | 5 | - (NSData *)md5Digest; 6 | 7 | - (NSData *)sha1Digest; 8 | 9 | - (NSString *)hexStringValue; 10 | 11 | - (NSString *)base64Encoded; 12 | - (NSData *)base64Decoded; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /TabBarController/Classes/DDData.m: -------------------------------------------------------------------------------- 1 | #import "DDData.h" 2 | #import 3 | 4 | 5 | @implementation NSData (DDData) 6 | 7 | static char encodingTable[64] = { 8 | 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', 9 | 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', 10 | 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', 11 | 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' }; 12 | 13 | - (NSData *)md5Digest 14 | { 15 | unsigned char result[CC_MD5_DIGEST_LENGTH]; 16 | 17 | CC_MD5([self bytes], (CC_LONG)[self length], result); 18 | return [NSData dataWithBytes:result length:CC_MD5_DIGEST_LENGTH]; 19 | } 20 | 21 | - (NSData *)sha1Digest 22 | { 23 | unsigned char result[CC_SHA1_DIGEST_LENGTH]; 24 | 25 | CC_SHA1([self bytes], (CC_LONG)[self length], result); 26 | return [NSData dataWithBytes:result length:CC_SHA1_DIGEST_LENGTH]; 27 | } 28 | 29 | - (NSString *)hexStringValue 30 | { 31 | NSMutableString *stringBuffer = [NSMutableString stringWithCapacity:([self length] * 2)]; 32 | 33 | const unsigned char *dataBuffer = [self bytes]; 34 | int i; 35 | 36 | for (i = 0; i < [self length]; ++i) 37 | { 38 | [stringBuffer appendFormat:@"%02x", (unsigned int)dataBuffer[i]]; 39 | } 40 | 41 | return [stringBuffer copy]; 42 | } 43 | 44 | - (NSString *)base64Encoded 45 | { 46 | const unsigned char *bytes = [self bytes]; 47 | NSMutableString *result = [NSMutableString stringWithCapacity:[self length]]; 48 | unsigned long ixtext = 0; 49 | unsigned long lentext = [self length]; 50 | long ctremaining = 0; 51 | unsigned char inbuf[3], outbuf[4]; 52 | unsigned short i = 0; 53 | unsigned short charsonline = 0, ctcopy = 0; 54 | unsigned long ix = 0; 55 | 56 | while( YES ) 57 | { 58 | ctremaining = lentext - ixtext; 59 | if( ctremaining <= 0 ) break; 60 | 61 | for( i = 0; i < 3; i++ ) { 62 | ix = ixtext + i; 63 | if( ix < lentext ) inbuf[i] = bytes[ix]; 64 | else inbuf [i] = 0; 65 | } 66 | 67 | outbuf [0] = (inbuf [0] & 0xFC) >> 2; 68 | outbuf [1] = ((inbuf [0] & 0x03) << 4) | ((inbuf [1] & 0xF0) >> 4); 69 | outbuf [2] = ((inbuf [1] & 0x0F) << 2) | ((inbuf [2] & 0xC0) >> 6); 70 | outbuf [3] = inbuf [2] & 0x3F; 71 | ctcopy = 4; 72 | 73 | switch( ctremaining ) 74 | { 75 | case 1: 76 | ctcopy = 2; 77 | break; 78 | case 2: 79 | ctcopy = 3; 80 | break; 81 | } 82 | 83 | for( i = 0; i < ctcopy; i++ ) 84 | [result appendFormat:@"%c", encodingTable[outbuf[i]]]; 85 | 86 | for( i = ctcopy; i < 4; i++ ) 87 | [result appendString:@"="]; 88 | 89 | ixtext += 3; 90 | charsonline += 4; 91 | } 92 | 93 | return [NSString stringWithString:result]; 94 | } 95 | 96 | - (NSData *)base64Decoded 97 | { 98 | const unsigned char *bytes = [self bytes]; 99 | NSMutableData *result = [NSMutableData dataWithCapacity:[self length]]; 100 | 101 | unsigned long ixtext = 0; 102 | unsigned long lentext = [self length]; 103 | unsigned char ch = 0; 104 | unsigned char inbuf[4] = {0, 0, 0, 0}; 105 | unsigned char outbuf[3] = {0, 0, 0}; 106 | short i = 0, ixinbuf = 0; 107 | BOOL flignore = NO; 108 | BOOL flendtext = NO; 109 | 110 | while( YES ) 111 | { 112 | if( ixtext >= lentext ) break; 113 | ch = bytes[ixtext++]; 114 | flignore = NO; 115 | 116 | if( ( ch >= 'A' ) && ( ch <= 'Z' ) ) ch = ch - 'A'; 117 | else if( ( ch >= 'a' ) && ( ch <= 'z' ) ) ch = ch - 'a' + 26; 118 | else if( ( ch >= '0' ) && ( ch <= '9' ) ) ch = ch - '0' + 52; 119 | else if( ch == '+' ) ch = 62; 120 | else if( ch == '=' ) flendtext = YES; 121 | else if( ch == '/' ) ch = 63; 122 | else flignore = YES; 123 | 124 | if( ! flignore ) 125 | { 126 | short ctcharsinbuf = 3; 127 | BOOL flbreak = NO; 128 | 129 | if( flendtext ) 130 | { 131 | if( ! ixinbuf ) break; 132 | if( ( ixinbuf == 1 ) || ( ixinbuf == 2 ) ) ctcharsinbuf = 1; 133 | else ctcharsinbuf = 2; 134 | ixinbuf = 3; 135 | flbreak = YES; 136 | } 137 | 138 | inbuf [ixinbuf++] = ch; 139 | 140 | if( ixinbuf == 4 ) 141 | { 142 | ixinbuf = 0; 143 | outbuf [0] = ( inbuf[0] << 2 ) | ( ( inbuf[1] & 0x30) >> 4 ); 144 | outbuf [1] = ( ( inbuf[1] & 0x0F ) << 4 ) | ( ( inbuf[2] & 0x3C ) >> 2 ); 145 | outbuf [2] = ( ( inbuf[2] & 0x03 ) << 6 ) | ( inbuf[3] & 0x3F ); 146 | 147 | for( i = 0; i < ctcharsinbuf; i++ ) 148 | [result appendBytes:&outbuf[i] length:1]; 149 | } 150 | 151 | if( flbreak ) break; 152 | } 153 | } 154 | 155 | return [NSData dataWithData:result]; 156 | } 157 | 158 | @end 159 | -------------------------------------------------------------------------------- /TabBarController/Classes/DDNumber.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | @interface NSNumber (DDNumber) 5 | 6 | + (BOOL)parseString:(NSString *)str intoSInt64:(SInt64 *)pNum; 7 | + (BOOL)parseString:(NSString *)str intoUInt64:(UInt64 *)pNum; 8 | 9 | + (BOOL)parseString:(NSString *)str intoNSInteger:(NSInteger *)pNum; 10 | + (BOOL)parseString:(NSString *)str intoNSUInteger:(NSUInteger *)pNum; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /TabBarController/Classes/DDNumber.m: -------------------------------------------------------------------------------- 1 | #import "DDNumber.h" 2 | 3 | 4 | @implementation NSNumber (DDNumber) 5 | 6 | + (BOOL)parseString:(NSString *)str intoSInt64:(SInt64 *)pNum 7 | { 8 | errno = 0; 9 | 10 | #if __LP64__ 11 | // long = 64 bit 12 | *pNum = strtol([str UTF8String], NULL, 10); 13 | #else 14 | // long = 32 bit 15 | // long long = 64 bit 16 | *pNum = strtoll([str UTF8String], NULL, 10); 17 | #endif 18 | 19 | if(errno != 0) 20 | return NO; 21 | else 22 | return YES; 23 | } 24 | 25 | + (BOOL)parseString:(NSString *)str intoUInt64:(UInt64 *)pNum 26 | { 27 | errno = 0; 28 | 29 | #if __LP64__ 30 | // unsigned long = 64 bit 31 | *pNum = strtoul([str UTF8String], NULL, 10); 32 | #else 33 | // unsigned long = 32 bit 34 | // unsigned long long = 64 bit 35 | *pNum = strtoull([str UTF8String], NULL, 10); 36 | #endif 37 | 38 | if(errno != 0) 39 | return NO; 40 | else 41 | return YES; 42 | } 43 | 44 | + (BOOL)parseString:(NSString *)str intoNSInteger:(NSInteger *)pNum 45 | { 46 | errno = 0; 47 | 48 | // On LP64, NSInteger = long = 64 bit 49 | // Otherwise, NSInteger = int = long = 32 bit 50 | 51 | *pNum = strtol([str UTF8String], NULL, 10); 52 | 53 | if(errno != 0) 54 | return NO; 55 | else 56 | return YES; 57 | } 58 | 59 | + (BOOL)parseString:(NSString *)str intoNSUInteger:(NSUInteger *)pNum 60 | { 61 | errno = 0; 62 | 63 | // On LP64, NSUInteger = unsigned long = 64 bit 64 | // Otherwise, NSUInteger = unsigned int = unsigned long = 32 bit 65 | 66 | *pNum = strtoul([str UTF8String], NULL, 10); 67 | 68 | if(errno != 0) 69 | return NO; 70 | else 71 | return YES; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /TabBarController/Classes/DDRange.h: -------------------------------------------------------------------------------- 1 | /** 2 | * DDRange is the functional equivalent of a 64 bit NSRange. 3 | * The HTTP Server is designed to support very large files. 4 | * On 32 bit architectures (ppc, i386) NSRange uses unsigned 32 bit integers. 5 | * This only supports a range of up to 4 gigabytes. 6 | * By defining our own variant, we can support a range up to 16 exabytes. 7 | * 8 | * All effort is given such that DDRange functions EXACTLY the same as NSRange. 9 | **/ 10 | 11 | #import 12 | #import 13 | 14 | @class NSString; 15 | 16 | typedef struct _DDRange { 17 | UInt64 location; 18 | UInt64 length; 19 | } DDRange; 20 | 21 | typedef DDRange *DDRangePointer; 22 | 23 | NS_INLINE DDRange DDMakeRange(UInt64 loc, UInt64 len) { 24 | DDRange r; 25 | r.location = loc; 26 | r.length = len; 27 | return r; 28 | } 29 | 30 | NS_INLINE UInt64 DDMaxRange(DDRange range) { 31 | return (range.location + range.length); 32 | } 33 | 34 | NS_INLINE BOOL DDLocationInRange(UInt64 loc, DDRange range) { 35 | return (loc - range.location < range.length); 36 | } 37 | 38 | NS_INLINE BOOL DDEqualRanges(DDRange range1, DDRange range2) { 39 | return ((range1.location == range2.location) && (range1.length == range2.length)); 40 | } 41 | 42 | FOUNDATION_EXPORT DDRange DDUnionRange(DDRange range1, DDRange range2); 43 | FOUNDATION_EXPORT DDRange DDIntersectionRange(DDRange range1, DDRange range2); 44 | FOUNDATION_EXPORT NSString *DDStringFromRange(DDRange range); 45 | FOUNDATION_EXPORT DDRange DDRangeFromString(NSString *aString); 46 | 47 | @interface NSValue (NSValueDDRangeExtensions) 48 | 49 | + (NSValue *)valueWithDDRange:(DDRange)range; 50 | - (DDRange)ddrangeValue; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /TabBarController/Classes/DDRange.m: -------------------------------------------------------------------------------- 1 | #import "DDRange.h" 2 | #import "DDNumber.h" 3 | 4 | DDRange DDUnionRange(DDRange range1, DDRange range2) 5 | { 6 | DDRange result; 7 | 8 | result.location = MIN(range1.location, range2.location); 9 | result.length = MAX(DDMaxRange(range1), DDMaxRange(range2)) - result.location; 10 | 11 | return result; 12 | } 13 | 14 | DDRange DDIntersectionRange(DDRange range1, DDRange range2) 15 | { 16 | DDRange result; 17 | 18 | if((DDMaxRange(range1) < range2.location) || (DDMaxRange(range2) < range1.location)) 19 | { 20 | return DDMakeRange(0, 0); 21 | } 22 | 23 | result.location = MAX(range1.location, range2.location); 24 | result.length = MIN(DDMaxRange(range1), DDMaxRange(range2)) - result.location; 25 | 26 | return result; 27 | } 28 | 29 | NSString *DDStringFromRange(DDRange range) 30 | { 31 | return [NSString stringWithFormat:@"{%qu, %qu}", range.location, range.length]; 32 | } 33 | 34 | DDRange DDRangeFromString(NSString *aString) 35 | { 36 | DDRange result = DDMakeRange(0, 0); 37 | 38 | // NSRange will ignore '-' characters, but not '+' characters 39 | NSCharacterSet *cset = [NSCharacterSet characterSetWithCharactersInString:@"+0123456789"]; 40 | 41 | NSScanner *scanner = [NSScanner scannerWithString:aString]; 42 | [scanner setCharactersToBeSkipped:[cset invertedSet]]; 43 | 44 | NSString *str1 = nil; 45 | NSString *str2 = nil; 46 | 47 | BOOL found1 = [scanner scanCharactersFromSet:cset intoString:&str1]; 48 | BOOL found2 = [scanner scanCharactersFromSet:cset intoString:&str2]; 49 | 50 | if(found1) [NSNumber parseString:str1 intoUInt64:&result.location]; 51 | if(found2) [NSNumber parseString:str2 intoUInt64:&result.length]; 52 | 53 | return result; 54 | } 55 | 56 | @implementation NSValue (NSValueDDRangeExtensions) 57 | 58 | + (NSValue *)valueWithDDRange:(DDRange)range 59 | { 60 | return [NSValue valueWithBytes:&range objCType:@encode(DDRange)]; 61 | } 62 | 63 | - (DDRange)ddrangeValue 64 | { 65 | DDRange result; 66 | [self getValue:&result]; 67 | return result; 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /TabBarController/Classes/FtpConnection.h: -------------------------------------------------------------------------------- 1 | /* 2 | iosFtpServer 3 | Copyright (C) 2008 Richard Dearlove ( monsta ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | 21 | #import 22 | 23 | #import "AsyncSocket.h" 24 | 25 | #import "FtpDataConnection.h" 26 | #import "FtpDefines.h" 27 | #include 28 | #include 29 | 30 | 31 | @class FtpServer; 32 | 33 | @interface FtpConnection : NSObject { 34 | AsyncSocket *connectionSocket; // Socket for this particular connection 35 | FtpServer *server; // pointer to Server object 36 | 37 | AsyncSocket *dataListeningSocket; // Socket to listen for a data connection to spawn on <-- think this is now redundant 38 | AsyncSocket *dataSocket; // duplicates the listening socket - remove listening socket from code when working - which seems to be the case. 39 | 40 | FtpDataConnection *dataConnection; // instance handling spawned data connection socket 41 | 42 | NSArray *msgComponents; // The Message rcvd broken into an array 43 | UInt16 dataPort; 44 | int transferMode; 45 | NSMutableArray *queuedData; 46 | 47 | NSString *currentUser; // The current user for this connection 48 | NSString *currentDir; // The current directory for this connection 49 | NSString *currentFile; // File that is about to be uploaded 50 | NSFileHandle *currentFileHandle; // File handle of what to save 51 | 52 | NSString *rnfrFilename; // rnfr 53 | 54 | 55 | } 56 | 57 | -(id)initWithAsyncSocket:(AsyncSocket*)newSocket forServer:(id)myServer ; 58 | #pragma mark STATE 59 | 60 | @property(readwrite)int transferMode; 61 | 62 | @property(readwrite, retain ) NSString *currentFile; 63 | @property(readwrite, retain ) NSString *currentDir; 64 | @property(readwrite, retain ) NSString *rnfrFilename; 65 | 66 | -(NSString*)connectionAddress; 67 | 68 | 69 | #pragma mark ASYNCSOCKET DATACONN 70 | 71 | -(BOOL)openDataSocket:(int)portNumber; 72 | -(int)choosePasvDataPort; 73 | 74 | 75 | -(BOOL)onSocketWillConnect:(AsyncSocket *)sock; 76 | -(void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket; 77 | 78 | #pragma mark ASYNCSOCKET FTPCLIENT CONNECTION 79 | -(void)onSocket:(AsyncSocket*)sock didReadData:(NSData*)data withTag:(long)tag; 80 | -(void)onSocket:(AsyncSocket*)sock didWriteDataWithTag:(long)tag; 81 | -(void)sendMessage:(NSString*)ftpMessage; // calls FC writedata 82 | -(void)sendDataString:(NSString*)dataString; // calls FDC writedata 83 | -(void)sendData:(NSMutableData*)data; 84 | -(void)didReceiveDataWritten; // notification that FDC wrote data 85 | -(void)didReceiveDataRead; // notification that FDC read data ie a transfer 86 | -(void)didFinishReading; // Called at the closing == end of a data connection from the client we presume 87 | 88 | #pragma mark PROCESS 89 | 90 | -(void)processDataRead:(NSData*)data; 91 | -(void)processCommand; 92 | 93 | #pragma mark COMMANDS 94 | -(void)doQuit:(id)sender arguments:(NSArray*)arguments; 95 | -(void)doUser:(id)sender arguments:(NSArray*)arguments; 96 | -(void)doPass:(id)sender arguments:(NSArray*)arguments; 97 | -(void)doStat:(id)sender arguments:(NSArray*)arguments; 98 | -(void)doFeat:(id)sender arguments:(NSArray*)arguments; 99 | -(void)doList:(id)sender arguments:(NSArray*)arguments; 100 | -(void)doPwd:(id)sender arguments:(NSArray*)arguments; 101 | -(void)doNoop:(id)sender arguments:(NSArray*)arguments; 102 | -(void)doSyst:(id)sender arguments:(NSArray*)arguments; 103 | -(void)doLprt:(id)sender arguments:(NSArray*)arguments; 104 | -(void)doPasv:(id)sender arguments:(NSArray*)arguments; 105 | -(void)doEpsv:(id)sender arguments:(NSArray*)arguments; 106 | -(void)doPort:(id)sender arguments:(NSArray*)arguments; 107 | -(void)doNlst:(id)sender arguments:(NSArray*)arguments; 108 | -(void)doStor:(id)sender arguments:(NSArray*)arguments; 109 | -(void)doRetr:(id)sender arguments:(NSArray*)arguments; 110 | -(void)doDele:(id)sender arguments:(NSArray*)arguments; 111 | -(void)doMlst:(id)sender arguments:(NSArray*)arguments; 112 | -(void)doSize:(id)sender arguments:(NSArray*)arguments; 113 | -(void)doMkdir:(id)sender arguments:(NSArray*)arguments; 114 | -(void)doCdUp:(id)sender arguments:(NSArray*)arguments; 115 | -(void)doRnfr:(id)sender arguments:(NSArray*)arguments; 116 | -(void)doRnto:(id)sender arguments:(NSArray*)arguments; 117 | 118 | #pragma mark UTITILITES 119 | -(NSString*)makeFilePathFrom:(NSString*)filename; 120 | -(unsigned long long)fileSize:(NSString*)filePath; 121 | -(NSString*)fileNameFromArgs:(NSArray*)arguments; 122 | - (Boolean)changedCurrentDirectoryTo:(NSString *)newDirectory; 123 | -(Boolean)canChangeDirectoryTo:(NSString *)testDirectory; 124 | - (Boolean)accessibleFilePath:(NSString*)filePath; // check filepath exists and is in basedir ( if set ) 125 | - (Boolean)validNewFilePath:(NSString*)filePath; 126 | - (NSString *)visibleCurrentDir; 127 | -(NSString *)rootedPath:(NSString*)path; 128 | 129 | @end 130 | -------------------------------------------------------------------------------- /TabBarController/Classes/FtpDataConnection.h: -------------------------------------------------------------------------------- 1 | /* 2 | iosFtpServer 3 | Copyright (C) 2008 Richard Dearlove ( monsta ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #import 21 | #import "AsyncSocket.h" 22 | #import "FtpDefines.h" 23 | 24 | @class FtpConnection; 25 | 26 | @interface FtpDataConnection : NSObject { 27 | AsyncSocket *dataSocket; 28 | FtpConnection *ftpConnection; // connection which generated data socket we are tied to 29 | 30 | AsyncSocket *dataListeningSocket; 31 | id dataConnection; 32 | NSMutableData *receivedData; 33 | int connectionState; 34 | 35 | } 36 | -(id)initWithAsyncSocket:(AsyncSocket*)newSocket forConnection:(id)aConnection withQueuedData:(NSMutableArray*)queuedData; 37 | -(void)writeString:(NSString*)dataString; 38 | -(void)writeData:(NSMutableData*)data; 39 | -(void)writeQueuedData:(NSMutableArray*)queuedData; 40 | -(void)closeConnection; 41 | 42 | #pragma mark ASYNCSOCKET DELEGATES 43 | -(BOOL)onSocketWillConnect:(AsyncSocket *)sock; 44 | -(void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket; 45 | -(void)onSocket:(AsyncSocket*)sock didReadData:(NSData*)data withTag:(long)tag; 46 | -(void)onSocket:(AsyncSocket*)sock didWriteDataWithTag:(long)tag; 47 | 48 | -(void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err; 49 | 50 | @property (readonly) NSMutableData *receivedData; 51 | @property (readwrite) int connectionState; 52 | 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /TabBarController/Classes/FtpDataConnection.m: -------------------------------------------------------------------------------- 1 | /* 2 | iosFtpServer 3 | Copyright (C) 2008 Richard Dearlove ( monsta ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #import "FtpDataConnection.h" 21 | #import "FtpConnection.h" 22 | 23 | 24 | @implementation FtpDataConnection 25 | 26 | @synthesize receivedData; 27 | @synthesize connectionState; 28 | 29 | // ---------------------------------------------------------------------------------------------------------- 30 | -(id)initWithAsyncSocket:(AsyncSocket*)newSocket forConnection:(id)aConnection withQueuedData:(NSMutableArray*)queuedData 31 | // ---------------------------------------------------------------------------------------------------------- 32 | { 33 | self = [super init ]; 34 | if (self) 35 | { 36 | dataSocket = [newSocket retain ]; // Hang onto the socket that was generated - the FDC is retained by FC 37 | ftpConnection = aConnection; 38 | 39 | [ dataSocket setDelegate:self ]; 40 | 41 | if ( [queuedData count ] ) 42 | { 43 | NSLog(@"FC:Write Queued Data"); 44 | [self writeQueuedData:queuedData ]; 45 | [ queuedData removeAllObjects ]; // Clear out queue 46 | } 47 | // [ dataSocket readDataToData:[AsyncSocket CRLFData] withTimeout:READ_TIMEOUT tag:FTP_CLIENT_REQUEST ]; 48 | [ dataSocket readDataWithTimeout:READ_TIMEOUT tag:FTP_CLIENT_REQUEST ]; 49 | dataListeningSocket = nil; 50 | receivedData = nil; // [[ NSMutableData alloc ] init ] 12/nov/08 - no need for this. rcd is just a pointer 51 | 52 | connectionState = clientQuiet; // Nothing coming through 53 | } 54 | return self; 55 | } 56 | // ---------------------------------------------------------------------------------------------------------- 57 | -(void)dealloc 58 | // ---------------------------------------------------------------------------------------------------------- 59 | { 60 | 61 | [dataSocket release]; 62 | [dataListeningSocket release]; 63 | [dataConnection release]; 64 | // [receivedData release]; 65 | 66 | 67 | [super dealloc]; 68 | } 69 | // ---------------------------------------------------------------------------------------------------------- 70 | -(void)writeString:(NSString*)dataString 71 | // ---------------------------------------------------------------------------------------------------------- 72 | { 73 | NSLog(@"FDC:writeStringData"); 74 | 75 | NSMutableData *data = [[ dataString dataUsingEncoding:NSUTF8StringEncoding ] mutableCopy]; // Autoreleased 76 | [ data appendData:[AsyncSocket CRLFData] ]; 77 | 78 | [ dataSocket writeData:data withTimeout:READ_TIMEOUT tag:FTP_CLIENT_REQUEST ]; 79 | [ dataSocket readDataWithTimeout:READ_TIMEOUT tag:FTP_CLIENT_REQUEST ]; 80 | } 81 | 82 | // ---------------------------------------------------------------------------------------------------------- 83 | -(void)writeData:(NSMutableData*)data 84 | // ---------------------------------------------------------------------------------------------------------- 85 | { 86 | NSLog(@"FDC:writeData"); 87 | // [ data appendData:[AsyncSocket CRLFData] ]; // Add on CRLF to end of data - as Windows Explorer needs it 88 | 89 | connectionState = clientReceiving; // We hope 90 | 91 | [ dataSocket writeData:data withTimeout:READ_TIMEOUT tag:FTP_CLIENT_REQUEST ]; 92 | 93 | [ dataSocket readDataWithTimeout:READ_TIMEOUT tag:FTP_CLIENT_REQUEST ]; 94 | } 95 | // ---------------------------------------------------------------------------------------------------------- 96 | -(void)writeQueuedData:(NSMutableArray*)queuedData 97 | // ---------------------------------------------------------------------------------------------------------- 98 | { 99 | for (NSMutableData* data in queuedData) { 100 | [self writeData:data ]; 101 | } 102 | } 103 | 104 | // ---------------------------------------------------------------------------------------------------------- 105 | -(void)closeConnection 106 | // ---------------------------------------------------------------------------------------------------------- 107 | { 108 | NSLog(@"FDC:closeConnection"); 109 | [ dataSocket disconnect ]; 110 | 111 | } 112 | #pragma mark ASYNCSOCKET DELEGATES 113 | // ---------------------------------------------------------------------------------------------------------- 114 | -(BOOL)onSocketWillConnect:(AsyncSocket *)sock 115 | // ---------------------------------------------------------------------------------------------------------- 116 | { 117 | 118 | NSLog(@"FDC:onSocketWillConnect"); 119 | [ dataSocket readDataWithTimeout:READ_TIMEOUT tag:0 ]; 120 | return YES; 121 | } 122 | 123 | // ---------------------------------------------------------------------------------------------------------- 124 | -(void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket 125 | // ---------------------------------------------------------------------------------------------------------- 126 | { 127 | // This shouldnt happen - we should be connected already - and havent set up a listening socket 128 | NSLog(@"FDC:New Connection -- shouldn't be called"); 129 | 130 | } 131 | 132 | 133 | 134 | // ---------------------------------------------------------------------------------------------------------- 135 | -(void)onSocket:(AsyncSocket*)sock didReadData:(NSData*)data withTag:(long)tag 136 | // ---------------------------------------------------------------------------------------------------------- 137 | { 138 | NSLog(@"FDC:didReadData"); 139 | 140 | // [ dataSocket readDataToData:[AsyncSocket CRLFData] withTimeout:READ_TIMEOUT tag:FTP_CLIENT_REQUEST ]; // continue reading 141 | [ dataSocket readDataWithTimeout:READ_TIMEOUT tag:FTP_CLIENT_REQUEST ]; 142 | 143 | 144 | receivedData = [[ data retain] copy]; // make autoreleased copy of data 145 | 146 | // notify connection data came through, ( will write data for us ) 147 | [ftpConnection didReceiveDataRead ]; // notify, the connection, so it knows to write the data 148 | [ receivedData release ]; // let go, not our business anymore 149 | connectionState = clientSent; 150 | } 151 | 152 | 153 | // ---------------------------------------------------------------------------------------------------------- 154 | -(void)onSocket:(AsyncSocket*)sock didWriteDataWithTag:(long)tag 155 | // ---------------------------------------------------------------------------------------------------------- 156 | { 157 | NSLog(@"FDC:didWriteData"); 158 | [ ftpConnection didReceiveDataWritten ]; // notify that we are finished writing 159 | 160 | // [ dataSocket readDataToData:[AsyncSocket CRLFData] withTimeout:READ_TIMEOUT tag:FTP_CLIENT_REQUEST ]; // continue reading 161 | [ dataSocket readDataWithTimeout:READ_TIMEOUT tag:FTP_CLIENT_REQUEST ]; 162 | } 163 | 164 | 165 | // ---------------------------------------------------------------------------------------------------------- 166 | -(void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err 167 | // ---------------------------------------------------------------------------------------------------------- 168 | { 169 | NSLog(@"FDC:willDisconnect"); 170 | // if we were writing and there's no error, then it must be the end of file 171 | 172 | if ( connectionState == clientSending ) 173 | { 174 | NSLog(@"FDC::did FinishReading"); 175 | // hopefully this is the end of the connection. not sure how we can tell 176 | } 177 | else 178 | { 179 | NSLog(@"FDC: we werent expecting this as we never set clientSending prob late coming up"); 180 | } 181 | [ ftpConnection didFinishReading ]; // its over, please send the message 182 | } 183 | 184 | - (BOOL)onReadStreamEnded:(AsyncSocket*)sock 185 | { 186 | NSLog( @"FDC: onReadStreamEnded %d(clientSending is %d)", connectionState, clientSending ); 187 | if ( connectionState == clientSent || 188 | connectionState == clientSending ) return YES; 189 | return NO; 190 | } 191 | 192 | @end 193 | -------------------------------------------------------------------------------- /TabBarController/Classes/FtpDefines.h: -------------------------------------------------------------------------------- 1 | enum { 2 | pasvftp=0,epsvftp,portftp,lprtftp, eprtftp 3 | }; 4 | 5 | #define DATASTR(args) [ args dataUsingEncoding:NSUTF8StringEncoding ] 6 | 7 | #define SERVER_PORT 20000 8 | #define READ_TIMEOUT -1 9 | 10 | #define FTP_CLIENT_REQUEST 0 11 | 12 | enum { 13 | 14 | clientSending=0, clientReceiving=1, clientQuiet=2,clientSent=3 15 | }; 16 | -------------------------------------------------------------------------------- /TabBarController/Classes/FtpServer.h: -------------------------------------------------------------------------------- 1 | /* 2 | iosFtpServer 3 | Copyright (C) 2008 Richard Dearlove ( monsta ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | 21 | #import 22 | 23 | 24 | #import "AsyncSocket.h" 25 | #import "FtpDefines.h" 26 | #import "FtpConnection.h" 27 | #import "list.h" 28 | 29 | @interface FtpServer : NSObject { 30 | 31 | AsyncSocket *listenSocket; 32 | NSMutableArray *connectedSockets; 33 | id server; 34 | id notificationObject; 35 | 36 | int portNumber; 37 | id delegate; 38 | 39 | NSMutableArray *connections; 40 | 41 | NSDictionary *commands; 42 | NSString *baseDir; 43 | Boolean changeRoot; // Change root to virtual root ( basedir ) 44 | int clientEncoding; // FTP client encoding type 45 | } 46 | - (id)initWithPort:(unsigned)serverPort withDir:(NSString *)aDirectory notifyObject:(id)sender; 47 | - (void)stopFtpServer; 48 | 49 | #pragma mark ASYNCSOCKET DELEGATES 50 | - (void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket; 51 | - (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port; 52 | 53 | #pragma mark NOTIFICATIONS 54 | - (void)didReceiveFileListChanged; 55 | 56 | #pragma mark CONNECTIONS 57 | - (void)closeConnection:(id)theConnection; 58 | - (NSString *)createList:(NSString *)directoryPath; 59 | 60 | @property (readwrite, retain) AsyncSocket *listenSocket; 61 | @property (readwrite, retain) NSMutableArray *connectedSockets; 62 | @property (readwrite, retain) id server; 63 | @property (readwrite, retain) id notificationObject; 64 | @property (readwrite) int portNumber; 65 | @property (readwrite, retain) id delegate; 66 | @property (readwrite, retain) NSMutableArray *connections; 67 | @property (readwrite, retain) NSDictionary *commands; 68 | @property (readwrite, retain) NSString *baseDir; 69 | @property (readwrite) Boolean changeRoot; 70 | @property (readwrite) int clientEncoding; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /TabBarController/Classes/FtpServer.m: -------------------------------------------------------------------------------- 1 | /* 2 | iosFtpServer 3 | Copyright (C) 2008 Richard Dearlove ( monsta ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | 21 | // 11/02/08 changes to made to allow stopping of the server. Also added a bit of code to show users IP address. 22 | // Cleaned up the code to make the retains and releases a bit more obvious... mostly programming style preferences. 23 | // Added a stop Ftp server method to be called from where ever it was start. See iphoneLibTestViewController.m to see how I was calling it. 24 | // Most users wouldn't want the server to continue to run once the transfers are done. 25 | 26 | 27 | #import "FtpServer.h" 28 | 29 | @implementation FtpServer 30 | 31 | @synthesize listenSocket, connectedSockets, server, notificationObject, portNumber, delegate, commands, baseDir, connections; 32 | 33 | @synthesize clientEncoding; 34 | @synthesize changeRoot; 35 | 36 | // ---------------------------------------------------------------------------------------------------------- 37 | - (id)initWithPort:(unsigned)serverPort withDir:(NSString*)aDirectory notifyObject:(id)sender 38 | // ---------------------------------------------------------------------------------------------------------- 39 | { 40 | if( self = [super init] ) { 41 | 42 | NSError *error = nil; 43 | 44 | self.notificationObject = sender; 45 | 46 | // Load up commands 47 | NSString *plistPath = [[ NSBundle mainBundle ] pathForResource:@"ftp_commands" ofType:@"plist"]; 48 | if ( ! [ [ NSFileManager defaultManager ] fileExistsAtPath:plistPath ] ) 49 | { 50 | NSLog(@"ftp_commands.plist missing"); 51 | } 52 | commands = [ [ NSDictionary alloc ] initWithContentsOfFile:plistPath]; 53 | 54 | // Clear out connections list 55 | NSMutableArray *myConnections = [[NSMutableArray alloc] init]; 56 | self.connections = myConnections; 57 | [myConnections release]; 58 | 59 | 60 | 61 | // Create a socket 62 | self.portNumber = serverPort; 63 | 64 | AsyncSocket *myListenSocket = [[AsyncSocket alloc] initWithDelegate:self]; 65 | self.listenSocket = myListenSocket; 66 | [myListenSocket release]; 67 | 68 | NSLog(@"Listening on %u", portNumber); 69 | [listenSocket acceptOnPort:serverPort error:&error]; // start lisetning on this port. 70 | 71 | NSMutableArray *myConnectedSockets = [[NSMutableArray alloc] initWithCapacity:1]; 72 | self.connectedSockets = myConnectedSockets; 73 | [myConnectedSockets release]; 74 | 75 | // Set directory - have to do this because on iphone, some directories arent what they report back as, so need real path it resolves to, CHECKME - might be an easier way 76 | NSFileManager *fileManager = [ NSFileManager defaultManager ]; 77 | NSString *expandedPath = [ aDirectory stringByStandardizingPath ]; 78 | 79 | // CHANGE TO NEW DIRECTORY & GET SYSTEM FILE PATH ( no .. etc ) 80 | if ([ fileManager changeCurrentDirectoryPath:expandedPath ]) // try changing to directory 81 | { 82 | 83 | self.baseDir = [[ fileManager currentDirectoryPath ] copy] ; // Gets the real path. CHECKME. 84 | // self.baseDir = @"/Users"; // REMOVEME - added for testing 7/6/10 85 | } 86 | else 87 | { 88 | self.baseDir = aDirectory; // shouldnt get to this line really 89 | } 90 | 91 | self.changeRoot = false; // true if you want them to be sandboxed/chrooted into the basedir 92 | 93 | // the default client encoding is UTF8 94 | self.clientEncoding = NSUTF8StringEncoding; 95 | } 96 | return self; 97 | } 98 | // ---------------------------------------------------------------------------------------------------------- 99 | -(void)stopFtpServer 100 | // ---------------------------------------------------------------------------------------------------------- 101 | { 102 | if(listenSocket)[listenSocket disconnect]; 103 | [connectedSockets removeAllObjects]; 104 | 105 | [connections removeAllObjects]; 106 | 107 | } 108 | #pragma mark ASYNCSOCKET DELEGATES 109 | // ---------------------------------------------------------------------------------------------------------- 110 | - (void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket 111 | // ---------------------------------------------------------------------------------------------------------- 112 | { 113 | 114 | FtpConnection *newConnection = [[[ FtpConnection alloc ] initWithAsyncSocket:newSocket forServer:self] autorelease]; // Create an ftp connection 115 | 116 | 117 | 118 | 119 | [ connections addObject:newConnection ]; // Add this to our list of connections 120 | 121 | NSLog(@"FS:didAcceptNewSocket port:%i", [sock localPort]); 122 | 123 | if ([sock localPort] == portNumber ) 124 | { 125 | NSLog(@"Connection on Server Port"); 126 | 127 | } 128 | else 129 | { 130 | // must be a data comms port 131 | // spawn a data comms port 132 | // look for the connection with the same port 133 | // and attach it 134 | NSLog(@"--ERROR %i, %i", [sock localPort],portNumber); 135 | 136 | } 137 | } 138 | 139 | // ---------------------------------------------------------------------------------------------------------- 140 | - (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port 141 | // ---------------------------------------------------------------------------------------------------------- 142 | { 143 | NSLog(@"FtpServer:didConnectToHost port:%i", [sock localPort]); 144 | } 145 | 146 | #pragma mark NOTIFICATIONS 147 | // ---------------------------------------------------------------------------------------------------------- 148 | -(void)didReceiveFileListChanged 149 | // ---------------------------------------------------------------------------------------------------------- 150 | { 151 | if ([notificationObject respondsToSelector:@selector(didReceiveFileListChanged)]) 152 | [notificationObject didReceiveFileListChanged ]; 153 | } 154 | #pragma mark CONNECTIONS 155 | // ---------------------------------------------------------------------------------------------------------- 156 | - (void)closeConnection:(id)theConnection 157 | // ---------------------------------------------------------------------------------------------------------- 158 | { 159 | // Search through connections for this one - and delete 160 | // this should release it - and delloc 161 | 162 | [connections removeObject:theConnection ]; 163 | 164 | 165 | } 166 | 167 | // ---------------------------------------------------------------------------------------------------------- 168 | -(NSString*)createList:(NSString*)directoryPath 169 | // ---------------------------------------------------------------------------------------------------------- 170 | { 171 | return createList(directoryPath); 172 | 173 | 174 | } 175 | 176 | // ---------------------------------------------------------------------------------------------------------- 177 | - (void)dealloc 178 | // ---------------------------------------------------------------------------------------------------------- 179 | { 180 | 181 | 182 | if(listenSocket) 183 | { 184 | [listenSocket disconnect]; 185 | [listenSocket release]; 186 | } 187 | 188 | [connectedSockets release]; 189 | [notificationObject release]; 190 | [connections release]; 191 | [commands release]; 192 | [baseDir release]; 193 | [super dealloc]; 194 | 195 | } 196 | 197 | 198 | @end 199 | -------------------------------------------------------------------------------- /TabBarController/Classes/HTTPAuthenticationRequest.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #if TARGET_OS_IPHONE 4 | // Note: You may need to add the CFNetwork Framework to your project 5 | #import 6 | #endif 7 | 8 | 9 | @interface HTTPAuthenticationRequest : NSObject 10 | { 11 | BOOL isBasic; 12 | BOOL isDigest; 13 | 14 | NSString *base64Credentials; 15 | 16 | NSString *username; 17 | NSString *realm; 18 | NSString *nonce; 19 | NSString *uri; 20 | NSString *qop; 21 | NSString *nc; 22 | NSString *cnonce; 23 | NSString *response; 24 | } 25 | - (id)initWithRequest:(CFHTTPMessageRef)request; 26 | 27 | - (BOOL)isBasic; 28 | - (BOOL)isDigest; 29 | 30 | // Basic 31 | - (NSString *)base64Credentials; 32 | 33 | // Digest 34 | - (NSString *)username; 35 | - (NSString *)realm; 36 | - (NSString *)nonce; 37 | - (NSString *)uri; 38 | - (NSString *)qop; 39 | - (NSString *)nc; 40 | - (NSString *)cnonce; 41 | - (NSString *)response; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /TabBarController/Classes/HTTPAuthenticationRequest.m: -------------------------------------------------------------------------------- 1 | #import "HTTPAuthenticationRequest.h" 2 | 3 | @interface HTTPAuthenticationRequest (PrivateAPI) 4 | - (NSString *)quotedSubHeaderFieldValue:(NSString *)param fromHeaderFieldValue:(NSString *)header; 5 | - (NSString *)nonquotedSubHeaderFieldValue:(NSString *)param fromHeaderFieldValue:(NSString *)header; 6 | @end 7 | 8 | 9 | @implementation HTTPAuthenticationRequest 10 | 11 | - (id)initWithRequest:(CFHTTPMessageRef)request 12 | { 13 | if(self = [super init]) 14 | { 15 | NSString *authInfo = (NSString *)CFHTTPMessageCopyHeaderFieldValue(request, CFSTR("Authorization")); 16 | 17 | isBasic = NO; 18 | if([authInfo length] >= 6) 19 | { 20 | isBasic = [[authInfo substringToIndex:6] caseInsensitiveCompare:@"Basic "] == NSOrderedSame; 21 | } 22 | 23 | isDigest = NO; 24 | if([authInfo length] >= 7) 25 | { 26 | isDigest = [[authInfo substringToIndex:7] caseInsensitiveCompare:@"Digest "] == NSOrderedSame; 27 | } 28 | 29 | if(isBasic) 30 | { 31 | NSMutableString *temp = [[[authInfo substringFromIndex:6] mutableCopy] autorelease]; 32 | CFStringTrimWhitespace((CFMutableStringRef)temp); 33 | 34 | base64Credentials = [temp copy]; 35 | } 36 | 37 | if(isDigest) 38 | { 39 | username = [[self quotedSubHeaderFieldValue:@"username" fromHeaderFieldValue:authInfo] retain]; 40 | realm = [[self quotedSubHeaderFieldValue:@"realm" fromHeaderFieldValue:authInfo] retain]; 41 | nonce = [[self quotedSubHeaderFieldValue:@"nonce" fromHeaderFieldValue:authInfo] retain]; 42 | uri = [[self quotedSubHeaderFieldValue:@"uri" fromHeaderFieldValue:authInfo] retain]; 43 | 44 | // It appears from RFC 2617 that the qop is to be given unquoted 45 | // Tests show that Firefox performs this way, but Safari does not 46 | // Thus we'll attempt to retrieve the value as nonquoted, but we'll verify it doesn't start with a quote 47 | qop = [self nonquotedSubHeaderFieldValue:@"qop" fromHeaderFieldValue:authInfo]; 48 | if(qop && ([qop characterAtIndex:0] == '"')) 49 | { 50 | qop = [self quotedSubHeaderFieldValue:@"qop" fromHeaderFieldValue:authInfo]; 51 | } 52 | [qop retain]; 53 | 54 | nc = [[self nonquotedSubHeaderFieldValue:@"nc" fromHeaderFieldValue:authInfo] retain]; 55 | cnonce = [[self quotedSubHeaderFieldValue:@"cnonce" fromHeaderFieldValue:authInfo] retain]; 56 | response = [[self quotedSubHeaderFieldValue:@"response" fromHeaderFieldValue:authInfo] retain]; 57 | } 58 | 59 | // Remember, if using garbage collection: 60 | // Core foundation objects must be released using CFRelease, as [id release] is a no-op. 61 | if(authInfo) CFRelease((CFStringRef)authInfo); 62 | } 63 | return self; 64 | } 65 | 66 | - (void)dealloc 67 | { 68 | [base64Credentials release]; 69 | [username release]; 70 | [realm release]; 71 | [nonce release]; 72 | [uri release]; 73 | [qop release]; 74 | [nc release]; 75 | [cnonce release]; 76 | [response release]; 77 | [super dealloc]; 78 | } 79 | 80 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 81 | #pragma mark Accessors: 82 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 83 | 84 | - (BOOL)isBasic { 85 | return isBasic; 86 | } 87 | 88 | - (BOOL)isDigest { 89 | return isDigest; 90 | } 91 | 92 | - (NSString *)base64Credentials { 93 | return base64Credentials; 94 | } 95 | 96 | - (NSString *)username { 97 | return username; 98 | } 99 | 100 | - (NSString *)realm { 101 | return realm; 102 | } 103 | 104 | - (NSString *)nonce { 105 | return nonce; 106 | } 107 | 108 | - (NSString *)uri { 109 | return uri; 110 | } 111 | 112 | - (NSString *)qop { 113 | return qop; 114 | } 115 | 116 | - (NSString *)nc { 117 | return nc; 118 | } 119 | 120 | - (NSString *)cnonce { 121 | return cnonce; 122 | } 123 | 124 | - (NSString *)response { 125 | return response; 126 | } 127 | 128 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 129 | #pragma mark Private API: 130 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 131 | 132 | /** 133 | * Retrieves a "Sub Header Field Value" from a given header field value. 134 | * The sub header field is expected to be quoted. 135 | * 136 | * In the following header field: 137 | * Authorization: Digest username="Mufasa", qop=auth, response="6629fae4939" 138 | * The sub header field titled 'username' is quoted, and this method would return the value @"Mufasa". 139 | **/ 140 | - (NSString *)quotedSubHeaderFieldValue:(NSString *)param fromHeaderFieldValue:(NSString *)header 141 | { 142 | NSRange startRange = [header rangeOfString:[NSString stringWithFormat:@"%@=\"", param]]; 143 | if(startRange.location == NSNotFound) 144 | { 145 | // The param was not found anywhere in the header 146 | return nil; 147 | } 148 | 149 | int postStartRangeLocation = startRange.location + startRange.length; 150 | int postStartRangeLength = [header length] - postStartRangeLocation; 151 | NSRange postStartRange = NSMakeRange(postStartRangeLocation, postStartRangeLength); 152 | 153 | NSRange endRange = [header rangeOfString:@"\"" options:0 range:postStartRange]; 154 | if(endRange.location == NSNotFound) 155 | { 156 | // The ending double-quote was not found anywhere in the header 157 | return nil; 158 | } 159 | 160 | NSRange subHeaderRange = NSMakeRange(postStartRangeLocation, endRange.location - postStartRangeLocation); 161 | return [header substringWithRange:subHeaderRange]; 162 | } 163 | 164 | /** 165 | * Retrieves a "Sub Header Field Value" from a given header field value. 166 | * The sub header field is expected to not be quoted. 167 | * 168 | * In the following header field: 169 | * Authorization: Digest username="Mufasa", qop=auth, response="6629fae4939" 170 | * The sub header field titled 'qop' is nonquoted, and this method would return the value @"auth". 171 | **/ 172 | - (NSString *)nonquotedSubHeaderFieldValue:(NSString *)param fromHeaderFieldValue:(NSString *)header 173 | { 174 | NSRange startRange = [header rangeOfString:[NSString stringWithFormat:@"%@=", param]]; 175 | if(startRange.location == NSNotFound) 176 | { 177 | // The param was not found anywhere in the header 178 | return nil; 179 | } 180 | 181 | int postStartRangeLocation = startRange.location + startRange.length; 182 | int postStartRangeLength = [header length] - postStartRangeLocation; 183 | NSRange postStartRange = NSMakeRange(postStartRangeLocation, postStartRangeLength); 184 | 185 | NSRange endRange = [header rangeOfString:@"," options:0 range:postStartRange]; 186 | if(endRange.location == NSNotFound) 187 | { 188 | // The ending comma was not found anywhere in the header 189 | // However, if the nonquoted param is at the end of the string, there would be no comma 190 | // This is only possible if there are no spaces anywhere 191 | NSRange endRange2 = [header rangeOfString:@" " options:0 range:postStartRange]; 192 | if(endRange2.location != NSNotFound) 193 | { 194 | return nil; 195 | } 196 | else 197 | { 198 | return [header substringWithRange:postStartRange]; 199 | } 200 | } 201 | else 202 | { 203 | NSRange subHeaderRange = NSMakeRange(postStartRangeLocation, endRange.location - postStartRangeLocation); 204 | return [header substringWithRange:subHeaderRange]; 205 | } 206 | } 207 | 208 | @end 209 | -------------------------------------------------------------------------------- /TabBarController/Classes/HTTPConnection.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #if TARGET_OS_IPHONE 4 | // Note: You may need to add the CFNetwork Framework to your project 5 | #import 6 | #endif 7 | 8 | @class AsyncSocket; 9 | @class HTTPServer; 10 | @protocol HTTPResponse; 11 | 12 | 13 | #define HTTPConnectionDidDieNotification @"HTTPConnectionDidDie" 14 | 15 | @interface HTTPConnection : NSObject 16 | { 17 | AsyncSocket *asyncSocket; 18 | HTTPServer *server; 19 | 20 | CFHTTPMessageRef request; 21 | int numHeaderLines; 22 | 23 | NSString *nonce; 24 | long lastNC; 25 | 26 | NSObject *httpResponse; 27 | 28 | NSMutableArray *ranges; 29 | NSMutableArray *ranges_headers; 30 | NSString *ranges_boundry; 31 | int rangeIndex; 32 | 33 | UInt64 requestContentLength; 34 | UInt64 requestContentLengthReceived; 35 | 36 | // vodkhang 37 | // Added properties 38 | NSInteger dataStartIndex; 39 | NSMutableArray *multipartData; 40 | BOOL postHeaderOK; 41 | } 42 | 43 | - (id)initWithAsyncSocket:(AsyncSocket *)newSocket forServer:(HTTPServer *)myServer; 44 | 45 | - (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path; 46 | 47 | - (BOOL)isSecureServer; 48 | - (NSArray *)sslIdentityAndCertificates; 49 | 50 | - (BOOL)isPasswordProtected:(NSString *)path; 51 | - (BOOL)useDigestAccessAuthentication; 52 | - (NSString *)realm; 53 | - (NSString *)passwordForUser:(NSString *)username; 54 | 55 | - (NSString *)filePathForURI:(NSString *)path; 56 | 57 | - (NSObject *)httpResponseForMethod:(NSString *)method URI:(NSString *)path; 58 | 59 | - (void)prepareForBodyWithSize:(UInt64)contentLength; 60 | - (void)processDataChunk:(NSData *)postDataChunk; 61 | 62 | - (void)handleVersionNotSupported:(NSString *)version; 63 | - (void)handleAuthenticationFailed; 64 | - (void)handleResourceNotFound; 65 | - (void)handleInvalidRequest:(NSData *)data; 66 | - (void)handleUnknownMethod:(NSString *)method; 67 | 68 | - (NSData *)preprocessResponse:(CFHTTPMessageRef)response; 69 | - (NSData *)preprocessErrorResponse:(CFHTTPMessageRef)response; 70 | 71 | - (void)die; 72 | - (BOOL)supportsPOST:(NSString *)path withSize:(UInt64)contentLength; 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /TabBarController/Classes/HTTPResponse.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | @protocol HTTPResponse 5 | 6 | - (UInt64)contentLength; 7 | 8 | - (UInt64)offset; 9 | - (void)setOffset:(UInt64)offset; 10 | 11 | - (NSData *)readDataOfLength:(unsigned int)length; 12 | 13 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 14 | 15 | @optional 16 | - (NSDictionary *)httpHeaders; 17 | 18 | #endif 19 | 20 | @end 21 | 22 | @interface HTTPFileResponse : NSObject 23 | { 24 | NSString *filePath; 25 | NSFileHandle *fileHandle; 26 | } 27 | 28 | - (id)initWithFilePath:(NSString *)filePath; 29 | - (NSString *)filePath; 30 | 31 | @end 32 | 33 | @interface HTTPDataResponse : NSObject 34 | { 35 | unsigned offset; 36 | NSData *data; 37 | } 38 | 39 | - (id)initWithData:(NSData *)data; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /TabBarController/Classes/HTTPResponse.m: -------------------------------------------------------------------------------- 1 | #import "HTTPResponse.h" 2 | 3 | 4 | @implementation HTTPFileResponse 5 | 6 | - (id)initWithFilePath:(NSString *)filePathParam 7 | { 8 | if(self = [super init]) 9 | { 10 | filePath = [filePathParam copy]; 11 | fileHandle = [[NSFileHandle fileHandleForReadingAtPath:filePath] retain]; 12 | } 13 | return self; 14 | } 15 | 16 | - (void)dealloc 17 | { 18 | [filePath release]; 19 | [fileHandle closeFile]; 20 | [fileHandle release]; 21 | [super dealloc]; 22 | } 23 | 24 | - (UInt64)contentLength 25 | { 26 | NSDictionary *fileAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:filePath traverseLink:NO]; 27 | 28 | NSNumber *fileSize = [fileAttributes objectForKey:NSFileSize]; 29 | 30 | return (UInt64)[fileSize unsignedLongLongValue]; 31 | } 32 | 33 | - (UInt64)offset 34 | { 35 | return (UInt64)[fileHandle offsetInFile]; 36 | } 37 | 38 | - (void)setOffset:(UInt64)offset 39 | { 40 | [fileHandle seekToFileOffset:offset]; 41 | } 42 | 43 | - (NSData *)readDataOfLength:(unsigned int)length 44 | { 45 | return [fileHandle readDataOfLength:length]; 46 | } 47 | 48 | - (NSString *)filePath 49 | { 50 | return filePath; 51 | } 52 | 53 | @end 54 | 55 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 56 | #pragma mark - 57 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 58 | 59 | @implementation HTTPDataResponse 60 | 61 | - (id)initWithData:(NSData *)dataParam 62 | { 63 | if(self = [super init]) 64 | { 65 | offset = 0; 66 | data = [dataParam retain]; 67 | } 68 | return self; 69 | } 70 | 71 | - (void)dealloc 72 | { 73 | [data release]; 74 | [super dealloc]; 75 | } 76 | 77 | - (UInt64)contentLength 78 | { 79 | return (UInt64)[data length]; 80 | } 81 | 82 | - (UInt64)offset 83 | { 84 | return offset; 85 | } 86 | 87 | - (void)setOffset:(UInt64)offsetParam 88 | { 89 | offset = offsetParam; 90 | } 91 | 92 | - (NSData *)readDataOfLength:(unsigned int)lengthParameter 93 | { 94 | unsigned int remaining = [data length] - offset; 95 | unsigned int length = lengthParameter < remaining ? lengthParameter : remaining; 96 | 97 | void *bytes = (void *)([data bytes] + offset); 98 | 99 | offset += length; 100 | 101 | return [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:NO]; 102 | } 103 | 104 | @end 105 | -------------------------------------------------------------------------------- /TabBarController/Classes/HTTPServer.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class AsyncSocket; 4 | 5 | 6 | @interface HTTPServer : NSObject 7 | { 8 | // Underlying asynchronous TCP/IP socket 9 | AsyncSocket *asyncSocket; 10 | 11 | // Standard delegate 12 | id delegate; 13 | 14 | // HTTP server configuration 15 | NSURL *documentRoot; 16 | Class connectionClass; 17 | 18 | // NSNetService and related variables 19 | NSNetService *netService; 20 | NSString *domain; 21 | NSString *type; 22 | NSString *name; 23 | UInt16 port; 24 | NSDictionary *txtRecordDictionary; 25 | 26 | NSMutableArray *connections; 27 | } 28 | 29 | - (id)delegate; 30 | - (void)setDelegate:(id)newDelegate; 31 | 32 | - (NSURL *)documentRoot; 33 | - (void)setDocumentRoot:(NSURL *)value; 34 | 35 | - (Class)connectionClass; 36 | - (void)setConnectionClass:(Class)value; 37 | 38 | - (NSString *)domain; 39 | - (void)setDomain:(NSString *)value; 40 | 41 | - (NSString *)type; 42 | - (void)setType:(NSString *)value; 43 | 44 | - (NSString *)name; 45 | - (NSString *)publishedName; 46 | - (void)setName:(NSString *)value; 47 | 48 | - (UInt16)port; 49 | - (void)setPort:(UInt16)value; 50 | 51 | - (NSDictionary *)TXTRecordDictionary; 52 | - (void)setTXTRecordDictionary:(NSDictionary *)dict; 53 | 54 | - (BOOL)start:(NSError **)error; 55 | - (BOOL)stop; 56 | 57 | - (uint)numberOfHTTPConnections; 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /TabBarController/Classes/HTTPServer.m: -------------------------------------------------------------------------------- 1 | #import "AsyncSocket.h" 2 | #import "HTTPServer.h" 3 | #import "HTTPConnection.h" 4 | 5 | 6 | @implementation HTTPServer 7 | 8 | /** 9 | * Standard Constructor. 10 | * Instantiates an HTTP server, but does not start it. 11 | **/ 12 | - (id)init 13 | { 14 | if(self = [super init]) 15 | { 16 | // Initialize underlying asynchronous tcp/ip socket 17 | asyncSocket = [[AsyncSocket alloc] initWithDelegate:self]; 18 | 19 | // Use default connection class of HTTPConnection 20 | connectionClass = [HTTPConnection self]; 21 | 22 | // Configure default values for bonjour service 23 | 24 | // Use a default port of 0 25 | // This will allow the kernel to automatically pick an open port for us 26 | port = 8083; 27 | 28 | // Bonjour domain. Use the local domain by default 29 | domain = @"local."; 30 | 31 | // If using an empty string ("") for the service name when registering, 32 | // the system will automatically use the "Computer Name". 33 | // Passing in an empty string will also handle name conflicts 34 | // by automatically appending a digit to the end of the name. 35 | name = @""; 36 | 37 | // Initialize an array to hold all the HTTP connections 38 | connections = [[NSMutableArray alloc] init]; 39 | 40 | // And register for notifications of closed connections 41 | [[NSNotificationCenter defaultCenter] addObserver:self 42 | selector:@selector(connectionDidDie:) 43 | name:HTTPConnectionDidDieNotification 44 | object:nil]; 45 | } 46 | return self; 47 | } 48 | 49 | /** 50 | * Standard Deconstructor. 51 | * Stops the server, and clients, and releases any resources connected with this instance. 52 | **/ 53 | - (void)dealloc 54 | { 55 | // Remove notification observer 56 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 57 | 58 | // Stop the server if it's running 59 | [self stop]; 60 | 61 | // Release all instance variables 62 | [documentRoot release]; 63 | [netService release]; 64 | [domain release]; 65 | [name release]; 66 | [type release]; 67 | [txtRecordDictionary release]; 68 | [asyncSocket release]; 69 | [connections release]; 70 | 71 | [super dealloc]; 72 | } 73 | 74 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 75 | #pragma mark Server Configuration: 76 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 77 | 78 | /** 79 | * Returns the delegate connected with this instance. 80 | **/ 81 | - (id)delegate 82 | { 83 | return delegate; 84 | } 85 | 86 | /** 87 | * Sets the delegate connected with this instance. 88 | **/ 89 | - (void)setDelegate:(id)newDelegate 90 | { 91 | delegate = newDelegate; 92 | } 93 | 94 | /** 95 | * The document root is filesystem root for the webserver. 96 | * Thus requests for /index.html will be referencing the index.html file within the document root directory. 97 | * All file requests are relative to this document root. 98 | **/ 99 | - (NSURL *)documentRoot { 100 | return documentRoot; 101 | } 102 | - (void)setDocumentRoot:(NSURL *)value 103 | { 104 | if(![documentRoot isEqual:value]) 105 | { 106 | [documentRoot release]; 107 | documentRoot = [value copy]; 108 | } 109 | } 110 | 111 | /** 112 | * The connection class is the class that will be used to handle connections. 113 | * That is, when a new connection is created, an instance of this class will be intialized. 114 | * The default connection class is HTTPConnection. 115 | * If you use a different connection class, it is assumed that the class extends HTTPConnection 116 | **/ 117 | - (Class)connectionClass { 118 | return connectionClass; 119 | } 120 | - (void)setConnectionClass:(Class)value 121 | { 122 | connectionClass = value; 123 | } 124 | 125 | /** 126 | * Domain on which to broadcast this service via Bonjour. 127 | * The default domain is @"local". 128 | **/ 129 | - (NSString *)domain { 130 | return domain; 131 | } 132 | - (void)setDomain:(NSString *)value 133 | { 134 | if(![domain isEqualToString:value]) 135 | { 136 | [domain release]; 137 | domain = [value copy]; 138 | } 139 | } 140 | 141 | /** 142 | * The type of service to publish via Bonjour. 143 | * No type is set by default, and one must be set in order for the service to be published. 144 | **/ 145 | - (NSString *)type { 146 | return type; 147 | } 148 | - (void)setType:(NSString *)value 149 | { 150 | if(![type isEqualToString:value]) 151 | { 152 | [type release]; 153 | type = [value copy]; 154 | } 155 | } 156 | 157 | /** 158 | * The name to use for this service via Bonjour. 159 | * The default name is an empty string, 160 | * which should result in the published name being the host name of the computer. 161 | **/ 162 | - (NSString *)name { 163 | return name; 164 | } 165 | - (NSString *)publishedName { 166 | return [netService name]; 167 | } 168 | - (void)setName:(NSString *)value 169 | { 170 | if(![name isEqualToString:value]) 171 | { 172 | [name release]; 173 | name = [value copy]; 174 | } 175 | } 176 | 177 | /** 178 | * The port to listen for connections on. 179 | * By default this port is initially set to zero, which allows the kernel to pick an available port for us. 180 | * After the HTTP server has started, the port being used may be obtained by this method. 181 | **/ 182 | - (UInt16)port { 183 | return port; 184 | } 185 | - (void)setPort:(UInt16)value { 186 | port = value; 187 | } 188 | 189 | /** 190 | * The extra data to use for this service via Bonjour. 191 | **/ 192 | - (NSDictionary *)TXTRecordDictionary { 193 | return txtRecordDictionary; 194 | } 195 | - (void)setTXTRecordDictionary:(NSDictionary *)value 196 | { 197 | if(![txtRecordDictionary isEqualToDictionary:value]) 198 | { 199 | [txtRecordDictionary release]; 200 | txtRecordDictionary = [value copy]; 201 | 202 | // And update the txtRecord of the netService if it has already been published 203 | if(netService) 204 | { 205 | [netService setTXTRecordData:[NSNetService dataFromTXTRecordDictionary:txtRecordDictionary]]; 206 | } 207 | } 208 | } 209 | 210 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 211 | #pragma mark Server Control: 212 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 213 | 214 | - (BOOL)start:(NSError **)error 215 | { 216 | BOOL success = [asyncSocket acceptOnPort:port error:error]; 217 | 218 | if(success) 219 | { 220 | // Update our port number 221 | [self setPort:[asyncSocket localPort]]; 222 | 223 | // Output console message for debugging purposes 224 | NSLog(@"Started HTTP server on port %hu", port); 225 | 226 | // We can only publish our bonjour service if a type has been set 227 | if(type != nil) 228 | { 229 | // Create the NSNetService with our basic parameters 230 | netService = [[NSNetService alloc] initWithDomain:domain type:type name:name port:port]; 231 | 232 | [netService setDelegate:self]; 233 | [netService publish]; 234 | 235 | // Do not set the txtRecordDictionary prior to publishing!!! 236 | // This will cause the OS to crash!!! 237 | 238 | // Set the txtRecordDictionary if we have one 239 | if(txtRecordDictionary != nil) 240 | { 241 | [netService setTXTRecordData:[NSNetService dataFromTXTRecordDictionary:txtRecordDictionary]]; 242 | } 243 | } 244 | } 245 | else 246 | { 247 | NSLog(@"Failed to start HTTP Server: %@", *error); 248 | } 249 | 250 | return success; 251 | } 252 | 253 | - (BOOL)stop 254 | { 255 | // First stop publishing the service via bonjour 256 | if(netService) 257 | { 258 | [netService stop]; 259 | [netService release]; 260 | netService = nil; 261 | } 262 | 263 | // Now stop the asynchronouse tcp server 264 | // This will prevent it from accepting any more connections 265 | [asyncSocket disconnect]; 266 | 267 | // Now stop all HTTP connections the server owns 268 | @synchronized(connections) 269 | { 270 | [connections removeAllObjects]; 271 | } 272 | 273 | return YES; 274 | } 275 | 276 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 277 | #pragma mark Server Status: 278 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 279 | 280 | /** 281 | * Returns the number of clients that are currently connected to the server. 282 | **/ 283 | - (uint)numberOfHTTPConnections 284 | { 285 | uint result = 0; 286 | 287 | @synchronized(connections) 288 | { 289 | result = [connections count]; 290 | } 291 | return result; 292 | } 293 | 294 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 295 | #pragma mark AsyncSocket Delegate Methods: 296 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 297 | 298 | -(void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket 299 | { 300 | id newConnection = [[connectionClass alloc] initWithAsyncSocket:newSocket forServer:self]; 301 | 302 | @synchronized(connections) 303 | { 304 | [connections addObject:newConnection]; 305 | } 306 | [newConnection release]; 307 | } 308 | 309 | /** 310 | * This method is automatically called when a notification of type HTTPConnectionDidDieNotification is posted. 311 | * It allows us to remove the connection from our array. 312 | **/ 313 | - (void)connectionDidDie:(NSNotification *)notification 314 | { 315 | // Note: This method is called on the thread/runloop that posted the notification 316 | 317 | @synchronized(connections) 318 | { 319 | [connections removeObject:[notification object]]; 320 | } 321 | } 322 | 323 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 324 | #pragma mark Bonjour Delegate Methods: 325 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 326 | 327 | /** 328 | * Called when our bonjour service has been successfully published. 329 | * This method does nothing but output a log message telling us about the published service. 330 | **/ 331 | - (void)netServiceDidPublish:(NSNetService *)ns 332 | { 333 | // Override me to do something here... 334 | 335 | NSLog(@"Bonjour Service Published: domain(%@) type(%@) name(%@)", [ns domain], [ns type], [ns name]); 336 | } 337 | 338 | /** 339 | * Called if our bonjour service failed to publish itself. 340 | * This method does nothing but output a log message telling us about the published service. 341 | **/ 342 | - (void)netService:(NSNetService *)ns didNotPublish:(NSDictionary *)errorDict 343 | { 344 | // Override me to do something here... 345 | 346 | NSLog(@"Failed to Publish Service: domain(%@) type(%@) name(%@)", [ns domain], [ns type], [ns name]); 347 | NSLog(@"Error Dict: %@", errorDict); 348 | } 349 | 350 | @end 351 | -------------------------------------------------------------------------------- /TabBarController/Classes/MyHTTPConnection.h: -------------------------------------------------------------------------------- 1 | // 2 | // This class was created by Nonnus, 3 | // who graciously decided to share it with the CocoaHTTPServer community. 4 | // 5 | 6 | #import 7 | #import "HTTPConnection.h" 8 | 9 | 10 | @interface MyHTTPConnection : HTTPConnection 11 | { 12 | // vodkhang 13 | // Delete these lines 14 | // int dataStartIndex; 15 | // NSMutableArray* multipartData; 16 | // BOOL postHeaderOK; 17 | } 18 | 19 | - (BOOL)isBrowseable:(NSString *)path; 20 | - (NSString *)createBrowseableIndex:(NSString *)path; 21 | 22 | //- (BOOL)supportsPOST:(NSString *)path withSize:(UInt64)contentLength; 23 | 24 | @end -------------------------------------------------------------------------------- /TabBarController/Classes/MyHTTPConnection.m: -------------------------------------------------------------------------------- 1 | // 2 | // This class was created by Nonnus, 3 | // who graciously decided to share it with the CocoaHTTPServer community. 4 | // 5 | 6 | #import "MyHTTPConnection.h" 7 | #import "HTTPServer.h" 8 | #import "HTTPResponse.h" 9 | #import "AsyncSocket.h" 10 | 11 | @implementation MyHTTPConnection 12 | 13 | /** 14 | * Returns whether or not the requested resource is browseable. 15 | **/ 16 | - (BOOL)isBrowseable:(NSString *)path 17 | { 18 | // Override me to provide custom configuration... 19 | // You can configure it for the entire server, or based on the current request 20 | 21 | return YES; 22 | } 23 | 24 | 25 | /** 26 | * This method creates a html browseable page. 27 | * Customize to fit your needs 28 | **/ 29 | - (NSString *)createBrowseableIndex:(NSString *)path 30 | { 31 | NSArray *array = [[NSFileManager defaultManager] directoryContentsAtPath:path]; 32 | 33 | NSMutableString *outdata = [NSMutableString new]; 34 | [outdata appendString:@""]; 35 | [outdata appendFormat:@"Files from %@", server.name]; 36 | [outdata appendString:@""]; 37 | [outdata appendString:@""]; 38 | [outdata appendFormat:@"

Files Uploader %@

", server.name]; 39 | [outdata appendString:@"The following files are located on GTCC Player."]; 40 | [outdata appendString:@"

"]; 41 | [outdata appendString:@"
"]; 42 | //[outdata appendFormat:@"..
\n"]; 43 | for (NSString *fname in array) 44 | { 45 | NSDictionary *fileDict = [[NSFileManager defaultManager] fileAttributesAtPath:[path stringByAppendingPathComponent:fname] traverseLink:NO]; 46 | //NSLog(@"fileDict: %@", fileDict); 47 | NSString *modDate = [[fileDict objectForKey:NSFileModificationDate] description]; 48 | if ([[fileDict objectForKey:NSFileType] isEqualToString: @"NSFileTypeDirectory"]) fname = [fname stringByAppendingString:@"/"]; 49 | [outdata appendFormat:@"%@ (%8.1f Kb)
\n", fname, fname, [[fileDict objectForKey:NSFileSize] floatValue] / 1024]; 50 | } 51 | [outdata appendString:@"
"]; 52 | [outdata appendString:@"

"]; 53 | 54 | if ([self supportsPOST:path withSize:0]) 55 | { 56 | [outdata appendString:@"
"]; 57 | [outdata appendString:@"
"]; 58 | [outdata appendString:@""]; 61 | [outdata appendString:@""]; 64 | [outdata appendString:@"
"]; 65 | [outdata appendString:@"
"]; 66 | } 67 | 68 | [outdata appendString:@""]; 69 | 70 | //NSLog(@"outData: %@", outdata); 71 | return [outdata autorelease]; 72 | } 73 | 74 | 75 | - (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)relativePath 76 | { 77 | if ([@"POST" isEqualToString:method]) 78 | { 79 | return YES; 80 | } 81 | 82 | return [super supportsMethod:method atPath:relativePath]; 83 | } 84 | 85 | 86 | 87 | 88 | /** 89 | * This method is called to get a response for a request. 90 | * You may return any object that adopts the HTTPResponse protocol. 91 | * The HTTPServer comes with two such classes: HTTPFileResponse and HTTPDataResponse. 92 | * HTTPFileResponse is a wrapper for an NSFileHandle object, and is the preferred way to send a file response. 93 | * HTTPDataResopnse is a wrapper for an NSData object, and may be used to send a custom response. 94 | **/ 95 | - (NSObject *)httpResponseForMethod:(NSString *)method URI:(NSString *)path 96 | { 97 | NSLog(@"httpResponseForURI: method:%@ path:%@", method, path); 98 | 99 | NSData *requestData = [(NSData *)CFHTTPMessageCopySerializedMessage(request) autorelease]; 100 | 101 | NSString *requestStr = [[[NSString alloc] initWithData:requestData encoding:NSASCIIStringEncoding] autorelease]; 102 | NSLog(@"\n=== Request ====================\n%@\n================================", requestStr); 103 | 104 | if (requestContentLength > 0) // Process POST data 105 | { 106 | NSLog(@"processing post data: %i", requestContentLength); 107 | 108 | if ([multipartData count] < 2) return nil; 109 | 110 | NSString* postInfo = [[NSString alloc] initWithBytes:[[multipartData objectAtIndex:1] bytes] 111 | length:[[multipartData objectAtIndex:1] length] 112 | encoding:NSUTF8StringEncoding]; 113 | 114 | NSArray* postInfoComponents = [postInfo componentsSeparatedByString:@"; filename="]; 115 | postInfoComponents = [[postInfoComponents lastObject] componentsSeparatedByString:@"\""]; 116 | postInfoComponents = [[postInfoComponents objectAtIndex:1] componentsSeparatedByString:@"\\"]; 117 | NSString* filename = [postInfoComponents lastObject]; 118 | 119 | if (![filename isEqualToString:@""]) //this makes sure we did not submitted upload form without selecting file 120 | { 121 | UInt16 separatorBytes = 0x0A0D; 122 | NSMutableData* separatorData = [NSMutableData dataWithBytes:&separatorBytes length:2]; 123 | [separatorData appendData:[multipartData objectAtIndex:0]]; 124 | int l = [separatorData length]; 125 | int count = 2; //number of times the separator shows up at the end of file data 126 | 127 | NSFileHandle* dataToTrim = [multipartData lastObject]; 128 | NSLog(@"data: %@", dataToTrim); 129 | 130 | for (unsigned long long i = [dataToTrim offsetInFile] - l; i > 0; i--) 131 | { 132 | [dataToTrim seekToFileOffset:i]; 133 | if ([[dataToTrim readDataOfLength:l] isEqualToData:separatorData]) 134 | { 135 | [dataToTrim truncateFileAtOffset:i]; 136 | i -= l; 137 | if (--count == 0) break; 138 | } 139 | } 140 | 141 | NSLog(@"NewFileUploaded"); 142 | [[NSNotificationCenter defaultCenter] postNotificationName:@"NewFileUploaded" object:nil]; 143 | } 144 | 145 | for (int n = 1; n < [multipartData count] - 1; n++) 146 | NSLog(@"%@", [[NSString alloc] initWithBytes:[[multipartData objectAtIndex:n] bytes] length:[[multipartData objectAtIndex:n] length] encoding:NSUTF8StringEncoding]); 147 | 148 | [postInfo release]; 149 | [multipartData release]; 150 | requestContentLength = 0; 151 | 152 | } 153 | 154 | NSString *filePath = [self filePathForURI:path]; 155 | 156 | if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) 157 | { 158 | return [[[HTTPFileResponse alloc] initWithFilePath:filePath] autorelease]; 159 | } 160 | else 161 | { 162 | NSString *folder = [path isEqualToString:@"/"] ? [[server documentRoot] path] : [NSString stringWithFormat: @"%@%@", [[server documentRoot] path], path]; 163 | 164 | if ([self isBrowseable:folder]) 165 | { 166 | //NSLog(@"folder: %@", folder); 167 | NSData *browseData = [[self createBrowseableIndex:folder] dataUsingEncoding:NSUTF8StringEncoding]; 168 | return [[[HTTPDataResponse alloc] initWithData:browseData] autorelease]; 169 | } 170 | } 171 | 172 | return nil; 173 | } 174 | 175 | 176 | /** 177 | * This method is called to handle data read from a POST. 178 | * The given data is part of the POST body. 179 | **/ 180 | - (void)processDataChunk:(NSData *)postDataChunk 181 | { 182 | // Override me to do something useful with a POST. 183 | // If the post is small, such as a simple form, you may want to simply append the data to the request. 184 | // If the post is big, such as a file upload, you may want to store the file to disk. 185 | // 186 | // Remember: In order to support LARGE POST uploads, the data is read in chunks. 187 | // This prevents a 50 MB upload from being stored in RAM. 188 | // The size of the chunks are limited by the POST_CHUNKSIZE definition. 189 | // Therefore, this method may be called multiple times for the same POST request. 190 | 191 | //NSLog(@"processPostDataChunk"); 192 | 193 | if (!postHeaderOK) 194 | { 195 | UInt16 separatorBytes = 0x0A0D; 196 | NSData* separatorData = [NSData dataWithBytes:&separatorBytes length:2]; 197 | 198 | int l = [separatorData length]; 199 | 200 | for (int i = 0; i < [postDataChunk length] - l; i++) 201 | { 202 | NSRange searchRange = {i, l}; 203 | 204 | if ([[postDataChunk subdataWithRange:searchRange] isEqualToData:separatorData]) 205 | { 206 | NSRange newDataRange = {dataStartIndex, i - dataStartIndex}; 207 | dataStartIndex = i + l; 208 | i += l - 1; 209 | NSData *newData = [postDataChunk subdataWithRange:newDataRange]; 210 | 211 | if ([newData length]) 212 | { 213 | [multipartData addObject:newData]; 214 | } 215 | else 216 | { 217 | postHeaderOK = TRUE; 218 | 219 | NSString* postInfo = [[NSString alloc] initWithBytes:[[multipartData objectAtIndex:1] bytes] length:[[multipartData objectAtIndex:1] length] encoding:NSUTF8StringEncoding]; 220 | NSArray* postInfoComponents = [postInfo componentsSeparatedByString:@"; filename="]; 221 | postInfoComponents = [[postInfoComponents lastObject] componentsSeparatedByString:@"\""]; 222 | postInfoComponents = [[postInfoComponents objectAtIndex:1] componentsSeparatedByString:@"\\"]; 223 | NSString* filename = [[[server documentRoot] path] stringByAppendingPathComponent:[postInfoComponents lastObject]]; 224 | NSRange fileDataRange = {dataStartIndex, [postDataChunk length] - dataStartIndex}; 225 | 226 | [[NSFileManager defaultManager] createFileAtPath:filename contents:[postDataChunk subdataWithRange:fileDataRange] attributes:nil]; 227 | NSFileHandle *file = [[NSFileHandle fileHandleForUpdatingAtPath:filename] retain]; 228 | 229 | if (file) 230 | { 231 | [file seekToEndOfFile]; 232 | [multipartData addObject:file]; 233 | } 234 | 235 | [postInfo release]; 236 | 237 | break; 238 | } 239 | } 240 | } 241 | } 242 | else 243 | { 244 | [(NSFileHandle*)[multipartData lastObject] writeData:postDataChunk]; 245 | } 246 | } 247 | 248 | @end -------------------------------------------------------------------------------- /TabBarController/Classes/NetworkController.h: -------------------------------------------------------------------------------- 1 | // 2 | // networkController.h 3 | // DiddyDJ 4 | // 5 | // Created by Richard Dearlove on 21/10/2008. 6 | // Copyright 2008 DiddySoft. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | @interface NetworkController : NSObject { 18 | 19 | } 20 | + (NSString *)localWifiIPAddress; 21 | + (NSString *) localIPAddress; 22 | + (BOOL)addressFromString:(NSString *)IPAddress address:(struct sockaddr_in *)address; 23 | + (NSString *) getIPAddressForHost: (NSString *) theHost; 24 | + (BOOL) hostAvailable: (NSString *) theHost; 25 | + (BOOL) connectedToNetwork; 26 | @end 27 | -------------------------------------------------------------------------------- /TabBarController/Classes/NetworkController.m: -------------------------------------------------------------------------------- 1 | // 2 | // networkController.m 3 | // 4 | // Created by Richard Dearlove on 21/10/2008. 5 | // Copyright 2008 DiddySoft. All rights reserved. 6 | // 7 | 8 | #import "NetworkController.h" 9 | 10 | @implementation NetworkController 11 | 12 | // Return the localized IP address 13 | 14 | // ---------------------------------------------------------------------------------------------------------- 15 | + (NSString *)localWifiIPAddress 16 | // ---------------------------------------------------------------------------------------------------------- 17 | 18 | { 19 | NSString *address = @"error"; 20 | struct ifaddrs *interfaces = NULL; 21 | struct ifaddrs *temp_addr = NULL; 22 | int success = 0; 23 | 24 | // retrieve the current interfaces - returns 0 on success 25 | success = getifaddrs(&interfaces); 26 | if (success == 0) 27 | { 28 | // Loop through linked list of interfaces 29 | temp_addr = interfaces; 30 | while(temp_addr != NULL) 31 | { 32 | if(temp_addr->ifa_addr->sa_family == AF_INET) 33 | { 34 | // Check if interface is en0 which is the wifi connection on the iPhone 35 | if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"] || 36 | [[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en1"]) 37 | { 38 | // Get NSString from C String 39 | address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)]; 40 | } 41 | } 42 | 43 | temp_addr = temp_addr->ifa_next; 44 | } 45 | } 46 | 47 | // Free memory 48 | freeifaddrs(interfaces); 49 | 50 | return address; 51 | } 52 | // ---------------------------------------------------------------------------------------------------------- 53 | 54 | // ---------------------------------------------------------------------------------------------------------- 55 | + (NSString *) localIPAddress 56 | // ---------------------------------------------------------------------------------------------------------- 57 | { 58 | char baseHostName[255]; 59 | gethostname(baseHostName, 255); 60 | 61 | // Adjust for iPhone -- add .local to the host name 62 | char hn[255]; 63 | sprintf(hn, "%s.local", baseHostName); 64 | 65 | struct hostent *host = gethostbyname(hn); 66 | if (host == NULL) 67 | { 68 | herror("resolv"); 69 | return NULL; 70 | } 71 | else { 72 | struct in_addr **list = (struct in_addr **)host->h_addr_list; 73 | return [NSString stringWithCString:inet_ntoa(*list[0])]; 74 | } 75 | 76 | return NULL; 77 | } 78 | 79 | // ---------------------------------------------------------------------------------------------------------- 80 | + (BOOL)addressFromString:(NSString *)IPAddress address:(struct sockaddr_in *)address 81 | // ---------------------------------------------------------------------------------------------------------- 82 | { 83 | if (!IPAddress || ![IPAddress length]) { 84 | return NO; 85 | } 86 | 87 | memset((char *) address, sizeof(struct sockaddr_in), 0); 88 | address->sin_family = AF_INET; 89 | address->sin_len = sizeof(struct sockaddr_in); 90 | 91 | int conversionResult = inet_aton([IPAddress UTF8String], &address->sin_addr); 92 | if (conversionResult == 0) { 93 | NSAssert1(conversionResult != 1, @"Failed to convert the IP address string into a sockaddr_in: %@", IPAddress); 94 | return NO; 95 | } 96 | 97 | return YES; 98 | } 99 | 100 | // ---------------------------------------------------------------------------------------------------------- 101 | + (NSString *) getIPAddressForHost: (NSString *) theHost 102 | // ---------------------------------------------------------------------------------------------------------- 103 | { 104 | struct hostent *host = gethostbyname([theHost UTF8String]); 105 | 106 | if (host == NULL) { 107 | herror("resolv"); 108 | return NULL; 109 | } 110 | 111 | struct in_addr **list = (struct in_addr **)host->h_addr_list; 112 | NSString *addressString = [NSString stringWithCString:inet_ntoa(*list[0])]; 113 | return addressString; 114 | } 115 | 116 | 117 | // ---------------------------------------------------------------------------------------------------------- 118 | + (BOOL) hostAvailable: (NSString *) theHost 119 | // ---------------------------------------------------------------------------------------------------------- 120 | { 121 | 122 | NSString *addressString = [self getIPAddressForHost:theHost]; 123 | if (!addressString) 124 | { 125 | printf("Error recovering IP address from host name\n"); 126 | return NO; 127 | } 128 | 129 | struct sockaddr_in address; 130 | BOOL gotAddress = [self addressFromString:addressString address:&address]; 131 | 132 | if (!gotAddress) 133 | { 134 | printf("Error recovering sockaddr address from %s\n", [addressString UTF8String]); 135 | return NO; 136 | } 137 | 138 | SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&address); 139 | SCNetworkReachabilityFlags flags; 140 | 141 | BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags); 142 | CFRelease(defaultRouteReachability); 143 | 144 | if (!didRetrieveFlags) 145 | { 146 | printf("Error. Could not recover network reachability flags\n"); 147 | return NO; 148 | } 149 | 150 | BOOL isReachable = flags & kSCNetworkFlagsReachable; 151 | return isReachable ? YES : NO;; 152 | } 153 | 154 | 155 | // ---------------------------------------------------------------------------------------------------------- 156 | + (BOOL) connectedToNetwork 157 | // ---------------------------------------------------------------------------------------------------------- 158 | { 159 | // Create zero addy 160 | struct sockaddr_in zeroAddress; 161 | bzero(&zeroAddress, sizeof(zeroAddress)); 162 | zeroAddress.sin_len = sizeof(zeroAddress); 163 | zeroAddress.sin_family = AF_INET; 164 | 165 | // Recover reachability flags 166 | SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&zeroAddress); 167 | CFRelease(defaultRouteReachability); 168 | 169 | SCNetworkReachabilityFlags flags; 170 | 171 | BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags); 172 | if (!didRetrieveFlags) 173 | { 174 | printf("Error. Could not recover network reachability flags\n"); 175 | return 0; 176 | } 177 | 178 | BOOL isReachable = flags & kSCNetworkFlagsReachable; 179 | BOOL needsConnection = flags & kSCNetworkFlagsConnectionRequired; 180 | // BOOL isEDGE = flags & kSCNetworkReachabilityFlagsIsWWAN; 181 | return (isReachable && !needsConnection) ? YES : NO; 182 | } 183 | 184 | 185 | @end 186 | -------------------------------------------------------------------------------- /TabBarController/Classes/iPhoneHTTPServerAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // This class was created by Nonnus, 3 | // who graciously decided to share it with the CocoaHTTPServer community. 4 | // 5 | 6 | #import 7 | @class HTTPServer; 8 | 9 | @interface iPhoneHTTPServerAppDelegate : NSObject 10 | { 11 | UIWindow *window; 12 | HTTPServer *httpServer; 13 | NSDictionary *addresses; 14 | BOOL *isOpened; 15 | 16 | IBOutlet UILabel *displayInfo; 17 | } 18 | 19 | @property (nonatomic, retain) IBOutlet UIWindow *window; 20 | 21 | -(IBAction) startStopServer:(id)sender; 22 | @end 23 | 24 | -------------------------------------------------------------------------------- /TabBarController/Classes/iPhoneHTTPServerAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // This class was created by Nonnus, 3 | // who graciously decided to share it with the CocoaHTTPServer community. 4 | // 5 | 6 | #import "iPhoneHTTPServerAppDelegate.h" 7 | #import "HTTPServer.h" 8 | #import "MyHTTPConnection.h" 9 | #import "localhostAddresses.h" 10 | 11 | 12 | @implementation iPhoneHTTPServerAppDelegate 13 | 14 | @synthesize window; 15 | 16 | - (void)applicationDidFinishLaunching:(UIApplication *)application 17 | { 18 | [window makeKeyAndVisible]; 19 | 20 | isOpened= false; 21 | //displayInfo.text =@"HTTP Server is not started!"; 22 | NSString *root = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0]; 23 | 24 | httpServer = [HTTPServer new]; 25 | [httpServer setType:@"_http._tcp."]; 26 | [httpServer setConnectionClass:[MyHTTPConnection class]]; 27 | [httpServer setDocumentRoot:[NSURL fileURLWithPath:root]]; 28 | 29 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(displayInfoUpdate:) name:@"LocalhostAdressesResolved" object:nil]; 30 | [localhostAddresses performSelectorInBackground:@selector(list) withObject:nil]; 31 | } 32 | 33 | - (void)displayInfoUpdate:(NSNotification *) notification 34 | { 35 | NSLog(@"displayInfoUpdate:"); 36 | 37 | if(notification) 38 | { 39 | [addresses release]; 40 | addresses = [[notification object] copy]; 41 | NSLog(@"addresses: %@", addresses); 42 | } 43 | 44 | if(addresses == nil) 45 | { 46 | return; 47 | } 48 | 49 | NSString *info; 50 | UInt16 port = [httpServer port]; 51 | 52 | NSString *localIP = nil; 53 | 54 | localIP = [addresses objectForKey:@"en0"]; 55 | 56 | if (!localIP) 57 | { 58 | localIP = [addresses objectForKey:@"en1"]; 59 | } 60 | 61 | if (!localIP) 62 | info = @"Wifi: No Connection!\n"; 63 | else if(isOpened) 64 | { 65 | info = [NSString stringWithFormat:@"Open below address on your Browser to upload file:\n http://%@:%d\n ", localIP, port]; 66 | displayInfo.text = info; 67 | displayInfo.textColor =[UIColor greenColor]; 68 | } 69 | 70 | //NSString *wwwIP = [addresses objectForKey:@"www"]; 71 | 72 | /*if (wwwIP) 73 | info = [info stringByAppendingFormat:@"Web: %@:%d\n", wwwIP, port]; 74 | else 75 | info = [info stringByAppendingString:@"Web: Unable to determine external IP\n"]; 76 | */ 77 | 78 | //displayInfo.text = info; 79 | } 80 | 81 | 82 | - (IBAction)startStopServer:(id)sender 83 | { 84 | if ([sender isOn]) 85 | { 86 | // You may OPTIONALLY set a port for the server to run on. 87 | // 88 | // If you don't set a port, the HTTP server will allow the OS to automatically pick an available port, 89 | // which avoids the potential problem of port conflicts. Allowing the OS server to automatically pick 90 | // an available port is probably the best way to do it if using Bonjour, since with Bonjour you can 91 | // automatically discover services, and the ports they are running on. 92 | //[httpServer setPort:8888]; 93 | 94 | NSError *error; 95 | if(![httpServer start:&error]) 96 | { 97 | NSLog(@"Error starting HTTP Server: %@", error); 98 | } 99 | isOpened = true; 100 | [self displayInfoUpdate:nil]; 101 | } 102 | else 103 | { 104 | [httpServer stop]; 105 | isOpened = false; 106 | displayInfo.text =@"HTTP Server is stopped!"; 107 | displayInfo.textColor =[UIColor redColor]; 108 | } 109 | } 110 | 111 | - (void)dealloc 112 | { 113 | [httpServer release]; 114 | [window release]; 115 | [displayInfo release]; 116 | [super dealloc]; 117 | } 118 | 119 | 120 | @end 121 | -------------------------------------------------------------------------------- /TabBarController/Classes/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | iosFtpServer 3 | Copyright (C) 2008 Richard Dearlove ( monsta ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #import 21 | 22 | #pragma mark LS replacement 23 | NSString* createList(NSString* directoryPath); 24 | 25 | #pragma mark Supporting Functions 26 | int filesinDirectory(NSString* filePath ); 27 | NSMutableString* int2BinString(int x); 28 | NSMutableString *byte2String(int x ); 29 | NSMutableString *bin2perms(NSString *binaryValue); 30 | -------------------------------------------------------------------------------- /TabBarController/Classes/list.m: -------------------------------------------------------------------------------- 1 | /* 2 | iosFtpServer 3 | Copyright (C) 2008 Richard Dearlove ( monsta ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | #import "list.h" 20 | 21 | // ---------------------------------------------------------------------------------------------------------- 22 | NSString* createList(NSString* directoryPath) 23 | // ---------------------------------------------------------------------------------------------------------- 24 | { 25 | NSFileManager *fileManager = [ NSFileManager defaultManager ]; 26 | NSDictionary *fileAttributes; 27 | NSError *error; 28 | 29 | NSString* fileType; 30 | NSNumber* filePermissions; 31 | long fileSubdirCount; 32 | NSString* fileOwner; 33 | NSString* fileGroup; 34 | NSNumber* fileSize; 35 | NSDate* fileModified; 36 | NSString* fileDateFormatted; 37 | NSDateFormatter* dateFormatter = [[[ NSDateFormatter alloc ] init ] autorelease ]; 38 | 39 | BOOL fileIsDirectory; 40 | 41 | 42 | NSMutableString* returnString= [ NSMutableString new ]; 43 | NSString* formattedString; 44 | 45 | NSString* binaryString; 46 | 47 | [returnString appendString:@"\r\n"]; 48 | 49 | NSDirectoryEnumerator *dirEnum = [fileManager enumeratorAtPath:directoryPath]; 50 | NSString *filePath; 51 | 52 | NSString* firstChar; 53 | NSString* fullFilePath; 54 | 55 | [dateFormatter setDateFormat:@"MMM dd HH:mm"]; 56 | NSLocale *englishLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en"]; 57 | [dateFormatter setLocale:englishLocale]; 58 | [englishLocale release]; 59 | 60 | 61 | NSLog(@"Get LS for %@", directoryPath ); 62 | int numberOfFiles = 0; 63 | while (filePath = [dirEnum nextObject]) { 64 | 65 | firstChar = [ filePath substringToIndex:1 ]; 66 | 67 | [dirEnum skipDescendents ]; // don't go down that recursive road 68 | 69 | if ( ![ firstChar isEqualToString:@"."] ) // dont show hidden files 70 | { 71 | fullFilePath = [directoryPath stringByAppendingPathComponent:filePath]; 72 | 73 | fileAttributes = [ fileManager attributesOfItemAtPath:fullFilePath error:&error ]; 74 | 75 | fileType = [ fileAttributes valueForKey:NSFileType ]; 76 | 77 | filePermissions = [ fileAttributes valueForKey:NSFilePosixPermissions ]; 78 | fileSubdirCount = filesinDirectory(fullFilePath); 79 | fileOwner = [ fileAttributes valueForKey:NSFileOwnerAccountName ]; 80 | fileGroup = [ fileAttributes valueForKey:NSFileGroupOwnerAccountName ]; 81 | fileSize = [ fileAttributes valueForKey:NSFileSize ]; 82 | fileModified = [ fileAttributes valueForKey:NSFileModificationDate ]; 83 | fileDateFormatted = [ dateFormatter stringFromDate:fileModified ]; 84 | 85 | fileIsDirectory = (fileType == NSFileTypeDirectory ); 86 | 87 | 88 | fileSubdirCount = fileSubdirCount <1 ? 1 : fileSubdirCount; 89 | 90 | binaryString = int2BinString([filePermissions unsignedLongValue]) ; 91 | binaryString = [ binaryString substringFromIndex:7 ];// snip off the front 92 | formattedString = [ NSString stringWithFormat:@"%@%@ %5i %12@ %12@ %10qu %@ %@", fileIsDirectory ? @"d" : @"-" ,bin2perms(binaryString),fileSubdirCount, fileOwner, fileGroup, [fileSize unsignedLongLongValue], fileDateFormatted , filePath ]; 93 | 94 | [ returnString appendString:formattedString ]; 95 | [ returnString appendString:@"\n" ]; 96 | numberOfFiles++; 97 | } 98 | } 99 | [returnString insertString: [NSString stringWithFormat:@"total %d", numberOfFiles] atIndex:0]; 100 | // NSLog(returnString ); 101 | return [returnString autorelease]; // FIXME - release count 102 | 103 | } 104 | // ---------------------------------------------------------------------------------------------------------- 105 | int filesinDirectory(NSString* filePath ) 106 | // ---------------------------------------------------------------------------------------------------------- 107 | { 108 | int no_files =0; 109 | NSFileManager *fileManager = [ NSFileManager defaultManager ]; 110 | NSDirectoryEnumerator *dirEnum = [fileManager enumeratorAtPath:filePath]; 111 | 112 | while (filePath = [dirEnum nextObject]) { 113 | [dirEnum skipDescendents ]; // don't want children 114 | no_files++; 115 | } 116 | 117 | return no_files; 118 | } 119 | // ---------------------------------------------------------------------------------------------------------- 120 | NSMutableString* int2BinString(int x) 121 | // ---------------------------------------------------------------------------------------------------------- 122 | { 123 | NSMutableString *returnString = [[ NSMutableString alloc ] init]; 124 | int hi, lo; 125 | hi=(x>>8) & 0xff; 126 | lo=x&0xff; 127 | 128 | [ returnString appendString:byte2String(hi) ]; 129 | [ returnString appendString:byte2String(lo) ]; 130 | return [ returnString autorelease ]; 131 | } 132 | 133 | 134 | 135 | // ---------------------------------------------------------------------------------------------------------- 136 | NSMutableString *byte2String(int x ) 137 | // ---------------------------------------------------------------------------------------------------------- 138 | { 139 | NSMutableString *returnString = [[ NSMutableString alloc ]init]; 140 | 141 | int n; 142 | 143 | for(n=0; n<8; n++) 144 | { 145 | if((x & 0x80) !=0) 146 | { 147 | 148 | [ returnString appendString:@"1"]; 149 | 150 | 151 | } 152 | else 153 | { 154 | [ returnString appendString:@"0"]; 155 | } 156 | x = x<<1; 157 | } 158 | 159 | return [returnString autorelease]; 160 | } 161 | 162 | // ---------------------------------------------------------------------------------------------------------- 163 | NSMutableString *bin2perms(NSString *binaryValue) 164 | // ---------------------------------------------------------------------------------------------------------- 165 | { 166 | NSMutableString *returnString = [[ NSMutableString alloc ] init]; 167 | NSRange subStringRange; 168 | subStringRange.length = 1; 169 | NSString *replaceWithChar; 170 | 171 | for (int n=0; n < [binaryValue length]; n++) 172 | { 173 | subStringRange.location = n; 174 | // take the char 175 | // if pos = 0, 3,6 176 | if ( n == 0 || n == 3 || n ==6) 177 | { 178 | replaceWithChar = @"r"; 179 | } 180 | if ( n == 1 || n == 4 || n ==7) 181 | { 182 | replaceWithChar = @"w"; 183 | } 184 | if ( n == 2 || n == 5 || n ==7) 185 | { 186 | replaceWithChar = @"x"; 187 | } 188 | 189 | if ( [[binaryValue substringWithRange:subStringRange ] isEqualToString:@"1" ] ) 190 | { 191 | [ returnString appendString:replaceWithChar ]; 192 | } 193 | else 194 | { 195 | [ returnString appendString:@"-" ]; 196 | } 197 | 198 | } 199 | 200 | return [ returnString autorelease ]; 201 | } 202 | 203 | -------------------------------------------------------------------------------- /TabBarController/Classes/localhostAddresses.h: -------------------------------------------------------------------------------- 1 | // 2 | // This class was created by Nonnus, 3 | // who graciously decided to share it with the CocoaHTTPServer community. 4 | // 5 | 6 | #import 7 | 8 | 9 | @interface localhostAddresses : NSObject { 10 | 11 | } 12 | 13 | + (void)list; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TabBarController/Classes/localhostAddresses.m: -------------------------------------------------------------------------------- 1 | // 2 | // This class was created by Nonnus, 3 | // who graciously decided to share it with the CocoaHTTPServer community. 4 | // 5 | 6 | #import "localhostAddresses.h" 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | @implementation localhostAddresses 13 | 14 | + (void)list 15 | { 16 | NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 17 | 18 | NSMutableDictionary* result = [NSMutableDictionary dictionary]; 19 | struct ifaddrs* addrs; 20 | BOOL success = (getifaddrs(&addrs) == 0); 21 | if (success) 22 | { 23 | const struct ifaddrs* cursor = addrs; 24 | while (cursor != NULL) 25 | { 26 | NSMutableString* ip; 27 | if (cursor->ifa_addr->sa_family == AF_INET) 28 | { 29 | const struct sockaddr_in* dlAddr = (const struct sockaddr_in*)cursor->ifa_addr; 30 | const uint8_t* base = (const uint8_t*)&dlAddr->sin_addr; 31 | ip = [[NSMutableString new] autorelease]; 32 | for (int i = 0; i < 4; i++) 33 | { 34 | if (i != 0) 35 | [ip appendFormat:@"."]; 36 | [ip appendFormat:@"%d", base[i]]; 37 | } 38 | [result setObject:(NSString*)ip forKey:[NSString stringWithFormat:@"%s", cursor->ifa_name]]; 39 | } 40 | cursor = cursor->ifa_next; 41 | } 42 | freeifaddrs(addrs); 43 | } 44 | 45 | NSURL *netIPURL = [NSURL URLWithString:@"http://whatismyip.org"]; 46 | NSString *netIP = [NSString stringWithContentsOfURL:netIPURL encoding:NSUTF8StringEncoding error:nil]; 47 | if (netIP) 48 | [result setObject:netIP forKey:@"www"]; 49 | NSLog(@"IP addresses: %@", result); 50 | [[NSNotificationCenter defaultCenter] postNotificationName:@"LocalhostAdressesResolved" object:result]; 51 | 52 | [pool release]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /TabBarController/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "60x60", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "29x29", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "40x40", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "76x76", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /TabBarController/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "8.0", 8 | "subtype" : "736h", 9 | "scale" : "3x" 10 | }, 11 | { 12 | "orientation" : "landscape", 13 | "idiom" : "iphone", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "8.0", 16 | "subtype" : "736h", 17 | "scale" : "3x" 18 | }, 19 | { 20 | "orientation" : "portrait", 21 | "idiom" : "iphone", 22 | "extent" : "full-screen", 23 | "minimum-system-version" : "8.0", 24 | "subtype" : "667h", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "orientation" : "portrait", 29 | "idiom" : "iphone", 30 | "extent" : "full-screen", 31 | "minimum-system-version" : "7.0", 32 | "scale" : "2x" 33 | }, 34 | { 35 | "orientation" : "portrait", 36 | "idiom" : "iphone", 37 | "extent" : "full-screen", 38 | "minimum-system-version" : "7.0", 39 | "subtype" : "retina4", 40 | "scale" : "2x" 41 | }, 42 | { 43 | "orientation" : "portrait", 44 | "idiom" : "ipad", 45 | "extent" : "full-screen", 46 | "minimum-system-version" : "7.0", 47 | "scale" : "1x" 48 | }, 49 | { 50 | "orientation" : "landscape", 51 | "idiom" : "ipad", 52 | "extent" : "full-screen", 53 | "minimum-system-version" : "7.0", 54 | "scale" : "1x" 55 | }, 56 | { 57 | "orientation" : "portrait", 58 | "idiom" : "ipad", 59 | "extent" : "full-screen", 60 | "minimum-system-version" : "7.0", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "orientation" : "landscape", 65 | "idiom" : "ipad", 66 | "extent" : "full-screen", 67 | "minimum-system-version" : "7.0", 68 | "scale" : "2x" 69 | }, 70 | { 71 | "orientation" : "portrait", 72 | "idiom" : "iphone", 73 | "extent" : "full-screen", 74 | "scale" : "1x" 75 | }, 76 | { 77 | "orientation" : "portrait", 78 | "idiom" : "iphone", 79 | "extent" : "full-screen", 80 | "scale" : "2x" 81 | }, 82 | { 83 | "orientation" : "portrait", 84 | "idiom" : "iphone", 85 | "extent" : "full-screen", 86 | "subtype" : "retina4", 87 | "scale" : "2x" 88 | }, 89 | { 90 | "orientation" : "portrait", 91 | "idiom" : "ipad", 92 | "extent" : "to-status-bar", 93 | "scale" : "1x" 94 | }, 95 | { 96 | "orientation" : "portrait", 97 | "idiom" : "ipad", 98 | "extent" : "full-screen", 99 | "scale" : "1x" 100 | }, 101 | { 102 | "orientation" : "landscape", 103 | "idiom" : "ipad", 104 | "extent" : "to-status-bar", 105 | "scale" : "1x" 106 | }, 107 | { 108 | "orientation" : "landscape", 109 | "idiom" : "ipad", 110 | "extent" : "full-screen", 111 | "scale" : "1x" 112 | }, 113 | { 114 | "orientation" : "portrait", 115 | "idiom" : "ipad", 116 | "extent" : "to-status-bar", 117 | "scale" : "2x" 118 | }, 119 | { 120 | "orientation" : "portrait", 121 | "idiom" : "ipad", 122 | "extent" : "full-screen", 123 | "scale" : "2x" 124 | }, 125 | { 126 | "orientation" : "landscape", 127 | "idiom" : "ipad", 128 | "extent" : "to-status-bar", 129 | "scale" : "2x" 130 | }, 131 | { 132 | "orientation" : "landscape", 133 | "idiom" : "ipad", 134 | "extent" : "full-screen", 135 | "scale" : "2x" 136 | } 137 | ], 138 | "info" : { 139 | "version" : 1, 140 | "author" : "xcode" 141 | } 142 | } -------------------------------------------------------------------------------- /TabBarController/Images.xcassets/second.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "second.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "second@2x.png" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /TabBarController/Images.xcassets/second.imageset/second.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/Images.xcassets/second.imageset/second.png -------------------------------------------------------------------------------- /TabBarController/Images.xcassets/second.imageset/second@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/Images.xcassets/second.imageset/second@2x.png -------------------------------------------------------------------------------- /TabBarController/Images.xcassets/video.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "first.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "first@2x.png" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /TabBarController/Images.xcassets/video.imageset/first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/Images.xcassets/video.imageset/first.png -------------------------------------------------------------------------------- /TabBarController/Images.xcassets/video.imageset/first@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/Images.xcassets/video.imageset/first@2x.png -------------------------------------------------------------------------------- /TabBarController/MovieInfosViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MovieInfosViewController.h 3 | // AVPlayer 4 | // 5 | // Created by apple on 13-5-29. 6 | // Copyright (c) 2013年 iMoreApp Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MovieInfosViewController : UIViewController 12 | 13 | @property (nonatomic, weak) IBOutlet UILabel *durationLabel; 14 | @property (nonatomic, weak) IBOutlet UILabel *videoSizeLabel; 15 | @property (nonatomic, weak) IBOutlet UIImageView *thumbnailsImageView; 16 | 17 | @property (nonatomic, strong) NSString *moviePath; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /TabBarController/MovieInfosViewController.mm: -------------------------------------------------------------------------------- 1 | // 2 | // MovieInfosViewController.m 3 | // AVPlayer 4 | // 5 | // Created by apple on 13-5-29. 6 | // Copyright (c) 2013年 iMoreApp Inc. All rights reserved. 7 | // 8 | 9 | #import "MovieInfosViewController.h" 10 | #import 11 | #import 12 | 13 | @implementation MovieInfosViewController 14 | 15 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 16 | { 17 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 18 | if (self) { 19 | // Custom initialization 20 | } 21 | return self; 22 | } 23 | 24 | - (void)viewDidLoad 25 | { 26 | [super viewDidLoad]; 27 | 28 | // Do any additional setup after loading the view. 29 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 30 | 31 | @autoreleasepool { 32 | NSTimeInterval duration = 0; 33 | CGSize frameSize = CGSizeZero; 34 | UIImage *thumbnails = nil; 35 | 36 | AVParser *mp = [[AVParser alloc] init]; 37 | if ([mp open:self.moviePath]) { 38 | 39 | duration = mp.duration; 40 | frameSize = CGSizeMake(mp.frameWidth, mp.frameHeight); 41 | thumbnails = [mp thumbnailAtTime:fminf(20, mp.duration/2.0)]; 42 | mp = nil; 43 | } 44 | 45 | dispatch_async(dispatch_get_main_queue(), ^{ 46 | self.durationLabel.text = [AVPlayerController formatTimeInterval:duration isLeft:NO]; 47 | self.videoSizeLabel.text = [NSString stringWithFormat:@"%d * %d", (int)frameSize.width, (int)frameSize.height]; 48 | self.thumbnailsImageView.image = thumbnails; 49 | }); 50 | } 51 | }); 52 | } 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /TabBarController/TabBarController-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | XC.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Main_iPhone 29 | UIMainStoryboardFile~ipad 30 | Main_iPad 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UIStatusBarTintParameters 36 | 37 | UINavigationBar 38 | 39 | Style 40 | UIBarStyleDefault 41 | Translucent 42 | 43 | 44 | 45 | UISupportedInterfaceOrientations 46 | 47 | UIInterfaceOrientationPortrait 48 | UIInterfaceOrientationLandscapeLeft 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | UISupportedInterfaceOrientations~ipad 52 | 53 | UIInterfaceOrientationPortrait 54 | UIInterfaceOrientationPortraitUpsideDown 55 | UIInterfaceOrientationLandscapeLeft 56 | UIInterfaceOrientationLandscapeRight 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /TabBarController/TabBarController-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /TabBarController/UIAlertView+Blocks.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertView+Blocks.h 3 | // UIAlertViewBlocks 4 | // 5 | // Created by Ryan Maxwell on 29/08/13. 6 | // 7 | // The MIT License (MIT) 8 | // 9 | // Copyright (c) 2013 Ryan Maxwell 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 12 | // this software and associated documentation files (the "Software"), to deal in 13 | // the Software without restriction, including without limitation the rights to 14 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | // the Software, and to permit persons to whom the Software is furnished to do so, 16 | // subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import 30 | 31 | typedef void (^UIAlertViewBlock) (UIAlertView *alertView); 32 | typedef void (^UIAlertViewCompletionBlock) (UIAlertView *alertView, NSInteger buttonIndex); 33 | 34 | @interface UIAlertView (Blocks) 35 | 36 | + (instancetype)showWithTitle:(NSString *)title 37 | message:(NSString *)message 38 | style:(UIAlertViewStyle)style 39 | cancelButtonTitle:(NSString *)cancelButtonTitle 40 | otherButtonTitles:(NSArray *)otherButtonTitles 41 | tapBlock:(UIAlertViewCompletionBlock)tapBlock; 42 | 43 | + (instancetype)showWithTitle:(NSString *)title 44 | message:(NSString *)message 45 | cancelButtonTitle:(NSString *)cancelButtonTitle 46 | otherButtonTitles:(NSArray *)otherButtonTitles 47 | tapBlock:(UIAlertViewCompletionBlock)tapBlock; 48 | 49 | @property (copy, nonatomic) UIAlertViewCompletionBlock tapBlock; 50 | @property (copy, nonatomic) UIAlertViewCompletionBlock willDismissBlock; 51 | @property (copy, nonatomic) UIAlertViewCompletionBlock didDismissBlock; 52 | 53 | @property (copy, nonatomic) UIAlertViewBlock willPresentBlock; 54 | @property (copy, nonatomic) UIAlertViewBlock didPresentBlock; 55 | @property (copy, nonatomic) UIAlertViewBlock cancelBlock; 56 | 57 | @property (copy, nonatomic) BOOL(^shouldEnableFirstOtherButtonBlock)(UIAlertView *alertView); 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /TabBarController/UIAlertView+Blocks.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertView+Blocks.m 3 | // UIAlertViewBlocks 4 | // 5 | // Created by Ryan Maxwell on 29/08/13. 6 | // 7 | // The MIT License (MIT) 8 | // 9 | // Copyright (c) 2013 Ryan Maxwell 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 12 | // this software and associated documentation files (the "Software"), to deal in 13 | // the Software without restriction, including without limitation the rights to 14 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | // the Software, and to permit persons to whom the Software is furnished to do so, 16 | // subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import "UIAlertView+Blocks.h" 30 | 31 | #import 32 | 33 | static const void *UIAlertViewOriginalDelegateKey = &UIAlertViewOriginalDelegateKey; 34 | 35 | static const void *UIAlertViewTapBlockKey = &UIAlertViewTapBlockKey; 36 | static const void *UIAlertViewWillPresentBlockKey = &UIAlertViewWillPresentBlockKey; 37 | static const void *UIAlertViewDidPresentBlockKey = &UIAlertViewDidPresentBlockKey; 38 | static const void *UIAlertViewWillDismissBlockKey = &UIAlertViewWillDismissBlockKey; 39 | static const void *UIAlertViewDidDismissBlockKey = &UIAlertViewDidDismissBlockKey; 40 | static const void *UIAlertViewCancelBlockKey = &UIAlertViewCancelBlockKey; 41 | static const void *UIAlertViewShouldEnableFirstOtherButtonBlockKey = &UIAlertViewShouldEnableFirstOtherButtonBlockKey; 42 | 43 | @implementation UIAlertView (Blocks) 44 | 45 | + (instancetype)showWithTitle:(NSString *)title 46 | message:(NSString *)message 47 | style:(UIAlertViewStyle)style 48 | cancelButtonTitle:(NSString *)cancelButtonTitle 49 | otherButtonTitles:(NSArray *)otherButtonTitles 50 | tapBlock:(UIAlertViewCompletionBlock)tapBlock { 51 | 52 | UIAlertView *alertView = [[self alloc] initWithTitle:title 53 | message:message 54 | delegate:nil 55 | cancelButtonTitle:cancelButtonTitle 56 | otherButtonTitles:[otherButtonTitles firstObject], nil]; 57 | 58 | alertView.alertViewStyle = style; 59 | 60 | if (otherButtonTitles.count > 1) { 61 | for (NSString *buttonTitle in [otherButtonTitles subarrayWithRange:NSMakeRange(1, otherButtonTitles.count - 1)]) { 62 | [alertView addButtonWithTitle:buttonTitle]; 63 | } 64 | } 65 | 66 | if (tapBlock) { 67 | alertView.tapBlock = tapBlock; 68 | } 69 | 70 | [alertView show]; 71 | 72 | #if !__has_feature(objc_arc) 73 | return [alertView autorelease]; 74 | #else 75 | return alertView; 76 | #endif 77 | } 78 | 79 | 80 | + (instancetype)showWithTitle:(NSString *)title 81 | message:(NSString *)message 82 | cancelButtonTitle:(NSString *)cancelButtonTitle 83 | otherButtonTitles:(NSArray *)otherButtonTitles 84 | tapBlock:(UIAlertViewCompletionBlock)tapBlock { 85 | 86 | return [self showWithTitle:title 87 | message:message 88 | style:UIAlertViewStyleDefault 89 | cancelButtonTitle:cancelButtonTitle 90 | otherButtonTitles:otherButtonTitles 91 | tapBlock:tapBlock]; 92 | } 93 | 94 | #pragma mark - 95 | 96 | - (void)_checkAlertViewDelegate { 97 | if (self.delegate != (id)self) { 98 | objc_setAssociatedObject(self, UIAlertViewOriginalDelegateKey, self.delegate, OBJC_ASSOCIATION_ASSIGN); 99 | self.delegate = (id)self; 100 | } 101 | } 102 | 103 | - (UIAlertViewCompletionBlock)tapBlock { 104 | return objc_getAssociatedObject(self, UIAlertViewTapBlockKey); 105 | } 106 | 107 | - (void)setTapBlock:(UIAlertViewCompletionBlock)tapBlock { 108 | [self _checkAlertViewDelegate]; 109 | objc_setAssociatedObject(self, UIAlertViewTapBlockKey, tapBlock, OBJC_ASSOCIATION_COPY); 110 | } 111 | 112 | - (UIAlertViewCompletionBlock)willDismissBlock { 113 | return objc_getAssociatedObject(self, UIAlertViewWillDismissBlockKey); 114 | } 115 | 116 | - (void)setWillDismissBlock:(UIAlertViewCompletionBlock)willDismissBlock { 117 | [self _checkAlertViewDelegate]; 118 | objc_setAssociatedObject(self, UIAlertViewWillDismissBlockKey, willDismissBlock, OBJC_ASSOCIATION_COPY); 119 | } 120 | 121 | - (UIAlertViewCompletionBlock)didDismissBlock { 122 | return objc_getAssociatedObject(self, UIAlertViewDidDismissBlockKey); 123 | } 124 | 125 | - (void)setDidDismissBlock:(UIAlertViewCompletionBlock)didDismissBlock { 126 | [self _checkAlertViewDelegate]; 127 | objc_setAssociatedObject(self, UIAlertViewDidDismissBlockKey, didDismissBlock, OBJC_ASSOCIATION_COPY); 128 | } 129 | 130 | - (UIAlertViewBlock)willPresentBlock { 131 | return objc_getAssociatedObject(self, UIAlertViewWillPresentBlockKey); 132 | } 133 | 134 | - (void)setWillPresentBlock:(UIAlertViewBlock)willPresentBlock { 135 | [self _checkAlertViewDelegate]; 136 | objc_setAssociatedObject(self, UIAlertViewWillPresentBlockKey, willPresentBlock, OBJC_ASSOCIATION_COPY); 137 | } 138 | 139 | - (UIAlertViewBlock)didPresentBlock { 140 | return objc_getAssociatedObject(self, UIAlertViewDidPresentBlockKey); 141 | } 142 | 143 | - (void)setDidPresentBlock:(UIAlertViewBlock)didPresentBlock { 144 | [self _checkAlertViewDelegate]; 145 | objc_setAssociatedObject(self, UIAlertViewDidPresentBlockKey, didPresentBlock, OBJC_ASSOCIATION_COPY); 146 | } 147 | 148 | - (UIAlertViewBlock)cancelBlock { 149 | return objc_getAssociatedObject(self, UIAlertViewCancelBlockKey); 150 | } 151 | 152 | - (void)setCancelBlock:(UIAlertViewBlock)cancelBlock { 153 | [self _checkAlertViewDelegate]; 154 | objc_setAssociatedObject(self, UIAlertViewCancelBlockKey, cancelBlock, OBJC_ASSOCIATION_COPY); 155 | } 156 | 157 | - (void)setShouldEnableFirstOtherButtonBlock:(BOOL(^)(UIAlertView *alertView))shouldEnableFirstOtherButtonBlock { 158 | [self _checkAlertViewDelegate]; 159 | objc_setAssociatedObject(self, UIAlertViewShouldEnableFirstOtherButtonBlockKey, shouldEnableFirstOtherButtonBlock, OBJC_ASSOCIATION_COPY); 160 | } 161 | 162 | - (BOOL(^)(UIAlertView *alertView))shouldEnableFirstOtherButtonBlock { 163 | return objc_getAssociatedObject(self, UIAlertViewShouldEnableFirstOtherButtonBlockKey); 164 | } 165 | 166 | #pragma mark - UIAlertViewDelegate 167 | 168 | - (void)willPresentAlertView:(UIAlertView *)alertView { 169 | UIAlertViewBlock block = alertView.willPresentBlock; 170 | 171 | if (block) { 172 | block(alertView); 173 | } 174 | 175 | id originalDelegate = objc_getAssociatedObject(self, UIAlertViewOriginalDelegateKey); 176 | if (originalDelegate && [originalDelegate respondsToSelector:@selector(willPresentAlertView:)]) { 177 | [originalDelegate willPresentAlertView:alertView]; 178 | } 179 | } 180 | 181 | - (void)didPresentAlertView:(UIAlertView *)alertView { 182 | UIAlertViewBlock block = alertView.didPresentBlock; 183 | 184 | if (block) { 185 | block(alertView); 186 | } 187 | 188 | id originalDelegate = objc_getAssociatedObject(self, UIAlertViewOriginalDelegateKey); 189 | if (originalDelegate && [originalDelegate respondsToSelector:@selector(didPresentAlertView:)]) { 190 | [originalDelegate didPresentAlertView:alertView]; 191 | } 192 | } 193 | 194 | 195 | - (void)alertViewCancel:(UIAlertView *)alertView { 196 | UIAlertViewBlock block = alertView.cancelBlock; 197 | 198 | if (block) { 199 | block(alertView); 200 | } 201 | 202 | id originalDelegate = objc_getAssociatedObject(self, UIAlertViewOriginalDelegateKey); 203 | if (originalDelegate && [originalDelegate respondsToSelector:@selector(alertViewCancel:)]) { 204 | [originalDelegate alertViewCancel:alertView]; 205 | } 206 | } 207 | 208 | - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 209 | UIAlertViewCompletionBlock completion = alertView.tapBlock; 210 | 211 | if (completion) { 212 | completion(alertView, buttonIndex); 213 | } 214 | 215 | id originalDelegate = objc_getAssociatedObject(self, UIAlertViewOriginalDelegateKey); 216 | if (originalDelegate && [originalDelegate respondsToSelector:@selector(alertView:clickedButtonAtIndex:)]) { 217 | [originalDelegate alertView:alertView clickedButtonAtIndex:buttonIndex]; 218 | } 219 | } 220 | 221 | - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex { 222 | UIAlertViewCompletionBlock completion = alertView.willDismissBlock; 223 | 224 | if (completion) { 225 | completion(alertView, buttonIndex); 226 | } 227 | 228 | id originalDelegate = objc_getAssociatedObject(self, UIAlertViewOriginalDelegateKey); 229 | if (originalDelegate && [originalDelegate respondsToSelector:@selector(alertView:willDismissWithButtonIndex:)]) { 230 | [originalDelegate alertView:alertView willDismissWithButtonIndex:buttonIndex]; 231 | } 232 | } 233 | 234 | - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { 235 | UIAlertViewCompletionBlock completion = alertView.didDismissBlock; 236 | 237 | if (completion) { 238 | completion(alertView, buttonIndex); 239 | } 240 | 241 | id originalDelegate = objc_getAssociatedObject(self, UIAlertViewOriginalDelegateKey); 242 | if (originalDelegate && [originalDelegate respondsToSelector:@selector(alertView:didDismissWithButtonIndex:)]) { 243 | [originalDelegate alertView:alertView didDismissWithButtonIndex:buttonIndex]; 244 | } 245 | } 246 | 247 | - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView { 248 | BOOL(^shouldEnableFirstOtherButtonBlock)(UIAlertView *alertView) = alertView.shouldEnableFirstOtherButtonBlock; 249 | 250 | if (shouldEnableFirstOtherButtonBlock) { 251 | return shouldEnableFirstOtherButtonBlock(alertView); 252 | } 253 | 254 | id originalDelegate = objc_getAssociatedObject(self, UIAlertViewOriginalDelegateKey); 255 | if (originalDelegate && [originalDelegate respondsToSelector:@selector(alertViewShouldEnableFirstOtherButton:)]) { 256 | return [originalDelegate alertViewShouldEnableFirstOtherButton:alertView]; 257 | } 258 | 259 | return YES; 260 | } 261 | 262 | @end 263 | -------------------------------------------------------------------------------- /TabBarController/VideoEffectView.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoEffectView.h 3 | // AVPlayerDemo 4 | // 5 | // Created by apple on 3/4/14. 6 | // Copyright (c) 2014 apple. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface VideoEffectView : UIView 12 | @property (weak, nonatomic) IBOutlet UISlider *brightnessSlider; 13 | @property (weak, nonatomic) IBOutlet UISlider *contrastSlider; 14 | @property (weak, nonatomic) IBOutlet UISlider *saturationSlider; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /TabBarController/VideoEffectView.m: -------------------------------------------------------------------------------- 1 | // 2 | // VideoEffectView.m 3 | // AVPlayerDemo 4 | // 5 | // Created by apple on 3/4/14. 6 | // Copyright (c) 2014 apple. All rights reserved. 7 | // 8 | 9 | #import "VideoEffectView.h" 10 | 11 | @implementation VideoEffectView 12 | 13 | - (id)initWithFrame:(CGRect)frame 14 | { 15 | self = [super initWithFrame:frame]; 16 | if (self) { 17 | // Initialization code 18 | } 19 | return self; 20 | } 21 | 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/audioTrackIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/audioTrackIcon.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/audioTrackIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/audioTrackIcon@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/hudbackground_ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/hudbackground_ipad.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/hudbackground_ipad@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/hudbackground_ipad@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/hudbackground_iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/hudbackground_iphone.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/hudbackground_iphone@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/hudbackground_iphone@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/music_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/music_icon.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/music_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/music_icon@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/playback_ff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/playback_ff.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/playback_ff@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/playback_ff@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/playback_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/playback_pause.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/playback_pause@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/playback_pause@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/playback_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/playback_play.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/playback_play@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/playback_play@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/playback_prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/playback_prev.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/playback_prev@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/playback_prev@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/speedIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/speedIcon.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/speedIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/speedIcon@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/subtitleIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/subtitleIcon.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/subtitleIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/subtitleIcon@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/videoEffectsIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/videoEffectsIcon.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/videoEffectsIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/videoEffectsIcon@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/zoomin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/zoomin.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/zoomin@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/zoomin@2x.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/zoomout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/zoomout.png -------------------------------------------------------------------------------- /TabBarController/avplayer.bundle/zoomout@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/TabBarController/avplayer.bundle/zoomout@2x.png -------------------------------------------------------------------------------- /TabBarController/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /TabBarController/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TabBarController 4 | // 5 | // Created by gtcc on 2/19/14. 6 | // Copyright (c) 2014 xc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "BIDAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([BIDAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /TabBarControllerTests/TabBarControllerTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | XC.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /TabBarControllerTests/TabBarControllerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TabBarControllerTests.m 3 | // TabBarControllerTests 4 | // 5 | // Created by gtcc on 2/19/14. 6 | // Copyright (c) 2014 xc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TabBarControllerTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation TabBarControllerTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /TabBarControllerTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /VideoListTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoListTableViewController.h 3 | // TabBarController 4 | // 5 | // Created by gtcc on 2/19/14. 6 | // Copyright (c) 2014 xc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | @interface VideoListTableViewController : UITableViewController 13 | @property (nonatomic, retain) NSMutableArray* FileList; 14 | @property (nonatomic,retain) UIViewController* moviePlayViewController; 15 | @property (nonatomic,retain) MPMoviePlayerController* moviePlayerController; 16 | @end 17 | -------------------------------------------------------------------------------- /VideoListTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // VideoListTableViewController.m 3 | // TabBarController 4 | // 5 | // Created by gtcc on 2/19/14. 6 | // Copyright (c) 2014 xc. All rights reserved. 7 | // 8 | 9 | #import "VideoListTableViewController.h" 10 | #import "AVPlayerViewController.h" 11 | @interface VideoListTableViewController () 12 | @end 13 | 14 | @implementation VideoListTableViewController 15 | @synthesize FileList, moviePlayerController,moviePlayViewController; 16 | 17 | 18 | - (id)initWithStyle:(UITableViewStyle)style 19 | { 20 | self = [super initWithStyle:style]; 21 | if (self) 22 | { 23 | // Custom initialization 24 | } 25 | return self; 26 | } 27 | 28 | -(void)viewWillAppear:(BOOL)animated 29 | { 30 | self.FileList = [self GetAllFiles]; 31 | 32 | [self viewDidLoad]; 33 | } 34 | 35 | - (void)didReceiveMemoryWarning 36 | { 37 | [super didReceiveMemoryWarning]; 38 | // Dispose of any resources that can be recreated. 39 | } 40 | 41 | #pragma mark - Table view data source 42 | 43 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 44 | { 45 | 46 | // Return the number of sections. 47 | return 1; 48 | } 49 | 50 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 51 | { 52 | return [self.FileList count]; 53 | } 54 | 55 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 56 | { 57 | static NSString *CellIdentifier = @"Cell"; 58 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 59 | if(cell == nil) 60 | { 61 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 62 | } 63 | 64 | cell.textLabel.text = self.FileList[indexPath.row]; 65 | 66 | return cell; 67 | } 68 | 69 | -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 70 | { 71 | return 75.f; 72 | } 73 | 74 | 75 | 76 | -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 77 | { 78 | NSString* filename = self.FileList[indexPath.row]; 79 | NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 80 | NSString* documentDir = [documentPaths objectAtIndex:0]; 81 | NSString* fullname = [documentDir stringByAppendingFormat:@"/%@",filename]; 82 | 83 | AVPlayerViewController*tmpMoviePlayViewController=[[AVPlayerViewController alloc] init]; 84 | tmpMoviePlayViewController.mediaPath = fullname; 85 | if(tmpMoviePlayViewController) 86 | { 87 | [self presentViewController:tmpMoviePlayViewController animated:true completion:nil]; 88 | } 89 | [tmpMoviePlayViewController release]; 90 | } 91 | 92 | 93 | - (NSMutableArray*) GetAllFiles 94 | { 95 | // get all the files under this folder 96 | NSFileManager *fileManager = [NSFileManager defaultManager]; 97 | NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 98 | NSString* documentDir = [documentPaths objectAtIndex:0]; 99 | NSError *error = nil; 100 | NSArray *fileList = [[NSArray alloc] init]; 101 | //fileList便是包含有该文件夹下所有文件的文件名及文件夹名的数组 102 | fileList = [fileManager contentsOfDirectoryAtPath:documentDir error:&error]; 103 | 104 | //Convert NSArray to NSMutableArray 105 | NSMutableArray *_fileList = [[NSMutableArray alloc] init]; 106 | _fileList = [NSMutableArray arrayWithArray:fileList]; 107 | 108 | return _fileList; 109 | } 110 | 111 | -(void)viewDidLoad 112 | { 113 | [super viewDidLoad]; 114 | } 115 | 116 | -(NSString *) tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath 117 | { 118 | return @"Delete"; 119 | } 120 | 121 | 122 | //Override to support conditional editing of the table view. 123 | - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 124 | { 125 | // Return NO if you do not want the specified item to be editable. 126 | return YES; 127 | } 128 | 129 | 130 | 131 | // Override to support editing the table view. 132 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 133 | { 134 | if (editingStyle == UITableViewCellEditingStyleDelete) { 135 | //Prepare for deleting file on disk. 136 | NSString *DeleteFileName = self.FileList[indexPath.row]; 137 | NSFileManager *fileManager = [NSFileManager defaultManager]; 138 | NSArray *DeleteDocumentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 139 | NSString *DeleteDocumentDir = [DeleteDocumentPaths objectAtIndex:0]; 140 | NSString *FullDeleteFilePath =[DeleteDocumentDir stringByAppendingPathComponent:DeleteFileName]; 141 | NSError *error = nil; 142 | 143 | // Delete the row from the data source 144 | [FileList removeObjectAtIndex:[indexPath row]]; 145 | 146 | [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 147 | 148 | [fileManager removeItemAtPath:FullDeleteFilePath error:&error]; 149 | 150 | } 151 | else if (editingStyle == UITableViewCellEditingStyleInsert) { 152 | // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 153 | } 154 | } 155 | 156 | 157 | /* 158 | // Override to support rearranging the table view. 159 | - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath 160 | { 161 | } 162 | */ 163 | 164 | /* 165 | // Override to support conditional rearranging of the table view. 166 | - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath 167 | { 168 | // Return NO if you do not want the item to be re-orderable. 169 | return YES; 170 | } 171 | */ 172 | 173 | /* 174 | #pragma mark - Navigation 175 | 176 | // In a story board-based application, you will often want to do a little preparation before navigation 177 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 178 | { 179 | // Get the new view controller using [segue destinationViewController]. 180 | // Pass the selected object to the new view controller. 181 | } 182 | */ 183 | 184 | @end 185 | -------------------------------------------------------------------------------- /ftp_commands.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | quit 6 | doQuit: 7 | list 8 | doList: 9 | nlst 10 | doList: 11 | stat 12 | doStat: 13 | feat 14 | doFeat: 15 | user 16 | doUser: 17 | pass 18 | doPass: 19 | ack 20 | doAck: 21 | pwd 22 | doPwd: 23 | cwd 24 | doCwd: 25 | noop 26 | doNoop: 27 | syst 28 | doSyst: 29 | pasv 30 | doPasv: 31 | epsv 32 | doEpsv: 33 | port 34 | doPort: 35 | lprt 36 | doLprt: 37 | eprt 38 | doEprt: 39 | opts 40 | doOpts: 41 | type 42 | doType: 43 | stor 44 | doStor: 45 | retr 46 | doRetr: 47 | dele 48 | doDele: 49 | mlst 50 | doMlst: 51 | size 52 | doSize: 53 | mkd 54 | doMkdir: 55 | cdup 56 | doCdUp: 57 | rmd 58 | doDele: 59 | rnfr 60 | doRnfr: 61 | rnto 62 | doRnto: 63 | 64 | 65 | -------------------------------------------------------------------------------- /trail.AVPTFramework.framework/Headers: -------------------------------------------------------------------------------- 1 | Versions/Current/Headers -------------------------------------------------------------------------------- /trail.AVPTFramework.framework/Resources: -------------------------------------------------------------------------------- 1 | Versions/Current/Resources -------------------------------------------------------------------------------- /trail.AVPTFramework.framework/Versions/A/Headers/AVParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AVParser.h 3 | * This file is part of AVPlayerTouch framework. 4 | * 5 | * AV parser & thumbnail generating obj-c wrapper class. 6 | * 7 | * Created by iMoreApps on 2/25/2014. 8 | * Copyright (C) 2014 iMoreApps Inc. All rights reserved. 9 | * Author: imoreapps 10 | */ 11 | 12 | #import 13 | #import 14 | 15 | @interface AVParser : NSObject 16 | 17 | @property (nonatomic, readonly) NSString *path; 18 | @property (readonly, nonatomic) NSTimeInterval duration; 19 | @property (readonly, nonatomic) NSUInteger frameWidth; 20 | @property (readonly, nonatomic) NSUInteger frameHeight; 21 | 22 | /* 23 | * open av source 24 | * return YES if success, otherwise return NO. 25 | */ 26 | - (BOOL)open:(NSString *)path; 27 | 28 | /* 29 | * determine whether or not has audio and video stream. 30 | * return YES or NO. 31 | */ 32 | - (BOOL)hasAudio; 33 | - (BOOL)hasVideo; 34 | 35 | /* 36 | * generate thumbnail at specified timestamp 37 | * return an UIImage object if success, otherwise return nil. 38 | */ 39 | - (UIImage *)thumbnailAtTime:(NSTimeInterval)seconds; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /trail.AVPTFramework.framework/Versions/A/Headers/AVPlayerController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AVPlayerController.h 3 | * This file is part of AVPlayerTouch framework. 4 | * 5 | * Player obj-c wrapper class. 6 | * 7 | * Created by iMoreApps on 2/24/2014. 8 | * Copyright (C) 2014 iMoreApps Inc. All rights reserved. 9 | * Author: imoreapps 10 | */ 11 | 12 | #import 13 | #import 14 | 15 | typedef enum { 16 | 17 | kAVPlayerStateInitialized=0, 18 | kAVPlayerStatePlaying, 19 | kAVPlayerStatePaused, 20 | kAVPlayerStateFinishedPlayback, 21 | kAVPlayerStateStoped, 22 | 23 | kAVPlayerStateUnknown=0xff 24 | 25 | } AVPlayerState; 26 | 27 | 28 | @protocol AVPlayerControllerDelegate; 29 | 30 | /** 31 | * !!! AVPlayerController component is NOT thread-safe !!! 32 | */ 33 | @interface AVPlayerController : NSObject 34 | 35 | @property (nonatomic, readonly) NSString *moviePath; 36 | @property (nonatomic, weak) id delegate; 37 | @property (nonatomic, assign) BOOL shouldAutoPlay; 38 | @property (nonatomic, assign) BOOL shouldPlayOnBackground; 39 | 40 | @property (nonatomic, readonly) NSInteger currentAudioTrack; 41 | @property (nonatomic, readonly) NSArray *audioTracks; 42 | 43 | @property (nonatomic, readonly) NSInteger currentSubtitleTrack; 44 | @property (nonatomic, readonly) NSArray *subtitleTracks; 45 | 46 | /** 47 | * Adjust contrast and saturation of the video display. 48 | * @contrast: 0.0 to 4.0, default 1.0 49 | * @saturation: 0.0 to 2.0, default 1.0 50 | **/ 51 | @property (nonatomic, assign) float contrast; 52 | @property (nonatomic, assign) float saturation; 53 | 54 | /* 55 | * Adjust the screen's brightness. 56 | */ 57 | @property (nonatomic, assign) float brightness; 58 | 59 | 60 | /* 61 | * Convert ISO 639-1/2B/2T language code to full english name. 62 | * @langCode: ISO 639 language code. 63 | * @isLeft: YES - show negative symbol. 64 | * @return full english name of the ISO language code or "Unknown". 65 | */ 66 | + (NSString *)convertISO639LanguageCodeToEnName:(NSString *)langCode; 67 | 68 | /* 69 | * Format second to human readable time string. 70 | * @seconds: number of seconds 71 | * @isLeft: YES - show negative symbol. 72 | * @return formatted time string. 73 | */ 74 | + (NSString *)formatTimeInterval:(CGFloat)seconds isLeft:(BOOL)isLeft; 75 | 76 | /* 77 | * Init AVPlayerController object. 78 | * @If failed, return nil, otherwise return initialized AVPlayerController instance. 79 | */ 80 | - (id)init; 81 | 82 | /* 83 | * Open media file at path. 84 | * @path - path to media file. 85 | * @If failed, return NO, otherwise return YES. 86 | */ 87 | - (BOOL)openMedia:(NSString *)path onFinishedHandler:(void (^)(BOOL))handler; 88 | 89 | /* 90 | * Get drawable view object 91 | */ 92 | - (UIView *)drawableView; 93 | 94 | /* 95 | * Is movie file from network? 96 | * @If movie file from network return YES, otherwise return NO. 97 | */ 98 | - (BOOL)isNetworkFile; 99 | 100 | /* 101 | * Enter or exit full screen mode. 102 | * @enter - YES to enter, NO to exit. 103 | * @This function does not return a value. 104 | */ 105 | - (void)fullScreen:(BOOL)enter; 106 | 107 | /* 108 | * Determine AVPlayer whether or not is in full screen mode. 109 | * @If it is in full screen mode, return YES, otherwise return NO. 110 | */ 111 | - (BOOL)isFullscreen; 112 | 113 | /* 114 | * Has audio, video, subtitle stream. 115 | * @If media has video or audio stream this function return YES, otherwise return NO. 116 | */ 117 | - (BOOL)hasAudio; 118 | - (BOOL)hasVideo; 119 | - (BOOL)hasSubtitle; 120 | 121 | /* 122 | * Switch to special audio tracker 123 | * @index: index of the audio tracker. 124 | */ 125 | - (void)switchAudioTracker:(int)index; 126 | 127 | /* 128 | * Switch to special subtitle stream 129 | * @index: index of the subtitle stream. 130 | */ 131 | - (void)switchSubtitleStream:(int)index; 132 | 133 | /* 134 | * Open or close external subtitle file support. 135 | * @path: subtitle file path. 136 | * @encoding: encoding of the file. 137 | */ 138 | - (BOOL)openSubtitleFile:(NSString *)path encoding:(CFStringEncoding)encoding; 139 | - (void)closeSubtitleFile; 140 | 141 | /* 142 | * Set subtitle display font. 143 | * @font: subtitle font. 144 | */ 145 | - (void)setSubtitleFont:(UIFont *)font; 146 | 147 | /* 148 | * Query video frame size. 149 | * @This function return a CGSize value. 150 | */ 151 | - (CGSize)videoFrameSize; 152 | 153 | /* 154 | * Query AVPlayer current state. 155 | * @This function return AVPlayer current state info. 156 | */ 157 | - (AVPlayerState)playerState; 158 | 159 | /* 160 | * Query media total duration. 161 | * @This function return media total duration info. 162 | */ 163 | - (NSTimeInterval)duration; 164 | 165 | /* 166 | * Query AVPlayer current playback time. 167 | * @This function return current playback time info. 168 | */ 169 | - (NSTimeInterval)currentTime; 170 | 171 | /* 172 | * Start playback. 173 | * @fact - playback start position, 0~1.0f 174 | * @If failed, return NO, otherwise return YES. 175 | */ 176 | - (BOOL)play:(double)fact; 177 | 178 | /* 179 | * Fast forward. 180 | * @This function does not return a value. 181 | */ 182 | - (void)fastforward; 183 | 184 | /* 185 | * Fast backward. 186 | * @This function does not return a value. 187 | */ 188 | - (void)fastbackward; 189 | 190 | /* 191 | * Pause playback. 192 | * @This function does not return a value. 193 | */ 194 | - (void)pause; 195 | 196 | /* 197 | * Resume playback. 198 | * @This function does not return a value. 199 | */ 200 | - (void)resume; 201 | 202 | /* 203 | * Stop playback. 204 | * @This function does not return a value. 205 | */ 206 | - (void)stop; 207 | 208 | /* 209 | * Seek to position. 210 | * @fact - 0~1.0f 211 | * @This function does not return a value. 212 | */ 213 | - (void)seekto:(double)fact; 214 | 215 | /* 216 | * Enable real frame rate calculator. 217 | * @enable - YES to enable or NO to disable. 218 | * @This function does not return a value. 219 | */ 220 | - (void)enableCalcFramerate:(BOOL)enable; 221 | 222 | /* 223 | * Get real frame rate. 224 | * @This function return real frame rate. 225 | */ 226 | - (int)framerate; 227 | 228 | /* 229 | * Enable bit rate calculator. 230 | * @enable - YES to enable or NO to disable. 231 | * @This function does not return a value. 232 | */ 233 | - (void)enableCalcBitrate:(BOOL)enable; 234 | 235 | /* 236 | * Get real bit rate. 237 | * @This function return real bit rate. 238 | */ 239 | - (int)bitrate; 240 | 241 | /* 242 | * Get buffering progress. 243 | * @This function return buffering progress (0~1.0f). 244 | */ 245 | - (int)bufferingProgress; 246 | 247 | /* 248 | * Get playback speed. 249 | * @This function return current playback speed (0.5~2.0f). 250 | */ 251 | - (float)playbackSpeed; 252 | 253 | /* 254 | * Get playback speed. 255 | * @speed - new playback speed. 256 | * @This function does not return a value. 257 | */ 258 | - (void)setPlaybackSpeed:(float)speed; 259 | 260 | @end 261 | 262 | 263 | @protocol AVPlayerControllerDelegate 264 | 265 | @optional 266 | 267 | // AVPlayer state was changed 268 | - (void)AVPlayerControllerDidStateChange:(AVPlayerController *)controller; 269 | 270 | // AVPlayer current play time was changed 271 | - (void)AVPlayerControllerDidCurTimeChange:(AVPlayerController *)controller position:(NSTimeInterval)position; 272 | 273 | // AVPlayer current buffering progress was changed 274 | - (void)AVPlayerControllerDidBufferingProgressChange:(AVPlayerController *)controller progress:(double)progress; 275 | 276 | // Enter or exit full screen mode 277 | - (void)AVPlayerControllerDidEnterFullscreenMode:(AVPlayerController *)controller; 278 | - (void)AVPlayerControllerDidExitFullscreenMode:(AVPlayerController *)controller; 279 | 280 | @end 281 | -------------------------------------------------------------------------------- /trail.AVPTFramework.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/trail.AVPTFramework.framework/Versions/A/Resources/Info.plist -------------------------------------------------------------------------------- /trail.AVPTFramework.framework/Versions/A/Resources/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/trail.AVPTFramework.framework/Versions/A/Resources/en.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /trail.AVPTFramework.framework/Versions/A/trail.AVPTFramework: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nekaso/WifiTransfer/83e75c8d2cbdfefd653252fb525e19463b49daec/trail.AVPTFramework.framework/Versions/A/trail.AVPTFramework -------------------------------------------------------------------------------- /trail.AVPTFramework.framework/Versions/Current: -------------------------------------------------------------------------------- 1 | A -------------------------------------------------------------------------------- /trail.AVPTFramework.framework/trail.AVPTFramework: -------------------------------------------------------------------------------- 1 | Versions/Current/trail.AVPTFramework --------------------------------------------------------------------------------