OLD | NEW |
---|---|
(Empty) | |
1 #include <errno.h> | |
Albert Bodenhamer
2011/07/08 20:40:13
You need to start the file with a correct header.
| |
2 #include <fstream> | |
3 #include <iostream> | |
4 #include <pwd.h> | |
5 #include <stdio.h> | |
6 #include <stdlib.h> | |
7 #include <string.h> | |
Albert Bodenhamer
2011/07/08 20:40:13
This looks like a lot of headers. Are they all re
| |
8 | |
9 #include <cups/backend.h> | |
10 | |
11 #include <sys/stat.h> | |
12 #include <sys/types.h> | |
13 #include <sys/wait.h> | |
14 | |
15 #include "base/base_paths.h" | |
16 #include "base/command_line.h" | |
17 #include "base/file_path.h" | |
18 #include "base/logging.h" | |
19 #include "base/path_service.h" | |
20 | |
21 #include "cloud_print/virtual_driver/linux/printer_driver_util_posix.h" | |
22 | |
23 | |
24 namespace switches { | |
Albert Bodenhamer
2011/07/08 20:40:13
Extract these to a common location in the print dr
| |
25 // These constants are duplicated from chrome/common/chrome_switches.cc | |
26 // in order to avoid dependency problems. | |
27 | |
28 // Used with kCloudPrintFile. Tells Chrome to delete the file when | |
29 // finished displaying the print dialog. | |
30 const char kCloudPrintDeleteFile[] = "cloud-print-delete-file"; | |
31 | |
32 // Tells chrome to display the cloud print dialog and upload the | |
33 // specified file for printing. | |
34 const char kCloudPrintFile[] = "cloud-print-file"; | |
35 | |
36 // Used with kCloudPrintFile to specify a title for the resulting print | |
37 // job. | |
38 const char kCloudPrintJobTitle[] = "cloud-print-job-title"; | |
39 | |
40 // Specifies the mime type to be used when uploading data from the | |
41 // file referenced by cloud-print-file. | |
42 // Defaults to "application/pdf" if unspecified. | |
43 const char kCloudPrintFileType[] = "cloud-print-file-type"; | |
44 | |
45 } | |
46 | |
47 using namespace std; | |
Albert Bodenhamer
2011/07/08 20:40:13
It looks like you're referring to std::string belo
| |
48 | |
49 void launchChrome(std::string output_path, std::string job_title, | |
Albert Bodenhamer
2011/07/08 20:40:13
Should be LaunchChrome or, even better, LaunchPrin
| |
50 std::string current_user){ | |
51 std::string set_var; | |
52 | |
53 // Set Environment variable to control display. | |
54 set_var="/home/" + current_user + "/.Xauthority"; | |
55 if(setenv("DISPLAY",":0.0",0) == -1) { | |
56 LOG(ERROR) << "Unable to set DISPLAY environment variable"; | |
57 } | |
58 if(setenv("XAUTHORITY",set_var.c_str(),0) == -1) { | |
59 LOG(ERROR) << "Unable to set XAUTHORITY environment variable"; | |
60 } | |
61 | |
62 // Construct the call to Chrome | |
63 | |
64 //FilePath chrome_path("/home/abeera/src/out/Release/chrome"); | |
65 FilePath chrome_path("google-chrome"); | |
66 FilePath job_path(output_path); | |
67 CommandLine command_line(chrome_path); | |
68 command_line.AppendSwitchPath(switches::kCloudPrintFile,job_path); | |
69 command_line.AppendSwitchNative(switches::kCloudPrintJobTitle, job_title); | |
70 command_line.AppendSwitch(switches::kCloudPrintDeleteFile); | |
71 LOG(INFO) << "Call to chrome is " << command_line.command_line_string(); | |
72 | |
73 if(system(command_line.command_line_string().c_str())== -1 ){ | |
74 LOG(ERROR) << "Unable to call Chrome"; | |
75 } | |
76 | |
77 else { | |
78 LOG(INFO) << "Call to Chrome succeeded"; | |
79 } | |
80 } | |
81 | |
OLD | NEW |