[Libreoffice-commits] core.git: 7 commits - ios/iosremote

siqi me at siqi.fr
Mon Jun 17 15:20:31 PDT 2013


 ios/iosremote/iosremote/Base64.h                                |   14 -
 ios/iosremote/iosremote/Communication/Client.h                  |    9 -
 ios/iosremote/iosremote/Communication/Client.m                  |   40 +----
 ios/iosremote/iosremote/Communication/CommandInterpreter.h      |    3 
 ios/iosremote/iosremote/Communication/CommandInterpreter.m      |    2 
 ios/iosremote/iosremote/Communication/CommandTransmitter.h      |   14 +
 ios/iosremote/iosremote/Communication/CommandTransmitter.m      |    1 
 ios/iosremote/iosremote/Communication/CommunicationManager.h    |   18 +-
 ios/iosremote/iosremote/Communication/CommunicationManager.m    |   76 ++++++---
 ios/iosremote/iosremote/Communication/SlideShow.h               |    5 
 ios/iosremote/iosremote/Communication/SlideShow.m               |   80 ++++++++--
 ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard |   56 ++++++-
 ios/iosremote/iosremote/libreoffice_sdremoteViewController.h    |   12 -
 ios/iosremote/iosremote/libreoffice_sdremoteViewController.m    |   38 ++--
 ios/iosremote/iosremote/slideShowViewController.h               |   13 -
 ios/iosremote/iosremote/slideShowViewController.m               |   56 ++++---
 16 files changed, 291 insertions(+), 146 deletions(-)

New commits:
commit 8ee20962ac4eb75798a4ea3b22a5361e0d0d50cb
Author: siqi <me at siqi.fr>
Date:   Mon Jun 17 21:31:21 2013 +0200

    Load image when fetched from server automatically

diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard
index e9efbc9..8a373a5 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="916"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="192.168.0.22" borderStyle="roundedRect" minimumFontSize="17" id="9w1-Ym-HcF">
+                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="192.168.40.101" 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"/>
@@ -174,6 +174,26 @@
             <point key="canvasLocation" x="3804" y="-569"/>
         </scene>
     </scenes>
+    <classes>
+        <class className="libreoffice_sdremoteViewController" superclassName="UIViewController">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/libreoffice_sdremoteViewController.h"/>
+            <relationships>
+                <relationship kind="action" name="connectToServer:"/>
+                <relationship kind="action" name="startPresentation:"/>
+                <relationship kind="outlet" name="ipAddressTextEdit" candidateClass="UITextField"/>
+                <relationship kind="outlet" name="pinLabel" candidateClass="UILabel"/>
+            </relationships>
+        </class>
+        <class className="slideShowViewController" superclassName="UIViewController">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/slideShowViewController.h"/>
+            <relationships>
+                <relationship kind="action" name="nextSlide:"/>
+                <relationship kind="action" name="previousSlide:"/>
+                <relationship kind="outlet" name="image" candidateClass="UIImageView"/>
+                <relationship kind="outlet" name="lecturer_notes" candidateClass="UIWebView"/>
+            </relationships>
+        </class>
+    </classes>
     <simulatedMetricsContainer key="defaultSimulatedMetrics">
         <simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/>
         <simulatedOrientationMetrics key="orientation"/>
commit 03fd884b6ea89ff12ae0a2750a7600a75859c39e
Author: siqi <me at siqi.fr>
Date:   Mon Jun 17 18:11:32 2013 +0200

    license

diff --git a/ios/iosremote/iosremote/Base64.h b/ios/iosremote/iosremote/Base64.h
index 71c4070..f222423 100644
--- a/ios/iosremote/iosremote/Base64.h
+++ b/ios/iosremote/iosremote/Base64.h
@@ -1,10 +1,10 @@
-/*
- * 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/.
- */
+// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+//
+// 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/CommandTransmitter.h b/ios/iosremote/iosremote/Communication/CommandTransmitter.h
index 39f85a8..95821c9 100644
--- a/ios/iosremote/iosremote/Communication/CommandTransmitter.h
+++ b/ios/iosremote/iosremote/Communication/CommandTransmitter.h
@@ -1,10 +1,10 @@
+// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 //
-//  CommandTransmitter.h
-//  iosremote
-//
-//  Created by Liu Siqi on 6/9/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/libreoffice_sdremoteViewController.h b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h
index e1bbb49..d664fdf 100644
--- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h
+++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h
@@ -1,10 +1,10 @@
+// -*- 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/slideShowViewController.h b/ios/iosremote/iosremote/slideShowViewController.h
index c5391b4..f915d65 100644
--- a/ios/iosremote/iosremote/slideShowViewController.h
+++ b/ios/iosremote/iosremote/slideShowViewController.h
@@ -1,10 +1,11 @@
+// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 //
-//  slideShowViewController.h
-//  iosremote
-//
-//  Created by Liu Siqi on 6/9/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>
 #import "SlideShow.h"
diff --git a/ios/iosremote/iosremote/slideShowViewController.m b/ios/iosremote/iosremote/slideShowViewController.m
index e1669df..5892ab9 100644
--- a/ios/iosremote/iosremote/slideShowViewController.m
+++ b/ios/iosremote/iosremote/slideShowViewController.m
@@ -1,10 +1,10 @@
+// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 //
-//  slideShowViewController.m
-//  iosremote
-//
-//  Created by Liu Siqi on 6/9/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 "slideShowViewController.h"
 #import "SlideShow.h"
commit 1c8ad3b464d4e2ecdd62b593dc3e53d340c66df6
Author: siqi <me at siqi.fr>
Date:   Mon Jun 17 18:09:35 2013 +0200

    asynchronsly load image into slideshow

diff --git a/ios/iosremote/iosremote/Communication/CommandInterpreter.m b/ios/iosremote/iosremote/Communication/CommandInterpreter.m
index 184633f..363fad4 100644
--- a/ios/iosremote/iosremote/Communication/CommandInterpreter.m
+++ b/ios/iosremote/iosremote/Communication/CommandInterpreter.m
@@ -51,7 +51,7 @@
         [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_CHANGED object:[NSNumber numberWithUnsignedInt:currentSlide]];
         
     } else if ([instruction isEqualToString:@"slideshow_finished"]){
-        NSLog(@"Interpreter: slideshow_started");
+        NSLog(@"Interpreter: slideshow_finished");
         self.slideShow = [[SlideShow alloc] init];
         [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_CONNECTED_NOSLIDESHOW object:nil];
     } else {
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.h b/ios/iosremote/iosremote/Communication/CommunicationManager.h
index 784ec05..8df7e09 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;
+ at class CommandTransmitter;
 @class SlideShow;
 
 #define MSG_SLIDESHOW_STARTED @"SLIDESHOW_STARTED"
@@ -57,5 +58,8 @@ enum ConnectionState : NSInteger {
 @property ConnectionState state;
 @property (nonatomic, strong) id delegate;
 @property (nonatomic, strong) CommandInterpreter* interpreter;
+ at property (nonatomic, strong) CommandTransmitter* transmitter;
+
++ (CommunicationManager *)sharedComManager;
 
 @end
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m
index c5ce0a5..bd86180 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.m
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m
@@ -19,7 +19,6 @@
 @interface CommunicationManager()
 
 @property (nonatomic, strong) Client* client;
- at property (nonatomic, strong) CommandTransmitter* transmitter;
 @property (atomic, strong) NSMutableSet* servers;
 @property (nonatomic, strong) id connectionConnectedObserver;
 @property (nonatomic, strong) id connectionDisconnectedObserver;
diff --git a/ios/iosremote/iosremote/Communication/SlideShow.h b/ios/iosremote/iosremote/Communication/SlideShow.h
index 7fd85e4..906ddcf 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;
- at property (nonatomic, strong) id delegate;
+ at property (nonatomic, strong) slideShowViewController* 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 6c2226b..27b8395 100644
--- a/ios/iosremote/iosremote/Communication/SlideShow.m
+++ b/ios/iosremote/iosremote/Communication/SlideShow.m
@@ -14,8 +14,12 @@
 
 @interface SlideShow()
 
- at property (nonatomic, strong) NSMutableArray* imagesArray;
- at property (nonatomic, strong) NSMutableArray* notesArray;
+ at property (nonatomic, strong) NSMutableDictionary* imagesDictionary;
+ at property (nonatomic, strong) NSMutableDictionary* notesDictionary;
+
+ at property int lastRequestedImage, lastRequestedNote;
+ at property (nonatomic, strong) id slideShowImageReadyObserver;
+ at property (nonatomic, strong) id slideShowNoteReadyObserver;
 
 @end
 
@@ -29,37 +33,80 @@ dispatch_queue_t backgroundQueue;
 
 - (SlideShow *) init{
     self = [super init];
-    self.imagesArray = [[NSMutableArray alloc] init];
-    self.notesArray = [[NSMutableArray alloc] init];
+    self.imagesDictionary = [[NSMutableDictionary alloc] init];
+    self.notesDictionary = [[NSMutableDictionary alloc] init];
     _size = 0;
     _currentSlide = 0;
     
     backgroundQueue = dispatch_queue_create("org.libreoffice.iosremote.bgqueue", NULL);
+    NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
+    
+    self.slideShowImageReadyObserver =[[NSNotificationCenter defaultCenter]
+                                              addObserverForName:@"storage_update_image_ready"
+                                                          object:nil
+                                                           queue:mainQueue
+                                                      usingBlock:^(NSNotification *note) {
+                                                          if ([[[note userInfo] objectForKey:@"index"] intValue] == self.lastRequestedImage) {
+                                                              [self.delegate.image setImage:[self getImageAtIndex:self.lastRequestedImage]];
+                                                              self.lastRequestedImage = -1;
+                                                          }
+                                                      }];
+    
+    self.slideShowNoteReadyObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"storage_update_note_ready"
+                                                          object:nil
+                                                           queue:mainQueue
+                                                      usingBlock:^(NSNotification *note) {
+                                                          if ([[[note userInfo] objectForKey:@"index"] intValue] == self.lastRequestedNote) {
+                                                              [self.delegate.lecturer_notes loadHTMLString:[self getNotesAtIndex:self.lastRequestedNote] baseURL:nil];
+                                                              self.lastRequestedNote = -1;
+                                                          }
+                                                      }];
     
     return self;
 }
 
 - (void) putImage: (NSString *)img AtIndex: (uint) index{
-    
-    NSData* data = [NSData dataWithBase64String:img];
-    UIImage* image = [UIImage imageWithData:data];
-    [self.imagesArray insertObject:image atIndex:index];
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"IMAGE_READY" object:nil];
+//    NSLog(@"Put Image into %u", index);
+    dispatch_async(backgroundQueue, ^(void) {
+        NSData* data = [NSData dataWithBase64String:img];
+        UIImage* image = [UIImage imageWithData:data];
+        [self.imagesDictionary setObject:image forKey:[NSNumber numberWithUnsignedInt:index]];
+        [[NSNotificationCenter defaultCenter] postNotificationName:@"storage_update_image_ready"
+                                                            object:nil
+                                                          userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:index] forKey:@"index"]];
+    });
 }
 
 - (void) putNotes: (NSString *)notes AtIndex: (uint) index{
-    [self.notesArray insertObject:notes atIndex:index];
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"NOTE_READY" object:nil];
+//    NSLog(@"Put note into %u", index);
+    [self.notesDictionary setObject:notes forKey:[NSNumber numberWithUnsignedInt:index]];
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"storage_update_note_ready"
+                                                        object:nil
+                                                      userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:index] forKey:@"index"]];
 }
 
 - (UIImage *) getImageAtIndex: (uint) index
 {
-    return [self.imagesArray objectAtIndex:index];
+    if (![self.imagesDictionary objectForKey:[NSNumber numberWithUnsignedInt:index]]) {
+        self.lastRequestedImage = index;
+        return nil;
+    }
+    else{
+        self.lastRequestedImage = -1;
+        return [self.imagesDictionary objectForKey:[NSNumber numberWithUnsignedInt:index]];
+    }
 }
 
 - (NSString *) getNotesAtIndex: (uint) index
 {
-    return [self.notesArray objectAtIndex:index];
+    if (![self.notesDictionary objectForKey:[NSNumber numberWithUnsignedInt:index]]) {
+        self.lastRequestedNote = index;
+        return nil;
+    }
+    else {
+        self.lastRequestedNote = -1;
+        return [self.notesDictionary objectForKey:[NSNumber numberWithUnsignedInt:index]];
+    }
 }
 
 
diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard
index 5870d89..e9efbc9 100644
--- a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard
+++ b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard
@@ -9,7 +9,7 @@
             <objects>
                 <viewController id="2" customClass="libreoffice_sdremoteViewController" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="5">
-                        <rect key="frame" x="0.0" y="64" width="768" height="960"/>
+                        <rect key="frame" x="0.0" y="64" width="768" height="916"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="192.168.0.22" borderStyle="roundedRect" minimumFontSize="17" id="9w1-Ym-HcF">
@@ -28,6 +28,13 @@
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                     </view>
+                    <toolbarItems>
+                        <barButtonItem title="Start Presentation" id="R1W-H8-kVN">
+                            <connections>
+                                <action selector="startPresentation:" destination="2" id="D8F-FY-mIu"/>
+                            </connections>
+                        </barButtonItem>
+                    </toolbarItems>
                     <navigationItem key="navigationItem" id="7ye-Vv-ZD0">
                         <barButtonItem key="rightBarButtonItem" title="Connect" id="ZJB-Ei-Sa9">
                             <connections>
@@ -35,6 +42,7 @@
                             </connections>
                         </barButtonItem>
                     </navigationItem>
+                    <simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
                     <connections>
                         <outlet property="ipAddressTextEdit" destination="9w1-Ym-HcF" id="hab-JH-3Lf"/>
                         <outlet property="pinLabel" destination="Cg3-f5-zuM" id="HaU-jr-8oJ"/>
@@ -126,22 +134,36 @@
             <objects>
                 <viewController id="zdX-BL-bmY" customClass="slideShowViewController" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="Tkv-NW-1bl">
