remove OSF1 support
[oweals/cde.git] / cde / programs / dtprintinfo / objects / PrintObj / PrintJob.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $TOG: PrintJob.C /main/6 1998/07/24 16:17:39 mgreess $ */
24 /*                                                                      *
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.                                *
29  */
30
31 #include "PrintJob.h"
32
33 // Object Class Name
34 const char *PRINTJOB = "PrintJob";
35
36 // Actions
37 const char *CANCEL_PRINT_JOB  = "CancelPrintJob";
38
39 // Attributes
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";
47
48 PrintJob::PrintJob(BaseObj *parent,
49                    char *JobName,
50                    char *JobNumber,
51                    char *Owner,
52                    char *Date,
53                    char *Time,
54                    char *Size)
55         : BaseObj(parent, JobName)
56 {
57    AddAction(&PrintJob::CancelJob, CANCEL_PRINT_JOB, MESSAGE(CancelChoiceL),
58              MESSAGE(CancelMnemonicL), NULL, NULL, true,
59              MESSAGE(CancelAcceleratorL), "<Key>osfDelete");
60
61    char *Help = NULL, *ContextualHelp = NULL, *Listing = NULL;
62    Characteristics Mask = OPTIONAL;
63    ValueList ValueListType = NO_LIST;
64    int n = 0;
65
66    AddAttribute(PRINTJOB_NAME, MESSAGE(JobNameL),
67                 Help, ContextualHelp, Mask, ValueListType, Listing);
68    _attributes[n]->Value = STRDUP(JobName);
69    _attributes[n]->DisplayValue = STRDUP(JobName);
70    n++;
71    AddAttribute(OWNER, MESSAGE(OwnerL),
72                 Help, ContextualHelp, Mask, ValueListType, Listing);
73    _attributes[n]->Value = STRDUP(Owner);
74    _attributes[n]->DisplayValue = STRDUP(Owner);
75    n++;
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;
81    n++;
82    AddAttribute(JOB_SIZE, MESSAGE(SizeL),
83                 Help, ContextualHelp, Mask, ValueListType, Listing);
84    _attributes[n]->Value = STRDUP(Size);
85    _attributes[n]->DisplayValue = STRDUP(Size);
86    n++;
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);
92    n++;
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);
100    delete [] message;
101    n++;
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);
108    delete [] message;
109 }
110
111 PrintJob::~PrintJob()
112 {
113    // Empty
114 }
115
116 int PrintJob::CancelJob(BaseObj *obj, char **output, BaseObj * /*requestor*/)
117 {
118    static char command[256];
119    PrintJob *me = (PrintJob *) obj;
120
121 #ifdef aix
122    sprintf(command, "enq -P%s -x%s", me->Parent()->Name(), me->_jobNumber);
123 #else
124    sprintf(command, "cancel %s-%s", me->Parent()->Name(), me->_jobNumber);
125 #endif
126    return me->RunCommand(command, NULL, output);
127 }