1 /*
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
978 }
979
980 /* get the printer info */
981 if (!::GetPrinter(hPrinter,
982 2,
983 (LPBYTE)pPrinterInfo,
984 cByteNeeded,
985 &cByteUsed))
986 {
987 /* failure to access the printer */
988 ::GlobalFree(pPrinterInfo);
989 pPrinterInfo = NULL;
990 ::ClosePrinter(hPrinter);
991 JNU_ReleaseStringPlatformChars(env, printer, printerName);
992 return -1;
993 }
994
995 if (type == GETJOBCOUNT) {
996 ret = pPrinterInfo->cJobs;
997 } else if (type == ACCEPTJOB) {
998 if (pPrinterInfo->Status &
999 (PRINTER_STATUS_ERROR |
1000 PRINTER_STATUS_NOT_AVAILABLE |
1001 PRINTER_STATUS_NO_TONER |
1002 PRINTER_STATUS_OUT_OF_MEMORY |
1003 PRINTER_STATUS_OFFLINE |
1004 PRINTER_STATUS_USER_INTERVENTION |
1005 PRINTER_STATUS_DOOR_OPEN)) {
1006 ret = 0;
1007 }
1008 else {
1009 ret = 1;
1010 }
1011 }
1012
1013 ::GlobalFree(pPrinterInfo);
1014 ::ClosePrinter(hPrinter);
1015 JNU_ReleaseStringPlatformChars(env, printer, printerName);
1016 return ret;
1017 }
1018
1019
1020 static jfieldID getIdOfLongField(JNIEnv *env, jobject self,
1021 const char *fieldName) {
1022 jclass myClass = env->GetObjectClass(self);
1023 jfieldID fieldId = env->GetFieldID(myClass, fieldName, "J");
1024 DASSERT(fieldId != 0);
1025 return fieldId;
|
1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
978 }
979
980 /* get the printer info */
981 if (!::GetPrinter(hPrinter,
982 2,
983 (LPBYTE)pPrinterInfo,
984 cByteNeeded,
985 &cByteUsed))
986 {
987 /* failure to access the printer */
988 ::GlobalFree(pPrinterInfo);
989 pPrinterInfo = NULL;
990 ::ClosePrinter(hPrinter);
991 JNU_ReleaseStringPlatformChars(env, printer, printerName);
992 return -1;
993 }
994
995 if (type == GETJOBCOUNT) {
996 ret = pPrinterInfo->cJobs;
997 } else if (type == ACCEPTJOB) {
998 if (pPrinterInfo->Status & PRINTER_STATUS_PENDING_DELETION) {
999 ret = 0;
1000 }
1001 else {
1002 ret = 1;
1003 }
1004 }
1005
1006 ::GlobalFree(pPrinterInfo);
1007 ::ClosePrinter(hPrinter);
1008 JNU_ReleaseStringPlatformChars(env, printer, printerName);
1009 return ret;
1010 }
1011
1012
1013 static jfieldID getIdOfLongField(JNIEnv *env, jobject self,
1014 const char *fieldName) {
1015 jclass myClass = env->GetObjectClass(self);
1016 jfieldID fieldId = env->GetFieldID(myClass, fieldName, "J");
1017 DASSERT(fieldId != 0);
1018 return fieldId;
|