-                        <rect key="frame" x="0.0" y="64" width="768" height="960"/>
+                        <rect key="frame" x="0.0" y="64" width="768" height="916"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                         <subviews>
                             <imageView userInteractionEnabled="NO" contentMode="scaleToFill" id="T6z-xu-j8h">
-                                <rect key="frame" x="14" y="20" width="741" height="442"/>
+                                <rect key="frame" x="14" y="20" width="741" height="398"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             </imageView>
                             <webView contentMode="scaleToFill" id="y0E-Wp-yUc">
-                                <rect key="frame" x="20" y="513" width="728" height="378"/>
+                                <rect key="frame" x="20" y="487.5" width="728" height="359.5"/>
                                 <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"/>
+                    <toolbarItems>
+                        <barButtonItem title="Previous" id="fEE-h8-5be">
+                            <connections>
+                                <action selector="previousSlide:" destination="zdX-BL-bmY" id="DMr-Rh-WfD"/>
+                            </connections>
+                        </barButtonItem>
+                    </toolbarItems>
+                    <navigationItem key="navigationItem" id="uc0-p3-wnG">
+                        <barButtonItem key="rightBarButtonItem" title="Next" id="502-Fp-Hjs">
+                            <connections>
+                                <action selector="nextSlide:" destination="zdX-BL-bmY" id="YU1-0k-qPi"/>
+                            </connections>
+                        </barButtonItem>
+                    </navigationItem>
+                    <simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
                     <connections>
                         <outlet property="image" destination="T6z-xu-j8h" id="o1L-LM-TbP"/>
                         <outlet property="lecturer_notes" destination="y0E-Wp-yUc" id="qNC-Bc-jAZ"/>
diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
index af798ba..eb2e61b 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 "CommandTransmitter.h"
 #import "CommandInterpreter.h"
 
 @interface libreoffice_sdremoteViewController ()
@@ -39,12 +40,12 @@
     self.slideShowPreviewStartObserver = [self.center addObserverForName:STATUS_CONNECTED_SLIDESHOW_RUNNING object:nil
                                                      queue:mainQueue usingBlock:^(NSNotification *note) {
                                                          NSLog(@"Received performSegue!");
-                                                         [self performSegueWithIdentifier:@"slidesPreviewSegue" sender:self];
+                                                         [self performSegueWithIdentifier:@"slidesPreviewSegue" sender:self ];
                                                      }];
 
 }
 
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
     if ([segue.identifier isEqualToString:@"slidesPreviewSegue"]) {
         slideShowViewController *destViewController = segue.destinationViewController;
         destViewController.slideshow = [self.comManager.interpreter slideShow];
@@ -67,6 +68,11 @@
     [self.comManager connectToServer:self.server];
 }
 
+
+- (IBAction)startPresentation:(id)sender {
+    [self.comManager.transmitter startPresentation];
+}
+
 - (void)viewDidUnload {
     [self setIpAddressTextEdit:nil];
     [self setPinLabel:nil];
diff --git a/ios/iosremote/iosremote/slideShowViewController.m b/ios/iosremote/iosremote/slideShowViewController.m
index 0df39d3..e1669df 100644
--- a/ios/iosremote/iosremote/slideShowViewController.m
+++ b/ios/iosremote/iosremote/slideShowViewController.m
@@ -8,9 +8,13 @@
 
 #import "slideShowViewController.h"
 #import "SlideShow.h"
+#import "CommandTransmitter.h"
+#import "CommunicationManager.h"
 
 @interface slideShowViewController ()
 
+ at property (nonatomic, strong) CommunicationManager* comManager;
+
 @end
 
 @implementation slideShowViewController
@@ -18,6 +22,7 @@
 @synthesize slideshow = _slideshow;
 @synthesize slideShowImageReadyObserver = _slideShowImageReadyObserver;
 @synthesize slideShowNoteReadyObserver = _slideShowNoteReadyObserver;
+ at synthesize comManager = _comManager;
 
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
 {
@@ -34,23 +39,34 @@
     
     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) {
-                                                                  if ([self.slideshow size] == 0)
-                                                                      NSLog(@"Oups");
-                                                                  NSLog(@"Getting image to display: %@", [self.slideshow getImageAtIndex:0]);
-                                                                  [self.image setImage:[self.slideshow getImageAtIndex:0]];
+
+    self.slideShowImageReadyObserver =[center addObserverForName:MSG_SLIDE_CHANGED
+                                                          object:nil
+                                                           queue:mainQueue
+                                                      usingBlock:^(NSNotification *note) {
+                                                                  NSLog(@"Getting slide: %u image to display: %@", self.slideshow.currentSlide, [self.slideshow getImageAtIndex:self.slideshow.currentSlide]);
+                                                          
+                                                                  [self.image setImage:[self.slideshow getImageAtIndex:self.slideshow.currentSlide]];
+                                                                  [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:self.slideshow.currentSlide]baseURL:nil];
                                                               }];
-    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.slideShowNoteReadyObserver = [center addObserverForName:STATUS_CONNECTED_NOSLIDESHOW
+                                                          object:nil
+                                                           queue:mainQueue
+                                                      usingBlock:^(NSNotification *note) {
+                                                                  [self.navigationController popViewControllerAnimated:YES];
                                                               }];
+    
+    self.comManager = [CommunicationManager sharedComManager];
 }
 
