summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorsiqi <me@siqi.fr>2013-06-15 22:15:31 +0200
committersiqi <me@siqi.fr>2013-06-18 00:20:01 +0200
commitf635e78632dfdde01dae8fb1ecc5fdf5f3dc3e73 (patch)
treec4d967fdeb7a7bc7dbec65d18af7258b616cac3e /ios
parentb202d328289d2854209694646c695ea263d27bb5 (diff)
comManager works now
Diffstat (limited to 'ios')
-rw-r--r--ios/iosremote/iosremote/Communication/Client.m11
-rw-r--r--ios/iosremote/iosremote/Communication/CommandTransmitter.m6
-rw-r--r--ios/iosremote/iosremote/Communication/CommunicationManager.h2
-rw-r--r--ios/iosremote/iosremote/Communication/CommunicationManager.m4
-rw-r--r--ios/iosremote/iosremote/Communication/SlideShow.h2
-rw-r--r--ios/iosremote/iosremote/Communication/SlideShow.m6
-rw-r--r--ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard2
-rw-r--r--ios/iosremote/iosremote/libreoffice_sdremoteViewController.m2
-rw-r--r--ios/iosremote/iosremote/slideShowViewController.m26
9 files changed, 32 insertions, 29 deletions
diff --git a/ios/iosremote/iosremote/Communication/Client.m b/ios/iosremote/iosremote/Communication/Client.m
index e1fe1edf1d46..aa8a1cc7807f 100644
--- a/ios/iosremote/iosremote/Communication/Client.m
+++ b/ios/iosremote/iosremote/Communication/Client.m
@@ -96,6 +96,11 @@
[self.outputStream setDelegate:self];
[self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.outputStream open];
+
+ 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];
}
}
@@ -114,18 +119,15 @@ int count = 0;
switch(eventCode) {
case NSStreamEventOpenCompleted:{
NSLog(@"Connection established");
- self.connected = YES;
if (count == 1) {
[[NSNotificationCenter defaultCenter]postNotificationName:@"connection.status.connected" object:nil];
} else {
count++;
- }
-
+ }
}
break;
case NSStreamEventErrorOccurred:{
NSLog(@"Connection error occured");
- [self disconnect];
[[NSNotificationCenter defaultCenter]postNotificationName:@"connection.status.disconnected" object:nil];
}
break;
@@ -153,7 +155,6 @@ int count = 0;
}
NSArray *commands = [str componentsSeparatedByString:@"\n"];
-
[self.receiver parse:commands];
data = nil;
str = nil;
diff --git a/ios/iosremote/iosremote/Communication/CommandTransmitter.m b/ios/iosremote/iosremote/Communication/CommandTransmitter.m
index cbf0d27d8d7c..a359f5e73543 100644
--- a/ios/iosremote/iosremote/Communication/CommandTransmitter.m
+++ b/ios/iosremote/iosremote/Communication/CommandTransmitter.m
@@ -24,11 +24,7 @@
{
self = [self init];
self.client = client;
-
- NSArray *temp = [[NSArray alloc]initWithObjects:@"LO_SERVER_CLIENT_PAIR\n", self.client.name, @"\n", self.client.pin, @"\n\n", nil];
- NSString *command = [temp componentsJoinedByString:@""];
-
- [self.client sendCommand:command];
+
return self;
}
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.h b/ios/iosremote/iosremote/Communication/CommunicationManager.h
index a5393d94877d..784ec0575741 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.h
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.h
@@ -12,6 +12,7 @@
@class Client;
@class Server;
@class CommandInterpreter;
+@class SlideShow;
#define MSG_SLIDESHOW_STARTED @"SLIDESHOW_STARTED"
#define MSG_SLIDE_CHANGED @"SLIDE_CHANGED"
@@ -55,5 +56,6 @@ enum ConnectionState : NSInteger {
@property ConnectionState state;
@property (nonatomic, strong) id delegate;
+@property (nonatomic, strong) CommandInterpreter* interpreter;
@end
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m
index 97e23a771cae..c5ce0a5b0be9 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.m
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m
@@ -10,6 +10,7 @@
#import "CommunicationManager.h"
#import "Client.h"
#import "Server.h"
+#import "SlideShow.h"
#import "CommandTransmitter.h"
#import "CommandInterpreter.h"
#import "libreoffice_sdremoteViewController.h"
@@ -18,7 +19,6 @@
@interface CommunicationManager()
@property (nonatomic, strong) Client* client;
-@property (nonatomic, strong) CommandInterpreter* interpreter;
@property (nonatomic, strong) CommandTransmitter* transmitter;
@property (atomic, strong) NSMutableSet* servers;
@property (nonatomic, strong) id connectionConnectedObserver;
@@ -74,6 +74,7 @@
{
self = [super init];
self.state = DISCONNECTED;
+ self.interpreter = [[CommandInterpreter alloc] init];
[[NSNotificationCenter defaultCenter]addObserver: self
selector: @selector(connectionStatusHandler:)
@@ -120,6 +121,7 @@
[self.client disconnect];
// initialise it with a given server
self.client = [[Client alloc]initWithServer:server managedBy:self interpretedBy:self.interpreter];
+ self.transmitter = [[CommandTransmitter alloc] initWithClient:self.client];
[self.client connect];
}
}
diff --git a/ios/iosremote/iosremote/Communication/SlideShow.h b/ios/iosremote/iosremote/Communication/SlideShow.h
index 98d14d9003ee..7fd85e47af6c 100644
--- a/ios/iosremote/iosremote/Communication/SlideShow.h
+++ b/ios/iosremote/iosremote/Communication/SlideShow.h
@@ -15,7 +15,7 @@
@property uint size;
@property uint currentSlide;
-@property (nonatomic, weak) id delegate;
+@property (nonatomic, strong) 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 7bd8c55266df..da06f34a4b5e 100644
--- a/ios/iosremote/iosremote/Communication/SlideShow.m
+++ b/ios/iosremote/iosremote/Communication/SlideShow.m
@@ -37,14 +37,12 @@
NSData* data = [NSData dataWithBase64String:img];
UIImage* image = [UIImage imageWithData:data];
[self.imagesArray insertObject:image atIndex:index];
- slideShowViewController* vc = [self delegate];
- [[vc image] setImage:image];
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"IMAGE_READY" object:nil];
}
- (void) putNotes: (NSString *)notes AtIndex: (uint) index{
[self.notesArray insertObject:notes atIndex:index];
- slideShowViewController* vc = [self delegate];
- [[vc lecturer_notes] loadHTMLString:notes baseURL:nil];
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"NOTE_READY" object:nil];
}
- (UIImage *) getImageAtIndex: (uint) index
diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard
index a530cbc4674f..5870d892f21a 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.40.101" borderStyle="roundedRect" minimumFontSize="17" id="9w1-Ym-HcF">
+ <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="192.168.0.22" 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_sdremoteViewController.m b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
index d7d1fc63c1d8..af798ba83ca8 100644
--- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
+++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
@@ -11,6 +11,7 @@
#import "Server.h"
#import "slideShowViewController.h"
#import "CommunicationManager.h"
+#import "CommandInterpreter.h"
@interface libreoffice_sdremoteViewController ()
@@ -46,6 +47,7 @@
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"slidesPreviewSegue"]) {
slideShowViewController *destViewController = segue.destinationViewController;
+ destViewController.slideshow = [self.comManager.interpreter slideShow];
[destViewController.slideshow setDelegate:destViewController];
}
}
diff --git a/ios/iosremote/iosremote/slideShowViewController.m b/ios/iosremote/iosremote/slideShowViewController.m
index 9f9bf7541288..0df39d34cdf5 100644
--- a/ios/iosremote/iosremote/slideShowViewController.m
+++ b/ios/iosremote/iosremote/slideShowViewController.m
@@ -32,20 +32,22 @@
{
[super viewDidLoad];
-// NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
-// NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
+ 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];
-// }]
+ self.slideShowImageReadyObserver = [center addObserverForName:@"IMAGE_READY" object:nil
+ queue:mainQueue usingBlock:^(NSNotification *note) {
+ if ([self.slideshow size] == 0)
+ NSLog(@"Oups");
+ 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];
+ }];
}