Renaming the uploaded PDF and we now delete it at the end
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 26 Feb 2008 16:48:55 +0000 (11:48 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 26 Feb 2008 16:48:55 +0000 (11:48 -0500)
Source/AppController.m

index feaafda8336d321d3d6e5456710012c07a3b6080..0a0aaf962caed023ff9d4d052280bbc371c5d812 100644 (file)
                [self setStatus:@"Bad username/password" isError:YES];
                goto shutdown;
        }
-       /*
+       
        stat([[dragRegion filePath] UTF8String], &fileInfo);
        
-       LIBSSH2_CHANNEL *channel = libssh2_scp_send(ssh, "~/tempupload.pdf", 0755, (unsigned long)fileInfo.st_size);
+       LIBSSH2_CHANNEL *channel = libssh2_scp_send(ssh, "~/__bu_print_drop__.pdf", 0755, (unsigned long)fileInfo.st_size);
        if (!channel)
        {
                [self setStatus:@"Unable to open upload SCP session" isError:YES];
        libssh2_channel_wait_closed(channel);
        libssh2_channel_free(channel);
        channel = NULL;
-        */
        
-       LIBSSH2_CHANNEL *channel = libssh2_channel_open_session(ssh);
+       channel = libssh2_channel_open_session(ssh);
        if (!channel)
        {
                [self setStatus:@"Could not open SSH channel for printing" isError:YES];
        // read the banner
        [self readChannel:channel];
        
-       char *cmd = "touch /u17/ugrad/rsesek/temp.foo\r\n\0";
+       // send the job to lpr
+       char *cmd = (char *)[[NSString stringWithFormat:@"touch ~/print-%@.drop\r\n\0", printer] UTF8String];
+       libssh2_channel_write(channel, cmd, sizeof(char) * strlen(cmd));
+       [self readChannel:channel];
+       
+       // remove our temp file
+       cmd = "rm -f __bu_print_drop__.pdf\r\n\0";
        libssh2_channel_write(channel, cmd, sizeof(char) * strlen(cmd));
        [self readChannel:channel];