+- (IBAction)nextSlide:(id)sender {
+    [self.comManager.transmitter nextTransition];
+}
 
+- (IBAction)previousSlide:(id)sender {
+    [self.comManager.transmitter previousTransition];
+}
 
 - (void)didReceiveMemoryWarning
 {
commit 98ae2b23d8566e4a66223edfff278fee4fe93aeb
Author: siqi <me at siqi.fr>
Date:   Sat Jun 15 22:22:29 2013 +0200

    comManager works now

diff --git a/ios/iosremote/iosremote/Communication/SlideShow.m b/ios/iosremote/iosremote/Communication/SlideShow.m
index da06f34..6c2226b 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 <dispatch/dispatch.h>
 #import "slideShowViewController.h"
 
 @interface SlideShow()
@@ -24,16 +25,22 @@
 @synthesize currentSlide = _currentSlide;
 @synthesize delegate = _delegate;
 
+dispatch_queue_t backgroundQueue;
+
 - (SlideShow *) init{
     self = [super init];
     self.imagesArray = [[NSMutableArray alloc] init];
     self.notesArray = [[NSMutableArray alloc] init];
     _size = 0;
     _currentSlide = 0;
+    
+    backgroundQueue = dispatch_queue_create("org.libreoffice.iosremote.bgqueue", NULL);
+    
     return self;
 }
 
 - (void) putImage: (NSString *)img AtIndex: (uint) index{
+    
     NSData* data = [NSData dataWithBase64String:img];
     UIImage* image = [UIImage imageWithData:data];
     [self.imagesArray insertObject:image atIndex:index];
commit f635e78632dfdde01dae8fb1ecc5fdf5f3dc3e73
Author: siqi <me at siqi.fr>
Date:   Sat Jun 15 22:15:31 2013 +0200

    comManager works now

diff --git a/ios/iosremote/iosremote/Communication/Client.m b/ios/iosremote/iosremote/Communication/Client.m
index e1fe1ed..aa8a1cc 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 cbf0d27..a359f5e 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 a5393d9..784ec05 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;
+ at 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;
+ at property (nonatomic, strong) CommandInterpreter* interpreter;
 
 @end
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m
index 97e23a7..c5ce0a5 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;
- at 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 98d14d9..7fd85e4 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;
- at property (nonatomic, weak) id delegate;
+ at 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 7bd8c55..da06f34 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 a530cbc..5870d89 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 d7d1fc6..af798ba 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 9f9bf75..0df39d3 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];
+                                                              }];
 }
 
 
commit b202d328289d2854209694646c695ea263d27bb5
Author: siqi <me at siqi.fr>
Date:   Sat Jun 15 14:49:54 2013 +0200

    before checkout

diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m
index 20b234c..97e23a7 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.m
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m
@@ -55,14 +55,18 @@
 - (void) connectionStatusHandler:(NSNotification *)note
 {
     if([[note name] isEqualToString:@"connection.status.connected"]){
-        NSLog(@"Connected");
-        self.transmitter = [[CommandTransmitter alloc] initWithClient:self.client];
-        self.state = CONNECTED;
-        [self.delegate setPinLabelText:[NSString stringWithFormat:@"%@", [self getPairingPin]]];
+        if (self.state!=CONNECTED){
+            NSLog(@"Connected");
+            self.transmitter = [[CommandTransmitter alloc] initWithClient:self.client];
+            self.state = CONNECTED;
+            [self.delegate setPinLabelText:[NSString stringWithFormat:@"%@", [self getPairingPin]]];
+        }
     } else if ([[note name] isEqualToString:@"connection.status.disconnected"]){
-        NSLog(@"Connection Failed");
-        self.state = DISCONNECTED;
-        [self.client disconnect];
+        if (self.state != DISCONNECTED) {
+            NSLog(@"Connection Failed");
+            self.state = DISCONNECTED;
+            [self.client disconnect];            
+        }
     }
 }
 
commit 894d19ab772a9f0705b97c1490bedc667c0fae5c
Author: siqi <me at siqi.fr>
Date:   Sat Jun 15 14:47:39 2013 +0200

    seems somthing get blocked...

