shlist

share and manage lists between multiple people
Log | Files | Refs

commit c56519b44214effaac33c54fb21ea265203a2543
parent affb5d2255cf8a2370ee8cd6d3c26648e1c35c87
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Mon, 15 Jun 2015 00:59:22 -0600

ios: open a socket

+ open a socket to remote host
+ change to "theos" style ide

Diffstat:
Mios/Makefile | 33+++++----------------------------
Aios/Resources/Info.plist | 16++++++++++++++++
Aios/RootViewController.h | 4++++
Aios/RootViewController.mm | 33+++++++++++++++++++++++++++++++++
Dios/ViewController.h | 10----------
Dios/ViewController.m | 57---------------------------------------------------------
Aios/control | 9+++++++++
Mios/main.m | 99+++++--------------------------------------------------------------------------
Aios/shlistApplication.mm | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 144 insertions(+), 188 deletions(-)

diff --git a/ios/Makefile b/ios/Makefile @@ -1,30 +1,7 @@ -# -# the sdk needs to be unpacked and ready to go before running this, see -# http://iphonedevwiki.net/index.php/Compiling_iOS_applications_on-device -# for more information -# +include theos/makefiles/common.mk -CC=clang -CFLAGS=-isysroot /var/sdks/iPhoneOS7.1.sdk -LDFLAGS=-framework Foundation -framework UIKit +APPLICATION_NAME = shlist +shlist_FILES = main.m shlistApplication.mm RootViewController.mm +shlist_FRAMEWORKS = UIKit CoreGraphics -PROG=shlist -OBJS=main.o ViewController.o - -.SUFFIXES: .m .o - -$(PROG): $(OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ - cp $@ /Applications/$(PROG).App/ - killall -HUP SpringBoard - -.m.o: - $(CC) $(CFLAGS) -c $< - -$(OBJS): ViewController.h - -open: - open net.iphonedevwiki.shlist - -clean: - rm -f *.o $(PROG) +include $(THEOS_MAKE_PATH)/application.mk diff --git a/ios/Resources/Info.plist b/ios/Resources/Info.plist @@ -0,0 +1,16 @@ +{ + CFBundleExecutable = "shlist"; + CFBundleIconFile = icon.png; + CFBundleIdentifier = "com.octopus.shlist"; + CFBundleInfoDictionaryVersion = 6.0; + CFBundlePackageType = APPL; + CFBundleSignature = "????"; + CFBundleSupportedPlatforms = ( + iPhoneOS + ); + CFBundleVersion = 1.0; + DTPlatformName = iphoneos; + DTSDKName = iphoneos3.0; + LSRequiresIPhoneOS = 1; + MinimumOSVersion = 3.0; +} diff --git a/ios/RootViewController.h b/ios/RootViewController.h @@ -0,0 +1,4 @@ +@interface RootViewController: UIViewController <NSStreamDelegate> { +} + +@end diff --git a/ios/RootViewController.mm b/ios/RootViewController.mm @@ -0,0 +1,33 @@ +#import "RootViewController.h" + +@implementation RootViewController + +NSInputStream *inputStream; +NSOutputStream *outputStream; + +- (void)loadView { + self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]; + self.view.backgroundColor = [UIColor redColor]; + + [self initNetworkCommunication]; +} + +- (void)initNetworkCommunication +{ + CFReadStreamRef readStream; + CFWriteStreamRef writeStream; + + CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"absentmindedproductions.ca", 5437, &readStream, &writeStream); + inputStream = (NSInputStream *)readStream; + outputStream = (NSOutputStream *)writeStream; + + [inputStream setDelegate:self]; + [outputStream setDelegate:self]; + + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + + [inputStream open]; + [outputStream open]; +} +@end diff --git a/ios/ViewController.h b/ios/ViewController.h @@ -1,10 +0,0 @@ -#import <UIKit/UIKit.h> - -@interface ViewController : UIViewController <NSStreamDelegate> - --(IBAction)showMessage; - -@end - -NSInputStream *inputStream; -NSOutputStream *outputStream; diff --git a/ios/ViewController.m b/ios/ViewController.m @@ -1,57 +0,0 @@ -#import "ViewController.h" - -@interface ViewController () - -@end - -@implementation ViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. - - [self showMessage]; - [self initNetworkCommunication]; -} - -- (void)viewDidUnload -{ - [super viewDidUnload]; - // Release any retained subviews of the main view. -} - -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation -{ - return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); -} - -- (IBAction)showMessage -{ - UIAlertView *helloWorldAlert = [[UIAlertView alloc] - initWithTitle:@"My First App" message:@"Hello, World!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - - // Display the Hello World Message - [helloWorldAlert show]; -} - -- (void)initNetworkCommunication -{ - CFReadStreamRef readStream; - CFWriteStreamRef writeStream; - - CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"absentmindedproductions.ca", 5437, &readStream, &writeStream); - inputStream = (NSInputStream *)readStream; - outputStream = (NSOutputStream *)writeStream; - - [inputStream setDelegate:self]; - [outputStream setDelegate:self]; - - [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - - [inputStream open]; - [outputStream open]; -} - -@end diff --git a/ios/control b/ios/control @@ -0,0 +1,9 @@ +Package: com.octopus.shlist +Name: shlist +Depends: +Version: 0.0.1 +Architecture: iphoneos-arm +Description: An awesome application! +Maintainer: Kyle Milz +Author: Kyle Milz +Section: Utilities diff --git a/ios/main.m b/ios/main.m @@ -1,95 +1,8 @@ -#import <UIKit/UIKit.h> -#import "ViewController.h" - -@class ViewController; - -@interface AppDelegate : UIResponder <UIApplicationDelegate> -@property (nonatomic, strong) UIWindow *window; -@property (strong, nonatomic) ViewController *viewController; -@end - -int main(int argc, char *argv[]) -{ - @autoreleasepool - { - return UIApplicationMain(argc, argv, nil, NSStringFromClass(AppDelegate.class)); - } -} - -@implementation AppDelegate - -@synthesize window = _window; -@synthesize viewController = _viewController; - --(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - // Override point for customization after application launch. - self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; - self.window.rootViewController = self.viewController; - [self.window makeKeyAndVisible]; - return YES; - - /* - self.window = [UIWindow.alloc initWithFrame:UIScreen.mainScreen.bounds]; - self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; - self.window.rootViewController = self.viewController; - - self.window.backgroundColor = UIColor.redColor; - - UILabel *label = [[TestLabel alloc] initWithBackgroundColor:self.window.backgroundColor]; - [self.window addSubview:label]; - [label release]; - - [self.window makeKeyAndVisible]; - - return YES; - */ -} - -- (void)applicationWillResignActive:(UIApplication *)application -{ - // 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. - // - // 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. -} - -- (void)applicationDidEnterBackground:(UIApplication *)application -{ - // 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. - // - // If your application supports background execution, this method is - // called instead of applicationWillTerminate: when the user quits. -} - -- (void)applicationWillEnterForeground:(UIApplication *)application -{ - // 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. -} - -- (void)applicationDidBecomeActive:(UIApplication *)application -{ - // 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. -} - -- (void)applicationWillTerminate:(UIApplication *)application -{ - // Called when the application is about to terminate. Save data if - // appropriate. See also applicationDidEnterBackground:. +int main(int argc, char **argv) { + NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init]; + int ret = UIApplicationMain(argc, argv, @"shlistApplication", @"shlistApplication"); + [p drain]; + return ret; } -@end +// vim:ft=objc diff --git a/ios/shlistApplication.mm b/ios/shlistApplication.mm @@ -0,0 +1,71 @@ +#import "RootViewController.h" + +@interface shlistApplication: UIApplication <UIApplicationDelegate> { + UIWindow *_window; + RootViewController *_viewController; +} +@property (nonatomic, retain) UIWindow *window; +@end + +@implementation shlistApplication +@synthesize window = _window; +- (void)applicationDidFinishLaunching:(UIApplication *)application { + _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + _viewController = [[RootViewController alloc] init]; + [_window addSubview:_viewController.view]; + [_window makeKeyAndVisible]; +} + + +- (void)applicationWillResignActive:(UIApplication *)application +{ + // 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. + // + // 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. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // 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. + // + // If your application supports background execution, this method is + // called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // 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. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + // 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. +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + // Called when the application is about to terminate. Save data if + // appropriate. See also applicationDidEnterBackground:. +} + +- (void)dealloc { + [_viewController release]; + [_window release]; + [super dealloc]; +} +@end + +// vim:ft=objc