Repository: thrift
Updated Branches:
  refs/heads/master 983bf7de4 -> 56e5b9b01


http://git-wip-us.apache.org/repos/asf/thrift/blob/56e5b9b0/lib/cocoa/src/transport/TSSLSocketTransportError.m
----------------------------------------------------------------------
diff --git a/lib/cocoa/src/transport/TSSLSocketTransportError.m 
b/lib/cocoa/src/transport/TSSLSocketTransportError.m
new file mode 100644
index 0000000..bcf941c
--- /dev/null
+++ b/lib/cocoa/src/transport/TSSLSocketTransportError.m
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#import "TSSLSocketTransportError.h"
+
+
+NSString *TSSLSocketTransportErrorDomain = @"TSSLSocketTransportErrorDomain";

http://git-wip-us.apache.org/repos/asf/thrift/blob/56e5b9b0/lib/cocoa/src/transport/TSocketClient.h
----------------------------------------------------------------------
diff --git a/lib/cocoa/src/transport/TSocketClient.h 
b/lib/cocoa/src/transport/TSocketClient.h
deleted file mode 100644
index 81a0247..0000000
--- a/lib/cocoa/src/transport/TSocketClient.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#import <Foundation/Foundation.h>
-#import "TNSStreamTransport.h"
-
-@interface TSocketClient : TNSStreamTransport 
-#if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
-<NSStreamDelegate>
-#endif
-{
-}
-
-- (id) initWithHostname: (NSString *) hostname
-                   port: (UInt32) port;
-
-@end
-
-
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/56e5b9b0/lib/cocoa/src/transport/TSocketClient.m
----------------------------------------------------------------------
diff --git a/lib/cocoa/src/transport/TSocketClient.m 
b/lib/cocoa/src/transport/TSocketClient.m
deleted file mode 100644
index b0bac74..0000000
--- a/lib/cocoa/src/transport/TSocketClient.m
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-#import "TSocketClient.h"
-#import "TObjective-C.h"
-
-#if !TARGET_OS_IPHONE
-#import <CoreServices/CoreServices.h>
-#else
-#import <CFNetwork/CFNetwork.h>
-#endif
-
-@interface TSocketClient ()
-{
-    NSInputStream * inputStream;
-       NSOutputStream * outputStream;
-}
-@end
-
-@implementation TSocketClient
-
-- (id) initWithHostname: (NSString *) hostname
-                   port: (UInt32) port
-{
-       inputStream = NULL;
-       outputStream = NULL;
-       CFReadStreamRef readStream = NULL;
-       CFWriteStreamRef writeStream = NULL;
-       CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (bridge_stub 
CFStringRef)hostname, port, &readStream, &writeStream);
-       if (readStream && writeStream) {
-               CFReadStreamSetProperty(readStream, 
kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
-               CFWriteStreamSetProperty(writeStream, 
kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
-               
-               inputStream = (bridge_stub NSInputStream *)readStream;
-               [inputStream retain_stub];
-               [inputStream setDelegate:self];
-               [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] 
forMode:NSDefaultRunLoopMode];
-               [inputStream open];
-               
-               outputStream = (bridge_stub NSOutputStream *)writeStream;
-               [outputStream retain_stub];
-               [outputStream setDelegate:self];
-               [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] 
forMode:NSDefaultRunLoopMode];
-               [outputStream open];
-        CFRelease(readStream);
-        CFRelease(writeStream);
-       }
-       
-       self = [super initWithInputStream: inputStream outputStream: 
outputStream];
-       
-       return self;
-}
-
--(void)dealloc
-{
-    [inputStream close];
-    [inputStream removeFromRunLoop:[NSRunLoop currentRunLoop] 
forMode:NSDefaultRunLoopMode];
-    [inputStream setDelegate:nil];
-    [inputStream release_stub];
-    
-    [outputStream close];
-    [outputStream removeFromRunLoop:[NSRunLoop currentRunLoop] 
forMode:NSDefaultRunLoopMode];
-    [outputStream setDelegate:nil];
-    [outputStream release_stub];
-    [super dealloc_stub];
-}
-
-
-@end
-
-
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/56e5b9b0/lib/cocoa/src/transport/TSocketTransport.h
----------------------------------------------------------------------
diff --git a/lib/cocoa/src/transport/TSocketTransport.h 
b/lib/cocoa/src/transport/TSocketTransport.h
new file mode 100644
index 0000000..4ea03cc
--- /dev/null
+++ b/lib/cocoa/src/transport/TSocketTransport.h
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import "TNSStreamTransport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+
+@interface TSocketTransport : TNSStreamTransport
+
+-(id) initWithHostname:(NSString *)hostname
+                  port:(int)port;
+
+@end
+
+
+NS_ASSUME_NONNULL_END

