From 3b097454b5660c8b0bfba42aec0eee8d20115414 Mon Sep 17 00:00:00 2001 From: Siqi LIU Date: Tue, 4 Jun 2013 09:31:57 +0200 Subject: initial commit --- ios/sdremote/sdremote/Client.h | 13 ---------- ios/sdremote/sdremote/Client.m | 13 ---------- ios/sdremote/sdremote/Communication/Client.m | 29 +++++++++++++++++++++- .../sdremote/libreoffice_sdremoteViewController.h | 2 ++ .../sdremote/libreoffice_sdremoteViewController.m | 4 +++ 5 files changed, 34 insertions(+), 27 deletions(-) delete mode 100644 ios/sdremote/sdremote/Client.h delete mode 100644 ios/sdremote/sdremote/Client.m (limited to 'ios') diff --git a/ios/sdremote/sdremote/Client.h b/ios/sdremote/sdremote/Client.h deleted file mode 100644 index 4cb809d988a9..000000000000 --- a/ios/sdremote/sdremote/Client.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// Client.h -// sdremote -// -// Created by Liu Siqi on 6/3/13. -// Copyright (c) 2013 libreoffice. All rights reserved. -// - -#import - -@interface Client : NSObject - -@end diff --git a/ios/sdremote/sdremote/Client.m b/ios/sdremote/sdremote/Client.m deleted file mode 100644 index 917b35770bbf..000000000000 --- a/ios/sdremote/sdremote/Client.m +++ /dev/null @@ -1,13 +0,0 @@ -// -// Client.m -// sdremote -// -// Created by Liu Siqi on 6/3/13. -// Copyright (c) 2013 libreoffice. All rights reserved. -// - -#import "Client.h" - -@implementation Client - -@end diff --git a/ios/sdremote/sdremote/Communication/Client.m b/ios/sdremote/sdremote/Communication/Client.m index 386b7a61d77f..5637f964d3b9 100644 --- a/ios/sdremote/sdremote/Communication/Client.m +++ b/ios/sdremote/sdremote/Communication/Client.m @@ -18,12 +18,14 @@ @property (nonatomic, strong) NSString* mPin; @property (nonatomic, strong) NSString* mName; -@property int mPort; +@property const int mPort; @property (nonatomic, weak) Server* mServer; @property (nonatomic, weak) Receiver* mReceiver; @property (nonatomic, weak) CommunicationManager* mComManager; +@property (nonatomic, retain) NSMutableData* mData; + @end @@ -36,6 +38,7 @@ @synthesize mName = _mName; @synthesize mServer = _mServer; @synthesize mComManager = _mComManager; +@synthesize mData = _mData; NSString * const CHARSET = @"UTF-8"; @@ -78,6 +81,30 @@ NSString * const CHARSET = @"UTF-8"; } } +- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode { + + switch(eventCode) { + case NSStreamEventHasBytesAvailable: + { + if(!self.mData) { + self.mData = [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]; + // bytesRead is an instance variable of type NSNumber. + [bytesRead setIntValue:[bytesRead intValue]+len]; + } else { + NSLog(@"no buffer!"); + } + break; + } + + } +} + - (void) connect { diff --git a/ios/sdremote/sdremote/libreoffice_sdremoteViewController.h b/ios/sdremote/sdremote/libreoffice_sdremoteViewController.h index 2e56b7adcae0..f120e0f322e7 100644 --- a/ios/sdremote/sdremote/libreoffice_sdremoteViewController.h +++ b/ios/sdremote/sdremote/libreoffice_sdremoteViewController.h @@ -9,5 +9,7 @@ #import @interface libreoffice_sdremoteViewController : UIViewController +@property (weak, nonatomic) IBOutlet UIBarButtonItem *connect; @end + diff --git a/ios/sdremote/sdremote/libreoffice_sdremoteViewController.m b/ios/sdremote/sdremote/libreoffice_sdremoteViewController.m index a955d8da1cb6..ed11a7369895 100644 --- a/ios/sdremote/sdremote/libreoffice_sdremoteViewController.m +++ b/ios/sdremote/sdremote/libreoffice_sdremoteViewController.m @@ -28,4 +28,8 @@ // Dispose of any resources that can be recreated. } +- (void)viewDidUnload { + [self setConnect:nil]; + [super viewDidUnload]; +} @end -- cgit