diff --git a/ios/iosremote/iosremote/Communication/Client.h b/ios/iosremote/iosremote/Communication/Client.h
index 45f7e95..51674fd 100644
--- a/ios/iosremote/iosremote/Communication/Client.h
+++ b/ios/iosremote/iosremote/Communication/Client.h
@@ -7,9 +7,10 @@
  */
 
 #import <Foundation/Foundation.h>
-#import "Server.h"
-#import "CommunicationManager.h"
-#import "CommandInterpreter.h"
+
+ at class Server;
+ at class CommunicationManager;
+ at class CommandInterpreter;
 
 @interface Client : NSObject
 
@@ -18,7 +19,7 @@
 @property (nonatomic, strong) NSString* name;
 @property (nonatomic, weak) Server* server;
 
-- (BOOL) connect;
+- (void) connect;
 - (void) disconnect;
 
 - (id) initWithServer:(Server*)server
diff --git a/ios/iosremote/iosremote/Communication/Client.m b/ios/iosremote/iosremote/Communication/Client.m
index bfa7648..e1fe1ed 100644
--- a/ios/iosremote/iosremote/Communication/Client.m
+++ b/ios/iosremote/iosremote/Communication/Client.m
@@ -20,14 +20,11 @@
 @property (nonatomic, strong) NSOutputStream* outputStream;
 
 @property uint mPort;
-
 @property (nonatomic, weak) CommandInterpreter* receiver;
 @property (nonatomic, weak) CommunicationManager* comManager;
 
 @end
 
-NSCondition *connected;
-
 @implementation Client
 
 @synthesize inputStream = _mInputStream;
@@ -39,6 +36,7 @@ NSCondition *connected;
 @synthesize connected = _mReady;
 @synthesize receiver = _receiver;
 
+
 - (id) initWithServer:(Server*)server
             managedBy:(CommunicationManager*)manager
         interpretedBy:(CommandInterpreter*)receiver
@@ -46,7 +44,6 @@ NSCondition *connected;
     self = [self init];
     if (self)
     {
-        connected = [NSCondition new];
         self.connected = NO;
         self.name = [[UIDevice currentDevice] name];
         self.pin = [NSNumber numberWithInteger:[self getPin]];
@@ -111,24 +108,25 @@ NSCondition *connected;
     [self.outputStream write:(uint8_t *)[data bytes] maxLength:[data length]];
 }
 