http://git-wip-us.apache.org/repos/asf/thrift/blob/56e5b9b0/lib/cocoa/src/transport/TSocketTransport.m
----------------------------------------------------------------------
diff --git a/lib/cocoa/src/transport/TSocketTransport.m 
b/lib/cocoa/src/transport/TSocketTransport.m
new file mode 100644
index 0000000..1b8fe9b
--- /dev/null
+++ b/lib/cocoa/src/transport/TSocketTransport.m
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#import "TSocketTransport.h"
+
+#if !TARGET_OS_IPHONE
+#import <CoreServices/CoreServices.h>
+#else
+#import <CFNetwork/CFNetwork.h>
+#endif
+
+@interface TSocketTransport () <NSStreamDelegate>
+@end
+
+
+@implementation TSocketTransport
+
+-(id) initWithHostname:(NSString *)hostname
+                  port:(int)port
+{
+  NSInputStream *inputStream = nil;
+  NSOutputStream *outputStream = nil;
+
+  CFReadStreamRef readStream = NULL;
+  CFWriteStreamRef writeStream = NULL;
+  CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (__bridge 
CFStringRef)hostname, port, &readStream, &writeStream);
+  if (readStream && writeStream) {
+
+    CFReadStreamSetProperty(readStream, 
kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
+    CFWriteStreamSetProperty(writeStream, 
kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
+
+    inputStream = (__bridge NSInputStream *)readStream;
+    [inputStream setDelegate:self];
+    [inputStream scheduleInRunLoop:NSRunLoop.mainRunLoop 
forMode:NSDefaultRunLoopMode];
+    [inputStream open];
+
+    outputStream = (__bridge NSOutputStream *)writeStream;
+    [outputStream setDelegate:self];
+    [outputStream scheduleInRunLoop:NSRunLoop.mainRunLoop 
forMode:NSDefaultRunLoopMode];
+    [outputStream open];
+  }
+  else {
+
+    if (readStream) {
+      CFRelease(readStream);
+    }
+
+    if (writeStream) {
+      CFRelease(writeStream);
+    }
+
+    return nil;
+  }
+
+  return [super initWithInputStream:inputStream outputStream:outputStream];
+}
+
+@end

http://git-wip-us.apache.org/repos/asf/thrift/blob/56e5b9b0/lib/cocoa/src/transport/TTransport.h
----------------------------------------------------------------------
diff --git a/lib/cocoa/src/transport/TTransport.h 
b/lib/cocoa/src/transport/TTransport.h
index 83aad9e..558cf60 100644
--- a/lib/cocoa/src/transport/TTransport.h
+++ b/lib/cocoa/src/transport/TTransport.h
@@ -17,20 +17,32 @@
  * under the License.
  */
 
+#import <Foundation/Foundation.h>
+
+
+NS_ASSUME_NONNULL_BEGIN
+
+
 @protocol TTransport <NSObject>
 
-  /**
-   * Guarantees that all of len bytes are read
-   *
-   * @param buf Buffer to read into
-   * @param offset Index in buffer to start storing bytes at
-   * @param length Maximum number of bytes to read
-   * @return The number of bytes actually read, which must be equal to len
-   * @throws TTransportException if there was an error reading data
-   */
-- (size_t) readAll: (uint8_t *) buf offset: (size_t) offset length: (size_t) 
length;
+/**
+ * Guarantees that all of len bytes are read
+ *
+ * @param buf Buffer to read into
+ * @param off Index in buffer to start storing bytes at
+ * @param len Maximum number of bytes to read
+ * @return YES if succeeded, NO if failed
+ * @throws TTransportError if there was an error reading data
+ */
+-(BOOL) readAll:(UInt8 *)buf offset:(UInt32)off length:(UInt32)len 
error:(NSError *__autoreleasing *)error;
+
+-(UInt32) readAvail:(UInt8 *)buf offset:(UInt32)off maxLength:(UInt32)maxLen 
error:(NSError *__autoreleasing *)error;
+
+-(BOOL) write:(const UInt8 *)data offset:(UInt32)offset length:(UInt32)length 
error:(NSError *__autoreleasing *)error;
 
-- (void) write: (const uint8_t *) data offset: (size_t) offset length: 
(size_t) length;
+-(BOOL) flush:(NSError *__autoreleasing *)error;
 
-- (void) flush;
 @end
+
+
+NS_ASSUME_NONNULL_END

http://git-wip-us.apache.org/repos/asf/thrift/blob/56e5b9b0/lib/cocoa/src/transport/TTransportError.h
----------------------------------------------------------------------
diff --git a/lib/cocoa/src/transport/TTransportError.h 
b/lib/cocoa/src/transport/TTransportError.h
new file mode 100644
index 0000000..c8c9f06
--- /dev/null
+++ b/lib/cocoa/src/transport/TTransportError.h
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#import "TError.h"
+
+
+extern NSString *TTransportErrorDomain;
+
+
+typedef NS_ENUM (int, TTransportError) {
+  TTransportErrorUnknown        = 0,
+  TTransportErrorNotOpen        = 1,
+  TTransportErrorAlreadyOpen    = 2,
+  TTransportErrorTimedOut       = 3,
+  TTransportErrorEndOfFile      = 4,
+};
+
+
+extern NSString *TTransportErrorExtendedErrorKey;
+extern NSString *TTransportErrorHttpErrorKey;
+
+
+typedef NS_ENUM(int, THttpTransportError) {
+  THttpTransportErrorInvalidResponse  = 1001,
+  THttpTransportErrorInvalidStatus    = 1002,
+  THttpTransportErrorAuthentication   = 1003,
+};

http://git-wip-us.apache.org/repos/asf/thrift/blob/56e5b9b0/lib/cocoa/src/transport/TTransportError.m
----------------------------------------------------------------------
diff --git a/lib/cocoa/src/transport/TTransportError.m 
b/lib/cocoa/src/transport/TTransportError.m
new file mode 100644
index 0000000..b1af076
--- /dev/null
+++ b/lib/cocoa/src/transport/TTransportError.m
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#import "TTransportError.h"
+
+
+NSString *TTransportErrorDomain = @"TTransportErrorDomain";
+
+
+NSString *TTransportErrorExtendedErrorKey = @"extendedError";
+NSString *TTransportErrorHttpErrorKey = @"httpError";

http://git-wip-us.apache.org/repos/asf/thrift/blob/56e5b9b0/lib/cocoa/src/transport/TTransportException.h
----------------------------------------------------------------------
diff --git a/lib/cocoa/src/transport/TTransportException.h 
b/lib/cocoa/src/transport/TTransportException.h
deleted file mode 100644
index 6749fe2..0000000
--- a/lib/cocoa/src/transport/TTransportException.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#import "TException.h"
-
-@interface TTransportException : TException {
-}
-
-+ (id) exceptionWithReason: (NSString *) reason
-                     error: (NSError *) error;
-
-+ (id) exceptionWithReason: (NSString *) reason;
-
-@end

http://git-wip-us.apache.org/repos/asf/thrift/blob/56e5b9b0/lib/cocoa/src/transport/TTransportException.m
----------------------------------------------------------------------
diff --git a/lib/cocoa/src/transport/TTransportException.m 
b/lib/cocoa/src/transport/TTransportException.m
deleted file mode 100644
index 43cdfbd..0000000
--- a/lib/cocoa/src/transport/TTransportException.m
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#import "TTransportException.h"
-#import "TObjective-C.h"
-
-@implementation TTransportException
-
-+ (id) exceptionWithReason: (NSString *) reason
-                     error: (NSError *) error
-{
-  NSDictionary * userInfo = nil;
-  if (error != nil) {
-    userInfo = [NSDictionary dictionaryWithObject: error forKey: @"error"];
-  }
-
-  return [super exceptionWithName: @"TTransportException"
-                           reason: reason
-                         userInfo: userInfo];
-}
-
-
-+ (id) exceptionWithReason: (NSString *) reason
-{
-  return [self exceptionWithReason: reason error: nil];
-}
-
-@end

Reply via email to