2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: PrintJob.C /main/6 1998/07/24 16:17:39 mgreess $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
34 const char *PRINTJOB = "PrintJob";
37 const char *CANCEL_PRINT_JOB = "CancelPrintJob";
40 const char *PRINTJOB_NAME = "PrintJobName";
41 const char *OWNER = "Owner";
42 const char *JOB_NUMBER = "JobNumber";
43 const char *JOB_SIZE = "JobSize";
44 const char *SUBMITTED = "Submitted";
45 const char *DATE_SUBMITTED = "DateSubmitted";
46 const char *TIME_SUBMITTED = "TimeSubmitted";
48 PrintJob::PrintJob(BaseObj *parent,
55 : BaseObj(parent, JobName)
57 AddAction(&PrintJob::CancelJob, CANCEL_PRINT_JOB, MESSAGE(CancelChoiceL),
58 MESSAGE(CancelMnemonicL), NULL, NULL, true,
59 MESSAGE(CancelAcceleratorL), "<Key>osfDelete");
61 char *Help = NULL, *ContextualHelp = NULL, *Listing = NULL;
62 Characteristics Mask = OPTIONAL;
63 ValueList ValueListType = NO_LIST;
66 AddAttribute(PRINTJOB_NAME, MESSAGE(JobNameL),
67 Help, ContextualHelp, Mask, ValueListType, Listing);
68 _attributes[n]->Value = STRDUP(JobName);
69 _attributes[n]->DisplayValue = STRDUP(JobName);
71 AddAttribute(OWNER, MESSAGE(OwnerL),
72 Help, ContextualHelp, Mask, ValueListType, Listing);
73 _attributes[n]->Value = STRDUP(Owner);
74 _attributes[n]->DisplayValue = STRDUP(Owner);
76 AddAttribute(JOB_NUMBER, MESSAGE(JobNumberL),
77 Help, ContextualHelp, Mask, ValueListType, Listing);
78 _attributes[n]->Value = STRDUP(JobNumber);
79 _attributes[n]->DisplayValue = STRDUP(JobNumber);
80 _jobNumber = _attributes[n]->DisplayValue;
82 AddAttribute(JOB_SIZE, MESSAGE(SizeL),
83 Help, ContextualHelp, Mask, ValueListType, Listing);
84 _attributes[n]->Value = STRDUP(Size);
85 _attributes[n]->DisplayValue = STRDUP(Size);
87 ValueListType = INFORMATION_LINE;
88 AddAttribute(SUBMITTED, MESSAGE(SubmittedL),
89 Help, ContextualHelp, Mask, ValueListType, Listing);
90 _attributes[n]->Value = STRDUP(Time);
91 _attributes[n]->DisplayValue = STRDUP(Time);
93 ValueListType = NO_LIST;
94 char *message = new char [strlen(MESSAGE(TimeL)) + 4];
95 sprintf(message, " %s", MESSAGE(TimeL));
96 AddAttribute(TIME_SUBMITTED, message,
97 Help, ContextualHelp, Mask, ValueListType, Listing);
98 _attributes[n]->Value = STRDUP(Time);
99 _attributes[n]->DisplayValue = STRDUP(Time);
102 message = new char [strlen(MESSAGE(DateL)) + 4];
103 sprintf(message, " %s", MESSAGE(DateL));
104 AddAttribute(DATE_SUBMITTED, message,
105 Help, ContextualHelp, Mask, ValueListType, Listing);
106 _attributes[n]->Value = STRDUP(Date);
107 _attributes[n]->DisplayValue = STRDUP(Date);
111 PrintJob::~PrintJob()
116 int PrintJob::CancelJob(BaseObj *obj, char **output, BaseObj * /*requestor*/)
118 static char command[256];
119 PrintJob *me = (PrintJob *) obj;
122 sprintf(command, "enq -P%s -x%s", me->Parent()->Name(), me->_jobNumber);
124 sprintf(command, "cancel %s-%s", me->Parent()->Name(), me->_jobNumber);
126 return me->RunCommand(command, NULL, output);