diff options
author | siqi <me@siqi.fr> | 2013-06-09 11:44:30 +0200 |
---|---|---|
committer | siqi <me@siqi.fr> | 2013-06-09 11:45:00 +0200 |
commit | 28faf7e3a91caab172bbd344bb568db4f66a433a (patch) | |
tree | 11175dbd401e618e7123d2b3d976035f490ab84a /ios | |
parent | 52a377585cd4877bf251b482ef016cd7d16846ad (diff) |
Command interpreter works, notification center can now call segua for view transition
Diffstat (limited to 'ios')
-rw-r--r-- | ios/iosremote/iosremote.xcodeproj/project.pbxproj | 16 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Base64.m | 4 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/Client.h | 6 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/Client.m | 96 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/CommandInterpreter.h | 2 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/CommandInterpreter.m | 49 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/SlideShow.h | 20 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/SlideShow.m | 42 | ||||
-rw-r--r-- | ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard | 28 | ||||
-rw-r--r-- | ios/iosremote/iosremote/libreoffice_sdremoteViewController.m | 21 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShowViewController.h | 15 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShowViewController.m | 42 |
12 files changed, 244 insertions, 97 deletions
diff --git a/ios/iosremote/iosremote.xcodeproj/project.pbxproj b/ios/iosremote/iosremote.xcodeproj/project.pbxproj index 7930e1116f6d..9642a8511c9c 100644 --- a/ios/iosremote/iosremote.xcodeproj/project.pbxproj +++ b/ios/iosremote/iosremote.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 57B152991764703500EECC67 /* Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 57B152981764703500EECC67 /* Base64.m */; }; + 57B1529C1764714900EECC67 /* slideShowViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 57B1529B1764714900EECC67 /* slideShowViewController.m */; }; 57B7625D17621E42007703F6 /* SlideShow.m in Sources */ = {isa = PBXBuildFile; fileRef = 57B7625C17621E42007703F6 /* SlideShow.m */; }; 57C6E3F3175E06E800E8BC5F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57C6E3F2175E06E800E8BC5F /* UIKit.framework */; }; 57C6E3F5175E06E800E8BC5F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57C6E3F4175E06E800E8BC5F /* Foundation.framework */; }; @@ -27,10 +29,12 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 57B152971764703500EECC67 /* Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Base64.h; path = iosremote/Base64.h; sourceTree = "<group>"; }; + 57B152981764703500EECC67 /* Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Base64.m; path = iosremote/Base64.m; sourceTree = "<group>"; }; + 57B1529A1764714900EECC67 /* slideShowViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = slideShowViewController.h; sourceTree = "<group>"; }; + 57B1529B1764714900EECC67 /* slideShowViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = slideShowViewController.m; sourceTree = "<group>"; }; 57B7625B17621E42007703F6 /* SlideShow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideShow.h; sourceTree = "<group>"; }; 57B7625C17621E42007703F6 /* SlideShow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideShow.m; sourceTree = "<group>"; }; - 57B7625E1762368F007703F6 /* Base64.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Base64.h; path = ../Base64.h; sourceTree = "<group>"; }; - 57B7625F1762368F007703F6 /* Base64.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Base64.m; path = ../Base64.m; sourceTree = "<group>"; }; 57C6E3EF175E06E800E8BC5F /* iosremote.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iosremote.app; sourceTree = BUILT_PRODUCTS_DIR; }; 57C6E3F2175E06E800E8BC5F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 57C6E3F4175E06E800E8BC5F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -75,6 +79,8 @@ 57C6E3E6175E06E800E8BC5F = { isa = PBXGroup; children = ( + 57B152971764703500EECC67 /* Base64.h */, + 57B152981764703500EECC67 /* Base64.m */, 57C6E425175E076900E8BC5F /* Communication */, 57C6E3F8175E06E800E8BC5F /* iosremote */, 57C6E3F1175E06E800E8BC5F /* Frameworks */, @@ -110,6 +116,8 @@ 57C6E410175E06E800E8BC5F /* libreoffice_sdremoteViewController.h */, 57C6E411175E06E800E8BC5F /* libreoffice_sdremoteViewController.m */, 57C6E3F9175E06E800E8BC5F /* Supporting Files */, + 57B1529A1764714900EECC67 /* slideShowViewController.h */, + 57B1529B1764714900EECC67 /* slideShowViewController.m */, ); path = iosremote; sourceTree = "<group>"; @@ -131,8 +139,6 @@ 57C6E425175E076900E8BC5F /* Communication */ = { isa = PBXGroup; children = ( - 57B7625E1762368F007703F6 /* Base64.h */, - 57B7625F1762368F007703F6 /* Base64.m */, 57C6E426175E076900E8BC5F /* Client.h */, 57C6E427175E076900E8BC5F /* Client.m */, 57C6E428175E076900E8BC5F /* CommunicationManager.h */, @@ -224,6 +230,8 @@ 57C6E430175E076900E8BC5F /* CommandInterpreter.m in Sources */, 57C6E431175E076900E8BC5F /* Server.m in Sources */, 57B7625D17621E42007703F6 /* SlideShow.m in Sources */, + 57B152991764703500EECC67 /* Base64.m in Sources */, + 57B1529C1764714900EECC67 /* slideShowViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ios/iosremote/iosremote/Base64.m b/ios/iosremote/iosremote/Base64.m index 56e080baae4a..fc2a36949153 100644 --- a/ios/iosremote/iosremote/Base64.m +++ b/ios/iosremote/iosremote/Base64.m @@ -46,8 +46,8 @@ static char decodingTable[128]; output[index + 3] = (i + 2) < length ? encodingTable[(value >> 0) & 0x3F] : '='; } - return [[[NSString alloc] initWithData:data - encoding:NSASCIIStringEncoding] autorelease]; + return [[NSString alloc] initWithData:data + encoding:NSASCIIStringEncoding]; } diff --git a/ios/iosremote/iosremote/Communication/Client.h b/ios/iosremote/iosremote/Communication/Client.h index 7ba32a54351f..5cd0a42535e8 100644 --- a/ios/iosremote/iosremote/Communication/Client.h +++ b/ios/iosremote/iosremote/Communication/Client.h @@ -13,9 +13,9 @@ @interface Client : NSObject -@property BOOL mReady; -@property (nonatomic, strong) NSNumber* mPin; -@property (nonatomic, strong) NSString* mName; +@property BOOL ready; +@property (nonatomic, strong) NSNumber* pin; +@property (nonatomic, strong) NSString* name; -(void) connect; diff --git a/ios/iosremote/iosremote/Communication/Client.m b/ios/iosremote/iosremote/Communication/Client.m index 16c4aa24aca3..3b1f1b6b5914 100644 --- a/ios/iosremote/iosremote/Communication/Client.m +++ b/ios/iosremote/iosremote/Communication/Client.m @@ -12,16 +12,18 @@ #import "CommandInterpreter.h" #import "CommunicationManager.h" +#define CHARSET @"UTF-8" + @interface Client() <NSStreamDelegate> -@property (nonatomic, strong) NSInputStream* mInputStream; -@property (nonatomic, strong) NSOutputStream* mOutputStream; +@property (nonatomic, strong) NSInputStream* inputStream; +@property (nonatomic, strong) NSOutputStream* outputStream; @property uint mPort; -@property (nonatomic, weak) Server* mServer; -@property (nonatomic, weak) CommandInterpreter* mReceiver; -@property (nonatomic, weak) CommunicationManager* mComManager; +@property (nonatomic, weak) Server* server; +@property (nonatomic, weak) CommandInterpreter* receiver; +@property (nonatomic, weak) CommunicationManager* comManager; @end @@ -29,15 +31,14 @@ @implementation Client -@synthesize mInputStream = _mInputStream; -@synthesize mOutputStream = _mOutputStream; -@synthesize mPin = _mPin; -@synthesize mName = _mName; -@synthesize mServer = _mServer; -@synthesize mComManager = _mComManager; -@synthesize mReady = _mReady; - -NSString * const CHARSET = @"UTF-8"; +@synthesize inputStream = _mInputStream; +@synthesize outputStream = _mOutputStream; +@synthesize pin = _mPin; +@synthesize name = _mName; +@synthesize server = _mServer; +@synthesize comManager = _mComManager; +@synthesize ready = _mReady; +@synthesize receiver = _receiver; - (id) initWithServer:(Server*)server managedBy:(CommunicationManager*)manager @@ -46,12 +47,12 @@ NSString * const CHARSET = @"UTF-8"; self = [self init]; if (self) { - self.mReady = NO; - self.mName = [[UIDevice currentDevice] name]; - self.mPin = [NSNumber numberWithInteger:[self getPin]]; - self.mServer = server; - self.mComManager = manager; - self.mReceiver = receiver; + self.ready = NO; + self.name = [[UIDevice currentDevice] name]; + self.pin = [NSNumber numberWithInteger:[self getPin]]; + self.server = server; + self.comManager = manager; + self.receiver = receiver; self.mPort = 1599; } return self; @@ -64,12 +65,12 @@ NSString * const CHARSET = @"UTF-8"; if(!userDefaluts) NSLog(@"userDefaults nil"); - NSInteger newPin = [userDefaluts integerForKey:self.mName]; + NSInteger newPin = [userDefaluts integerForKey:self.name]; // If not, generate one. if (!newPin) { newPin = arc4random() % 9999; - [userDefaluts setInteger:newPin forKey:self.mName]; + [userDefaluts setInteger:newPin forKey:self.name]; } return newPin; @@ -88,20 +89,20 @@ NSString * const CHARSET = @"UTF-8"; CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue); //Setup mInputStream - self.mInputStream = (__bridge NSInputStream *)readStream; - [self.mInputStream setDelegate:self]; - [self.mInputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - [self.mInputStream open]; + self.inputStream = (__bridge NSInputStream *)readStream; + [self.inputStream setDelegate:self]; + [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [self.inputStream open]; //Setup outputstream - self.mOutputStream = (__bridge NSOutputStream *)writeStream; - [self.mOutputStream setDelegate:self]; - [self.mOutputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - [self.mOutputStream open]; + self.outputStream = (__bridge NSOutputStream *)writeStream; + [self.outputStream setDelegate:self]; + [self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [self.outputStream open]; // NSLog(@"Stream opened %@ %@", @"iPad", self.mPin); - NSArray *temp = [[NSArray alloc]initWithObjects:@"LO_SERVER_CLIENT_PAIR\n", self.mName, @"\n", self.mPin, @"\n\n", nil]; + NSArray *temp = [[NSArray alloc]initWithObjects:@"LO_SERVER_CLIENT_PAIR\n", self.name, @"\n", self.pin, @"\n\n", nil]; NSString *command = [temp componentsJoinedByString:@""]; @@ -115,7 +116,7 @@ NSString * const CHARSET = @"UTF-8"; // UTF-8 as speficied in specification NSData * data = [aCommand dataUsingEncoding:NSUTF8StringEncoding]; - [self.mOutputStream write:(uint8_t *)[data bytes] maxLength:[data length]]; + [self.outputStream write:(uint8_t *)[data bytes] maxLength:[data length]]; } - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode { @@ -123,7 +124,7 @@ NSString * const CHARSET = @"UTF-8"; switch(eventCode) { case NSStreamEventOpenCompleted: NSLog(@"Connection established"); - self.mReady = YES; + self.ready = YES; break; case NSStreamEventErrorOccurred: NSLog(@"Connection error occured"); @@ -133,25 +134,30 @@ NSString * const CHARSET = @"UTF-8"; NSMutableData* data; NSLog(@"NSStreamEventHasBytesAvailable"); if(!data) { - data = [NSMutableData data]; + data = [[NSMutableData alloc] init]; } uint8_t buf[1024]; unsigned int len = 0; - len = [(NSInputStream *)stream read:buf maxLength:1024]; - if(len) { + NSString *str; + while (true) { + len = [(NSInputStream *)stream read:buf maxLength:1024]; [data appendBytes:(const void *)buf length:len]; - int bytesRead = 0; - // bytesRead is an instance variable of type NSNumber. - bytesRead += len; - } else { - NSLog(@"No data but received event for whatever reasons!"); + if (len < 1024) { + // Potentially the end of a command + str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + if ([str hasSuffix:@"\n\n"]) { + // Finished current command + break; + } + } } - NSString *str = [[NSString alloc] initWithData:data - encoding:NSUTF8StringEncoding]; - NSLog(@"Data Received: %@", str); + NSArray *commands = [str componentsSeparatedByString:@"\n"]; +// NSLog(@"Data Received: %@", commands); + [self.receiver parse:commands]; data = nil; + str = nil; } break; default: { @@ -164,7 +170,7 @@ NSString * const CHARSET = @"UTF-8"; - (void) connect { - [self streamOpenWithIp:self.mServer.serverAddress withPortNumber:self.mPort]; + [self streamOpenWithIp:self.server.serverAddress withPortNumber:self.mPort]; } diff --git a/ios/iosremote/iosremote/Communication/CommandInterpreter.h b/ios/iosremote/iosremote/Communication/CommandInterpreter.h index 856bff766b10..faa07cf66d88 100644 --- a/ios/iosremote/iosremote/Communication/CommandInterpreter.h +++ b/ios/iosremote/iosremote/Communication/CommandInterpreter.h @@ -12,7 +12,7 @@ @interface CommandInterpreter : NSObject -@property (nonatomic, strong) SlideShow* mSlideShow; +@property (nonatomic, strong) SlideShow* slideShow; - (void) parse:(NSArray *)cmd; diff --git a/ios/iosremote/iosremote/Communication/CommandInterpreter.m b/ios/iosremote/iosremote/Communication/CommandInterpreter.m index 91c513d748cc..779e2f6359a4 100644 --- a/ios/iosremote/iosremote/Communication/CommandInterpreter.m +++ b/ios/iosremote/iosremote/Communication/CommandInterpreter.m @@ -18,10 +18,16 @@ @implementation CommandInterpreter -@synthesize mSlideShow = _mSlideShow; +@synthesize slideShow = _slideShow; + +- (SlideShow*) slideshow{ + if (!self.slideShow) + self.slideShow = [[SlideShow alloc] init]; + return self.slideShow; +} - (BOOL) isSlideRunning { - return [self.mSlideShow size] > 0; + return [self.slideShow size] > 0; } // Received a set of instructions from server. @@ -32,45 +38,50 @@ NSString *instruction = [command objectAtIndex:0]; if([instruction isEqualToString:@"slideshow_started"]){ - unsigned int slideLength = [[command objectAtIndex:1] unsignedIntValue]; - unsigned int currentSlide = [[command objectAtIndex:2] unsignedIntValue]; + NSLog(@"Interpreter: slideshow_started"); + uint slideLength = [[command objectAtIndex:1] integerValue]; + uint currentSlide = [[command objectAtIndex:2] integerValue]; + NSLog(@"Interpreter: with slideLength %u, currentSlide %u", slideLength, currentSlide); + self.slideShow = [[SlideShow alloc] init]; - [self.mSlideShow setLength:slideLength]; - [self.mSlideShow setCurrentSlide:currentSlide]; + [self.slideShow setSize:slideLength]; + [self.slideShow setCurrentSlide:currentSlide]; - [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_CONNECTED_NOSLIDESHOW + [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_CONNECTED_SLIDESHOW_RUNNING object:nil]; - [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_CHANGED object:self.mSlideShow.mCurrentSlide]; + [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_CHANGED object:[NSNumber numberWithUnsignedInt:currentSlide]]; } else if ([instruction isEqualToString:@"slideshow_finished"]){ - self.mSlideShow = [SlideShow init]; + NSLog(@"Interpreter: slideshow_started"); + self.slideShow = [[SlideShow alloc] init]; [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_CONNECTED_NOSLIDESHOW object:nil]; } else { - if (self.mSlideShow == nil) + if (self.slideShow == nil) return; if ([instruction isEqualToString:@"slide_updated"]) { - unsigned int newSlideNumber = [[command objectAtIndex:1] unsignedIntValue]; - [self.mSlideShow setCurrentSlide:newSlideNumber]; + NSLog(@"Interpreter: slide_updated"); + uint newSlideNumber = [[command objectAtIndex:1] integerValue]; + [self.slideShow setCurrentSlide:newSlideNumber]; [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_CHANGED object:nil]; } else if ([instruction isEqualToString:@"slide_preview"]){ - unsigned int slideNumber = [[command objectAtIndex:1] unsignedIntValue]; + NSLog(@"Interpreter: slide_preview"); + uint slideNumber = [[command objectAtIndex:1] integerValue]; NSString * imageData = [command objectAtIndex:2]; - [Base64 initialize]; - NSData* data = [Base64 decode:imageData]; - UIImage* img = [UIImage imageWithData:data]; - [self.mSlideShow putImage:img + + [self.slideShow putImage:imageData AtIndex:slideNumber]; [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_PREVIEW object:[NSNumber numberWithUnsignedInt:slideNumber]]; } else if ([instruction isEqualToString:@"slide_notes"]){ - unsigned int slideNumber = [[command objectAtIndex:1] unsignedIntValue]; + NSLog(@"Interpreter: slide_notes"); + uint slideNumber = [[command objectAtIndex:1] integerValue]; NSString *notes; for (int i = 2; i<command.count; ++i) { [notes stringByAppendingString:[command objectAtIndex:i]]; } - [self.mSlideShow putNotes:notes + [self.slideShow putNotes:notes AtIndex:slideNumber]; [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_NOTES object: [NSNumber numberWithUnsignedInt:slideNumber]]; } diff --git a/ios/iosremote/iosremote/Communication/SlideShow.h b/ios/iosremote/iosremote/Communication/SlideShow.h index 11ea4d83117c..c2e30ccfb4b0 100644 --- a/ios/iosremote/iosremote/Communication/SlideShow.h +++ b/ios/iosremote/iosremote/Communication/SlideShow.h @@ -1,20 +1,20 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// SlideShow.h -// iosremote -// -// Created by Liu Siqi on 6/7/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// This file is part of the LibreOffice project. // +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + #import <Foundation/Foundation.h> @interface SlideShow : NSObject -@property (nonatomic, strong) NSArray* mSlides; -@property (nonatomic, strong) NSNumber* mCurrentSlide; +@property uint size; +@property uint currentSlide; -- (NSUInteger) size; -- (void) setCurrentSlide:(NSUInteger)number; -- (void) setLength:(NSUInteger)number; +- (void) putImage: (NSString *)img AtIndex: (uint) index; +- (void) putNotes: (NSString *)notes AtIndex: (uint) index; @end diff --git a/ios/iosremote/iosremote/Communication/SlideShow.m b/ios/iosremote/iosremote/Communication/SlideShow.m index d6435e9abd54..b2a4c084f908 100644 --- a/ios/iosremote/iosremote/Communication/SlideShow.m +++ b/ios/iosremote/iosremote/Communication/SlideShow.m @@ -1,20 +1,44 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// SlideShow.m -// iosremote -// -// Created by Liu Siqi on 6/7/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// This file is part of the LibreOffice project. // +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + #import "SlideShow.h" +#import "Base64.h" + +@interface SlideShow() + +@property (nonatomic, strong) NSMutableArray* imagesArray; +@property (nonatomic, strong) NSMutableArray* notesArray; + +@end @implementation SlideShow -@synthesize mSlides = _mSlides; -@synthesize mCurrentSlide = _mCurrentSlide; +@synthesize size = _size; +@synthesize currentSlide = _currentSlide; -- (NSUInteger) size{ - return self.mSlides.count; +- (SlideShow *) init{ + self = [super init]; + _size = 0; + _currentSlide = 0; + return self; } +- (void) putImage: (NSString *)img AtIndex: (uint) index{ + [Base64 initialize]; + NSData* data = [Base64 decode:img]; + UIImage* image = [UIImage imageWithData:data]; + [self.imagesArray insertObject:image atIndex:index]; +} + +- (void) putNotes: (NSString *)notes AtIndex: (uint) index{ + [self.notesArray insertObject:notes atIndex:index]; +} + + @end diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard index d4a118a6a6ad..cb43691aeb3d 100644 --- a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard +++ b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard @@ -12,7 +12,7 @@ <rect key="frame" x="0.0" y="64" width="768" height="960"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="172.25.19.11" borderStyle="roundedRect" minimumFontSize="17" id="9w1-Ym-HcF"> + <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="192.168.1.97" borderStyle="roundedRect" minimumFontSize="17" id="9w1-Ym-HcF"> <rect key="frame" x="234" y="402" width="301" height="30"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> @@ -38,6 +38,7 @@ <connections> <outlet property="ipAddressTextEdit" destination="9w1-Ym-HcF" id="hab-JH-3Lf"/> <outlet property="pinLabel" destination="Cg3-f5-zuM" id="HaU-jr-8oJ"/> + <segue destination="zdX-BL-bmY" kind="push" identifier="slidesPreview" id="9Yb-di-Q6v"/> </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/> @@ -62,6 +63,31 @@ </objects> <point key="canvasLocation" x="721" y="-301"/> </scene> + <!--Slide Show View Controller--> + <scene sceneID="wDH-NE-E5t"> + <objects> + <viewController id="zdX-BL-bmY" customClass="slideShowViewController" sceneMemberID="viewController"> + <view key="view" contentMode="scaleToFill" id="Tkv-NW-1bl"> + <rect key="frame" x="0.0" y="64" width="768" height="960"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <subviews> + <imageView userInteractionEnabled="NO" contentMode="scaleToFill" id="T6z-xu-j8h"> + <rect key="frame" x="0.0" y="0.0" width="768" height="960"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + </imageView> + </subviews> + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> + </view> + <navigationItem key="navigationItem" id="uc0-p3-wnG"/> + <connections> + <outlet property="image" destination="T6z-xu-j8h" id="o1L-LM-TbP"/> + <outlet property="view" destination="T6z-xu-j8h" id="YKN-ib-gU3"/> + </connections> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="Dqn-Ae-ABD" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="2616" y="-293"/> + </scene> </scenes> <simulatedMetricsContainer key="defaultSimulatedMetrics"> <simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/> diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m index ba4340bbe624..45e23ee76fd8 100644 --- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m +++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m @@ -16,6 +16,9 @@ // For debug use, will use a manager to manage server and client instead @property (nonatomic, strong) Server* server; @property (nonatomic, strong) Client* client; +@property (nonatomic, strong) CommandInterpreter * interpreter; +@property (nonatomic, weak) NSNotificationCenter* center; +@property (nonatomic, strong) id slideShowPreviewStartObserver; @end @@ -23,11 +26,22 @@ @synthesize server = _server; @synthesize client = _client; +@synthesize center = _center; +@synthesize interpreter = _interpreter; +@synthesize slideShowPreviewStartObserver = _slideShowPreviewStartObserver; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. + self.center = [NSNotificationCenter defaultCenter]; + NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; + self.slideShowPreviewStartObserver = [self.center addObserverForName:STATUS_CONNECTED_SLIDESHOW_RUNNING object:nil + queue:mainQueue usingBlock:^(NSNotification *note) { + NSLog(@"Received performSegue!"); + [self performSegueWithIdentifier:@"slidesPreview" sender:self]; + }]; + } - (void)didReceiveMemoryWarning @@ -39,13 +53,14 @@ - (IBAction)connectToServer:(id)sender { NSString * address = [self.ipAddressTextEdit text]; + self.interpreter = [[CommandInterpreter alloc] init]; self.server = [[Server alloc] initWithProtocol:NETWORK atAddress:address ofName:@"Server"]; - self.client = [[Client alloc] initWithServer:self.server managedBy:nil interpretedBy:nil]; + self.client = [[Client alloc] initWithServer:self.server managedBy:nil interpretedBy:self.interpreter]; [self.client connect]; - if([self.client mReady]) + if([self.client ready]) { - [self.pinLabel setText:[NSString stringWithFormat:@"%@", self.client.mPin]]; + [self.pinLabel setText:[NSString stringWithFormat:@"%@", self.client.pin]]; } } diff --git a/ios/iosremote/iosremote/slideShowViewController.h b/ios/iosremote/iosremote/slideShowViewController.h new file mode 100644 index 000000000000..f44b849d334c --- /dev/null +++ b/ios/iosremote/iosremote/slideShowViewController.h @@ -0,0 +1,15 @@ +// +// slideShowViewController.h +// iosremote +// +// Created by Liu Siqi on 6/9/13. +// Copyright (c) 2013 libreoffice. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface slideShowViewController : UIViewController + +@property (weak, nonatomic) IBOutlet UIImageView *image; + +@end diff --git a/ios/iosremote/iosremote/slideShowViewController.m b/ios/iosremote/iosremote/slideShowViewController.m new file mode 100644 index 000000000000..cd04f3987aa5 --- /dev/null +++ b/ios/iosremote/iosremote/slideShowViewController.m @@ -0,0 +1,42 @@ +// +// slideShowViewController.m +// iosremote +// +// Created by Liu Siqi on 6/9/13. +// Copyright (c) 2013 libreoffice. All rights reserved. +// + +#import "slideShowViewController.h" + +@interface slideShowViewController () + +@end + +@implementation slideShowViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)viewDidUnload { + [self setImage:nil]; + [super viewDidUnload]; +} +@end |