ios/iosremote/iosremote/Communication/Client.m               |    2 
 ios/iosremote/iosremote/Communication/CommunicationManager.h |    1 
 ios/iosremote/iosremote/Communication/CommunicationManager.m |    3 
 ios/iosremote/iosremote/en.lproj/iPhone_autoSize.storyboard  |   74 +++
 ios/iosremote/iosremote/serverList_vc.m                      |  219 ++++++++++-
 sd/Library_sd.mk                                             |    6 
 sd/source/ui/remotecontrol/BluetoothServer.mm                |    2 
 sd/source/ui/remotecontrol/DiscoveryService.cxx              |   86 ++--
 sd/source/ui/remotecontrol/DiscoveryService.hxx              |    2 
 9 files changed, 336 insertions(+), 59 deletions(-)

New commits:
commit 793f19d17111af6b79713f98a1e841d6e132248f
Author: Siqi LIU <m...@siqi.fr>
Date:   Fri Jul 19 18:58:42 2013 +0200

    bonjour autodiscovery for mac osx, let me know if it crashes on other build
    
    Change-Id: Ibbaa7b583aaf48b28a913dfd8c12742b76c31d82

diff --git a/ios/iosremote/iosremote/Communication/Client.m 
b/ios/iosremote/iosremote/Communication/Client.m
index 4ad51f8..417b418 100644
--- a/ios/iosremote/iosremote/Communication/Client.m
+++ b/ios/iosremote/iosremote/Communication/Client.m
@@ -202,8 +202,6 @@ int count = 0;
                     }
                 }
             }
-            //            NSLog(@"Command:%@", str);
-            
             backgroundQueue = 
