harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apavle...@apache.org
Subject svn commit: r594925 - /harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c
Date Wed, 14 Nov 2007 15:59:35 GMT
Author: apavlenko
Date: Wed Nov 14 07:59:35 2007
New Revision: 594925

URL: http://svn.apache.org/viewvc?rev=594925&view=rev
Log:
Reimplemented getDefaultPrinterName() because the current implementation uses GetDefaultPrinterW
which causes an error on some systems

Modified:
    harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c

Modified: harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c?rev=594925&r1=594924&r2=594925&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c
Wed Nov 14 07:59:35 2007
@@ -99,19 +99,19 @@
 // ----------------   JNI functions   -----------------------
 
 JNIEXPORT jstring JNICALL Java_org_apache_harmony_x_print_WinPrinterFactory_getDefaultPrinterName(JNIEnv
* env, jclass c) {
-	DWORD len = 1024;
+	jstring name = NULL;
 	unsigned short buff[1024];
-	jstring name;
-	BOOL result = GetDefaultPrinterW(buff, &len);
+	unsigned int i;
+	unsigned int size = GetProfileStringW(L"windows", L"device", L",,,", buff,
+			sizeof(buff) / sizeof(unsigned short));
 
-	if (!result) {
-		handleLastError(__FUNCTION__,__FILE__ , __LINE__, env);
-	} else if (result == ERROR_FILE_NOT_FOUND) {
-		handleError(__FUNCTION__,__FILE__ , __LINE__, env, "No default printer");
-	} else if (result == ERROR_INSUFFICIENT_BUFFER) {
-		handleError(__FUNCTION__,__FILE__ , __LINE__, env, "Printer name is too long");
-	} else {
-		name = (*env)->NewString(env, buff, len - 1);
+	for (i = 0; i < size; i++) {
+		if (buff[i] == L',') {
+			if (i > 0) {
+				name = (*env)->NewString(env, buff, i);
+			}
+			break;
+		}
 	}
 
 	return name;



Mime
View raw message