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

cmd interpreter implemented

üst f7807037
......@@ -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 = "<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; };
......@@ -47,8 +52,8 @@
57C6E427175E076900E8BC5F /* Client.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Client.m; sourceTree = "<group>"; };
57C6E428175E076900E8BC5F /* CommunicationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommunicationManager.h; sourceTree = "<group>"; };
57C6E429175E076900E8BC5F /* CommunicationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommunicationManager.m; sourceTree = "<group>"; };
57C6E42A175E076900E8BC5F /* Receiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Receiver.h; sourceTree = "<group>"; };
57C6E42B175E076900E8BC5F /* Receiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Receiver.m; sourceTree = "<group>"; };
57C6E42A175E076900E8BC5F /* CommandInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandInterpreter.h; sourceTree = "<group>"; };
57C6E42B175E076900E8BC5F /* CommandInterpreter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommandInterpreter.m; sourceTree = "<group>"; };
57C6E42C175E076900E8BC5F /* Server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Server.h; sourceTree = "<group>"; };
57C6E42D175E076900E8BC5F /* Server.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Server.m; sourceTree = "<group>"; };
/* 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;
};
......
//
// 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 <Foundation/Foundation.h>
@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
//
// 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
......@@ -9,15 +9,19 @@
#import <Foundation/Foundation.h>
#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;
......
......@@ -9,7 +9,7 @@
#import "Client.h"
#import "Server.h"
#import "Receiver.h"
#import "CommandInterpreter.h"
#import "CommunicationManager.h"
@interface Client() <NSStreamDelegate>
......@@ -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:
{
}
}
}
......
......@@ -8,7 +8,12 @@
#import <Foundation/Foundation.h>
#import "SlideShow.h"
@interface Receiver : NSObject
@interface CommandInterpreter : NSObject
@property (nonatomic, strong) SlideShow* mSlideShow;
- (void) parse:(NSArray *)cmd;
@end
// -*- 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<command.count; ++i) {
[notes stringByAppendingString:[command objectAtIndex:i]];
}
[self.mSlideShow putNotes:notes
AtIndex:slideNumber];
[[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_NOTES object: [NSNumber numberWithUnsignedInt:slideNumber]];
}
}
}
@end
......@@ -9,6 +9,34 @@
#import <Foundation/Foundation.h>
#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
// -*- 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
//
// SlideShow.h
// iosremote
//
// Created by Liu Siqi on 6/7/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SlideShow : NSObject
@property (nonatomic, strong) NSArray* mSlides;
@property (nonatomic, strong) NSNumber* mCurrentSlide;
- (NSUInteger) size;
- (void) setCurrentSlide:(NSUInteger)number;
- (void) setLength:(NSUInteger)number;
@end
//
// 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
......@@ -18,6 +18,13 @@
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="pinLabel" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Cg3-f5-zuM">
<rect key="frame" x="253" y="218" width="263" height="82"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="64"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
......@@ -30,6 +37,7 @@
</navigationItem>
<connections>
<outlet property="ipAddressTextEdit" destination="9w1-Ym-HcF" id="hab-JH-3Lf"/>
<outlet property="pinLabel" destination="Cg3-f5-zuM" id="HaU-jr-8oJ"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/>
......@@ -55,15 +63,6 @@
<point key="canvasLocation" x="721" y="-301"/>
</scene>
</scenes>
<classes>
<class className="libreoffice_sdremoteViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/libreoffice_sdremoteViewController.h"/>
<relationships>
<relationship kind="action" name="connectToServer:"/>
<relationship kind="outlet" name="ipAddressTextEdit" candidateClass="UITextField"/>
</relationships>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/>
<simulatedOrientationMetrics key="orientation"/>
......
// -*- 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 <UIKit/UIKit.h>
......@@ -13,6 +12,8 @@
- (IBAction)connectToServer:(id)sender;
@property (weak, nonatomic) IBOutlet UILabel *pinLabel;
@property (weak, nonatomic) IBOutlet UITextField *ipAddressTextEdit;
@end
......@@ -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
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