shlist

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

commit 7dfdbf09145a8c6d761ae60ac722fdbd7915b173
parent cc14403ddffc7be992b71e4bfe76e0d35c318c36
Author: Kyle Milz <kyle@Kyles-MacBook-Pro.local>
Date:   Wed,  1 Jul 2015 01:06:44 -0600

ios: add some features

+ tab bar at bottom of screen
  + about us page
  + rudimentary contacts chooser
+ sending and receiving network messages

Diffstat:
Aios-ng/ContactsViewController.h | 10++++++++++
Aios-ng/ContactsViewController.m | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mios-ng/shlist.xcodeproj/project.pbxproj | 26++++++++++++++++++++------
Mios-ng/shlist/AppDelegate.m | 2+-
Mios-ng/shlist/Base.lproj/Main.storyboard | 121+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Mios-ng/shlist/NewListViewController.m | 8+++++---
Dios-ng/shlist/Server.h | 8--------
Dios-ng/shlist/Server.m | 52----------------------------------------------------
Mios-ng/shlist/SharedList.h | 1-
Mios-ng/shlist/SharedListsTableViewController.m | 26+++++++++++++++++++++++---
Aios-ng/shlist/ShlistServer.h | 12++++++++++++
Aios-ng/shlist/ShlistServer.m | 158+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 files changed, 393 insertions(+), 88 deletions(-)

