From d3aa6c58d40a6516c188e85ed6ad12f1b4012a94 Mon Sep 17 00:00:00 2001 From: siqi Date: Fri, 7 Jun 2013 18:25:00 +0200 Subject: cmd interpreter implemented --- ios/iosremote/iosremote.xcodeproj/project.pbxproj | 22 +++-- ios/iosremote/iosremote/Base64.h | 29 ++++++ ios/iosremote/iosremote/Base64.m | 97 +++++++++++++++++++++ ios/iosremote/iosremote/Communication/.DS_Store | Bin 6148 -> 6148 bytes ios/iosremote/iosremote/Communication/Client.h | 8 +- ios/iosremote/iosremote/Communication/Client.m | 69 ++++++++------- .../iosremote/Communication/CommandInterpreter.h | 19 ++++ .../iosremote/Communication/CommandInterpreter.m | 82 +++++++++++++++++ .../iosremote/Communication/CommunicationManager.h | 28 ++++++ ios/iosremote/iosremote/Communication/Receiver.h | 14 --- ios/iosremote/iosremote/Communication/Receiver.m | 14 --- ios/iosremote/iosremote/Communication/SlideShow.h | 20 +++++ ios/iosremote/iosremote/Communication/SlideShow.m | 20 +++++ .../en.lproj/MainStoryboard_iPad.storyboard | 17 ++-- .../iosremote/libreoffice_sdremoteViewController.h | 13 +-- .../iosremote/libreoffice_sdremoteViewController.m | 7 ++ 16 files changed, 378 insertions(+), 81 deletions(-) create mode 100644 ios/iosremote/iosremote/Base64.h create mode 100644 ios/iosremote/iosremote/Base64.m create mode 100644 ios/iosremote/iosremote/Communication/CommandInterpreter.h create mode 100644 ios/iosremote/iosremote/Communication/CommandInterpreter.m delete mode 100644 ios/iosremote/iosremote/Communication/Receiver.h delete mode 100644 ios/iosremote/iosremote/Communication/Receiver.m create mode 100644 ios/iosremote/iosremote/Communication/SlideShow.h create mode 100644 ios/iosremote/iosremote/Communication/SlideShow.m (limited to 'ios') diff --git a/ios/iosremote/iosremote.xcodeproj/project.pbxproj b/ios/iosremote/iosremote.xcodeproj/project.pbxproj index 9e02f0fcc305..7930e1116f6d 100644 --- a/ios/iosremote/iosremote.xcodeproj/project.pbxproj +++ b/ios/iosremote/iosremote.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 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 */; }; 57C6E3F7175E06E800E8BC5F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57C6E3F6175E06E800E8BC5F /* CoreGraphics.framework */; }; @@ -21,11 +22,15 @@ 57C6E412175E06E800E8BC5F /* libreoffice_sdremoteViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 57C6E411175E06E800E8BC5F /* libreoffice_sdremoteViewController.m */; }; 57C6E42E175E076900E8BC5F /* Client.m in Sources */ = {isa = PBXBuildFile; fileRef = 57C6E427175E076900E8BC5F /* Client.m */; }; 57C6E42F175E076900E8BC5F /* CommunicationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 57C6E429175E076900E8BC5F /* CommunicationManager.m */; }; - 57C6E430175E076900E8BC5F /* Receiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 57C6E42B175E076900E8BC5F /* Receiver.m */; }; + 57C6E430175E076900E8BC5F /* CommandInterpreter.m in Sources */ = {isa = PBXBuildFile; fileRef = 57C6E42B175E076900E8BC5F /* CommandInterpreter.m */; }; 57C6E431175E076900E8BC5F /* Server.m in Sources */ = {isa = PBXBuildFile; fileRef = 57C6E42D175E076900E8BC5F /* Server.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 57B7625B17621E42007703F6 /* SlideShow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideShow.h; sourceTree = ""; }; + 57B7625C17621E42007703F6 /* SlideShow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideShow.m; sourceTree = ""; }; + 57B7625E1762368F007703F6 /* Base64.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Base64.h; path = ../Base64.h; sourceTree = ""; }; + 57B7625F1762368F007703F6 /* Base64.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Base64.m; path = ../Base64.m; sourceTree = ""; }; 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; }; @@ -47,8 +52,8 @@ 57C6E427175E076900E8BC5F /* Client.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Client.m; sourceTree = ""; }; 57C6E428175E076900E8BC5F /* CommunicationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommunicationManager.h; sourceTree = ""; }; 57C6E429175E076900E8BC5F /* CommunicationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommunicationManager.m; sourceTree = ""; }; - 57C6E42A175E076900E8BC5F /* Receiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Receiver.h; sourceTree = ""; }; - 57C6E42B175E076900E8BC5F /* Receiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Receiver.m; sourceTree = ""; }; + 57C6E42A175E076900E8BC5F /* CommandInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandInterpreter.h; sourceTree = ""; }; + 57C6E42B175E076900E8BC5F /* CommandInterpreter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommandInterpreter.m; sourceTree = ""; }; 57C6E42C175E076900E8BC5F /* Server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Server.h; sourceTree = ""; }; 57C6E42D175E076900E8BC5F /* Server.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Server.m; sourceTree = ""; }; /* End PBXFileReference section */ @@ -126,14 +131,18 @@ 57C6E425175E076900E8BC5F /* Communication */ = { isa = PBXGroup; children = ( + 57B7625E1762368F007703F6 /* Base64.h */, + 57B7625F1762368F007703F6 /* Base64.m */, 57C6E426175E076900E8BC5F /* Client.h */, 57C6E427175E076900E8BC5F /* Client.m */, 57C6E428175E076900E8BC5F /* CommunicationManager.h */, 57C6E429175E076900E8BC5F /* CommunicationManager.m */, - 57C6E42A175E076900E8BC5F /* Receiver.h */, - 57C6E42B175E076900E8BC5F /* Receiver.m */, + 57C6E42A175E076900E8BC5F /* CommandInterpreter.h */, + 57C6E42B175E076900E8BC5F /* CommandInterpreter.m */, 57C6E42C175E076900E8BC5F /* Server.h */, 57C6E42D175E076900E8BC5F /* Server.m */, + 57B7625B17621E42007703F6 /* SlideShow.h */, + 57B7625C17621E42007703F6 /* SlideShow.m */, ); name = Communication; path = iosremote/Communication; @@ -212,8 +221,9 @@ 57C6E412175E06E800E8BC5F /* libreoffice_sdremoteViewController.m in Sources */, 57C6E42E175E076900E8BC5F /* Client.m in Sources */, 57C6E42F175E076900E8BC5F /* CommunicationManager.m in Sources */, - 57C6E430175E076900E8BC5F /* Receiver.m in Sources */, + 57C6E430175E076900E8BC5F /* CommandInterpreter.m in Sources */, 57C6E431175E076900E8BC5F /* Server.m in Sources */, + 57B7625D17621E42007703F6 /* SlideShow.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ios/iosremote/iosremote/Base64.h b/ios/iosremote/iosremote/Base64.h new file mode 100644 index 000000000000..f61160d34bbc --- /dev/null +++ b/ios/iosremote/iosremote/Base64.h @@ -0,0 +1,29 @@ +// +// Base64.h +// CryptTest +// +// Created by Kiichi Takeuchi on 4/20/10. +// Copyright 2010 ObjectGraph LLC. All rights reserved. +// +// Original Source Code is donated by Cyrus +// Public Domain License +// http://www.cocoadev.com/index.pl?BaseSixtyFour + +#import + + +@interface Base64 : NSObject { + +} + ++ (void) initialize; + ++ (NSString*) encode:(const uint8_t*) input length:(NSInteger) length; + ++ (NSString*) encode:(NSData*) rawBytes; + ++ (NSData*) decode:(const char*) string length:(NSInteger) inputLength; + ++ (NSData*) decode:(NSString*) string; + +@end diff --git a/ios/iosremote/iosremote/Base64.m b/ios/iosremote/iosremote/Base64.m new file mode 100644 index 000000000000..56e080baae4a --- /dev/null +++ b/ios/iosremote/iosremote/Base64.m @@ -0,0 +1,97 @@ +// +// Base64.m +// CryptTest +// +// Created by Kiichi Takeuchi on 4/20/10. +// Copyright 2010 ObjectGraph LLC. All rights reserved. +// + +#import "Base64.h" + + +@implementation Base64 +#define ArrayLength(x) (sizeof(x)/sizeof(*(x))) + +static char encodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static char decodingTable[128]; + ++ (void) initialize { + if (self == [Base64 class]) { + memset(decodingTable, 0, ArrayLength(decodingTable)); + for (NSInteger i = 0; i < ArrayLength(encodingTable); i++) { + decodingTable[encodingTable[i]] = i; + } + } +} + + ++ (NSString*) encode:(const uint8_t*) input length:(NSInteger) length { + NSMutableData* data = [NSMutableData dataWithLength:((length + 2) / 3) * 4]; + uint8_t* output = (uint8_t*)data.mutableBytes; + + for (NSInteger i = 0; i < length; i += 3) { + NSInteger value = 0; + for (NSInteger j = i; j < (i + 3); j++) { + value <<= 8; + + if (j < length) { + value |= (0xFF & input[j]); + } + } + + NSInteger index = (i / 3) * 4; + output[index + 0] = encodingTable[(value >> 18) & 0x3F]; + output[index + 1] = encodingTable[(value >> 12) & 0x3F]; + output[index + 2] = (i + 1) < length ? encodingTable[(value >> 6) & 0x3F] : '='; + output[index + 3] = (i + 2) < length ? encodingTable[(value >> 0) & 0x3F] : '='; + } + + return [[[NSString alloc] initWithData:data + encoding:NSASCIIStringEncoding] autorelease]; +} + + ++ (NSString*) encode:(NSData*) rawBytes { + return [self encode:(const uint8_t*) rawBytes.bytes length:rawBytes.length]; +} + + ++ (NSData*) decode:(const char*) string length:(NSInteger) inputLength { + if ((string == NULL) || (inputLength % 4 != 0)) { + return nil; + } + + while (inputLength > 0 && string[inputLength - 1] == '=') { + inputLength--; + } + + NSInteger outputLength = inputLength * 3 / 4; + NSMutableData* data = [NSMutableData dataWithLength:outputLength]; + uint8_t* output = data.mutableBytes; + + NSInteger inputPoint = 0; + NSInteger outputPoint = 0; + while (inputPoint < inputLength) { + char i0 = string[inputPoint++]; + char i1 = string[inputPoint++]; + char i2 = inputPoint < inputLength ? string[inputPoint++] : 'A'; /* 'A' will decode to \0 */ + char i3 = inputPoint < inputLength ? string[inputPoint++] : 'A'; + + output[outputPoint++] = (decodingTable[i0] << 2) | (decodingTable[i1] >> 4); + if (outputPoint < outputLength) { + output[outputPoint++] = ((decodingTable[i1] & 0xf) << 4) | (decodingTable[i2] >> 2); + } + if (outputPoint < outputLength) { + output[outputPoint++] = ((decodingTable[i2] & 0x3) << 6) | decodingTable[i3]; + } + } + + return data; +} + + ++ (NSData*) decode:(NSString*) string { + return [self decode:[string cStringUsingEncoding:NSASCIIStringEncoding] length:string.length]; +} + +@end diff --git a/ios/iosremote/iosremote/Communication/.DS_Store b/ios/iosremote/iosremote/Communication/.DS_Store index bbb5276d7d0d..83d9e2aef8f3 100644 Binary files a/ios/iosremote/iosremote/Communication/.DS_Store and b/ios/iosremote/iosremote/Communication/.DS_Store differ diff --git a/ios/iosremote/iosremote/Communication/Client.h b/ios/iosremote/iosremote/Communication/Client.h index ac98afd8d287..7ba32a54351f 100644 --- a/ios/iosremote/iosremote/Communication/Client.h +++ b/ios/iosremote/iosremote/Communication/Client.h @@ -9,15 +9,19 @@ #import #import "Server.h" #import "CommunicationManager.h" -#import "Receiver.h" +#import "CommandInterpreter.h" @interface Client : NSObject +@property BOOL mReady; +@property (nonatomic, strong) NSNumber* mPin; +@property (nonatomic, strong) NSString* mName; + -(void) connect; - (id) initWithServer:(Server*)server managedBy:(CommunicationManager*)manager - interpretedBy:(Receiver*)receiver; + interpretedBy:(CommandInterpreter*)receiver; -(void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode; diff --git a/ios/iosremote/iosremote/Communication/Client.m b/ios/iosremote/iosremote/Communication/Client.m index 37ac0e92c85c..16c4aa24aca3 100644 --- a/ios/iosremote/iosremote/Communication/Client.m +++ b/ios/iosremote/iosremote/Communication/Client.m @@ -9,7 +9,7 @@ #import "Client.h" #import "Server.h" -#import "Receiver.h" +#import "CommandInterpreter.h" #import "CommunicationManager.h" @interface Client() @@ -17,18 +17,12 @@ @property (nonatomic, strong) NSInputStream* mInputStream; @property (nonatomic, strong) NSOutputStream* mOutputStream; -@property (nonatomic, strong) NSString* mPin; -@property (nonatomic, strong) NSString* mName; @property uint mPort; @property (nonatomic, weak) Server* mServer; -@property (nonatomic, weak) Receiver* mReceiver; +@property (nonatomic, weak) CommandInterpreter* mReceiver; @property (nonatomic, weak) CommunicationManager* mComManager; -@property (nonatomic, retain) NSMutableData* mData; - -@property BOOL mReady; - @end @@ -41,31 +35,44 @@ @synthesize mName = _mName; @synthesize mServer = _mServer; @synthesize mComManager = _mComManager; -@synthesize mData = _mData; @synthesize mReady = _mReady; NSString * const CHARSET = @"UTF-8"; - (id) initWithServer:(Server*)server managedBy:(CommunicationManager*)manager - interpretedBy:(Receiver*)receiver + interpretedBy:(CommandInterpreter*)receiver { - self.mPin = [self getPin]; - NSLog(@"mPin: %@", self.mPin); - self.mName = [[UIDevice currentDevice] name]; - self.mServer = server; - self.mComManager = manager; - self.mReceiver = receiver; - // hardcoded here to test the communication TODO - self.mPort = 1599; - + 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.mPort = 1599; + } return self; } -- (NSString *) getPin +- (NSInteger) getPin { + // Look up if there is already a pin code for this client. + NSUserDefaults * userDefaluts = [NSUserDefaults standardUserDefaults]; + + if(!userDefaluts) + NSLog(@"userDefaults nil"); + NSInteger newPin = [userDefaluts integerForKey:self.mName]; + + // If not, generate one. + if (!newPin) { + newPin = arc4random() % 9999; + [userDefaluts setInteger:newPin forKey:self.mName]; + } - NSString* newPin = [NSString stringWithFormat:@"%04d", arc4random() % 9999]; + return newPin; } - (void)streamOpenWithIp:(NSString *)ip withPortNumber:(uint)portNumber @@ -91,8 +98,8 @@ NSString * const CHARSET = @"UTF-8"; [self.mOutputStream setDelegate:self]; [self.mOutputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [self.mOutputStream 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]; @@ -116,21 +123,23 @@ NSString * const CHARSET = @"UTF-8"; switch(eventCode) { case NSStreamEventOpenCompleted: NSLog(@"Connection established"); + self.mReady = YES; break; case NSStreamEventErrorOccurred: NSLog(@"Connection error occured"); break; case NSStreamEventHasBytesAvailable: { + NSMutableData* data; NSLog(@"NSStreamEventHasBytesAvailable"); - if(!self.mData) { - self.mData = [NSMutableData data]; + if(!data) { + data = [NSMutableData data]; } uint8_t buf[1024]; unsigned int len = 0; len = [(NSInputStream *)stream read:buf maxLength:1024]; if(len) { - [self.mData appendBytes:(const void *)buf length:len]; + [data appendBytes:(const void *)buf length:len]; int bytesRead = 0; // bytesRead is an instance variable of type NSNumber. bytesRead += len; @@ -138,17 +147,17 @@ NSString * const CHARSET = @"UTF-8"; NSLog(@"No data but received event for whatever reasons!"); } - NSString *str = [[NSString alloc] initWithData:self.mData + NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"Data Received: %@", str); - self.mData = nil; + data = nil; } break; default: { - + } - + } } diff --git a/ios/iosremote/iosremote/Communication/CommandInterpreter.h b/ios/iosremote/iosremote/Communication/CommandInterpreter.h new file mode 100644 index 000000000000..856bff766b10 --- /dev/null +++ b/ios/iosremote/iosremote/Communication/CommandInterpreter.h @@ -0,0 +1,19 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +// +// 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 +#import "SlideShow.h" + +@interface CommandInterpreter : NSObject + +@property (nonatomic, strong) SlideShow* mSlideShow; + +- (void) parse:(NSArray *)cmd; + +@end diff --git a/ios/iosremote/iosremote/Communication/CommandInterpreter.m b/ios/iosremote/iosremote/Communication/CommandInterpreter.m new file mode 100644 index 000000000000..91c513d748cc --- /dev/null +++ b/ios/iosremote/iosremote/Communication/CommandInterpreter.m @@ -0,0 +1,82 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +// +// 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 "CommandInterpreter.h" +#import "SlideShow.h" +#import "Base64.h" +#import "CommunicationManager.h" + +@interface CommandInterpreter() + +@end + +@implementation CommandInterpreter + +@synthesize mSlideShow = _mSlideShow; + +- (BOOL) isSlideRunning { + return [self.mSlideShow size] > 0; +} + +// Received a set of instructions from server. +- (void) parse:(NSArray*)command{ + if ([command count] == 0) { + return; + } + NSString *instruction = [command objectAtIndex:0]; + + if([instruction isEqualToString:@"slideshow_started"]){ + unsigned int slideLength = [[command objectAtIndex:1] unsignedIntValue]; + unsigned int currentSlide = [[command objectAtIndex:2] unsignedIntValue]; + + [self.mSlideShow setLength:slideLength]; + [self.mSlideShow setCurrentSlide:currentSlide]; + + [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_CONNECTED_NOSLIDESHOW + object:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_CHANGED object:self.mSlideShow.mCurrentSlide]; + + } else if ([instruction isEqualToString:@"slideshow_finished"]){ + self.mSlideShow = [SlideShow init]; + [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_CONNECTED_NOSLIDESHOW object:nil]; + } else { + if (self.mSlideShow == nil) + return; + if ([instruction isEqualToString:@"slide_updated"]) { + unsigned int newSlideNumber = [[command objectAtIndex:1] unsignedIntValue]; + [self.mSlideShow setCurrentSlide:newSlideNumber]; + + [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_CHANGED object:nil]; + + } else if ([instruction isEqualToString:@"slide_preview"]){ + unsigned int slideNumber = [[command objectAtIndex:1] unsignedIntValue]; + NSString * imageData = [command objectAtIndex:2]; + [Base64 initialize]; + NSData* data = [Base64 decode:imageData]; + UIImage* img = [UIImage imageWithData:data]; + [self.mSlideShow putImage:img + 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]; + NSString *notes; + for (int i = 2; i +#define MSG_SLIDESHOW_STARTED @"SLIDESHOW_STARTED" +#define MSG_SLIDE_CHANGED @"SLIDE_CHANGED" +#define MSG_SLIDE_PREVIEW @"SLIDE_PREVIEW" +#define MSG_SLIDE_NOTES @"SLIDE_NOTES" + +#define MSG_SERVERLIST_CHANGED @"SERVERLIST_CHANGED" +#define MSG_PAIRING_STARTED @"PAIRING_STARTED" +#define MSG_PAIRING_SUCCESSFUL @"PAIRING_SUCCESSFUL" + +/** + * Notify the UI that the service has connected to a server AND a slideshow + * is running. + * In this case the PresentationActivity should be started. + */ +#define STATUS_CONNECTED_SLIDESHOW_RUNNING @"STATUS_CONNECTED_SLIDESHOW_RUNNING" +/** + * Notify the UI that the service has connected to a server AND no slideshow + * is running. + * In this case the StartPresentationActivity should be started. + */ +#define STATUS_CONNECTED_NOSLIDESHOW @"STATUS_CONNECTED_NOSLIDESHOW" + +#define STATUS_PAIRING_PINVALIDATION @"STATUS_PAIRING_PINVALIDATION" + +#define STATUS_CONNECTION_FAILED @"STATUS_CONNECTION_FAILED" + + + @interface CommunicationManager : NSObject @end diff --git a/ios/iosremote/iosremote/Communication/Receiver.h b/ios/iosremote/iosremote/Communication/Receiver.h deleted file mode 100644 index cf3781b4bbff..000000000000 --- a/ios/iosremote/iosremote/Communication/Receiver.h +++ /dev/null @@ -1,14 +0,0 @@ -// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -// -// 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 - -@interface Receiver : NSObject - -@end diff --git a/ios/iosremote/iosremote/Communication/Receiver.m b/ios/iosremote/iosremote/Communication/Receiver.m deleted file mode 100644 index bffd302c2e98..000000000000 --- a/ios/iosremote/iosremote/Communication/Receiver.m +++ /dev/null @@ -1,14 +0,0 @@ -// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -// -// 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 "Receiver.h" - -@implementation Receiver - -@end diff --git a/ios/iosremote/iosremote/Communication/SlideShow.h b/ios/iosremote/iosremote/Communication/SlideShow.h new file mode 100644 index 000000000000..11ea4d83117c --- /dev/null +++ b/ios/iosremote/iosremote/Communication/SlideShow.h @@ -0,0 +1,20 @@ +// +// SlideShow.h +// iosremote +// +// Created by Liu Siqi on 6/7/13. +// Copyright (c) 2013 libreoffice. All rights reserved. +// + +#import + +@interface SlideShow : NSObject + +@property (nonatomic, strong) NSArray* mSlides; +@property (nonatomic, strong) NSNumber* mCurrentSlide; + +- (NSUInteger) size; +- (void) setCurrentSlide:(NSUInteger)number; +- (void) setLength:(NSUInteger)number; + +@end diff --git a/ios/iosremote/iosremote/Communication/SlideShow.m b/ios/iosremote/iosremote/Communication/SlideShow.m new file mode 100644 index 000000000000..d6435e9abd54 --- /dev/null +++ b/ios/iosremote/iosremote/Communication/SlideShow.m @@ -0,0 +1,20 @@ +// +// SlideShow.m +// iosremote +// +// Created by Liu Siqi on 6/7/13. +// Copyright (c) 2013 libreoffice. All rights reserved. +// + +#import "SlideShow.h" + +@implementation SlideShow + +@synthesize mSlides = _mSlides; +@synthesize mCurrentSlide = _mCurrentSlide; + +- (NSUInteger) size{ + return self.mSlides.count; +} + +@end diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard index 0571d206afe2..d4a118a6a6ad 100644 --- a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard +++ b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard @@ -18,6 +18,13 @@ + @@ -30,6 +37,7 @@ + @@ -55,15 +63,6 @@ - - - - - - - - - diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h index 077b1b389ea6..504c902a3d50 100644 --- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h +++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h @@ -1,11 +1,10 @@ -// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// This file is part of the LibreOffice project. +// libreoffice_sdremoteViewController.h +// iosremote +// +// Created by Liu Siqi on 6/4/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 @@ -13,6 +12,8 @@ - (IBAction)connectToServer:(id)sender; +@property (weak, nonatomic) IBOutlet UILabel *pinLabel; + @property (weak, nonatomic) IBOutlet UITextField *ipAddressTextEdit; @end diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m index 504b976cb522..ba4340bbe624 100644 --- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m +++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m @@ -42,11 +42,18 @@ self.server = [[Server alloc] initWithProtocol:NETWORK atAddress:address ofName:@"Server"]; self.client = [[Client alloc] initWithServer:self.server managedBy:nil interpretedBy:nil]; [self.client connect]; + + if([self.client mReady]) + { + [self.pinLabel setText:[NSString stringWithFormat:@"%@", self.client.mPin]]; + } } - (void)viewDidUnload { [self setIpAddressTextEdit:nil]; + [self setPinLabel:nil]; + [self setPinLabel:nil]; [super viewDidUnload]; } @end -- cgit