dispatch_queue_create("com.libreoffice.iosremote", DISPATCH_QUEUE_CONCURRENT);
             dispatch_async(backgroundQueue, ^(void) {
                 NSArray *commands = [str componentsSeparatedByString:@"\n"];
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.h 
b/ios/iosremote/iosremote/Communication/CommunicationManager.h
index d4a1f75..af7b6c0 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.h
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.h
@@ -72,6 +72,7 @@ enum ConnectionState : NSInteger {
 @property ConnectionState state;
 @property (nonatomic, strong) id delegate;
 @property (atomic, strong) NSMutableArray* servers;
+@property (atomic, strong) NSMutableArray* autoDiscoveryServers;
 @property (nonatomic, strong) Client* client;
 @property (nonatomic, strong) CommandInterpreter* interpreter;
 @property (nonatomic, strong) CommandTransmitter* transmitter;
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m 
b/ios/iosremote/iosremote/Communication/CommunicationManager.m
index 199f69c..c2c0332 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.m
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m
@@ -30,6 +30,7 @@
 @synthesize transmitter = _transmitter;
 @synthesize servers = _servers;
 @synthesize delegate = _delegate;
+@synthesize autoDiscoveryServers = _autoDiscoveryServers;
 
 + (CommunicationManager *)sharedComManager
 {
@@ -116,7 +117,7 @@
                                             selector: 
@selector(connectionStatusHandler:)
                                                 name: 
@"connection.status.disconnected"
                                               object: nil];
-    
+    self.autoDiscoveryServers = [[NSMutableArray alloc] init];
     return self;
 }
 
diff --git a/ios/iosremote/iosremote/en.lproj/iPhone_autoSize.storyboard 
b/ios/iosremote/iosremote/en.lproj/iPhone_autoSize.storyboard
index 5a17393..e03f4bf 100644
--- a/ios/iosremote/iosremote/en.lproj/iPhone_autoSize.storyboard
+++ b/ios/iosremote/iosremote/en.lproj/iPhone_autoSize.storyboard
@@ -8,15 +8,15 @@
         <scene sceneID="5">
             <objects>
                 <viewController id="2" customClass="server_list_vc" 
sceneMemberID="viewController">
-                    <tableView key="view" clipsSubviews="YES" 
contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" 
style="plain" showsSelectionImmediatelyOnTouchBegin="NO" rowHeight="44" 
sectionHeaderHeight="22" sectionFooterHeight="22" id="naQ-T4-jWV">
+                    <tableView key="view" clipsSubviews="YES" 
contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" 
style="grouped" separatorStyle="singleLineEtched" 
showsSelectionImmediatelyOnTouchBegin="NO" rowHeight="44" 
sectionHeaderHeight="10" sectionFooterHeight="10" id="naQ-T4-jWV">
                         <rect key="frame" x="0.0" y="64" width="320" 
height="504"/>
-                        <color key="backgroundColor" white="1" alpha="1" 
colorSpace="calibratedWhite"/>
+                        <color key="backgroundColor" 
cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
                         <prototypes>
                             <tableViewCell contentMode="scaleToFill" 
selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" 
indentationWidth="0.0" reuseIdentifier="server_item_cell" 
editingAccessoryType="disclosureIndicator" textLabel="Rg3-PU-OuS" 
detailTextLabel="9Mc-gD-acc" style="IBUITableViewCellStyleValue1" 
id="Pvl-Uw-Ghs">
-                                <rect key="frame" x="0.0" y="22" width="320" 
height="44"/>
+                                <rect key="frame" x="0.0" y="46" width="320" 
height="46"/>
                                 <autoresizingMask key="autoresizingMask"/>
                                 <view key="contentView" opaque="NO" 
clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
-                                    <rect key="frame" x="0.0" y="0.0" 
width="320" height="43"/>
+                                    <rect key="frame" x="10" y="1" width="300" 
height="43"/>
                                     <autoresizingMask key="autoresizingMask"/>
                                     <subviews>
                                         <label opaque="NO" clipsSubviews="YES" 
multipleTouchEnabled="YES" contentMode="left" text="Title" 
lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" 
adjustsFontSizeToFit="NO" id="Rg3-PU-OuS">
@@ -26,7 +26,7 @@
                                             <color key="highlightedColor" 
red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                                         </label>
                                         <label opaque="NO" clipsSubviews="YES" 
multipleTouchEnabled="YES" contentMode="left" text="Detail" 
textAlignment="right" lineBreakMode="tailTruncation" 
baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="9Mc-gD-acc">
-                                            <rect key="frame" x="266" y="11" 
width="44" height="21"/>
+                                            <rect key="frame" x="246" y="11" 
width="44" height="21"/>
                                             <fontDescription 
key="fontDescription" type="system" pointSize="17"/>
                                             <color key="textColor" 
red="0.21960784310000001" green="0.3294117647" blue="0.52941176469999995" 
alpha="1" colorSpace="calibratedRGB"/>
                                             <color key="highlightedColor" 
red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
@@ -555,13 +555,75 @@
         <image name="timer_clear_btn.png" width="74" height="74"/>
         <image name="timer_start_btn.png" width="74" height="74"/>
     </resources>
+    <classes>
+        <class className="EditableTableViewCell" 
superclassName="UITableViewCell">
+            <source key="sourceIdentifier" type="project" 
relativePath="./Classes/EditableTableViewCell.h"/>
+        </class>
+        <class className="SWRevealViewController" 
superclassName="UIViewController">
+            <source key="sourceIdentifier" type="project" 
relativePath="./Classes/SWRevealViewController.h"/>
+        </class>
+        <class className="newServerViewController" 
superclassName="UITableViewController">
+            <source key="sourceIdentifier" type="project" 
relativePath="./Classes/newServerViewController.h"/>
+            <relationships>
+                <relationship kind="action" name="save:"/>
+            </relationships>
+        </class>
+        <class className="pinValidation_vc" superclassName="UIViewController">
+            <source key="sourceIdentifier" type="project" 
relativePath="./Classes/pinValidation_vc.h"/>
+            <relationships>
+                <relationship kind="outlet" name="pinLabel" 
candidateClass="UILabel"/>
+                <relationship kind="outlet" name="statusLabel" 
candidateClass="UILabel"/>
+            </relationships>
+        </class>
+        <class className="server_list_vc" 
superclassName="UITableViewController">
+            <source key="sourceIdentifier" type="project" 
relativePath="./Classes/server_list_vc.h"/>
+            <relationships>
+                <relationship kind="outlet" name="serverTable" 
candidateClass="UITableView"/>
+            </relationships>
+        </class>
+        <class className="slideShowPreviewTable_vc" 
superclassName="UITableViewController">
+            <source key="sourceIdentifier" type="project" 
relativePath="./Classes/slideShowPreviewTable_vc.h"/>
+            <relationships>
+                <relationship kind="action" name="startPresentationAction:"/>
+                <relationship kind="outlet" name="optionsTable" 
candidateClass="UITableView"/>
+            </relationships>
+        </class>
+        <class className="slideShowSwipeInList" 
superclassName="UITableViewController">
+            <source key="sourceIdentifier" type="project" 
relativePath="./Classes/slideShowSwipeInList.h"/>
+            <relationships>
+                <relationship kind="action" name="stopWatchClear:"/>
+                <relationship kind="action" name="stopWatchStart:"/>
+            </relationships>
+        </class>
+        <class className="slideShow_vc" superclassName="UIViewController">
+            <source key="sourceIdentifier" type="project" 
relativePath="./Classes/slideShow_vc.h"/>
+            <relationships>
+                <relationship kind="action" name="accPointerAction:"/>
+                <relationship kind="action" name="nextSlideAction:"/>
+                <relationship kind="action" name="pointerAction:"/>
+                <relationship kind="action" name="previousSlideAction:"/>
+                <relationship kind="outlet" name="blockingView" 
candidateClass="UIView"/>
+                <relationship kind="outlet" name="bottomView" 
candidateClass="UIView"/>
+                <relationship kind="outlet" name="lecturer_notes" 
candidateClass="UIWebView"/>
+                <relationship kind="outlet" name="movingPointer" 
candidateClass="UIView"/>
+                <relationship kind="outlet" name="notesView" 
candidateClass="UIView"/>
+                <relationship kind="outlet" name="pointerBtn" 
candidateClass="UIButton"/>
+                <relationship kind="outlet" name="revealButtonItem" 
candidateClass="UIBarButtonItem"/>
+                <relationship kind="outlet" name="secondarySlideView" 
candidateClass="UIImageView"/>
+                <relationship kind="outlet" name="slideNumber" 
candidateClass="UILabel"/>
+                <relationship kind="outlet" name="slideView" 
candidateClass="UIImageView"/>
+                <relationship kind="outlet" name="touchPointerImage" 
candidateClass="UIImageView"/>
+                <relationship kind="outlet" name="touchPointerScrollView" 
candidateClass="UIScrollView"/>
+            </relationships>
+        </class>
+    </classes>
     <simulatedMetricsContainer key="defaultSimulatedMetrics">
         <simulatedStatusBarMetrics key="statusBar"/>
         <simulatedOrientationMetrics key="orientation"/>
         <simulatedScreenMetrics key="destination" type="retina4"/>
     </simulatedMetricsContainer>
     <inferredMetricsTieBreakers>
-        <segue reference="pTl-ua-9pr"/>
         <segue reference="eIY-4P-1sI"/>
+        <segue reference="EWS-Nn-mQc"/>
     </inferredMetricsTieBreakers>
 </document>
\ No newline at end of file
diff --git a/ios/iosremote/iosremote/serverList_vc.m 
b/ios/iosremote/iosremote/serverList_vc.m
index 5d26463..28ebba7 100644
--- a/ios/iosremote/iosremote/serverList_vc.m
+++ b/ios/iosremote/iosremote/serverList_vc.m
@@ -12,7 +12,11 @@
 #import "Server.h"
 #import "Client.h"
 
-@interface server_list_vc ()
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+@interface server_list_vc () <NSNetServiceBrowserDelegate, 
NSNetServiceDelegate>
 
 @property (nonatomic, strong) CommunicationManager *comManager;
 @property (nonatomic, weak) NSNotificationCenter* center;
@@ -20,6 +24,7 @@
 @property (nonatomic, strong) id pinValidationObserver;
 @property (atomic, strong) NSIndexPath *lastSpinningCellIndex;
 
+@property (nonatomic, strong) NSNetServiceBrowser *serviceBrowser;
 @end
 
 @implementation server_list_vc
@@ -29,6 +34,83 @@
 @synthesize lastSpinningCellIndex = _lastSpinningCellIndex;
 @synthesize slideShowPreviewStartObserver = _slideShowPreviewStartObserver;
 @synthesize pinValidationObserver = _pinValidationObserver;
+@synthesize serviceBrowser = _serviceBrowser;
+
+#pragma mark - netservice resolve delegate
+-(void) netServiceDidResolveAddress:(NSNetService *)sender
+{
+    if ([sender.addresses count]){
+        NSData * address = [[sender addresses] objectAtIndex: 0];
+        struct sockaddr_in *socketAddress = (struct sockaddr_in *) [address 
bytes];
+        NSString * ipString = [NSString stringWithFormat: 
@"%s",inet_ntoa(socketAddress->sin_addr)];
+        int port = socketAddress->sin_port;
+        NSLog(@"Resolved at %@:%u", ipString, port);
+        
+        [self.comManager.autoDiscoveryServers 
replaceObjectAtIndex:[self.comManager.autoDiscoveryServers count]-1
+                                                         withObject:[[Server 
alloc] initWithProtocol:NETWORK atAddress:ipString ofName:sender.name]];
+        [self.tableView reloadData];
+    }
+}
+
+-(void) netService:(NSNetService *)sender didNotResolve:(NSDictionary 
*)errorDict
+{
+    NSLog(@"Failed to resolve");
+}
+
+#pragma mark - bonjour service discovery
+
+-(void) netServiceBrowserWillSearch:(NSNetServiceBrowser *)aNetServiceBrowser
+{
+    NSLog(@"Will search");
+    UITableViewCell * cell = [self.tableView 
cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
+    [(UIActivityIndicatorView *)[cell viewWithTag:5] startAnimating];
+}
+
+-(void) netServiceBrowserDidStopSearch:(NSNetServiceBrowser 
*)aNetServiceBrowser
+{
+    NSLog(@"End search");
+    UITableViewCell * cell = [self.tableView 
cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
+    [(UIActivityIndicatorView *)[cell viewWithTag:5] stopAnimating];
+}
+
+- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser 
didNotSearch:(NSDictionary *)errorDict
+{
+    NSLog(@"search error");
+    UITableViewCell * cell = [self.tableView 
cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
+    [(UIActivityIndicatorView *)[cell viewWithTag:5] stopAnimating];
+}
+
+- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser
+           didFindService:(NSNetService *)aNetService
+               moreComing:(BOOL)moreComing
+{
+    [self.comManager.autoDiscoveryServers addObject:aNetService];
+    
+    NSLog(@"Got service %p with hostname %@\n", aNetService,
+          [aNetService name]);
+    [aNetService resolveWithTimeout:0.0];
+    
+    [aNetService setDelegate:self];
+    
+    if(!moreComing)
+    {
+        UITableViewCell * cell = [self.tableView 
cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
+        [(UIActivityIndicatorView *)[cell viewWithTag:5] stopAnimating];
+    }
+}
+
+// Sent when a service disappears
+- (void)netServiceBrowser:(NSNetServiceBrowser *)browser
+         didRemoveService:(NSNetService *)aNetService
+               moreComing:(BOOL)moreComing
+{
+    [self.comManager.autoDiscoveryServers removeObject:aNetService];
+    
+    if(!moreComing)
+    {
+        [self.tableView reloadData];
+    }
+}
 
 - (id)initWithStyle:(UITableViewStyle)style
 {
@@ -48,7 +130,6 @@
     // Uncomment the following line to display an Edit button in the 
navigation bar for this view controller.
     // self.navigationItem.rightBarButtonItem = self.editButtonItem;
     
-//    self.lastSpinningCellIndex = [[NSIndexPath alloc] init];
     self.center = [NSNotificationCenter defaultCenter];
     self.comManager = [CommunicationManager sharedComManager];
     self.serverTable.dataSource = self;
@@ -77,6 +158,13 @@
                                                                                
            [self performSegueWithIdentifier:@"SlideShowPreview" sender:self ];
                                                                                
        }];
     [super viewDidAppear:animated];
+    
+    NSLog(@"Clear auto discovered servers");
+    [self.comManager.autoDiscoveryServers removeAllObjects];
+    self.serviceBrowser = [[NSNetServiceBrowser alloc] init];
+    [self.serviceBrowser setDelegate:self];
+    [self.serviceBrowser searchForServicesOfType:@"_impressRemote._tcp" 
inDomain:@"local"];
+    [self.serviceBrowser scheduleInRunLoop:[NSRunLoop currentRunLoop] 
forMode:NSDefaultRunLoopMode];
 }
 
 - (void) viewWillDisappear:(BOOL)animated
@@ -122,6 +210,11 @@
 - (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
     UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+ 
+    if ([cell.detailTextLabel.text isEqualToString:@""]) {
+        [tableView deselectRowAtIndexPath:indexPath animated:YES];
+        return;
+    }
     
     if(self.comManager.state!=CONNECTING){
         self.lastSpinningCellIndex = indexPath;
@@ -130,8 +223,14 @@
         [cell setAccessoryView:activityView];
     }
 
-    NSLog(@"Connecting to %@:%@", [[self.comManager.servers 
objectAtIndex:indexPath.row] serverName], [[self.comManager.servers 
objectAtIndex:indexPath.row] serverAddress]);
-    [self.comManager connectToServer:[self.comManager.servers 
objectAtIndex:indexPath.row]];
+    if (indexPath.section == 1){
+        NSLog(@"Connecting to %@:%@", [[self.comManager.servers 
objectAtIndex:indexPath.row] serverName], [[self.comManager.servers 
objectAtIndex:indexPath.row] serverAddress]);
+        [self.comManager connectToServer:[self.comManager.servers 
objectAtIndex:indexPath.row]];
+    } else if (indexPath.section == 0){
+        NSLog(@"Connecting to %@:%@", [[self.comManager.servers 
objectAtIndex:indexPath.row] serverName], 
[[self.comManager.autoDiscoveryServers objectAtIndex:indexPath.row] 
serverAddress]);
+        [self.comManager connectToServer:[self.comManager.autoDiscoveryServers 
objectAtIndex:indexPath.row]];
+    }
+    
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
 }
 
@@ -140,29 +239,125 @@
     [super viewDidUnload];
 }
 
+- (UIView *)tableView:(UITableView *)tableView 
viewForHeaderInSection:(NSInteger)section {
+    
+    NSString *sectionName = nil;
+    
+    switch (section) {
+        case 0:
+            sectionName = [NSString stringWithFormat:@"Visible computers"];
+            break;
+        case 1:
+            sectionName = [NSString stringWithFormat:@"Manual computers"];
+            break;
+    }
+    
+    UILabel *sectionHeader = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 
200, 40)];
+    sectionHeader.backgroundColor = [UIColor clearColor];
+    sectionHeader.font = [UIFont boldSystemFontOfSize:18];
+    sectionHeader.textColor = [UIColor darkTextColor];
+    sectionHeader.text = sectionName;
+    
+    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 
tableView.bounds.size.width, [self tableView:tableView 
heightForHeaderInSection:section])];
+    [view addSubview:sectionHeader];
+    
+    return view;
+}
+
+- (UIView *)tableView:(UITableView *)tableView 
viewForFooterInSection:(NSInteger)section {
+    if ([self.comManager.servers count] == 0 && section == 1) {
+        UILabel *sectionFooter = [[UILabel alloc] initWithFrame:CGRectMake(20, 
10, tableView.frame.size.width - 50, 40)];
+        [sectionFooter setLineBreakMode:NSLineBreakByCharWrapping];
+        [sectionFooter setNumberOfLines:5];
+        sectionFooter.backgroundColor = [UIColor clearColor];
+        sectionFooter.font = [UIFont systemFontOfSize:14];
+        sectionFooter.textColor = [UIColor colorWithRed:0.22 green:0.33 
blue:0.53 alpha:1.0];
+        sectionFooter.text = @"Please manually add a computer with its IP 
address.";
+        
+        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 
tableView.bounds.size.width, [self tableView:tableView 
heightForHeaderInSection:section])];
+        [view addSubview:sectionFooter];
+        return view;
+    }
+    return nil;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView 
heightForHeaderInSection:(NSInteger)section
+{
+    return 50.0;
+}
+
+-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+    return 2;
+}
+
 -(NSInteger)tableView:(UITableView *)tableView 