+int count = 0;
+
 - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {
-    
     switch(eventCode) {
         case NSStreamEventOpenCompleted:{
             NSLog(@"Connection established");
-            [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];
+            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;
         case NSStreamEventHasBytesAvailable:
@@ -179,18 +177,9 @@ NSCondition *connected;
     self.connected = NO;
 }
 
-- (BOOL) connect
+- (void) 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/CommandInterpreter.h b/ios/iosremote/iosremote/Communication/CommandInterpreter.h
index faa07cf..287cdc5 100644
--- a/ios/iosremote/iosremote/Communication/CommandInterpreter.h
+++ b/ios/iosremote/iosremote/Communication/CommandInterpreter.h
@@ -8,7 +8,8 @@
 
 
 #import <Foundation/Foundation.h>
-#import "SlideShow.h"
+
+ at class SlideShow;
 
 @interface CommandInterpreter : NSObject
 
diff --git a/ios/iosremote/iosremote/Communication/CommandTransmitter.h b/ios/iosremote/iosremote/Communication/CommandTransmitter.h
index 05ddc24..39f85a8 100644
--- a/ios/iosremote/iosremote/Communication/CommandTransmitter.h
+++ b/ios/iosremote/iosremote/Communication/CommandTransmitter.h
@@ -7,7 +7,9 @@
 //
 
 #import <Foundation/Foundation.h>
-#import "Client.h"
+
+ at class Client;
+
 
 @interface CommandTransmitter : NSObject
 
diff --git a/ios/iosremote/iosremote/Communication/CommandTransmitter.m b/ios/iosremote/iosremote/Communication/CommandTransmitter.m
index ae7c12a..cbf0d27 100644
--- a/ios/iosremote/iosremote/Communication/CommandTransmitter.m
+++ b/ios/iosremote/iosremote/Communication/CommandTransmitter.m
@@ -24,6 +24,11 @@
 {
     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 f64edb7..a5393d9 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.h
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.h
@@ -8,9 +8,10 @@
 
 
 #import <Foundation/Foundation.h>
-#import "Client.h"
-#import "Server.h"
-#import "CommandInterpreter.h"
+
+ at class Client;
+ at class Server;
+ at class CommandInterpreter;
 
 #define MSG_SLIDESHOW_STARTED @"SLIDESHOW_STARTED"
 #define MSG_SLIDE_CHANGED @"SLIDE_CHANGED"
@@ -48,10 +49,11 @@ enum ConnectionState : NSInteger {
     CONNECTED
 };
 
-dispatch_queue_t backgroundQueue;
-
 @interface CommunicationManager : NSObject
 
+- (void) connectToServer:(Server*)server;
+
 @property ConnectionState state;
+ at property (nonatomic, strong) id delegate;
 
 @end
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m
index fdd4ade..20b234c 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.m
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m
@@ -12,6 +12,7 @@
 #import "Server.h"
 #import "CommandTransmitter.h"
 #import "CommandInterpreter.h"
+#import "libreoffice_sdremoteViewController.h"
 #import <dispatch/dispatch.h>
 
 @interface CommunicationManager()
@@ -19,7 +20,9 @@
 @property (nonatomic, strong) Client* client;
 @property (nonatomic, strong) CommandInterpreter* interpreter;
 @property (nonatomic, strong) CommandTransmitter* transmitter;
- at property (atomic, strong) NSMutableArray* servers;
+ at property (atomic, strong) NSMutableSet* servers;
+ at property (nonatomic, strong) id connectionConnectedObserver;
+ at property (nonatomic, strong) id connectionDisconnectedObserver;
 
 @end
 
@@ -31,8 +34,9 @@
 @synthesize interpreter = _interpreter;
 @synthesize transmitter = _transmitter;
 @synthesize servers = _servers;
-
-NSLock *connectionLock;
+ at synthesize delegate = _delegate;
+ at synthesize connectionConnectedObserver = _connectionConnectedObserver;
+ at synthesize connectionDisconnectedObserver = _connectionDisconnectedObserver;
 
 + (CommunicationManager *)sharedComManager
 {
@@ -47,15 +51,40 @@ NSLock *connectionLock;
     return sharedComManager;
 }
 
+
+- (void) connectionStatusHandler:(NSNotification *)note
+{
+    if([[note name] isEqualToString:@"connection.status.connected"]){
+        NSLog(@"Connected");
+        self.transmitter = [[CommandTransmitter alloc] initWithClient:self.client];
+        self.state = CONNECTED;
+        [self.delegate setPinLabelText:[NSString stringWithFormat:@"%@", [self getPairingPin]]];
+    } else if ([[note name] isEqualToString:@"connection.status.disconnected"]){
+        NSLog(@"Connection Failed");
+        self.state = DISCONNECTED;
+        [self.client disconnect];
+    }
+}
+
 - (id) init
 {
     self = [super init];
     self.state = DISCONNECTED;
-    connectionLock = [NSLock new];
-    backgroundQueue = dispatch_queue_create("org.libreoffice.iosremote", NULL);
+    
+    [[NSNotificationCenter defaultCenter]addObserver: self
+                                            selector: @selector(connectionStatusHandler:)
+                                                name: @"connection.status.connected"
+                                              object: nil];
+    [[NSNotificationCenter defaultCenter]addObserver: self
+                                            selector: @selector(connectionStatusHandler:)
+                                                name: @"connection.status.disconnected"
+                                              object: nil];
+    
     return self;
 }
 
+
+
 - (id) initWithExistingServers
 {
     self = [self init];
@@ -70,36 +99,28 @@ NSLock *connectionLock;
     {
         NSArray *oldSavedArray = [NSKeyedUnarchiver unarchiveObjectWithData:dataRepresentingExistingServers];
         if (oldSavedArray != nil)
-            self.servers = [[NSMutableArray alloc] initWithArray:oldSavedArray];
+            self.servers = [[NSMutableSet alloc] initWithArray:oldSavedArray];
         else
-            self.servers = [[NSMutableArray alloc] init];
+            self.servers = [[NSMutableSet alloc] init];
     }
+    return self;
 }
 
 - (void) connectToServer:(Server*)server
 {
-    dispatch_async(backgroundQueue, ^(void) {
-        if ([connectionLock tryLock]) {
+    [self.servers addObject:server];
+    if (self.state == CONNECTING || self.state == CONNECTED) {
+        return;
+    } else {
             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;
-    });
+            [self.client connect];
+    }
 }
 
+
 - (NSNumber *) getPairingPin{
     return [self.client pin];
 }
diff --git a/ios/iosremote/iosremote/Communication/SlideShow.h b/ios/iosremote/iosremote/Communication/SlideShow.h
index 7160100..98d14d9 100644
--- a/ios/iosremote/iosremote/Communication/SlideShow.h
+++ b/ios/iosremote/iosremote/Communication/SlideShow.h
@@ -8,7 +8,8 @@
 
 
 #import <Foundation/Foundation.h>
-#import "slideShowViewController.h"
+
+ at class slideShowViewController;
 
 @interface SlideShow : NSObject
 
diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard
index 4dc5762..a530cbc 100644
--- a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard
+++ b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPad.storyboard
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12D78" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="KFV-Ae-zm8">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12E55" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="KFV-Ae-zm8">
     <dependencies>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/>
     </dependencies>
@@ -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="172.25.19.11" borderStyle="roundedRect" minimumFontSize="17" id="9w1-Ym-HcF">
+                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="192.168.40.101" 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"/>
@@ -130,11 +130,11 @@
                         <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="458"/>
+                                <rect key="frame" x="14" y="20" width="741" height="442"/>
                                 <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"/>
+                                <rect key="frame" x="20" y="513" 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>
diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h
index 504c902..e1bbb49 100644
--- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h
+++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.h
@@ -11,9 +11,9 @@
 @interface libreoffice_sdremoteViewController : UIViewController
 
 - (IBAction)connectToServer:(id)sender;
+- (void)setPinLabelText:(NSString*)text;
 
 @property (weak, nonatomic) IBOutlet UILabel *pinLabel;
-
 @property (weak, nonatomic) IBOutlet UITextField *ipAddressTextEdit;
 
 @end
diff --git a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
index a44eacb..d7d1fc6 100644
--- a/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
+++ b/ios/iosremote/iosremote/libreoffice_sdremoteViewController.m
@@ -9,15 +9,14 @@
 
 #import "libreoffice_sdremoteViewController.h"
 #import "Server.h"
-#import "Client.h"
 #import "slideShowViewController.h"
+#import "CommunicationManager.h"
 
 @interface libreoffice_sdremoteViewController ()
 
 // For debug use, will use a manager to manage server and client instead
 @property (nonatomic, strong) Server* server;
- at property (nonatomic, strong) Client* client;
- at property (nonatomic, strong) CommandInterpreter * interpreter;
+ at property (nonatomic, strong) CommunicationManager *comManager;
 @property (nonatomic, weak) NSNotificationCenter* center;
 @property (nonatomic, strong) id slideShowPreviewStartObserver;
 
@@ -26,9 +25,8 @@
 @implementation libreoffice_sdremoteViewController
 
 @synthesize server = _server;
- at synthesize client = _client;
 @synthesize center = _center;
- at synthesize interpreter = _interpreter;
+ at synthesize comManager = _comManager;
 @synthesize slideShowPreviewStartObserver = _slideShowPreviewStartObserver;
 
 - (void)viewDidLoad
@@ -48,7 +46,6 @@
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
     if ([segue.identifier isEqualToString:@"slidesPreviewSegue"]) {
         slideShowViewController *destViewController = segue.destinationViewController;
-        destViewController.slideshow = [self.interpreter slideShow];
         [destViewController.slideshow setDelegate:destViewController];
     }
 }
@@ -62,22 +59,19 @@
 
 - (IBAction)connectToServer:(id)sender {
     NSString * address = [self.ipAddressTextEdit text];
-    self.interpreter = [[CommandInterpreter alloc] init];
-    self.server = [[Server alloc] initWithProtocol:NETWORK atAddress:address ofName:@"Server"];
-    self.client = [[Client alloc] initWithServer:self.server managedBy:nil interpretedBy:self.interpreter];
-    [self.client connect];
-    
-    if([self.client connected])
-    {
-        [self.pinLabel setText:[NSString stringWithFormat:@"%@", self.client.pin]];
-    }
+    self.comManager = [[CommunicationManager alloc] init];
+    self.server = [[Server alloc] initWithProtocol:NETWORK atAddress:address ofName:@"Macbook Pro Retina"];
+    [self.comManager setDelegate:self];
+    [self.comManager connectToServer:self.server];
 }
 
-
 - (void)viewDidUnload {
     [self setIpAddressTextEdit:nil];
     [self setPinLabel:nil];
-    [self setPinLabel:nil];
     [super viewDidUnload];
 }
+
+- (void)setPinLabelText:(NSString *)text{
+    [self.pinLabel setText:text];
+}
 @end
diff --git a/ios/iosremote/iosremote/slideShowViewController.h b/ios/iosremote/iosremote/slideShowViewController.h
index 314bd12..c5391b4 100644
--- a/ios/iosremote/iosremote/slideShowViewController.h
+++ b/ios/iosremote/iosremote/slideShowViewController.h
@@ -14,7 +14,7 @@
 @property (weak, nonatomic) IBOutlet UIImageView *image;
 @property (weak, nonatomic) IBOutlet UIWebView *lecturer_notes;
 
- at property (nonatomic, strong) SlideShow *slideshow;
+ at property (nonatomic, strong) SlideShow* slideshow;
 @property (nonatomic, strong) id slideShowImageReadyObserver;
 @property (nonatomic, strong) id slideShowNoteReadyObserver;
 


More information about the Libreoffice-commits mailing list