diff options
author | siqi <me@siqi.fr> | 2013-06-05 10:29:11 +0200 |
---|---|---|
committer | siqi <me@siqi.fr> | 2013-06-05 10:30:41 +0200 |
commit | 628065f90a15f8663426de2c2de11bd3fa96d0cd (patch) | |
tree | 3fc9b9ae110a25faf3af756571e58e3e42f65d28 /ios | |
parent | 5d81b207e8c4dd96c34836d29bc82275f0a1c2c8 (diff) |
iPad talks to server! Need to implement receiver and manager now
Diffstat (limited to 'ios')
13 files changed, 99 insertions, 70 deletions
diff --git a/ios/iosremote/iosremote/Communication/Client.h b/ios/iosremote/iosremote/Communication/Client.h index 3827b2f33a8a..ac98afd8d287 100644 --- a/ios/iosremote/iosremote/Communication/Client.h +++ b/ios/iosremote/iosremote/Communication/Client.h @@ -1,10 +1,10 @@ -// -// Client.h -// -// -// Created by Liu Siqi on 6/3/13. -// Copyright (c) 2013 libreoffice. All rights reserved. -// +/* + * 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 <Foundation/Foundation.h> #import "Server.h" diff --git a/ios/iosremote/iosremote/Communication/Client.m b/ios/iosremote/iosremote/Communication/Client.m index 5e18e6c52aaf..b5e6644cbff7 100644 --- a/ios/iosremote/iosremote/Communication/Client.m +++ b/ios/iosremote/iosremote/Communication/Client.m @@ -1,10 +1,11 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// Client.m -// sdremote -// -// Created by Liu Siqi on 6/3/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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 "Client.h" #import "Server.h" @@ -20,7 +21,7 @@ @property (nonatomic, strong) NSString* mName; @property uint mPort; -@property (nonatomic, strong) Server* mServer; +@property (nonatomic, weak) Server* mServer; @property (nonatomic, weak) Receiver* mReceiver; @property (nonatomic, weak) CommunicationManager* mComManager; @@ -49,8 +50,9 @@ NSString * const CHARSET = @"UTF-8"; managedBy:(CommunicationManager*)manager interpretedBy:(Receiver*)receiver { - self.mPin = @""; - self.mName = server.serverName; + self.mPin = [NSString stringWithFormat:@"%04d", arc4random() % 9999]; + NSLog(@"mPin: %@", self.mPin); + self.mName = [[UIDevice currentDevice] name]; self.mServer = server; self.mComManager = manager; self.mReceiver = receiver; @@ -83,12 +85,20 @@ NSString * const CHARSET = @"UTF-8"; [self.mOutputStream setDelegate:self]; [self.mOutputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [self.mOutputStream open]; - NSLog(@"Connected"); + +// NSLog(@"Stream opened %@ %@", @"iPad", self.mPin); + + NSArray *temp = [[NSArray alloc]initWithObjects:@"LO_SERVER_CLIENT_PAIR\n", self.mName, @"\n", self.mPin, @"\n\n", nil]; + + NSString *command = [temp componentsJoinedByString:@""]; + + [self sendCommand:command]; } } - (void) sendCommand:(NSString *)aCommand { + NSLog(@"Sending command %@", aCommand); // UTF-8 as speficied in specification NSData * data = [aCommand dataUsingEncoding:NSUTF8StringEncoding]; @@ -98,6 +108,12 @@ NSString * const CHARSET = @"UTF-8"; - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode { switch(eventCode) { + case NSStreamEventOpenCompleted: + NSLog(@"Connection established"); + break; + case NSStreamEventErrorOccurred: + NSLog(@"Connection error occured"); + break; case NSStreamEventHasBytesAvailable: { NSLog(@"NSStreamEventHasBytesAvailable"); diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.h b/ios/iosremote/iosremote/Communication/CommunicationManager.h index d649e3c55beb..152c77973c9c 100644 --- a/ios/iosremote/iosremote/Communication/CommunicationManager.h +++ b/ios/iosremote/iosremote/Communication/CommunicationManager.h @@ -1,10 +1,11 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// CommunicationManager.h -// sdremote -// -// Created by Liu Siqi on 6/3/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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 <Foundation/Foundation.h> diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m index c91b2f5e2ae6..2e1843226686 100644 --- a/ios/iosremote/iosremote/Communication/CommunicationManager.m +++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m @@ -1,10 +1,11 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// CommunicationManager.m -// sdremote -// -// Created by Liu Siqi on 6/3/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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 "CommunicationManager.h" diff --git a/ios/iosremote/iosremote/Communication/Receiver.h b/ios/iosremote/iosremote/Communication/Receiver.h index 9889ec749577..cf3781b4bbff 100644 --- a/ios/iosremote/iosremote/Communication/Receiver.h +++ b/ios/iosremote/iosremote/Communication/Receiver.h @@ -1,10 +1,11 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// Receiver.h -// sdremote -// -// Created by Liu Siqi on 6/3/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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 <Foundation/Foundation.h> diff --git a/ios/iosremote/iosremote/Communication/Receiver.m b/ios/iosremote/iosremote/Communication/Receiver.m index 30a48c675d68..bffd302c2e98 100644 --- a/ios/iosremote/iosremote/Communication/Receiver.m +++ b/ios/iosremote/iosremote/Communication/Receiver.m @@ -1,10 +1,11 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// Receiver.m -// sdremote -// -// Created by Liu Siqi on 6/3/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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" diff --git a/ios/iosremote/iosremote/Communication/Server.h b/ios/iosremote/iosremote/Communication/Server.h index 1cf483dd64b0..ceeff1ff0ef4 100644 --- a/ios/iosremote/iosremote/Communication/Server.h +++ b/ios/iosremote/iosremote/Communication/Server.h @@ -1,10 +1,10 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// Server.h -// sdremote -// -// Created by Liu Siqi on 6/3/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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 <Foundation/Foundation.h> diff --git a/ios/iosremote/iosremote/Communication/Server.m b/ios/iosremote/iosremote/Communication/Server.m index 8cc722215664..08061ffca485 100644 --- a/ios/iosremote/iosremote/Communication/Server.m +++ b/ios/iosremote/iosremote/Communication/Server.m @@ -1,10 +1,10 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// Server.m -// sdremote -// -// Created by Liu Siqi on 6/3/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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 "Server.h" diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard index 6206f1655c78..0571d206afe2 100644 --- a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard +++ b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard @@ -12,7 +12,7 @@ <rect key="frame" x="0.0" y="64" width="768" height="960"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="192.168.43.173" borderStyle="roundedRect" minimumFontSize="17" id="9w1-Ym-HcF"> + <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="172.25.19.11" borderStyle="roundedRect" minimumFontSize="17" id="9w1-Ym-HcF"> <rect key="frame" x="234" y="402" width="301" height="30"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteAppDelegate.h b/ios/iosremote/iosremote/libreoffice_sdremoteAppDelegate.h index 1507d06e0a0f..9b87a86735c7 100644 --- a/ios/iosremote/iosremote/libreoffice_sdremoteAppDelegate.h +++ b/ios/iosremote/iosremote/libreoffice_sdremoteAppDelegate.h @@ -1,10 +1,10 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// libreoffice_sdremoteAppDelegate.h -// iosremote -// -// Created by Liu Siqi on 6/4/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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 <UIKit/UIKit.h> diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteAppDelegate.m b/ios/iosremote/iosremote/libreoffice_sdremoteAppDelegate.m index eab546142124..0123ac6c38d9 100644 --- a/ios/iosremote/iosremote/libreoffice_sdremoteAppDelegate.m +++ b/ios/iosremote/iosremote/libreoffice_sdremoteAppDelegate.m @@ -1,10 +1,10 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// libreoffice_sdremoteAppDelegate.m -// iosremote -// -// Created by Liu Siqi on 6/4/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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 "libreoffice_sdremoteAppDelegate.h" diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h index fdeaf69abe02..077b1b389ea6 100644 --- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h +++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h @@ -1,10 +1,11 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// libreoffice_sdremoteViewController.h -// iosremote -// -// Created by Liu Siqi on 6/4/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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 <UIKit/UIKit.h> diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m index 823c7039aaed..504b976cb522 100644 --- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m +++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m @@ -1,10 +1,11 @@ +// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // -// libreoffice_sdremoteViewController.m -// iosremote -// -// Created by Liu Siqi on 6/4/13. -// Copyright (c) 2013 libreoffice. All rights reserved. +// 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 "libreoffice_sdremoteViewController.h" #import "Server.h" @@ -12,10 +13,17 @@ @interface libreoffice_sdremoteViewController () +// For debug use, will use a manager to manage server and client instead +@property (nonatomic, strong) Server* server; +@property (nonatomic, strong) Client* client; + @end @implementation libreoffice_sdremoteViewController +@synthesize server = _server; +@synthesize client = _client; + - (void)viewDidLoad { [super viewDidLoad]; @@ -31,9 +39,9 @@ - (IBAction)connectToServer:(id)sender { NSString * address = [self.ipAddressTextEdit text]; - Server * server = [[Server alloc] initWithProtocol:NETWORK atAddress:address ofName:@"Server"]; - Client * client = [[Client alloc] initWithServer:server managedBy:nil interpretedBy:nil]; - [client connect]; + self.server = [[Server alloc] initWithProtocol:NETWORK atAddress:address ofName:@"Server"]; + self.client = [[Client alloc] initWithServer:self.server managedBy:nil interpretedBy:nil]; + [self.client connect]; } |