diff options
author | Siqi LIU <me@siqi.fr> | 2013-06-04 09:31:57 +0200 |
---|---|---|
committer | siqi <me@siqi.fr> | 2013-06-04 13:49:12 +0200 |
commit | 3b097454b5660c8b0bfba42aec0eee8d20115414 (patch) | |
tree | 5c9247204e702bcfcf5acac432c96640b45295ff | |
parent | deac1594da2db18a7e393206e73329a5891269f6 (diff) |
initial commit
-rw-r--r-- | ios/sdremote/sdremote/Client.h | 13 | ||||
-rw-r--r-- | ios/sdremote/sdremote/Client.m | 13 | ||||
-rw-r--r-- | ios/sdremote/sdremote/Communication/Client.m | 29 | ||||
-rw-r--r-- | ios/sdremote/sdremote/libreoffice_sdremoteViewController.h | 2 | ||||
-rw-r--r-- | ios/sdremote/sdremote/libreoffice_sdremoteViewController.m | 4 |
5 files changed, 34 insertions, 27 deletions
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 <Foundation/Foundation.h> - -@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 <UIKit/UIKit.h> @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 |