[Libreoffice-commits] core.git: 3 commits - ios/iosremote
siqi
me at siqi.fr
Wed Jun 12 00:02:03 PDT 2013
ios/iosremote/iosremote/Base64.h | 33 ---
ios/iosremote/iosremote/Base64.m | 100 +--------
ios/iosremote/iosremote/Communication/Client.h | 6
ios/iosremote/iosremote/Communication/Client.m | 54 +++--
ios/iosremote/iosremote/Communication/CommandInterpreter.m | 6
ios/iosremote/iosremote/Communication/CommandTransmitter.m | 6
ios/iosremote/iosremote/Communication/CommunicationManager.h | 15 +
ios/iosremote/iosremote/Communication/CommunicationManager.m | 102 ++++++++++
ios/iosremote/iosremote/Communication/Server.h | 2
ios/iosremote/iosremote/Communication/Server.m | 17 +
ios/iosremote/iosremote/Communication/SlideShow.h | 5
ios/iosremote/iosremote/Communication/SlideShow.m | 22 +-
ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard | 86 +++++++-
ios/iosremote/iosremote/libreoffice_sdremoteViewController.m | 13 +
ios/iosremote/iosremote/slideShowViewController.h | 6
ios/iosremote/iosremote/slideShowViewController.m | 24 ++
16 files changed, 345 insertions(+), 152 deletions(-)
New commits:
commit 651a96e3fde964164f80aa7c83af01168465aa2b
Author: siqi <me at siqi.fr>
Date: Wed Jun 12 09:01:15 2013 +0200
multithreading in comManager
diff --git a/ios/iosremote/iosremote/Communication/Client.h b/ios/iosremote/iosremote/Communication/Client.h
index 94fe6c7..45f7e95 100644
--- a/ios/iosremote/iosremote/Communication/Client.h
+++ b/ios/iosremote/iosremote/Communication/Client.h
@@ -13,11 +13,13 @@
@interface Client : NSObject
- at property BOOL ready;
+ at property BOOL connected;
@property (nonatomic, strong) NSNumber* pin;
@property (nonatomic, strong) NSString* name;
+ at property (nonatomic, weak) Server* server;
--(void) connect;
+- (BOOL) connect;
+- (void) disconnect;
- (id) initWithServer:(Server*)server
managedBy:(CommunicationManager*)manager
diff --git a/ios/iosremote/iosremote/Communication/Client.m b/ios/iosremote/iosremote/Communication/Client.m
index 3b1f1b6..bfa7648 100644
--- a/ios/iosremote/iosremote/Communication/Client.m
+++ b/ios/iosremote/iosremote/Communication/Client.m
@@ -21,13 +21,12 @@
@property uint mPort;
- at property (nonatomic, weak) Server* server;
@property (nonatomic, weak) CommandInterpreter* receiver;
@property (nonatomic, weak) CommunicationManager* comManager;
@end
-
+NSCondition *connected;
@implementation Client
@@ -37,7 +36,7 @@
@synthesize name = _mName;
@synthesize server = _mServer;
@synthesize comManager = _mComManager;
- at synthesize ready = _mReady;
+ at synthesize connected = _mReady;
@synthesize receiver = _receiver;
- (id) initWithServer:(Server*)server
@@ -47,7 +46,8 @@
self = [self init];
if (self)
{
- self.ready = NO;
+ connected = [NSCondition new];
+ self.connected = NO;
self.name = [[UIDevice currentDevice] name];
self.pin = [NSNumber numberWithInteger:[self getPin]];
self.server = server;
@@ -99,14 +99,6 @@
[self.outputStream setDelegate:self];
[self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.outputStream open];
-
- // NSLog(@"Stream opened %@ %@", @"iPad", self.mPin);
-
- NSArray *temp = [[NSArray alloc]initWithObjects:@"LO_SERVER_CLIENT_PAIR\n", self.name, @"\n", self.pin, @"\n\n", nil];
-
- NSString *command = [temp componentsJoinedByString:@""];
-
- [self sendCommand:command];
}
}
@@ -122,12 +114,22 @@
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {
switch(eventCode) {
- case NSStreamEventOpenCompleted:
+ case NSStreamEventOpenCompleted:{
NSLog(@"Connection established");
- self.ready = YES;
+ [connected lock];
+ NSArray *temp = [[NSArray alloc]initWithObjects:@"LO_SERVER_CLIENT_PAIR\n", self.name, @"\n", self.pin, @"\n\n", nil];
+ NSString *command = [temp componentsJoinedByString:@""];
+ [self sendCommand:command];
+ self.connected = YES;
+ [connected signal];
+ [connected unlock];
+ }
+
break;
- case NSStreamEventErrorOccurred:
+ case NSStreamEventErrorOccurred:{
NSLog(@"Connection error occured");
+ [self disconnect];
+ }
break;
case NSStreamEventHasBytesAvailable:
{
@@ -153,7 +155,6 @@
}
NSArray *commands = [str componentsSeparatedByString:@"\n"];
-// NSLog(@"Data Received: %@", commands);
[self.receiver parse:commands];
data = nil;
@@ -167,10 +168,29 @@
}
}
+- (void) disconnect
+{
+ if(self.inputStream == nil && self.outputStream == nil)
+ return;
+ [self.inputStream close];
+ [self.outputStream close];
+ self.inputStream = nil;
+ self.outputStream = nil;
+ self.connected = NO;
+}
-- (void) connect
+- (BOOL) connect
{
[self streamOpenWithIp:self.server.serverAddress withPortNumber:self.mPort];
+ [connected lock];
+ if([connected waitUntilDate:[NSDate dateWithTimeIntervalSinceNow:5]]){
+ [connected unlock];
+ return YES;
+ } else {
+ [self disconnect];
+ [connected unlock];
+ return NO;
+ }
}
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.h b/ios/iosremote/iosremote/Communication/CommunicationManager.h
index 93046a1..f64edb7 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.h
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.h
@@ -48,6 +48,7 @@ enum ConnectionState : NSInteger {
CONNECTED
};
+dispatch_queue_t backgroundQueue;
@interface CommunicationManager : NSObject
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m
index a629886..fdd4ade 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.m
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m
@@ -12,11 +12,13 @@
#import "Server.h"
#import "CommandTransmitter.h"
#import "CommandInterpreter.h"
+#import <dispatch/dispatch.h>
@interface CommunicationManager()
@property (nonatomic, strong) Client* client;
@property (nonatomic, strong) CommandInterpreter* interpreter;
+ at property (nonatomic, strong) CommandTransmitter* transmitter;
@property (atomic, strong) NSMutableArray* servers;
@end
@@ -27,8 +29,11 @@
@synthesize client = _client;
@synthesize state = _state;
@synthesize interpreter = _interpreter;
+ at synthesize transmitter = _transmitter;
@synthesize servers = _servers;
+NSLock *connectionLock;
+
+ (CommunicationManager *)sharedComManager
{
static CommunicationManager *sharedComManager = nil;
@@ -46,13 +51,15 @@
{
self = [super init];
self.state = DISCONNECTED;
+ connectionLock = [NSLock new];
+ backgroundQueue = dispatch_queue_create("org.libreoffice.iosremote", NULL);
return self;
}
- (id) initWithExistingServers
{
self = [self init];
-
+
NSUserDefaults * userDefaluts = [NSUserDefaults standardUserDefaults];
if(!userDefaluts)
@@ -69,6 +76,39 @@
}
}
+- (void) connectToServer:(Server*)server
+{
+ dispatch_async(backgroundQueue, ^(void) {
+ if ([connectionLock tryLock]) {
+ self.state = CONNECTING;
+ [self.client disconnect];
+ // initialise it with a given server
+ self.client = [[Client alloc]initWithServer:server managedBy:self interpretedBy:self.interpreter];
+ if([self.client connect]){
+ self.state = CONNECTED;
+ self.transmitter = [[CommandTransmitter alloc] initWithClient:self.client];
+ }
+ else{
+ // streams closing is handled by client itself in case of connection failure
+ self.state = DISCONNECTED;
+ }
+ [connectionLock unlock];
+ }
+ else
+ // Already a threading working on that ... and that thread will unlock in 5 seconds anyway, so just return for now.
+ return;
+ });
+}
+
+- (NSNumber *) getPairingPin{
+ return [self.client pin];
+}
+
+- (NSString *) getPairingDeviceName
+{
+ return [self.client name];
+}
+
+ (id)allocWithZone:(NSZone *)zone
{
return [self sharedComManager];
diff --git a/ios/iosremote/iosremote/Communication/SlideShow.h b/ios/iosremote/iosremote/Communication/SlideShow.h
index b43c810..7160100 100644
--- a/ios/iosremote/iosremote/Communication/SlideShow.h
+++ b/ios/iosremote/iosremote/Communication/SlideShow.h
@@ -8,11 +8,13 @@
#import <Foundation/Foundation.h>
+#import "slideShowViewController.h"
@interface SlideShow : NSObject
@property uint size;
@property uint currentSlide;
+ at property (nonatomic, weak) id delegate;
- (void) putImage: (NSString *)img AtIndex: (uint) index;
- (void) putNotes: (NSString *)notes AtIndex: (uint) index;
diff --git a/ios/iosremote/iosremote/Communication/SlideShow.m b/ios/iosremote/iosremote/Communication/SlideShow.m
index dfecb9f..7bd8c55 100644
--- a/ios/iosremote/iosremote/Communication/SlideShow.m
+++ b/ios/iosremote/iosremote/Communication/SlideShow.m
@@ -9,6 +9,7 @@
#import "SlideShow.h"
#import "Base64.h"
+#import "slideShowViewController.h"
@interface SlideShow()
@@ -21,6 +22,7 @@
@synthesize size = _size;
@synthesize currentSlide = _currentSlide;
+ at synthesize delegate = _delegate;
- (SlideShow *) init{
self = [super init];
@@ -35,12 +37,14 @@
NSData* data = [NSData dataWithBase64String:img];
UIImage* image = [UIImage imageWithData:data];
[self.imagesArray insertObject:image atIndex:index];
- [[NSNotificationCenter defaultCenter] postNotificationName:@"IMAGE_READY" object:nil];
+ slideShowViewController* vc = [self delegate];
+ [[vc image] setImage:image];
}
- (void) putNotes: (NSString *)notes AtIndex: (uint) index{
[self.notesArray insertObject:notes atIndex:index];
- [[NSNotificationCenter defaultCenter] postNotificationName:@"NOTE_READY" object:nil];
+ slideShowViewController* vc = [self delegate];
+ [[vc lecturer_notes] loadHTMLString:notes baseURL:nil];
}
- (UIImage *) getImageAtIndex: (uint) index
diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
index 0f913db..a44eacb 100644
--- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
+++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
@@ -49,6 +49,7 @@
if ([segue.identifier isEqualToString:@"slidesPreviewSegue"]) {
slideShowViewController *destViewController = segue.destinationViewController;
destViewController.slideshow = [self.interpreter slideShow];
+ [destViewController.slideshow setDelegate:destViewController];
}
}
@@ -66,7 +67,7 @@
self.client = [[Client alloc] initWithServer:self.server managedBy:nil interpretedBy:self.interpreter];
[self.client connect];
- if([self.client ready])
+ if([self.client connected])
{
[self.pinLabel setText:[NSString stringWithFormat:@"%@", self.client.pin]];
}
diff --git a/ios/iosremote/iosremote/slideShowViewController.m b/ios/iosremote/iosremote/slideShowViewController.m
index d79cb28..9f9bf75 100644
--- a/ios/iosremote/iosremote/slideShowViewController.m
+++ b/ios/iosremote/iosremote/slideShowViewController.m
@@ -32,20 +32,20 @@
{
[super viewDidLoad];
- NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
- NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
- [self.image setImage:[self.slideshow getImageAtIndex:0]];
- [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:0]baseURL:nil];
- self.slideShowImageReadyObserver = [center addObserverForName:@"IMAGE_READY" object:nil
- queue:mainQueue usingBlock:^(NSNotification *note) {
- NSLog(@"Getting image to display: %@", [self.slideshow getImageAtIndex:0]);
- [self.image setImage:[self.slideshow getImageAtIndex:0]];
- }];
- self.slideShowNoteReadyObserver = [center addObserverForName:@"NOTE_READY" object:nil
- queue:mainQueue usingBlock:^(NSNotification *note) {
- NSLog(@"Getting note to display: %@", [self.slideshow getNotesAtIndex:0]);
- [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:0]baseURL:nil];
- }];
+// NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+// NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
+// [self.image setImage:[self.slideshow getImageAtIndex:0]];
+// [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:0]baseURL:nil];
+// self.slideShowImageReadyObserver = [center addObserverForName:@"IMAGE_READY" object:nil
+// queue:mainQueue usingBlock:^(NSNotification *note) {
+// NSLog(@"Getting image to display: %@", [self.slideshow getImageAtIndex:0]);
+// [self.image setImage:[self.slideshow getImageAtIndex:0]];
+// }];
+// self.slideShowNoteReadyObserver = [center addObserverForName:@"NOTE_READY" object:nil
+// queue:mainQueue usingBlock:^(NSNotification *note) {
+// NSLog(@"Getting note to display: %@", [self.slideshow getNotesAtIndex:0]);
+// [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:0]baseURL:nil];
+// }]
}
commit 22e4465d8cbc7b8cbc29948705994284c84475a1
Author: siqi <me at siqi.fr>
Date: Tue Jun 11 22:44:00 2013 +0200
loading existing server lsit
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.h b/ios/iosremote/iosremote/Communication/CommunicationManager.h
index 3612a50..93046a1 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.h
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.h
@@ -8,6 +8,9 @@
#import <Foundation/Foundation.h>
+#import "Client.h"
+#import "Server.h"
+#import "CommandInterpreter.h"
#define MSG_SLIDESHOW_STARTED @"SLIDESHOW_STARTED"
#define MSG_SLIDE_CHANGED @"SLIDE_CHANGED"
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m
index 2be29fc..a629886 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.m
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m
@@ -16,6 +16,8 @@
@interface CommunicationManager()
@property (nonatomic, strong) Client* client;
+ at property (nonatomic, strong) CommandInterpreter* interpreter;
+ at property (atomic, strong) NSMutableArray* servers;
@end
@@ -24,6 +26,8 @@
@synthesize client = _client;
@synthesize state = _state;
+ at synthesize interpreter = _interpreter;
+ at synthesize servers = _servers;
+ (CommunicationManager *)sharedComManager
{
@@ -45,6 +49,26 @@
return self;
}
+- (id) initWithExistingServers
+{
+ self = [self init];
+
+ NSUserDefaults * userDefaluts = [NSUserDefaults standardUserDefaults];
+
+ if(!userDefaluts)
+ NSLog(@"userDefaults nil");
+
+ NSData *dataRepresentingExistingServers = [userDefaluts objectForKey:@"ExistingServers"];
+ if (dataRepresentingExistingServers != nil)
+ {
+ NSArray *oldSavedArray = [NSKeyedUnarchiver unarchiveObjectWithData:dataRepresentingExistingServers];
+ if (oldSavedArray != nil)
+ self.servers = [[NSMutableArray alloc] initWithArray:oldSavedArray];
+ else
+ self.servers = [[NSMutableArray alloc] init];
+ }
+}
+
+ (id)allocWithZone:(NSZone *)zone
{
return [self sharedComManager];
diff --git a/ios/iosremote/iosremote/Communication/Server.h b/ios/iosremote/iosremote/Communication/Server.h
index ceeff1f..0fb6c9d 100644
--- a/ios/iosremote/iosremote/Communication/Server.h
+++ b/ios/iosremote/iosremote/Communication/Server.h
@@ -10,7 +10,7 @@
typedef enum protocol {NETWORK} Protocol_t;
- at interface Server : NSObject
+ at interface Server : NSObject <NSCoding>
@property (nonatomic) Protocol_t protocol;
@property (nonatomic, strong) NSString* serverName;
diff --git a/ios/iosremote/iosremote/Communication/Server.m b/ios/iosremote/iosremote/Communication/Server.m
index 08061ff..71547c7 100644
--- a/ios/iosremote/iosremote/Communication/Server.m
+++ b/ios/iosremote/iosremote/Communication/Server.m
@@ -16,11 +16,28 @@
@implementation Server
+
@synthesize protocol = _protocol;
@synthesize serverName = _serverName;
@synthesize serverAddress = _serverAddress;
+- (void)encodeWithCoder:(NSCoder *)coder;
+{
+ [coder encodeObject:self.serverName forKey:@"name"];
+ [coder encodeObject:self.serverAddress forKey:@"address"];
+ [coder encodeInteger:self.protocol forKey:@"protocol"];
+}
+
+- (id)initWithCoder:(NSCoder *)coder;
+{
+ self = [self initWithProtocol:[coder decodeIntegerForKey:@"protocol"]
+ atAddress:[coder decodeObjectForKey:@"address"]
+ ofName:[coder decodeObjectForKey:@"name"]];
+ return self;
+}
+
+
- (id)initWithProtocol:(Protocol_t)protocal
atAddress:(NSString*) address
ofName:(NSString*) name
diff --git a/ios/iosremote/iosremote/Communication/SlideShow.m b/ios/iosremote/iosremote/Communication/SlideShow.m
index 7cecc70..dfecb9f 100644
--- a/ios/iosremote/iosremote/Communication/SlideShow.m
+++ b/ios/iosremote/iosremote/Communication/SlideShow.m
@@ -35,7 +35,6 @@
NSData* data = [NSData dataWithBase64String:img];
UIImage* image = [UIImage imageWithData:data];
[self.imagesArray insertObject:image atIndex:index];
-
[[NSNotificationCenter defaultCenter] postNotificationName:@"IMAGE_READY" object:nil];
}
diff --git a/ios/iosremote/iosremote/slideShowViewController.m b/ios/iosremote/iosremote/slideShowViewController.m
index f39bead..d79cb28 100644
--- a/ios/iosremote/iosremote/slideShowViewController.m
+++ b/ios/iosremote/iosremote/slideShowViewController.m
@@ -34,6 +34,8 @@
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
+ [self.image setImage:[self.slideshow getImageAtIndex:0]];
+ [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:0]baseURL:nil];
self.slideShowImageReadyObserver = [center addObserverForName:@"IMAGE_READY" object:nil
queue:mainQueue usingBlock:^(NSNotification *note) {
NSLog(@"Getting image to display: %@", [self.slideshow getImageAtIndex:0]);
commit 5705833197bceff4fc1be5bd179d8eff3225b386
Author: siqi <me at siqi.fr>
Date: Tue Jun 11 17:41:43 2013 +0200
slides preview works
diff --git a/ios/iosremote/iosremote/Base64.h b/ios/iosremote/iosremote/Base64.h
index f61160d..71c4070 100644
--- a/ios/iosremote/iosremote/Base64.h
+++ b/ios/iosremote/iosremote/Base64.h
@@ -1,29 +1,16 @@
-//
-// 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
+/*
+ * 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>
- at interface Base64 : NSObject {
+ at interface NSData (Base64)
-}
++(id)dataWithBase64String:(NSString *)base64String;
-+ (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;
-
- at end
+ at end
\ No newline at end of file
diff --git a/ios/iosremote/iosremote/Base64.m b/ios/iosremote/iosremote/Base64.m
index fc2a369..9b380eb 100644
--- a/ios/iosremote/iosremote/Base64.m
+++ b/ios/iosremote/iosremote/Base64.m
@@ -1,97 +1,23 @@
-//
-// Base64.m
-// CryptTest
-//
-// Created by Kiichi Takeuchi on 4/20/10.
-// Copyright 2010 ObjectGraph LLC. 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 "Base64.h"
+ at implementation NSData(Base64)
- at 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];
-}
-
-
-+ (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)) {
++ (id) dataWithBase64String:(NSString *)base64Encoding
+{
+ if ([base64Encoding length] % 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;
+ NSString *plist = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><plist version=\"1.0\"><data>%@</data></plist>", base64Encoding];
+ return [NSPropertyListSerialization propertyListWithData:[plist dataUsingEncoding:NSASCIIStringEncoding] options:0 format:NULL error:NULL];
}
-+ (NSData*) decode:(NSString*) string {
- return [self decode:[string cStringUsingEncoding:NSASCIIStringEncoding] length:string.length];
-}
-
@end
diff --git a/ios/iosremote/iosremote/Communication/CommandInterpreter.m b/ios/iosremote/iosremote/Communication/CommandInterpreter.m
index 05708e1..184633f 100644
--- a/ios/iosremote/iosremote/Communication/CommandInterpreter.m
+++ b/ios/iosremote/iosremote/Communication/CommandInterpreter.m
@@ -73,13 +73,11 @@
AtIndex:slideNumber];
[[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_PREVIEW object:[NSNumber numberWithUnsignedInt:slideNumber]];
} else if ([instruction isEqualToString:@"slide_notes"]){
- NSLog(@"Interpreter: slide_notes");
uint slideNumber = [[command objectAtIndex:1] integerValue];
- NSString *notes;
+ NSMutableString *notes = [[NSMutableString alloc] init];
for (int i = 2; i<command.count; ++i) {
- [notes stringByAppendingString:[command objectAtIndex:i]];
+ [notes appendString:[command objectAtIndex:i]];
}
-
[self.slideShow putNotes:notes
AtIndex:slideNumber];
[[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_NOTES object: [NSNumber numberWithUnsignedInt:slideNumber]];
diff --git a/ios/iosremote/iosremote/Communication/CommandTransmitter.m b/ios/iosremote/iosremote/Communication/CommandTransmitter.m
index 43c1361..ae7c12a 100644
--- a/ios/iosremote/iosremote/Communication/CommandTransmitter.m
+++ b/ios/iosremote/iosremote/Communication/CommandTransmitter.m
@@ -62,11 +62,11 @@
*/
- (void) blankScreenWithColor:(UIColor*)color
{
- CGColorRef colorRef = color.CGColor;
- NSString *colorString = [CIColor colorWithCGColor:colorRef].stringRepresentation;
+// CGColorRef colorRef = color.CGColor;
+// NSString *colorString = [CIColor colorWithCGColor:colorRef].stringRepresentation;
// Need new server-end interface, since this is a platform dependent representation
- [self.client sendCommand:[NSString stringWithFormat:@"presentation_blank_screen\n%@\n\n", colorString]];
+// [self.client sendCommand:[NSString stringWithFormat:@"presentation_blank_screen\n%@\n\n", colorString]];
}
- (void) resume
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.h b/ios/iosremote/iosremote/Communication/CommunicationManager.h
index 5f6de05..3612a50 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.h
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.h
@@ -36,7 +36,18 @@
#define STATUS_CONNECTION_FAILED @"STATUS_CONNECTION_FAILED"
+typedef enum ConnectionState : NSInteger ConnectionState;
+
+enum ConnectionState : NSInteger {
+ DISCONNECTED,
+ SEARCHING,
+ CONNECTING,
+ CONNECTED
+};
+
@interface CommunicationManager : NSObject
+ at property ConnectionState state;
+
@end
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m
index d155a46..2be29fc 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.m
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m
@@ -8,12 +8,50 @@
#import "CommunicationManager.h"
+#import "Client.h"
+#import "Server.h"
+#import "CommandTransmitter.h"
+#import "CommandInterpreter.h"
@interface CommunicationManager()
+ at property (nonatomic, strong) Client* client;
@end
+// Singlton Pattern
@implementation CommunicationManager
+ at synthesize client = _client;
+ at synthesize state = _state;
+
++ (CommunicationManager *)sharedComManager
+{
+ static CommunicationManager *sharedComManager = nil;
+
+ static dispatch_once_t _singletonPredicate;
+
+ dispatch_once(&_singletonPredicate, ^{
+ sharedComManager = [[super allocWithZone:nil] init];
+ });
+
+ return sharedComManager;
+}
+
+- (id) init
+{
+ self = [super init];
+ self.state = DISCONNECTED;
+ return self;
+}
+
++ (id)allocWithZone:(NSZone *)zone
+{
+ return [self sharedComManager];
+}
+
+
+
+
+
@end
diff --git a/ios/iosremote/iosremote/Communication/SlideShow.h b/ios/iosremote/iosremote/Communication/SlideShow.h
index c2e30cc..b43c810 100644
--- a/ios/iosremote/iosremote/Communication/SlideShow.h
+++ b/ios/iosremote/iosremote/Communication/SlideShow.h
@@ -17,4 +17,7 @@
- (void) putImage: (NSString *)img AtIndex: (uint) index;
- (void) putNotes: (NSString *)notes AtIndex: (uint) index;
+- (UIImage *) getImageAtIndex: (uint) index;
+- (NSString *) getNotesAtIndex: (uint) index;
+
@end
diff --git a/ios/iosremote/iosremote/Communication/SlideShow.m b/ios/iosremote/iosremote/Communication/SlideShow.m
index b2a4c08..7cecc70 100644
--- a/ios/iosremote/iosremote/Communication/SlideShow.m
+++ b/ios/iosremote/iosremote/Communication/SlideShow.m
@@ -24,21 +24,36 @@
- (SlideShow *) init{
self = [super init];
+ self.imagesArray = [[NSMutableArray alloc] init];
+ self.notesArray = [[NSMutableArray alloc] init];
_size = 0;
_currentSlide = 0;
return self;
}
- (void) putImage: (NSString *)img AtIndex: (uint) index{
- [Base64 initialize];
- NSData* data = [Base64 decode:img];
+ NSData* data = [NSData dataWithBase64String:img];
UIImage* image = [UIImage imageWithData:data];
[self.imagesArray insertObject:image atIndex:index];
+
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"IMAGE_READY" object:nil];
}
- (void) putNotes: (NSString *)notes AtIndex: (uint) index{
[self.notesArray insertObject:notes atIndex:index];
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"NOTE_READY" object:nil];
}
+- (UIImage *) getImageAtIndex: (uint) index
+{
+ return [self.imagesArray objectAtIndex:index];
+}
+
+- (NSString *) getNotesAtIndex: (uint) index
+{
+ return [self.notesArray objectAtIndex:index];
+}
+
+
@end
diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard
index cb43691..4dc5762 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.1.97" 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"/>
@@ -38,30 +38,88 @@
<connections>
<outlet property="ipAddressTextEdit" destination="9w1-Ym-HcF" id="hab-JH-3Lf"/>
<outlet property="pinLabel" destination="Cg3-f5-zuM" id="HaU-jr-8oJ"/>
- <segue destination="zdX-BL-bmY" kind="push" identifier="slidesPreview" id="9Yb-di-Q6v"/>
+ <segue destination="zdX-BL-bmY" kind="push" identifier="slidesPreviewSegue" id="9Yb-di-Q6v"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/>
</objects>
- <point key="canvasLocation" x="1618" y="-293"/>
+ <point key="canvasLocation" x="2766" y="-569"/>
+ </scene>
+ <!--Table View Controller-->
+ <scene sceneID="Whz-cu-Rds">
+ <objects>
+ <tableViewController id="Q3M-g5-7cc" sceneMemberID="viewController">
+ <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="Wpt-pb-meU">
+ <rect key="frame" x="0.0" y="20" width="768" height="1004"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ <prototypes>
+ <tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="PmM-ch-mza" detailTextLabel="epJ-IU-4Ja" style="IBUITableViewCellStyleValue1" id="Jgt-j6-gHM">
+ <rect key="frame" x="0.0" y="22" width="768" height="44"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
+ <rect key="frame" x="0.0" y="0.0" width="748" height="43"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <subviews>
+ <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Servername" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="PmM-ch-mza">
+ <rect key="frame" x="10" y="11" width="98" height="21"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+ </label>
+ <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="IP Address" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="epJ-IU-4Ja">
+ <rect key="frame" x="654" y="11" width="84" height="21"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
+ <color key="textColor" red="0.2196078431372549" green="0.32941176470588235" blue="0.52941176470588236" alpha="1" colorSpace="calibratedRGB"/>
+ <color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+ </label>
+ </subviews>
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+ </view>
+ </tableViewCell>
+ </prototypes>
+ <connections>
+ <outlet property="dataSource" destination="Q3M-g5-7cc" id="Ram-95-c0p"/>
+ <outlet property="delegate" destination="Q3M-g5-7cc" id="B8s-db-s0A"/>
+ </connections>
+ </tableView>
+ <navigationItem key="navigationItem" id="Jgb-PO-hv6">
+ <barButtonItem key="rightBarButtonItem" title="Add new Server" id="OYa-b3-ARI"/>
+ </navigationItem>
+ <connections>
+ <segue destination="2" kind="push" id="e6A-u1-Kqr"/>
+ </connections>
+ </tableViewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="Nq5-gt-sEh" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="1640" y="-1071"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="00H-XM-3gJ">
<objects>
- <navigationController id="KFV-Ae-zm8" sceneMemberID="viewController">
- <toolbarItems/>
+ <navigationController toolbarHidden="NO" id="KFV-Ae-zm8" sceneMemberID="viewController">
+ <toolbarItems>
+ <barButtonItem title="Diconnect" id="U8F-bC-QHV"/>
+ </toolbarItems>
+ <simulatedToolbarMetrics key="simulatedBottomBarMetrics" barStyle="blackTranslucent"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="QnQ-yW-KgX">
<rect key="frame" x="0.0" y="0.0" width="768" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
+ <toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" barStyle="blackTranslucent" id="Eh6-CN-U8v">
+ <rect key="frame" x="0.0" y="980" width="768" height="44"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </toolbar>
<connections>
- <segue destination="2" kind="relationship" relationship="rootViewController" id="nce-OO-TOv"/>
+ <segue destination="2" kind="relationship" relationship="rootViewController" id="m46-Fm-sAa"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="sOJ-6b-jVh" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
- <point key="canvasLocation" x="721" y="-301"/>
+ <point key="canvasLocation" x="1666" y="89"/>
</scene>
<!--Slide Show View Controller-->
<scene sceneID="wDH-NE-E5t">
@@ -72,21 +130,26 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" id="T6z-xu-j8h">
- <rect key="frame" x="0.0" y="0.0" width="768" height="960"/>
+ <rect key="frame" x="0.0" y="0.0" width="768" height="458"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
+ <webView contentMode="scaleToFill" id="y0E-Wp-yUc">
+ <rect key="frame" x="20" y="492" width="728" height="378"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
+ <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+ </webView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="uc0-p3-wnG"/>
<connections>
<outlet property="image" destination="T6z-xu-j8h" id="o1L-LM-TbP"/>
- <outlet property="view" destination="T6z-xu-j8h" id="YKN-ib-gU3"/>
+ <outlet property="lecturer_notes" destination="y0E-Wp-yUc" id="qNC-Bc-jAZ"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Dqn-Ae-ABD" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
- <point key="canvasLocation" x="2616" y="-293"/>
+ <point key="canvasLocation" x="3804" y="-569"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
@@ -94,4 +157,7 @@
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination"/>
</simulatedMetricsContainer>
+ <inferredMetricsTieBreakers>
+ <segue reference="m46-Fm-sAa"/>
+ </inferredMetricsTieBreakers>
</document>
\ No newline at end of file
diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
index 45e23ee..0f913db 100644
--- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
+++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
@@ -10,6 +10,7 @@
#import "libreoffice_sdremoteViewController.h"
#import "Server.h"
#import "Client.h"
+#import "slideShowViewController.h"
@interface libreoffice_sdremoteViewController ()
@@ -39,11 +40,18 @@
self.slideShowPreviewStartObserver = [self.center addObserverForName:STATUS_CONNECTED_SLIDESHOW_RUNNING object:nil
queue:mainQueue usingBlock:^(NSNotification *note) {
NSLog(@"Received performSegue!");
- [self performSegueWithIdentifier:@"slidesPreview" sender:self];
+ [self performSegueWithIdentifier:@"slidesPreviewSegue" sender:self];
}];
}
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+ if ([segue.identifier isEqualToString:@"slidesPreviewSegue"]) {
+ slideShowViewController *destViewController = segue.destinationViewController;
+ destViewController.slideshow = [self.interpreter slideShow];
+ }
+}
+
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
diff --git a/ios/iosremote/iosremote/slideShowViewController.h b/ios/iosremote/iosremote/slideShowViewController.h
index f44b849..314bd12 100644
--- a/ios/iosremote/iosremote/slideShowViewController.h
+++ b/ios/iosremote/iosremote/slideShowViewController.h
@@ -7,9 +7,15 @@
//
#import <UIKit/UIKit.h>
+#import "SlideShow.h"
@interface slideShowViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIImageView *image;
+ at property (weak, nonatomic) IBOutlet UIWebView *lecturer_notes;
+
+ at property (nonatomic, strong) SlideShow *slideshow;
+ at property (nonatomic, strong) id slideShowImageReadyObserver;
+ at property (nonatomic, strong) id slideShowNoteReadyObserver;
@end
diff --git a/ios/iosremote/iosremote/slideShowViewController.m b/ios/iosremote/iosremote/slideShowViewController.m
index cd04f39..f39bead 100644
--- a/ios/iosremote/iosremote/slideShowViewController.m
+++ b/ios/iosremote/iosremote/slideShowViewController.m
@@ -7,6 +7,7 @@
//
#import "slideShowViewController.h"
+#import "SlideShow.h"
@interface slideShowViewController ()
@@ -14,6 +15,10 @@
@implementation slideShowViewController
+ at synthesize slideshow = _slideshow;
+ at synthesize slideShowImageReadyObserver = _slideShowImageReadyObserver;
+ at synthesize slideShowNoteReadyObserver = _slideShowNoteReadyObserver;
+
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
@@ -26,9 +31,23 @@
- (void)viewDidLoad
{
[super viewDidLoad];
- // Do any additional setup after loading the view.
+
+ NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+ NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
+ self.slideShowImageReadyObserver = [center addObserverForName:@"IMAGE_READY" object:nil
+ queue:mainQueue usingBlock:^(NSNotification *note) {
+ NSLog(@"Getting image to display: %@", [self.slideshow getImageAtIndex:0]);
+ [self.image setImage:[self.slideshow getImageAtIndex:0]];
+ }];
+ self.slideShowNoteReadyObserver = [center addObserverForName:@"NOTE_READY" object:nil
+ queue:mainQueue usingBlock:^(NSNotification *note) {
+ NSLog(@"Getting note to display: %@", [self.slideshow getNotesAtIndex:0]);
+ [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:0]baseURL:nil];
+ }];
}
+
+
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
@@ -37,6 +56,7 @@
- (void)viewDidUnload {
[self setImage:nil];
+ [self setLecturer_notes:nil];
[super viewDidUnload];
}
@end
More information about the Libreoffice-commits
mailing list