Kaydet (Commit) 28faf7e3 authored tarafından siqi's avatar siqi

Command interpreter works, notification center can now call segua for view transition

üst 52a37758
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* 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 */; }; 57B7625D17621E42007703F6 /* SlideShow.m in Sources */ = {isa = PBXBuildFile; fileRef = 57B7625C17621E42007703F6 /* SlideShow.m */; };
57C6E3F3175E06E800E8BC5F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57C6E3F2175E06E800E8BC5F /* UIKit.framework */; }; 57C6E3F3175E06E800E8BC5F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57C6E3F2175E06E800E8BC5F /* UIKit.framework */; };
57C6E3F5175E06E800E8BC5F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57C6E3F4175E06E800E8BC5F /* Foundation.framework */; }; 57C6E3F5175E06E800E8BC5F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57C6E3F4175E06E800E8BC5F /* Foundation.framework */; };
...@@ -27,10 +29,12 @@ ...@@ -27,10 +29,12 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference 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>"; }; 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>"; }; 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; }; 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; }; 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; }; 57C6E3F4175E06E800E8BC5F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
...@@ -75,6 +79,8 @@ ...@@ -75,6 +79,8 @@
57C6E3E6175E06E800E8BC5F = { 57C6E3E6175E06E800E8BC5F = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
57B152971764703500EECC67 /* Base64.h */,
57B152981764703500EECC67 /* Base64.m */,
57C6E425175E076900E8BC5F /* Communication */, 57C6E425175E076900E8BC5F /* Communication */,
57C6E3F8175E06E800E8BC5F /* iosremote */, 57C6E3F8175E06E800E8BC5F /* iosremote */,
57C6E3F1175E06E800E8BC5F /* Frameworks */, 57C6E3F1175E06E800E8BC5F /* Frameworks */,
...@@ -110,6 +116,8 @@ ...@@ -110,6 +116,8 @@
57C6E410175E06E800E8BC5F /* libreoffice_sdremoteViewController.h */, 57C6E410175E06E800E8BC5F /* libreoffice_sdremoteViewController.h */,
57C6E411175E06E800E8BC5F /* libreoffice_sdremoteViewController.m */, 57C6E411175E06E800E8BC5F /* libreoffice_sdremoteViewController.m */,
57C6E3F9175E06E800E8BC5F /* Supporting Files */, 57C6E3F9175E06E800E8BC5F /* Supporting Files */,
57B1529A1764714900EECC67 /* slideShowViewController.h */,
57B1529B1764714900EECC67 /* slideShowViewController.m */,
); );
path = iosremote; path = iosremote;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -131,8 +139,6 @@ ...@@ -131,8 +139,6 @@
57C6E425175E076900E8BC5F /* Communication */ = { 57C6E425175E076900E8BC5F /* Communication */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
57B7625E1762368F007703F6 /* Base64.h */,
57B7625F1762368F007703F6 /* Base64.m */,
57C6E426175E076900E8BC5F /* Client.h */, 57C6E426175E076900E8BC5F /* Client.h */,
57C6E427175E076900E8BC5F /* Client.m */, 57C6E427175E076900E8BC5F /* Client.m */,
57C6E428175E076900E8BC5F /* CommunicationManager.h */, 57C6E428175E076900E8BC5F /* CommunicationManager.h */,
...@@ -224,6 +230,8 @@ ...@@ -224,6 +230,8 @@
57C6E430175E076900E8BC5F /* CommandInterpreter.m in Sources */, 57C6E430175E076900E8BC5F /* CommandInterpreter.m in Sources */,
57C6E431175E076900E8BC5F /* Server.m in Sources */, 57C6E431175E076900E8BC5F /* Server.m in Sources */,
57B7625D17621E42007703F6 /* SlideShow.m in Sources */, 57B7625D17621E42007703F6 /* SlideShow.m in Sources */,
57B152991764703500EECC67 /* Base64.m in Sources */,
57B1529C1764714900EECC67 /* slideShowViewController.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
......
...@@ -46,8 +46,8 @@ static char decodingTable[128]; ...@@ -46,8 +46,8 @@ static char decodingTable[128];
output[index + 3] = (i + 2) < length ? encodingTable[(value >> 0) & 0x3F] : '='; output[index + 3] = (i + 2) < length ? encodingTable[(value >> 0) & 0x3F] : '=';
} }
return [[[NSString alloc] initWithData:data return [[NSString alloc] initWithData:data
encoding:NSASCIIStringEncoding] autorelease]; encoding:NSASCIIStringEncoding];
} }
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
@interface Client : NSObject @interface Client : NSObject
@property BOOL mReady; @property BOOL ready;
@property (nonatomic, strong) NSNumber* mPin; @property (nonatomic, strong) NSNumber* pin;
@property (nonatomic, strong) NSString* mName; @property (nonatomic, strong) NSString* name;
-(void) connect; -(void) connect;
......
...@@ -12,16 +12,18 @@ ...@@ -12,16 +12,18 @@
#import "CommandInterpreter.h" #import "CommandInterpreter.h"
#import "CommunicationManager.h" #import "CommunicationManager.h"
#define CHARSET @"UTF-8"
@interface Client() <NSStreamDelegate> @interface Client() <NSStreamDelegate>
@property (nonatomic, strong) NSInputStream* mInputStream; @property (nonatomic, strong) NSInputStream* inputStream;
@property (nonatomic, strong) NSOutputStream* mOutputStream; @property (nonatomic, strong) NSOutputStream* outputStream;
@property uint mPort; @property uint mPort;
@property (nonatomic, weak) Server* mServer; @property (nonatomic, weak) Server* server;
@property (nonatomic, weak) CommandInterpreter* mReceiver; @property (nonatomic, weak) CommandInterpreter* receiver;
@property (nonatomic, weak) CommunicationManager* mComManager; @property (nonatomic, weak) CommunicationManager* comManager;
@end @end
...@@ -29,15 +31,14 @@ ...@@ -29,15 +31,14 @@
@implementation Client @implementation Client
@synthesize mInputStream = _mInputStream; @synthesize inputStream = _mInputStream;
@synthesize mOutputStream = _mOutputStream; @synthesize outputStream = _mOutputStream;
@synthesize mPin = _mPin; @synthesize pin = _mPin;
@synthesize mName = _mName; @synthesize name = _mName;
@synthesize mServer = _mServer; @synthesize server = _mServer;
@synthesize mComManager = _mComManager; @synthesize comManager = _mComManager;
@synthesize mReady = _mReady; @synthesize ready = _mReady;
@synthesize receiver = _receiver;
NSString * const CHARSET = @"UTF-8";
- (id) initWithServer:(Server*)server - (id) initWithServer:(Server*)server
managedBy:(CommunicationManager*)manager managedBy:(CommunicationManager*)manager
...@@ -46,12 +47,12 @@ NSString * const CHARSET = @"UTF-8"; ...@@ -46,12 +47,12 @@ NSString * const CHARSET = @"UTF-8";
self = [self init]; self = [self init];
if (self) if (self)
{ {
self.mReady = NO; self.ready = NO;
self.mName = [[UIDevice currentDevice] name]; self.name = [[UIDevice currentDevice] name];
self.mPin = [NSNumber numberWithInteger:[self getPin]]; self.pin = [NSNumber numberWithInteger:[self getPin]];
self.mServer = server; self.server = server;
self.mComManager = manager; self.comManager = manager;
self.mReceiver = receiver; self.receiver = receiver;
self.mPort = 1599; self.mPort = 1599;
} }
return self; return self;
...@@ -64,12 +65,12 @@ NSString * const CHARSET = @"UTF-8"; ...@@ -64,12 +65,12 @@ NSString * const CHARSET = @"UTF-8";
if(!userDefaluts) if(!userDefaluts)
NSLog(@"userDefaults nil"); NSLog(@"userDefaults nil");
NSInteger newPin = [userDefaluts integerForKey:self.mName]; NSInteger newPin = [userDefaluts integerForKey:self.name];
// If not, generate one. // If not, generate one.
if (!newPin) { if (!newPin) {
newPin = arc4random() % 9999; newPin = arc4random() % 9999;
[userDefaluts setInteger:newPin forKey:self.mName]; [userDefaluts setInteger:newPin forKey:self.name];
} }
return newPin; return newPin;
...@@ -88,20 +89,20 @@ NSString * const CHARSET = @"UTF-8"; ...@@ -88,20 +89,20 @@ NSString * const CHARSET = @"UTF-8";
CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue); CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
//Setup mInputStream //Setup mInputStream
self.mInputStream = (__bridge NSInputStream *)readStream; self.inputStream = (__bridge NSInputStream *)readStream;
[self.mInputStream setDelegate:self]; [self.inputStream setDelegate:self];
[self.mInputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.mInputStream open]; [self.inputStream open];
//Setup outputstream //Setup outputstream
self.mOutputStream = (__bridge NSOutputStream *)writeStream; self.outputStream = (__bridge NSOutputStream *)writeStream;
[self.mOutputStream setDelegate:self]; [self.outputStream setDelegate:self];
[self.mOutputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.mOutputStream open]; [self.outputStream open];
// NSLog(@"Stream opened %@ %@", @"iPad", self.mPin); // 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:@""]; NSString *command = [temp componentsJoinedByString:@""];
...@@ -115,7 +116,7 @@ NSString * const CHARSET = @"UTF-8"; ...@@ -115,7 +116,7 @@ NSString * const CHARSET = @"UTF-8";
// UTF-8 as speficied in specification // UTF-8 as speficied in specification
NSData * data = [aCommand dataUsingEncoding:NSUTF8StringEncoding]; 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 { - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {
...@@ -123,7 +124,7 @@ NSString * const CHARSET = @"UTF-8"; ...@@ -123,7 +124,7 @@ NSString * const CHARSET = @"UTF-8";
switch(eventCode) { switch(eventCode) {
case NSStreamEventOpenCompleted: case NSStreamEventOpenCompleted:
NSLog(@"Connection established"); NSLog(@"Connection established");
self.mReady = YES; self.ready = YES;
break; break;
case NSStreamEventErrorOccurred: case NSStreamEventErrorOccurred:
NSLog(@"Connection error occured"); NSLog(@"Connection error occured");
...@@ -133,25 +134,30 @@ NSString * const CHARSET = @"UTF-8"; ...@@ -133,25 +134,30 @@ NSString * const CHARSET = @"UTF-8";
NSMutableData* data; NSMutableData* data;
NSLog(@"NSStreamEventHasBytesAvailable"); NSLog(@"NSStreamEventHasBytesAvailable");
if(!data) { if(!data) {
data = [NSMutableData data]; data = [[NSMutableData alloc] init];
} }
uint8_t buf[1024]; uint8_t buf[1024];
unsigned int len = 0; unsigned int len = 0;
len = [(NSInputStream *)stream read:buf maxLength:1024]; NSString *str;
if(len) { while (true) {
len = [(NSInputStream *)stream read:buf maxLength:1024];
[data appendBytes:(const void *)buf length:len]; [data appendBytes:(const void *)buf length:len];
int bytesRead = 0; if (len < 1024) {
// bytesRead is an instance variable of type NSNumber. // Potentially the end of a command
bytesRead += len; str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
} else { if ([str hasSuffix:@"\n\n"]) {
NSLog(@"No data but received event for whatever reasons!"); // Finished current command
break;
}
}
} }
NSString *str = [[NSString alloc] initWithData:data NSArray *commands = [str componentsSeparatedByString:@"\n"];
encoding:NSUTF8StringEncoding]; // NSLog(@"Data Received: %@", commands);
NSLog(@"Data Received: %@", str);
[self.receiver parse:commands];
data = nil; data = nil;
str = nil;
} break; } break;
default: default:
{ {
...@@ -164,7 +170,7 @@ NSString * const CHARSET = @"UTF-8"; ...@@ -164,7 +170,7 @@ NSString * const CHARSET = @"UTF-8";
- (void) connect - (void) connect
{ {
[self streamOpenWithIp:self.mServer.serverAddress withPortNumber:self.mPort]; [self streamOpenWithIp:self.server.serverAddress withPortNumber:self.mPort];
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
@interface CommandInterpreter : NSObject @interface CommandInterpreter : NSObject
@property (nonatomic, strong) SlideShow* mSlideShow; @property (nonatomic, strong) SlideShow* slideShow;
- (void) parse:(NSArray *)cmd; - (void) parse:(NSArray *)cmd;
......
...@@ -18,10 +18,16 @@ ...@@ -18,10 +18,16 @@
@implementation CommandInterpreter @implementation CommandInterpreter
@synthesize mSlideShow = _mSlideShow; @synthesize slideShow = _slideShow;
- (SlideShow*) slideshow{
if (!self.slideShow)
self.slideShow = [[SlideShow alloc] init];
return self.slideShow;
}
- (BOOL) isSlideRunning { - (BOOL) isSlideRunning {
return [self.mSlideShow size] > 0; return [self.slideShow size] > 0;
} }
// Received a set of instructions from server. // Received a set of instructions from server.
...@@ -32,45 +38,50 @@ ...@@ -32,45 +38,50 @@
NSString *instruction = [command objectAtIndex:0]; NSString *instruction = [command objectAtIndex:0];
if([instruction isEqualToString:@"slideshow_started"]){ if([instruction isEqualToString:@"slideshow_started"]){
unsigned int slideLength = [[command objectAtIndex:1] unsignedIntValue]; NSLog(@"Interpreter: slideshow_started");
unsigned int currentSlide = [[command objectAtIndex:2] unsignedIntValue]; 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.slideShow setSize:slideLength];
[self.mSlideShow setCurrentSlide:currentSlide]; [self.slideShow setCurrentSlide:currentSlide];
[[NSNotificationCenter defaultCenter] postNotificationName:STATUS_CONNECTED_NOSLIDESHOW [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_CONNECTED_SLIDESHOW_RUNNING
object:nil]; 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"]){ } 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]; [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_CONNECTED_NOSLIDESHOW object:nil];
} else { } else {
if (self.mSlideShow == nil) if (self.slideShow == nil)
return; return;
if ([instruction isEqualToString:@"slide_updated"]) { if ([instruction isEqualToString:@"slide_updated"]) {
unsigned int newSlideNumber = [[command objectAtIndex:1] unsignedIntValue]; NSLog(@"Interpreter: slide_updated");
[self.mSlideShow setCurrentSlide:newSlideNumber]; uint newSlideNumber = [[command objectAtIndex:1] integerValue];
[self.slideShow setCurrentSlide:newSlideNumber];
[[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_CHANGED object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_CHANGED object:nil];
} else if ([instruction isEqualToString:@"slide_preview"]){ } 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]; NSString * imageData = [command objectAtIndex:2];
[Base64 initialize];
NSData* data = [Base64 decode:imageData]; [self.slideShow putImage:imageData
UIImage* img = [UIImage imageWithData:data];
[self.mSlideShow putImage:img
AtIndex:slideNumber]; AtIndex:slideNumber];
[[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_PREVIEW object:[NSNumber numberWithUnsignedInt:slideNumber]]; [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_PREVIEW object:[NSNumber numberWithUnsignedInt:slideNumber]];
} else if ([instruction isEqualToString:@"slide_notes"]){ } 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; NSString *notes;
for (int i = 2; i<command.count; ++i) { for (int i = 2; i<command.count; ++i) {
[notes stringByAppendingString:[command objectAtIndex:i]]; [notes stringByAppendingString:[command objectAtIndex:i]];
} }
[self.mSlideShow putNotes:notes [self.slideShow putNotes:notes
AtIndex:slideNumber]; AtIndex:slideNumber];
[[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_NOTES object: [NSNumber numberWithUnsignedInt:slideNumber]]; [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_NOTES object: [NSNumber numberWithUnsignedInt:slideNumber]];
} }
......
// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
// //
// SlideShow.h // This file is part of the LibreOffice project.
// iosremote
//
// Created by Liu Siqi on 6/7/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
// //
// 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> #import <Foundation/Foundation.h>
@interface SlideShow : NSObject @interface SlideShow : NSObject
@property (nonatomic, strong) NSArray* mSlides; @property uint size;
@property (nonatomic, strong) NSNumber* mCurrentSlide; @property uint currentSlide;
- (NSUInteger) size; - (void) putImage: (NSString *)img AtIndex: (uint) index;
- (void) setCurrentSlide:(NSUInteger)number; - (void) putNotes: (NSString *)notes AtIndex: (uint) index;
- (void) setLength:(NSUInteger)number;
@end @end
// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
// //
// SlideShow.m // This file is part of the LibreOffice project.
// iosremote
//
// Created by Liu Siqi on 6/7/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
// //
// 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 "SlideShow.h"
#import "Base64.h"
@interface SlideShow()
@property (nonatomic, strong) NSMutableArray* imagesArray;
@property (nonatomic, strong) NSMutableArray* notesArray;
@end
@implementation SlideShow @implementation SlideShow
@synthesize mSlides = _mSlides; @synthesize size = _size;
@synthesize mCurrentSlide = _mCurrentSlide; @synthesize currentSlide = _currentSlide;
- (NSUInteger) size{ - (SlideShow *) init{
return self.mSlides.count; 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 @end
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<rect key="frame" x="0.0" y="64" width="768" height="960"/> <rect key="frame" x="0.0" y="64" width="768" height="960"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <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"/> <rect key="frame" x="234" y="402" width="301" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
<connections> <connections>
<outlet property="ipAddressTextEdit" destination="9w1-Ym-HcF" id="hab-JH-3Lf"/> <outlet property="ipAddressTextEdit" destination="9w1-Ym-HcF" id="hab-JH-3Lf"/>
<outlet property="pinLabel" destination="Cg3-f5-zuM" id="HaU-jr-8oJ"/> <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> </connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/>
...@@ -62,6 +63,31 @@ ...@@ -62,6 +63,31 @@
</objects> </objects>
<point key="canvasLocation" x="721" y="-301"/> <point key="canvasLocation" x="721" y="-301"/>
</scene> </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> </scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics"> <simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/> <simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/>
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
// For debug use, will use a manager to manage server and client instead // For debug use, will use a manager to manage server and client instead
@property (nonatomic, strong) Server* server; @property (nonatomic, strong) Server* server;
@property (nonatomic, strong) Client* client; @property (nonatomic, strong) Client* client;
@property (nonatomic, strong) CommandInterpreter * interpreter;
@property (nonatomic, weak) NSNotificationCenter* center;
@property (nonatomic, strong) id slideShowPreviewStartObserver;
@end @end
...@@ -23,11 +26,22 @@ ...@@ -23,11 +26,22 @@
@synthesize server = _server; @synthesize server = _server;
@synthesize client = _client; @synthesize client = _client;
@synthesize center = _center;
@synthesize interpreter = _interpreter;
@synthesize slideShowPreviewStartObserver = _slideShowPreviewStartObserver;
- (void)viewDidLoad - (void)viewDidLoad
{ {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. // 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 - (void)didReceiveMemoryWarning
...@@ -39,13 +53,14 @@ ...@@ -39,13 +53,14 @@
- (IBAction)connectToServer:(id)sender { - (IBAction)connectToServer:(id)sender {
NSString * address = [self.ipAddressTextEdit text]; NSString * address = [self.ipAddressTextEdit text];
self.interpreter = [[CommandInterpreter alloc] init];
self.server = [[Server alloc] initWithProtocol:NETWORK atAddress:address ofName:@"Server"]; 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]; [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]];
} }
} }
......
//
// 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
//
// 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment