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

siqi me at siqi.fr
Mon Jul 15 03:06:50 PDT 2013


 .gitignore                                                   |    2 
 dev/null                                                     |binary
 ios/iosremote/.DS_Store                                      |binary
 ios/iosremote/ic_launcher.png                                |binary
 ios/iosremote/ic_launcher at 2x.png                             |binary
 ios/iosremote/ic_launcher at 2x.psd                             |binary
 ios/iosremote/iosremote/.DS_Store                            |binary
 ios/iosremote/iosremote/Communication/Client.m               |   54 ++++++-----
 ios/iosremote/iosremote/Communication/CommunicationManager.m |   15 +--
 ios/iosremote/iosremote/Communication/pinValidation_vc.m     |    1 
 10 files changed, 42 insertions(+), 30 deletions(-)

New commits:
commit 062de1e49312fda5e184d12576d37a569769bb86
Author: siqi <me at siqi.fr>
Date:   Mon Jul 15 12:04:17 2013 +0200

    improved thread safety during disconnection

diff --git a/ios/iosremote/.DS_Store b/ios/iosremote/.DS_Store
index eb47908..493f094 100644
Binary files a/ios/iosremote/.DS_Store and b/ios/iosremote/.DS_Store differ
diff --git a/ios/iosremote/ic_launcher.png b/ios/iosremote/ic_launcher.png
index f81bf7a..508d947 100644
Binary files a/ios/iosremote/ic_launcher.png and b/ios/iosremote/ic_launcher.png differ
diff --git a/ios/iosremote/ic_launcher at 2x.png b/ios/iosremote/ic_launcher at 2x.png
index 3333308..6febfad 100644
Binary files a/ios/iosremote/ic_launcher at 2x.png and b/ios/iosremote/ic_launcher at 2x.png differ
diff --git a/ios/iosremote/ic_launcher at 2x.psd b/ios/iosremote/ic_launcher at 2x.psd
index 2b8023b..7b50ef9 100644
Binary files a/ios/iosremote/ic_launcher at 2x.psd and b/ios/iosremote/ic_launcher at 2x.psd differ
diff --git a/ios/iosremote/iosremote/.DS_Store b/ios/iosremote/iosremote/.DS_Store
index 5008ddf..ef99c3a 100644
Binary files a/ios/iosremote/iosremote/.DS_Store and b/ios/iosremote/iosremote/.DS_Store differ
diff --git a/ios/iosremote/iosremote/Communication/Client.m b/ios/iosremote/iosremote/Communication/Client.m
index 1320de1..a17f097 100644
--- a/ios/iosremote/iosremote/Communication/Client.m
+++ b/ios/iosremote/iosremote/Communication/Client.m
@@ -42,12 +42,14 @@
 
 
 dispatch_queue_t backgroundQueue;
+NSLock *streamStatusLock;
 
 - (id) initWithServer:(Server*)server
             managedBy:(CommunicationManager*)manager
         interpretedBy:(CommandInterpreter*)receiver
 {
     self = [self init];
+    streamStatusLock = [[NSLock alloc] init];
     if (self)
     {
         self.connected = NO;
@@ -65,7 +67,7 @@ dispatch_queue_t backgroundQueue;
 - (void)startConnectionTimeoutTimerwithInterval:(double) interval
 {
     [self stopConnectionTimeoutTimer]; // Or make sure any existing timer is stopped before this method is called
-
+    
     self.connectionTimeoutTimer = [NSTimer scheduledTimerWithTimeInterval:interval
                                                                    target:self
                                                                  selector:@selector(handleConnectionTimeout)
@@ -101,17 +103,17 @@ dispatch_queue_t backgroundQueue;
 {
     // Look up if there is already a pin code for this client.
     NSUserDefaults * userDefaluts = [NSUserDefaults standardUserDefaults];
-
+    
     if(!userDefaluts)
         NSLog(@"userDefaults nil");
     NSInteger newPin = [userDefaluts integerForKey:self.name];
-
+    
     // If not, generate one.
     if (!newPin) {
         newPin = arc4random() % 9999;
         [userDefaluts setInteger:newPin forKey:self.name];
     }
-
+    
     return newPin;
 }
 
@@ -121,12 +123,12 @@ dispatch_queue_t backgroundQueue;
     CFReadStreamRef readStream;
     CFWriteStreamRef writeStream;
     CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (__bridge CFStringRef)ip, portNumber, &readStream, &writeStream);
-
+    
     if(readStream && writeStream)
     {
         CFReadStreamSetProperty(readStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
         CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
-
+        
         //Setup mInputStream
         self.inputStream = (__bridge NSInputStream *)readStream;
         [self.inputStream setDelegate:self];
@@ -134,7 +136,7 @@ dispatch_queue_t backgroundQueue;
             [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
         });
         [self.inputStream open];
-
+        
         //Setup outputstream
         self.outputStream = (__bridge NSOutputStream *)writeStream;
         [self.outputStream setDelegate:self];
@@ -142,10 +144,10 @@ dispatch_queue_t backgroundQueue;
             [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];
     }
 }
@@ -155,7 +157,7 @@ dispatch_queue_t backgroundQueue;
     NSLog(@"Sending command %@", aCommand);
     // UTF-8 as speficied in specification
     NSData * data = [aCommand dataUsingEncoding:NSUTF8StringEncoding];
-
+    
     [self.outputStream write:(uint8_t *)[data bytes] maxLength:[data length]];
 }
 
@@ -169,10 +171,13 @@ int count = 0;
         }
             break;
         case NSStreamEventErrorOccurred:{
-            [self stopConnectionTimeoutTimer];
-            [self disconnect];
-            NSLog(@"Connection error occured");
-            [[NSNotificationCenter defaultCenter]postNotificationName:@"connection.status.disconnected" object:nil];
+            @synchronized(self){
+                [self disconnect];
+                NSLog(@"Connection error occured");
+                if (!self.inputStream && !self.outputStream) {
+                    [[NSNotificationCenter defaultCenter]postNotificationName:@"connection.status.disconnected" object:nil];
+                }
+            }
         }
             break;
         case NSStreamEventHasBytesAvailable:
@@ -197,7 +202,7 @@ int count = 0;
                     }
                 }
             }
-//            NSLog(@"Command:%@", str);
+            //            NSLog(@"Command:%@", str);
             NSArray *commands = [str componentsSeparatedByString:@"\n"];
             [self.receiver parse:commands];
             data = nil;
@@ -205,9 +210,9 @@ int count = 0;
         } break;
         default:
         {
-
+            
         }
-
+            
     }
 }
 
@@ -215,10 +220,17 @@ int count = 0;
 {
     if(self.inputStream == nil && self.outputStream == nil)
         return;
-    [self.inputStream close];
-    [self.outputStream close];
-    [self.inputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
-    [self.outputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
+    [self stopConnectionTimeoutTimer];
+    NSLog(@"stream status i:%u o:%u", self.inputStream.streamStatus, self.outputStream.streamStatus);
+    if ([self.inputStream streamStatus] != NSStreamStatusClosed && [self.inputStream streamStatus] != NSStreamStatusError) {
+//        NSLog(@"ci");
+        [self.inputStream close];
+    }
+    
+    if ([self.outputStream streamStatus] != NSStreamStatusClosed && [self.outputStream streamStatus] != NSStreamStatusError) {
+//        NSLog(@"co");
+        [self.outputStream close];
+    }
     self.inputStream = nil;
     self.outputStream = nil;
     self.connected = NO;
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m
index 683f1f7..306b6c9 100644
--- a/ios/iosremote/iosremote/Communication/CommunicationManager.m
+++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m
@@ -59,13 +59,14 @@
         if (self.state != DISCONNECTED) {
             NSLog(@"Connection Failed");
             self.state = DISCONNECTED;
-            [self.client disconnect];
-            UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Failed to reach server"
-                                                              message:@"Please verify the IP address and try again later"
-                                                             delegate:nil
-                                                    cancelButtonTitle:@"OK"
-                                                    otherButtonTitles:@"Help", nil];
-            [message show];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Failed to reach server"
+                                                                  message:@"Please verify the IP address and try again later"
+                                                                 delegate:nil
+                                                        cancelButtonTitle:@"OK"
+                                                        otherButtonTitles:@"Help", nil];
+                [message show];
+            });
         }
     }
 }
diff --git a/ios/iosremote/iosremote/Communication/pinValidation_vc.m b/ios/iosremote/iosremote/Communication/pinValidation_vc.m
index 2d9d3c3..5956d41 100644
--- a/ios/iosremote/iosremote/Communication/pinValidation_vc.m
+++ b/ios/iosremote/iosremote/Communication/pinValidation_vc.m
@@ -7,7 +7,6 @@
  */
 
 #import "pinValidation_vc.h"
-#import "slideShowPreview_vc.h"
 #import "SlideShow.h"
 #import "CommandInterpreter.h"
 #import "CommunicationManager.h"
commit 138ecf78253dd9116c96f27b4e0b78be322c6dd3
Author: siqi <me at siqi.fr>
Date:   Mon Jul 15 12:02:57 2013 +0200

    remove userstate from repo

diff --git a/.gitignore b/.gitignore
index e666c0e..10bb787 100644
--- a/.gitignore
+++ b/.gitignore
@@ -77,4 +77,4 @@
 /moz/zipped/*.zip
 __pycache__
 
-
+ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate
diff --git a/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate b/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate
deleted file mode 100644
index e3e428c..0000000
Binary files a/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ


More information about the Libreoffice-commits mailing list