Using polled reading and don't allow actual LPR-ing in debug mode
authorRobert Sesek <rsesek@bluestatic.org>
Thu, 28 Feb 2008 03:53:26 +0000 (22:53 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Thu, 28 Feb 2008 03:53:26 +0000 (22:53 -0500)
* Source/AppController.m:
([AppController readChannel:]): Use libssh2_poll_channel_read() to check and see if there's more to read as it's much faster
([AppController uploadAndPrint:]): If BLU_DEBUG, do not LPR anything, but rather touch a file

Source/AppController.m

index 4cac97a1d678f1f4c4525a79a3319af9ae363d03..2a8c95265ba26e4e22ea686e2281c3bdedc15402 100644 (file)
        do
        {
                memset(&buf, '\0', sizeof(buf));
-               sleep(1);
                numbytes = libssh2_channel_read(channel, buf, sizeof(buf));
+               sleep(1);
 #ifdef BLU_DEBUG
                NSLog(@"buf: %s", buf);
 #endif
-       } while (numbytes > 0);
+       } while (libssh2_poll_channel_read(channel, 0));
 }
 
 /**
        [progress setHidden:NO];
        [status setHidden:NO];
        
-       NSString *printer = [[printersController selection] valueForKey:@"unixName"];
        FILE *localFile;
        struct stat fileInfo;
        
        [self readChannel:channel];
        
        // send the job to lpr
-       char *cmd = (char *)[[NSString stringWithFormat:@"lpr -m -P%@ __bu_print_drop__.pdf\r\n\0", printer] UTF8String];
+       char *cmd;
+#ifndef BLU_DEBUG
+       NSString *printer = [[printersController selection] valueForKey:@"unixName"];
+       cmd = (char *)[[NSString stringWithFormat:@"lpr -m -P%@ __bu_print_drop__.pdf\r\n\0", printer] UTF8String];
+#else
+       cmd = "touch abc.def\r\n\0";
+#endif
        libssh2_channel_write(channel, cmd, sizeof(char) * strlen(cmd));
        [self readChannel:channel];