From 560f7eb4384f3b13e3d0ff0839a39fa59e246a3e Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 4 Aug 2007 01:37:19 -0700 Subject: [PATCH] Instead of data received being an NSString, have it be NSData because converting to NSString was actually causing problems and NSXMLDocument can take in NSData just fine * Source/DebuggerConnection.m: Making all of the delivery functions use NSData not NSString ([DebuggerConnection _handshake:]) ([DebuggerConnection _updateStatus:]) ([DebuggerConnection _stackReceived:]) * Source/SocketWrapper.m|h: ditto ([SocketWrapper dataReceived:deliverTo:]): Now uses NSData ([SocketWrapper receive:]): Save ourselves some trouble and don't convert the data to NSString --- Source/DebuggerConnection.m | 10 +++++----- Source/SocketWrapper.h | 2 +- Source/SocketWrapper.m | 7 ++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index 12a8903..2bf2d72 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -139,7 +139,7 @@ * The initial packet handshake. This allows us to set things like the title of the window * and glean information about hte server we are debugging */ -- (void)_handshake: (NSString *)packet +- (void)_handshake: (NSData *)packet { [self refreshStatus]; } @@ -148,9 +148,9 @@ * Handler used by dataReceived:deliverTo: for anytime the status command is issued. It sets * the window controller's status text */ -- (void)_updateStatus: (NSString *)packet +- (void)_updateStatus: (NSData *)packet { - NSXMLDocument *doc = [[NSXMLDocument alloc] initWithXMLString: packet options: NSXMLDocumentTidyXML error: nil]; + NSXMLDocument *doc = [[NSXMLDocument alloc] initWithData: packet options: NSXMLDocumentTidyXML error: nil]; [_windowController setStatus: [[[[doc rootElement] attributeForName: @"status"] stringValue] capitalizedString]]; [doc release]; } @@ -200,9 +200,9 @@ * Called by the dataReceived delivery delegate. This updates the window controller's data * for the stack trace */ -- (void)_stackReceived: (NSString *)packet +- (void)_stackReceived: (NSData *)packet { - NSXMLDocument *doc = [[NSXMLDocument alloc] initWithXMLString: packet options: NSXMLDocumentTidyXML error: nil]; + NSXMLDocument *doc = [[NSXMLDocument alloc] initWithData: packet options: NSXMLDocumentTidyXML error: nil]; NSArray *children = [[doc rootElement] children]; NSMutableArray *stack = [NSMutableArray array]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; diff --git a/Source/SocketWrapper.h b/Source/SocketWrapper.h index dac2af1..0dd5ddd 100644 --- a/Source/SocketWrapper.h +++ b/Source/SocketWrapper.h @@ -52,7 +52,7 @@ - (void)socketDidAccept; // data handlers -- (void)dataReceived: (NSString *)response deliverTo: (SEL)selector; +- (void)dataReceived: (NSData *)response deliverTo: (SEL)selector; - (void)dataSent: (NSString *)sent; @end diff --git a/Source/SocketWrapper.m b/Source/SocketWrapper.m index 28b4f58..c6f03ad 100644 --- a/Source/SocketWrapper.m +++ b/Source/SocketWrapper.m @@ -248,18 +248,15 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; } } - // convert the NSData into a NSString - NSString *string = [[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease]; - if (selector != nil) { [self _postNotification: NsockDataReceived - withObject: string + withObject: data withDict: [NSMutableDictionary dictionaryWithObject: NSStringFromSelector(selector) forKey: sockNotificationReceiver]]; } else { - [self _postNotification: NsockDataReceived withObject: string]; + [self _postNotification: NsockDataReceived withObject: data]; } } -- 2.22.5