- (LogEntry*)recordSend:(NSString*)command
{
LoggingController* logger = [(AppDelegate*)[NSApp delegate] loggingController];
- [logger performSelectorOnMainThread:@selector(recordSend:)
- withObject:command
+ LogEntry* entry = [LogEntry newSendEntry:command];
+ entry.lastReadTransactionID = lastReadTransaction_;
+ entry.lastWrittenTransactionID = lastWrittenTransaction_;
+ [logger performSelectorOnMainThread:@selector(recordEntry:)
+ withObject:entry
waitUntilDone:NO];
- return [logger.logEntries lastObject];
+ return [entry autorelease];
}
- (LogEntry*)recordReceive:(NSString*)command
{
LoggingController* logger = [(AppDelegate*)[NSApp delegate] loggingController];
- [logger performSelectorOnMainThread:@selector(recordReceive:)
- withObject:command
+ LogEntry* entry = [LogEntry newReceiveEntry:command];
+ entry.lastReadTransactionID = lastReadTransaction_;
+ entry.lastWrittenTransactionID = lastWrittenTransaction_;
+ [logger performSelectorOnMainThread:@selector(recordEntry:)
+ withObject:entry
waitUntilDone:NO];
- return [logger.logEntries lastObject];
-}
+ return [entry autorelease];
+}
// Stream Managers /////////////////////////////////////////////////////////////
// Log this receive event.
LogEntry* log = [self recordReceive:currentPacket_];
log.error = error;
- log.lastWrittenTransactionID = lastWrittenTransaction_;
- log.lastReadTransactionID = lastReadTransaction_;
// Finally, dispatch the handler for this response.
[self handleResponse:[xmlTest autorelease]];
}
// Log this trancation.
- LogEntry* log = [self recordSend:command];
- log.lastWrittenTransactionID = lastWrittenTransaction_;
- log.lastReadTransactionID = lastReadTransaction_;
+ [self recordSend:command];
}
/**
// Designated initializer.
- (id)init;
-// Creates a new log entry with the specified command, adds it to the entries
-// list, and returns the new entry as a weak pointer. Callers can then set
-// additional properties.
-- (LogEntry*)recordSend:(NSString*)command;
-
-// Creates a new log entry with the specified response data, adds it to the list
-// of entries, and returns the new entry as a weak pointer. Callers can then set
-// additional properties.
-- (LogEntry*)recordReceive:(NSString*)response;
+// Records a log entry. This will add it to the list and will update the UI.
+// This will take ownership of |entry|.
+- (void)recordEntry:(LogEntry*)entry;
@end
@property (retain) NSError* error;
@property (assign) NSUInteger lastWrittenTransactionID;
@property (assign) NSUInteger lastReadTransactionID;
+
- (NSString*)directionName;
+
++ (LogEntry*)newSendEntry:(NSString*)command;
++ (LogEntry*)newReceiveEntry:(NSString*)command;
+
@end
[super dealloc];
}
-- (LogEntry*)recordSend:(NSString*)command
+- (void)recordEntry:(LogEntry*)entry
{
- LogEntry* entry = [LogEntry new];
- entry.direction = kLogEntrySending;
- entry.contents = command;
[logEntries_ addObject:entry];
- [logEntriesController_ rearrangeObjects];
- return [entry autorelease];
-}
-
-- (LogEntry*)recordReceive:(NSString*)response
-{
- LogEntry* entry = [LogEntry new];
- entry.direction = kLogEntryReceiving;
- entry.contents = response;
- [logEntries_ addObject:entry];
- [logEntriesController_ rearrangeObjects];
- return [entry autorelease];
+ [logEntriesController_ rearrangeObjects];
}
@end
@synthesize lastWrittenTransactionID = lastWrittenTransactionID_;
@synthesize lastReadTransactionID = lastReadTransactionID_;
++ (LogEntry*)newSendEntry:(NSString*)command
+{
+ LogEntry* entry = [LogEntry new];
+ entry.direction = kLogEntrySending;
+ entry.contents = command;
+ return entry;
+}
+
++ (LogEntry*)newReceiveEntry:(NSString*)command
+{
+ LogEntry* entry = [LogEntry new];
+ entry.direction = kLogEntryReceiving;
+ entry.contents = command;
+ return entry;
+}
+
- (void)dealloc
{
self.contents = nil;