diff --git a/ios-ng/ContactsViewController.h b/ios-ng/ContactsViewController.h @@ -0,0 +1,9 @@ +#import <UIKit/UIKit.h> +#import <AddressBookUI/AddressBookUI.h> + +@interface ContactsViewController : UIViewController <ABPeoplePickerNavigationControllerDelegate> { + ABPeoplePickerNavigationController *picker; +} + + +@end +\ No newline at end of file diff --git a/ios-ng/ContactsViewController.m b/ios-ng/ContactsViewController.m @@ -0,0 +1,57 @@ +#import "ContactsViewController.h" + +@interface ContactsViewController () + +@end + +@implementation ContactsViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + + picker = [[ABPeoplePickerNavigationController alloc] init]; + picker.peoplePickerDelegate = self; + + // [self presentModalViewController:picker animated:YES]; + + picker.view.frame = self.view.bounds; + [self.view addSubview:picker.view]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (BOOL)peoplePickerNavigationController: +(ABPeoplePickerNavigationController *)peoplePicker + shouldContinueAfterSelectingPerson:(ABRecordRef)person { + + NSLog(@"%s", person); + // [self displayPerson:person]; + // [self dismissModalViewControllerAnimated:YES]; + + return NO; +} + +- (BOOL)peoplePickerNavigationController: +(ABPeoplePickerNavigationController *)peoplePicker + shouldContinueAfterSelectingPerson:(ABRecordRef)person + property:(ABPropertyID)property + identifier:(ABMultiValueIdentifier)identifier +{ + return NO; +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/ios-ng/shlist.xcodeproj/project.pbxproj b/ios-ng/shlist.xcodeproj/project.pbxproj @@ -7,9 +7,12 @@ objects = { /* Begin PBXBuildFile section */ + 27B039FF1B43B6830054B6D2 /* ContactsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 27B039FE1B43B6830054B6D2 /* ContactsViewController.m */; }; + 27B03A021B43B8660054B6D2 /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27B03A001B43B8660054B6D2 /* AddressBook.framework */; }; + 27B03A031B43B8660054B6D2 /* AddressBookUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27B03A011B43B8660054B6D2 /* AddressBookUI.framework */; }; 27C70F051B32AF8000DADEB3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C70F041B32AF8000DADEB3 /* main.m */; }; 27C70F081B32AF8000DADEB3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C70F071B32AF8000DADEB3 /* AppDelegate.m */; }; - 27C70F0B1B32AF8000DADEB3 /* Server.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C70F0A1B32AF8000DADEB3 /* Server.m */; }; + 27C70F0B1B32AF8000DADEB3 /* ShlistServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C70F0A1B32AF8000DADEB3 /* ShlistServer.m */; }; 27C70F0E1B32AF8000DADEB3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27C70F0C1B32AF8000DADEB3 /* Main.storyboard */; }; 27C70F101B32AF8000DADEB3 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 27C70F0F1B32AF8000DADEB3 /* Images.xcassets */; }; 27C70F131B32AF8000DADEB3 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 27C70F111B32AF8000DADEB3 /* LaunchScreen.xib */; }; @@ -34,13 +37,17 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 27B039FD1B43B6830054B6D2 /* ContactsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactsViewController.h; sourceTree = SOURCE_ROOT; }; + 27B039FE1B43B6830054B6D2 /* ContactsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactsViewController.m; sourceTree = SOURCE_ROOT; }; + 27B03A001B43B8660054B6D2 /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; }; + 27B03A011B43B8660054B6D2 /* AddressBookUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBookUI.framework; path = System/Library/Frameworks/AddressBookUI.framework; sourceTree = SDKROOT; }; 27C70EFF1B32AF8000DADEB3 /* shlist.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = shlist.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27C70F031B32AF8000DADEB3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 27C70F041B32AF8000DADEB3 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 1; }; 27C70F061B32AF8000DADEB3 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; 27C70F071B32AF8000DADEB3 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; - 27C70F091B32AF8000DADEB3 /* Server.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Server.h; path = shlist/Server.h; sourceTree = "<group>"; }; - 27C70F0A1B32AF8000DADEB3 /* Server.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Server.m; path = shlist/Server.m; sourceTree = "<group>"; }; + 27C70F091B32AF8000DADEB3 /* ShlistServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ShlistServer.h; path = shlist/ShlistServer.h; sourceTree = "<group>"; }; + 27C70F0A1B32AF8000DADEB3 /* ShlistServer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ShlistServer.m; path = shlist/ShlistServer.m; sourceTree = "<group>"; }; 27C70F0D1B32AF8000DADEB3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; 27C70F0F1B32AF8000DADEB3 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; }; 27C70F121B32AF8000DADEB3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; }; @@ -67,6 +74,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 27B03A021B43B8660054B6D2 /* AddressBook.framework in Frameworks */, + 27B03A031B43B8660054B6D2 /* AddressBookUI.framework in Frameworks */, 27C70F321B3650CB00DADEB3 /* libsqlite3.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -84,10 +93,12 @@ 27C70EF61B32AF7F00DADEB3 = { isa = PBXGroup; children = ( + 27B03A001B43B8660054B6D2 /* AddressBook.framework */, + 27B03A011B43B8660054B6D2 /* AddressBookUI.framework */, 27C70F331B36513200DADEB3 /* DBManager.h */, 27C70F341B36513200DADEB3 /* DBManager.m */, - 27C70F091B32AF8000DADEB3 /* Server.h */, - 27C70F0A1B32AF8000DADEB3 /* Server.m */, + 27C70F091B32AF8000DADEB3 /* ShlistServer.h */, + 27C70F0A1B32AF8000DADEB3 /* ShlistServer.m */, 27C70F311B3650CB00DADEB3 /* libsqlite3.dylib */, 27C70F011B32AF8000DADEB3 /* shlist */, 27C70F1B1B32AF8000DADEB3 /* shlistTests */, @@ -109,6 +120,8 @@ children = ( 27C70F061B32AF8000DADEB3 /* AppDelegate.h */, 27C70F071B32AF8000DADEB3 /* AppDelegate.m */, + 27B039FD1B43B6830054B6D2 /* ContactsViewController.h */, + 27B039FE1B43B6830054B6D2 /* ContactsViewController.m */, 27C70F0C1B32AF8000DADEB3 /* Main.storyboard */, BF7776B71B38928D00526CB0 /* ListDetailTableViewController.h */, BF7776B81B38928D00526CB0 /* ListDetailTableViewController.m */, @@ -257,10 +270,11 @@ BF7776B91B38928D00526CB0 /* ListDetailTableViewController.m in Sources */, 27C70F351B36513200DADEB3 /* DBManager.m in Sources */, BF7776BC1B38D0DB00526CB0 /* ListItem.m in Sources */, - 27C70F0B1B32AF8000DADEB3 /* Server.m in Sources */, + 27C70F0B1B32AF8000DADEB3 /* ShlistServer.m in Sources */, 27C70F2A1B33D1C900DADEB3 /* SharedList.m in Sources */, 27C70F2D1B33F3C300DADEB3 /* NewListViewController.m in Sources */, 27C70F081B32AF8000DADEB3 /* AppDelegate.m in Sources */, + 27B039FF1B43B6830054B6D2 /* ContactsViewController.m in Sources */, 27C70F301B33F4FA00DADEB3 /* SharedListsTableViewController.m in Sources */, 27C70F051B32AF8000DADEB3 /* main.m in Sources */, ); diff --git a/ios-ng/shlist/AppDelegate.m b/ios-ng/shlist/AppDelegate.m @@ -9,7 +9,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Override point for customization after application launch. + // customization after application launch return YES; } diff --git a/ios-ng/shlist/Base.lproj/Main.storyboard b/ios-ng/shlist/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="0GJ-5e-Vr4"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="KKJ-Fr-5sX"> <dependencies> <deployment identifier="iOS"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/> @@ -44,7 +44,7 @@ </tableViewController> <placeholder placeholderIdentifier="IBFirstResponder" id="H64-xB-1er" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="1008" y="-358"/> + <point key="canvasLocation" x="1188" y="-70"/> </scene> <!--Shared Lists--> <scene sceneID="hc1-Lv-WtP"> @@ -112,16 +112,16 @@ <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="new list name" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="gPO-fo-XXP"> - <rect key="frame" x="0.0" y="88" width="600" height="30"/> + <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="new list name" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="gPO-fo-XXP"> + <rect key="frame" x="16" y="72" width="568" height="30"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <textInputTraits key="textInputTraits" returnKeyType="done"/> <connections> <action selector="textField" destination="BYZ-38-t0r" eventType="editingDidEnd" id="x6t-Ub-mbI"/> </connections> </textField> - <datePicker contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" datePickerMode="date" minuteInterval="1" translatesAutoresizingMaskIntoConstraints="NO" id="6qD-8D-Z17"> - <rect key="frame" x="0.0" y="134" width="600" height="162"/> + <datePicker contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" datePickerMode="date" minuteInterval="1" translatesAutoresizingMaskIntoConstraints="NO" id="6qD-8D-Z17"> + <rect key="frame" x="16" y="110" width="568" height="162"/> <date key="date" timeIntervalSinceReferenceDate="456394105.70743901"> <!--2015-06-19 08:08:25 +0000--> </date> @@ -130,11 +130,12 @@ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> <constraints> <constraint firstAttribute="centerX" secondItem="gPO-fo-XXP" secondAttribute="centerX" id="1OY-B2-wev"/> - <constraint firstAttribute="trailingMargin" secondItem="6qD-8D-Z17" secondAttribute="trailing" constant="-16" id="Bo3-B6-6Tu"/> - <constraint firstItem="gPO-fo-XXP" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" constant="-16" id="H3z-m6-BeL"/> - <constraint firstAttribute="trailingMargin" secondItem="gPO-fo-XXP" secondAttribute="trailing" constant="-16" id="iEx-da-9za"/> - <constraint firstItem="6qD-8D-Z17" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" constant="-16" id="o9a-P2-Pqm"/> - <constraint firstAttribute="centerX" secondItem="6qD-8D-Z17" secondAttribute="centerX" id="scx-j8-F8B"/> + <constraint firstItem="gPO-fo-XXP" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="G0c-db-8sM"/> + <constraint firstItem="6qD-8D-Z17" firstAttribute="top" secondItem="gPO-fo-XXP" secondAttribute="bottom" constant="8" id="SJ3-NV-PjO"/> + <constraint firstItem="gPO-fo-XXP" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="8" id="ZtU-cg-SZX"/> + <constraint firstItem="6qD-8D-Z17" firstAttribute="trailing" secondItem="8bC-Xf-vdC" secondAttribute="trailingMargin" id="dr7-PJ-P2B"/> + <constraint firstItem="6qD-8D-Z17" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="fhE-11-QTl"/> + <constraint firstItem="gPO-fo-XXP" firstAttribute="trailing" secondItem="8bC-Xf-vdC" secondAttribute="trailingMargin" id="qlT-al-6aa"/> </constraints> </view> <navigationItem key="navigationItem" title="New List" id="5ys-ck-wLj"> @@ -158,12 +159,104 @@ <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> <exit id="C3w-Ab-gX6" userLabel="Exit" sceneMemberID="exit"/> </objects> - <point key="canvasLocation" x="2064" y="387"/> + <point key="canvasLocation" x="2044" y="811"/> </scene> - <!--Navigation Controller--> + <!--About Us--> + <scene sceneID="noJ-Ez-70t"> + <objects> + <viewController id="FlT-Xw-f5e" userLabel="About Us" sceneMemberID="viewController"> + <layoutGuides> + <viewControllerLayoutGuide type="top" id="3hJ-K1-i1o"/> + <viewControllerLayoutGuide type="bottom" id="9zw-4a-J6h"/> + </layoutGuides> + <view key="view" contentMode="scaleToFill" id="BEH-Qp-ix3"> + <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" text="This is something we do on our free time. If you respect that, please donate." translatesAutoresizingMaskIntoConstraints="NO" id="3Tn-bI-uKk"> + <rect key="frame" x="16" y="134" width="568" height="37"/> + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <fontDescription key="fontDescription" type="system" pointSize="14"/> + <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/> + </textView> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="About Us" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hjG-BQ-XBF"> + <rect key="frame" x="16" y="28" width="72" height="21"/> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vqD-fu-CUL"> + <rect key="frame" x="16" y="49" width="568" height="77"/> + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <string key="text">This project is a humble attempt to help people be more organized. It's main purpose is to make group events easy to plan and execute. It's founders hope you find it as useful as they do.</string> + <fontDescription key="fontDescription" type="system" pointSize="14"/> + <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/> + </textView> + </subviews> + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <constraints> + <constraint firstItem="vqD-fu-CUL" firstAttribute="trailing" secondItem="BEH-Qp-ix3" secondAttribute="trailingMargin" id="0kQ-sN-zkj"/> + <constraint firstItem="hjG-BQ-XBF" firstAttribute="leading" secondItem="BEH-Qp-ix3" secondAttribute="leadingMargin" id="64i-ls-ddW"/> + <constraint firstItem="3Tn-bI-uKk" firstAttribute="trailing" secondItem="BEH-Qp-ix3" secondAttribute="trailingMargin" id="AlZ-Vo-99h"/> + <constraint firstItem="vqD-fu-CUL" firstAttribute="leading" secondItem="BEH-Qp-ix3" secondAttribute="leadingMargin" id="Bxp-G1-gOp"/> + <constraint firstItem="3Tn-bI-uKk" firstAttribute="top" secondItem="vqD-fu-CUL" secondAttribute="bottom" constant="8" id="GR0-aa-vSO"/> + <constraint firstItem="3Tn-bI-uKk" firstAttribute="leading" secondItem="BEH-Qp-ix3" secondAttribute="leadingMargin" id="e5J-II-Cyn"/> + <constraint firstAttribute="trailingMargin" secondItem="hjG-BQ-XBF" secondAttribute="trailing" constant="496" id="mgk-JE-jzk"/> + <constraint firstItem="vqD-fu-CUL" firstAttribute="top" secondItem="hjG-BQ-XBF" secondAttribute="bottom" constant="8" id="rnu-FP-hp6"/> + <constraint firstItem="hjG-BQ-XBF" firstAttribute="top" secondItem="3hJ-K1-i1o" secondAttribute="bottom" constant="8" id="vgR-2B-gRS"/> + <constraint firstItem="9zw-4a-J6h" firstAttribute="top" secondItem="3Tn-bI-uKk" secondAttribute="bottom" constant="8" symbolic="YES" id="w2y-Cf-BBd"/> + </constraints> + </view> + <tabBarItem key="tabBarItem" title="About Us" id="djS-DN-skn" userLabel="About Us"/> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="BxS-VD-IQ2" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="292" y="-1628"/> + </scene> + <!--Contacts--> + <scene sceneID="QO3-Nz-2Rw"> + <objects> + <viewController id="U8c-wO-OWj" userLabel="Contacts" customClass="ContactsViewController" sceneMemberID="viewController"> + <layoutGuides> + <viewControllerLayoutGuide type="top" id="lbu-UM-pRT"/> + <viewControllerLayoutGuide type="bottom" id="FAF-HB-8uI"/> + </layoutGuides> + <view key="view" contentMode="scaleToFill" id="rZG-yU-46M"> + <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + </view> + <tabBarItem key="tabBarItem" systemItem="contacts" id="Ify-RM-5Th"/> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="ess-Hw-XyD" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="292" y="-702"/> + </scene> + <!--Tab Bar Controller--> + <scene sceneID="TmM-gX-MFR"> + <objects> + <tabBarController id="KKJ-Fr-5sX" sceneMemberID="viewController"> + <nil key="simulatedBottomBarMetrics"/> + <tabBar key="tabBar" contentMode="scaleToFill" id="v2a-Bs-81y"> + <rect key="frame" x="0.0" y="0.0" width="320" height="49"/> + <autoresizingMask key="autoresizingMask"/> + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> + </tabBar> + <connections> + <segue destination="0GJ-5e-Vr4" kind="relationship" relationship="viewControllers" id="nLJ-0v-l7T"/> + <segue destination="U8c-wO-OWj" kind="relationship" relationship="viewControllers" id="Tf1-0f-ulH"/> + <segue destination="FlT-Xw-f5e" kind="relationship" relationship="viewControllers" id="Hqb-Fa-lrf"/> + </connections> + </tabBarController> + <placeholder placeholderIdentifier="IBFirstResponder" id="PWN-St-ASU" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="-520" y="-702"/> + </scene> + <!--Shared Lists--> <scene sceneID="vP4-SE-UGa"> <objects> <navigationController automaticallyAdjustsScrollViewInsets="NO" id="0GJ-5e-Vr4" sceneMemberID="viewController"> + <tabBarItem key="tabBarItem" title="Shared Lists" id="NkE-iK-fG8"/> <toolbarItems/> <navigationBar key="navigationBar" contentMode="scaleToFill" id="WYU-lv-pXW"> <rect key="frame" x="0.0" y="0.0" width="320" height="44"/> @@ -194,7 +287,7 @@ </navigationController> <placeholder placeholderIdentifier="IBFirstResponder" id="9KD-4M-SJA" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="1252" y="387"/> + <point key="canvasLocation" x="1188" y="811"/> </scene> </scenes> </document> diff --git a/ios-ng/shlist/NewListViewController.m b/ios-ng/shlist/NewListViewController.m @@ -24,10 +24,11 @@ #pragma mark - Navigation // preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. - + if (sender != self.saveButton) return; if (self.textField.text.length > 0) { @@ -40,4 +41,4 @@ } } -@end +@end +\ No newline at end of file diff --git a/ios-ng/shlist/Server.h b/ios-ng/shlist/Server.h @@ -1,8 +0,0 @@ -#import <UIKit/UIKit.h> - -@interface Server : NSObject <NSStreamDelegate> - -- (void)read; -- (void)write; - -@end diff --git a/ios-ng/shlist/Server.m b/ios-ng/shlist/Server.m @@ -1,52 +0,0 @@ -#import "Server.h" - -@interface Server () - -- (void)network_init; - -@end - -@implementation Server - -NSInputStream *inputStream; -NSOutputStream *outputStream; - -bool initialized = 0; - -- (void)network_init -{ - CFReadStreamRef readStream; - CFWriteStreamRef writeStream; - - CFStringRef host_name = CFSTR("absentmindedproductions.ca"); - - CFStreamCreatePairWithSocketToHost(NULL, host_name, 5437, &readStream, &writeStream); - inputStream = (__bridge NSInputStream *)readStream; - outputStream = (__bridge NSOutputStream *)writeStream; - - [inputStream setDelegate:self]; - [outputStream setDelegate:self]; - - [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - - [inputStream open]; - [outputStream open]; -} - -- (void)read -{ - if (!initialized) { - [self network_init]; - } -} - -- (void)write -{ - if (!initialized) { - [self network_init]; - } -} - - -@end diff --git a/ios-ng/shlist/SharedList.h b/ios-ng/shlist/SharedList.h @@ -10,7 +10,6 @@ @property NSString *list_members; @property NSDate *list_date; -- (void)set_name:(NSString*)name; @end #endif diff --git a/ios-ng/shlist/SharedListsTableViewController.m b/ios-ng/shlist/SharedListsTableViewController.m @@ -1,32 +1,52 @@ #import "SharedListsTableViewController.h" #import "SharedList.h" #import "NewListViewController.h" +#import "ShlistServer.h" @interface SharedListsTableViewController () +@property (strong, nonatomic) ShlistServer *server; + @end @implementation SharedListsTableViewController -- (void)load_initial_data +- (void) load_initial_data { + // register if we've never registered before // load local shared list data from db // sync with server and check if there's any updates + // initialize connection + _server = [[ShlistServer alloc] init]; + + bool initialized = false; + if (!initialized) { + // new client + [_server writeToServer:"\x00\x00\x00\x0a" "4037082094" :15]; + // [server readFromServer]; + } + NSLog(@"SharedListsTableViewController::load_initial_data()"); + // NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@"SBFormattedPhoneNumber"]; + // NSLog(@"%@\n", num); + + // ShlistServer *server = [[ShlistServer alloc] init]; + // [server writeToServer:"\x00\x00\xff\0x00"]; + SharedList *list1 = [[SharedList alloc] init]; list1.list_name = @"Camping"; list1.list_members = @"David, Kyle, Greg"; [self.shared_lists addObject:list1]; - + SharedList *list2 = [[SharedList alloc] init]; list2.list_name = @"Wedding"; list2.list_members = @"Kyle, Stephanie"; [self.shared_lists addObject:list2]; } -- (IBAction)unwindToList:(UIStoryboardSegue *)segue +- (IBAction) unwindToList:(UIStoryboardSegue *)segue { NewListViewController *source = [segue sourceViewController]; SharedList *list = source.shared_list; diff --git a/ios-ng/shlist/ShlistServer.h b/ios-ng/shlist/ShlistServer.h @@ -0,0 +1,11 @@ +#import <UIKit/UIKit.h> + +@interface ShlistServer : NSObject <NSStreamDelegate> { + NSInputStream *inputShlistStream; + NSOutputStream *outputShlistStream; + int *bytesRead; +} + +- (void) writeToServer:(const char *)data :(size_t)length; + +@end +\ No newline at end of file diff --git a/ios-ng/shlist/ShlistServer.m b/ios-ng/shlist/ShlistServer.m @@ -0,0 +1,158 @@ +#import "ShlistServer.h" + +@interface ShlistServer () + +@property (strong, retain) NSMutableData *data; + +@end + +@implementation ShlistServer + +- (id) init +{ + if (self = [super init]) { + CFReadStreamRef readStream; + CFWriteStreamRef writeStream; + + CFStringRef host_name = CFSTR("absentmindedproductions.ca"); + + CFStreamCreatePairWithSocketToHost(NULL, host_name, 5437, &readStream, &writeStream); + inputShlistStream = (__bridge NSInputStream *)readStream; + outputShlistStream = (__bridge NSOutputStream *)writeStream; + + [inputShlistStream setDelegate:self]; + [outputShlistStream setDelegate:self]; + + [inputShlistStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [outputShlistStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + + [inputShlistStream open]; + [outputShlistStream open]; + } + + return self; +} + +- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode +{ + switch (eventCode) { + case NSStreamEventNone: + break; + case NSStreamEventOpenCompleted: + NSLog(@"Stream Opened"); + break; + case NSStreamEventHasBytesAvailable: + + if (aStream == inputShlistStream) { + NSInteger len; + uint16_t msg_metadata[2]; + + len = [inputShlistStream read:(uint8_t *)&msg_metadata maxLength:4]; + + if (len != 4) { + NSLog(@"warn: msg metadata was %li bytes, expected 4 bytes", + (long)len); + break; + } + if (msg_metadata[0] > 4) { + NSLog(@"warn: out of range msg type %i", msg_metadata[0]); + break; + } + + NSLog(@"info: received message type %i", msg_metadata[0]); + + if (msg_metadata[1] > 1024) { + NSLog(@"warn: message too large: %i bytes", msg_metadata[1]); + break; + } + NSLog(@"info: message size is %i bytes", msg_metadata[1]); + + uint8_t *buffer = malloc(msg_metadata[1]); + if (buffer == nil) { + NSLog(@"warn: couldn't allocate receiving buffer size %i", + msg_metadata[1]); + break; + } + + len = [inputShlistStream read:buffer maxLength:msg_metadata[1]]; + if (len != msg_metadata[1]) { + NSLog(@"warn: main message read byte mismatch: %li vs %i", + (long)len, msg_metadata[1]); + break; + } + NSString *output = [[NSString alloc] initWithBytes:buffer length:len encoding:NSASCIIStringEncoding]; + + if (output == nil) { + NSLog(@"warn: couldn't allocate output string"); + break; + } + NSLog(@"info: message is %@", output); + } + break; + case NSStreamEventHasSpaceAvailable: + [self _writeData]; + break; + case NSStreamEventErrorOccurred: + NSLog(@"ShlistServer::NSStreamEventErrorOccurred"); + break; + case NSStreamEventEndEncountered: + { + NSLog(@"ShlistServer::NSStreamEventEndEncountered"); + [inputShlistStream close]; + [outputShlistStream close]; + + [inputShlistStream removeFromRunLoop:[NSRunLoop currentRunLoop] + forMode:NSDefaultRunLoopMode]; + [outputShlistStream removeFromRunLoop:[NSRunLoop currentRunLoop] + forMode:NSDefaultRunLoopMode]; + // [inputShlistStream release]; + // [outputShlistStream release]; + + inputShlistStream = nil; // stream is ivar, so reinit it + outputShlistStream = nil; // stream is ivar, so reinit it + + break; + } + default: + break; + } +} + +- (void) dealloc +{ + [inputShlistStream close]; + [outputShlistStream close]; + + [inputShlistStream removeFromRunLoop:[NSRunLoop currentRunLoop] + forMode:NSDefaultRunLoopMode]; + [outputShlistStream removeFromRunLoop:[NSRunLoop currentRunLoop] + forMode:NSDefaultRunLoopMode]; + + + inputShlistStream = nil; // stream is ivar, so reinit it + outputShlistStream = nil; // stream is ivar, so reinit it +} + +- (void) _readData +{ +} + +- (void) _writeData +{ + NSLog(@"_writeData"); +} + +- (void) writeToServer:(const char *)bytes :(size_t)length +{ + // const char bytes[] = "\x00\x00\xff\0x00"; + //string literals have implicit trailing '\0' + // size_t length = (sizeof bytes) - 1; + + NSData *data = [NSData dataWithBytes:bytes length:length]; + [outputShlistStream write:[data bytes] maxLength:[data length]]; +} + +// - (void) readFromServer: + + +@end