Threading the print command with -[uploadAndPrint:]
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 26 Feb 2008 16:54:54 +0000 (11:54 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 26 Feb 2008 16:54:54 +0000 (11:54 -0500)
Source/AppController.m

index 0a0aaf962caed023ff9d4d052280bbc371c5d812..2d5f4151fb48dd5020cd4f072829251d72685efb 100644 (file)
 
 @interface AppController (Private)
 
-//- (BOOL)uploadFile;
 - (void)setStatus:(NSString *)msg isError:(BOOL)error;
 
 - (void)readChannel:(LIBSSH2_CHANNEL *)channel;
+- (void)uploadAndPrint:(id)sender;
 
 @end
 
  */
 - (IBAction)print:(id)sender
 {
+       [NSThread detachNewThreadSelector:@selector(uploadAndPrint:) toTarget:self withObject:sender];
+}
+
+/**
+ * Opens an SSH session, creates a SCP channel to upload the file, followed by a shell channel
+ * to queue up LPR
+ */
+- (void)uploadAndPrint:(id)sender
+{
+       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+       
        [progress startAnimation:self];
        [progress setHidden:NO];
        [status setHidden:NO];
@@ -230,6 +241,8 @@ shutdown:
        close(sock);
        
        [progress stopAnimation:self];
+       
+       [pool release];
 }
 
 @end