Browse Source

Merge branch 'master' of github.com:antialize/wkhtmltopdf

Jakob Truelsen 15 years ago
parent
commit
d9aeadc575
3 changed files with 30 additions and 17 deletions
  1. 28 13
      src/wkhtmltopdf.cc
  2. 1 3
      static_qt_conf_base
  3. 1 1
      static_qt_conf_linux

+ 28 - 13
src/wkhtmltopdf.cc

@@ -151,6 +151,31 @@ public:
 	}
 };
 
+int handleError(bool success, int errorCode) {
+	QHash<int, const char *> cm;
+	cm[400] = "Bad Request";
+	cm[401] = "Unauthorized";
+	cm[402] = "Payment Required";
+	cm[403] = "Forbidden";
+	cm[404] = "Page not found";
+	cm[405] = "Method Not Allowed";
+	cm[500] = "Internal Server Error";
+	cm[501] = "Not Implemented";
+	cm[503] = "Service Unavailable";
+	cm[505] = "HTTP Version Not Supported";
+	QHash<int, int> ce;
+	ce[404] = 2;
+	ce[401] = 3;
+	if (errorCode) {
+		int c = EXIT_FAILURE;
+		if (ce.contains(errorCode)) c = ce[errorCode];
+		const char * m = "";
+		if (cm.contains(errorCode)) m = cm[errorCode];
+		fprintf(stderr, "Exit with code %d do to http error: %d %s\n", c, errorCode, m);
+		return c;
+	}
+	return success?EXIT_SUCCESS:EXIT_FAILURE;
+}
 
 int main(int argc, char * argv[]) {
 	//This will store all our settings
@@ -207,17 +232,7 @@ int main(int argc, char * argv[]) {
 	ProgressFeedback feedback(converter);
 	foreach(const Page & page, pageSettings) 
 		converter.addResource(page);
-	
-	if (!converter.convert())
-		return EXIT_FAILURE;
-	switch(converter.httpErrorCode()) {
-	case 401:
-		return 3;
-	case 404: 
-		return 2;
-	case 0:
-		return EXIT_SUCCESS;
-	default:
-		return EXIT_FAILURE;
-	}
+
+	bool success = converter.convert();
+	return handleError(success, converter.httpErrorCode());
 }

+ 1 - 3
static_qt_conf_base

@@ -29,7 +29,7 @@
 -no-phonon
 -no-phonon-backend
 -webkit
-# -no-scripttools
+-no-scripttools
 -no-mmx
 -no-3dnow
 -no-sse
@@ -51,6 +51,4 @@
 -no-dbus
 -no-multimedia
 -openssl
--no-audio-backend
-# -no-multimedia
 -no-declarative

+ 1 - 1
static_qt_conf_linux

@@ -35,4 +35,4 @@
 -no-opengl
 -no-xsync
 -no-svg
-
+-no-audio-backend