numberOfRowsInSection:(NSInteger)section {
-    return [self.comManager.servers count];
+    switch (section) {
+        case 0:
+            return [self.comManager.autoDiscoveryServers count] == 0 ? 1 : 
[self.comManager.autoDiscoveryServers count];
+            break;
+        case 1:
+            return [self.comManager.servers count];
+        default:
+            return -1;
+            break;
+    }
 }
 
 -(UITableViewCell *)tableView:(UITableView *)tableView 
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     static NSString *cellIdentifier = @"server_item_cell";
-    
     UITableViewCell *cell = [tableView 
dequeueReusableCellWithIdentifier:cellIdentifier];
     
-    Server *s = [self.comManager.servers objectAtIndex:indexPath.row];
-    
-    [cell.textLabel setText:[s serverName]];
-    [cell.detailTextLabel setText:[s serverAddress]];
+    if (indexPath.section == 0){
+        if ([self.comManager.autoDiscoveryServers count] == 0){
+            // Looking for one
+            UIActivityIndicatorView *spinner = [[UIActivityIndicatorView 
alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
+            int vCenter = [cell frame].size.height / 2;
+            int hCenter = [cell frame].size.width / 2;
+            
+            int SPINNER_SIZE = spinner.frame.size.width;
+            [spinner setFrame:CGRectMake(hCenter - SPINNER_SIZE, vCenter - 
SPINNER_SIZE/2, SPINNER_SIZE, SPINNER_SIZE)];
+            [[cell contentView] addSubview:spinner];
+            
+            [spinner setTag:5];
+            
+            cell.textLabel.text = @"";
+            cell.detailTextLabel.text = @"";
+        } else {
+            id s = [self.comManager.autoDiscoveryServers 
objectAtIndex:indexPath.row];
+            
+            if ([s isKindOfClass:[Server class]]) {
+                [cell.textLabel setText:[s serverName]];
+                [cell.detailTextLabel setText:[s serverAddress]];
+            } else if ([s isKindOfClass:[NSNetService class]]){
+                [cell.textLabel setText:[s name]];
+                [cell.detailTextLabel setText:@"loading..."];
+            }
+        }
+    }
+    else {
+        Server *s = [self.comManager.servers objectAtIndex:indexPath.row];
+        
+        [cell.textLabel setText:[s serverName]];
+        [cell.detailTextLabel setText:[s serverAddress]];
+    }
     return cell;
 }
 
 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath 
*)indexPath
 {
-    return YES;
+    if (indexPath.section == 1)
+        return YES;
+    else
+        return NO;
 }
 
 - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView 
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
-    return UITableViewCellEditingStyleDelete;
+    if (indexPath.section == 1) {
+        return UITableViewCellEditingStyleDelete;
+    } else {
+        return UITableViewCellEditingStyleNone;
+    }
 }
 
 - (void)tableView:(UITableView *)tableView 
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath{
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk
index 6c57b4b..1586ba0 100644
--- a/sd/Library_sd.mk
+++ b/sd/Library_sd.mk
@@ -523,7 +523,6 @@ ifeq ($(ENABLE_SDREMOTE),YES)
 $(eval $(call gb_Library_add_exception_objects,sd,\
     sd/source/ui/remotecontrol/BufferedStreamSocket \
     sd/source/ui/remotecontrol/Communicator \
-    sd/source/ui/remotecontrol/DiscoveryService \
     sd/source/ui/remotecontrol/ImagePreparer \
     sd/source/ui/remotecontrol/Server \
     sd/source/ui/remotecontrol/Receiver \
@@ -541,13 +540,16 @@ ifeq (,$(filter IOS MACOSX,$(OS)))
 
 $(eval $(call gb_Library_add_exception_objects,sd,\
     sd/source/ui/remotecontrol/BluetoothServer \
+    sd/source/ui/remotecontrol/DiscoveryService \
 ))
 
 else
 
 $(eval $(call gb_Library_add_objcxxobjects,sd,\
     sd/source/ui/remotecontrol/BluetoothServer \
-    sd/source/ui/remotecontrol/OSXBluetooth,\
+    sd/source/ui/remotecontrol/OSXBluetooth\
+    sd/source/ui/remotecontrol/DiscoveryService \
+    sd/source/ui/remotecontrol/OSXNetworkService, \
     -Wno-error \
 ))
 
diff --git a/sd/source/ui/remotecontrol/BluetoothServer.mm 
b/sd/source/ui/remotecontrol/BluetoothServer.mm
index eabecac..28288ff 100644
--- a/sd/source/ui/remotecontrol/BluetoothServer.mm
+++ b/sd/source/ui/remotecontrol/BluetoothServer.mm
@@ -1 +1 @@
-#include "BluetoothServer.cxx"
+#include "BluetoothServer.cxx"
\ No newline at end of file
diff --git a/sd/source/ui/remotecontrol/DiscoveryService.cxx 
b/sd/source/ui/remotecontrol/DiscoveryService.cxx
index e18b89f..b5d4544 100644
--- a/sd/source/ui/remotecontrol/DiscoveryService.cxx
+++ b/sd/source/ui/remotecontrol/DiscoveryService.cxx
@@ -33,13 +33,30 @@
   #include <arpa/inet.h>
 #endif
 
+#ifdef MACOSX
+  #include <osl/conditn.hxx> // Include this early to avoid error as check() 
gets defined by some SDK header to empty
+  #include <premac.h>
+  #import <CoreFoundation/CoreFoundation.h>
+  #include <postmac.h>
+  #import "OSXNetworkService.h"
+#endif
+
 using namespace osl;
 using namespace rtl;
 using namespace sd;
 
-DiscoveryService::DiscoveryService() :
-    mSocket(0)
+void SAL_CALL DiscoveryService::run()
+{
+
+}
+
+DiscoveryService::DiscoveryService()
 {
+  #ifdef MACOSX
+    OSXNetworkService * service = [[OSXNetworkService alloc] init];
+    [service publishImpressRemoteServiceOnLocalNetworkWithName: @""];
+  #endif
+  /*
     mSocket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
 
     sockaddr_in aAddr;
@@ -72,42 +89,43 @@ DiscoveryService::DiscoveryService() :
         SAL_WARN("sd", "DiscoveryService: setsockopt failed: " << errno);
         return; // would be better to throw, but unsure if caller handles that
     }
+    */
 }
 
 DiscoveryService::~DiscoveryService()
 {
-#ifdef WNT
-    closesocket( mSocket );
-#else
-    close( mSocket );
-#endif
-}
-
-void SAL_CALL DiscoveryService::run()
-{
-    char aBuffer[BUFFER_SIZE];
-    while ( true )
-    {
-        memset( aBuffer, 0, sizeof(char) * BUFFER_SIZE );
-        sockaddr_in aAddr;
-        socklen_t aLen = sizeof( aAddr );
-        recvfrom( mSocket, aBuffer, BUFFER_SIZE, 0, (sockaddr*) &aAddr, &aLen 
);
-        OString aString( aBuffer, strlen( "LOREMOTE_SEARCH" ) );
-        if ( aString == "LOREMOTE_SEARCH" )
-        {
-            OStringBuffer aStringBuffer("LOREMOTE_ADVERTISE\n");
-            aStringBuffer.append( OUStringToOString(
-                osl::SocketAddr::getLocalHostname(), RTL_TEXTENCODING_UTF8 ) )
-                .append( "\n\n" );
-            if ( sendto( mSocket, aStringBuffer.getStr(),
-                aStringBuffer.getLength(), 0, (sockaddr*) &aAddr,
-                         sizeof(aAddr) ) <= 0 )
-            {
-                // Read error or closed socket -- we are done.
-                return;
-            }
-        }
-    }
+// #ifdef WNT
+//     closesocket( mSocket );
+// #else
+//     close( mSocket );
+// #endif
+// }
+
+// void SAL_CALL DiscoveryService::run()
+// {
+//     char aBuffer[BUFFER_SIZE];
+//     while ( true )
+//     {
+//         memset( aBuffer, 0, sizeof(char) * BUFFER_SIZE );
+//         sockaddr_in aAddr;
+//         socklen_t aLen = sizeof( aAddr );
+//         recvfrom( mSocket, aBuffer, BUFFER_SIZE, 0, (sockaddr*) &aAddr, 
&aLen );
+//         OString aString( aBuffer, strlen( "LOREMOTE_SEARCH" ) );
+//         if ( aString == "LOREMOTE_SEARCH" )
+//         {
+//             OStringBuffer aStringBuffer("LOREMOTE_ADVERTISE\n");
+//             aStringBuffer.append( OUStringToOString(
+//                 osl::SocketAddr::getLocalHostname(), RTL_TEXTENCODING_UTF8 
) )
+//                 .append( "\n\n" );
+//             if ( sendto( mSocket, aStringBuffer.getStr(),
+//                 aStringBuffer.getLength(), 0, (sockaddr*) &aAddr,
+//                          sizeof(aAddr) ) <= 0 )
+//             {
+//                 // Read error or closed socket -- we are done.
+//                 return;
+//             }
+//         }
+//     }
 }
 
 DiscoveryService *sd::DiscoveryService::spService = NULL;
diff --git a/sd/source/ui/remotecontrol/DiscoveryService.hxx 
b/sd/source/ui/remotecontrol/DiscoveryService.hxx
index b47f049..a50454b 100644
--- a/sd/source/ui/remotecontrol/DiscoveryService.hxx
+++ b/sd/source/ui/remotecontrol/DiscoveryService.hxx
@@ -48,7 +48,7 @@ namespace sd
             virtual void SAL_CALL run();
 
 //             osl::DatagramSocket mSocket;
-            int mSocket;
+            // int mSocket;
 
     };
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to