File kink-libinklevel066rc6.patch of Package kink

# Marcus D. Hanwell <cryos@gentoo.org> 6 January 2007.
# Fixes to allow kink to compile against the new API in libinklevel-0.6.6
diff -u ../kink-0.2.1-orig/kink/kink.cpp kink/kink.cpp
--- ../kink-0.2.1-orig/kink/kink.cpp	2007-01-06 14:04:45.000000000 +0000
+++ kink/kink.cpp	2007-01-06 18:47:06.000000000 +0000
@@ -80,10 +80,10 @@
 		switch(callback)
 		{
 		  case OK:
-			  add_device_to_list(PARPORT,i,level.model);
+			  add_device_to_list(PARPORT, i, level.model);
 				break;
 			case PRINTER_NOT_SUPPORTED:
-			  add_device_to_list(PARPORT,i,(unsigned char *)"Unsupported device");
+			  add_device_to_list(PARPORT,i,(char *)"Unsupported device");
 				break;
 		}
 	}
@@ -95,10 +95,10 @@
 		switch(callback)
 		{
 		  case OK:
-			  add_device_to_list(USB,i,level.model);
+			  add_device_to_list(USB , i, (level.model));
 				break;
 			case PRINTER_NOT_SUPPORTED:
-			  add_device_to_list(USB,i,(unsigned char *)"Unsupported device");
+			  add_device_to_list(USB, i, (char *)"Unsupported device");
 				break;
 		}
 	}
@@ -150,7 +150,7 @@
     \fn KInk::add_device_to_list(void)
 		Add a device to the combo box list
  */
-void KInk::add_device_to_list(int type, int port, unsigned char *model)
+void KInk::add_device_to_list(int type, int port, char *model)
 {
   listed_devices[listed_count].device_type = type;
 	listed_devices[listed_count].device_port = port;
@@ -203,116 +203,79 @@
 	grpLevels->show();
 
 	callback=get_ink_level(last_type,last_port,&level);
-	switch(callback)
+	if (callback == OK)
 	{
-	case OK:
-
-	if(level.black == 0 &&
-	   level.color == 0 &&
-		 level.cyan == 0 &&
-		 level.magenta == 0 &&
-		 level.yellow == 0 &&
-		 level.photo == 0 &&
-		 level.photocyan == 0 &&
-		 level.photomagenta == 0 &&
-		 level.photoyellow == 0)
-		 level.type = RESPONSE_INVALID;
-
-	  switch (level.type) {
-    case ONE_COLOR_FOUND:
-		  barColor->setEnabled(true);
-		  barColor->setProgress(level.color);
-      break;
-    case ONE_BLACK_COLOR_FOUND:
-		  barBlack->setEnabled(true);
-		  barBlack->setProgress(level.black);
-      break;
-    case TWO_COLORS_FOUND:
-		  barBlack->setEnabled(true);
-		  barColor->setEnabled(true);
-		  barBlack->setProgress(level.black);
-		  barColor->setProgress(level.color);
-      break;
-    case TWO_PHOTO_COLORS_FOUND:
-		  barPhoto->setEnabled(true);
-		  barColor->setEnabled(true);
-		  barPhoto->setProgress(level.photo);
-		  barColor->setProgress(level.color);
-      break;
-    case THREE_COLORS_FOUND:
-		  barCyan->setEnabled(true);
-		  barMagenta->setEnabled(true);
-		  barYellow->setEnabled(true);
-		  barCyan->setProgress(level.cyan);
-		  barMagenta->setProgress(level.magenta);
-		  barYellow->setProgress(level.yellow);
-      break;
-    case FOUR_COLORS_FOUND:
-  		barBlack->setEnabled(true);
-		  barCyan->setEnabled(true);
-		  barMagenta->setEnabled(true);
-		  barYellow->setEnabled(true);
-		  barBlack->setProgress(level.black);
-		  barCyan->setProgress(level.cyan);
-		  barMagenta->setProgress(level.magenta);
-		  barYellow->setProgress(level.yellow);
-      break;
-    case SIX_COLORS_FOUND:
-  		barBlack->setEnabled(true);
-		  barPhotoCyan->setEnabled(true);
-		  barPhotoMagenta->setEnabled(true);
-		  barCyan->setEnabled(true);
-		  barMagenta->setEnabled(true);
-		  barYellow->setEnabled(true);
-		  barBlack->setProgress(level.black);
-		  barPhotoCyan->setProgress(level.photocyan);
-		  barPhotoMagenta->setProgress(level.photomagenta);
-		  barCyan->setProgress(level.cyan);
-		  barMagenta->setProgress(level.magenta);
-		  barYellow->setProgress(level.yellow);
-      break;
-    case SEVEN_COLORS_FOUND:
-  		barBlack->setEnabled(true);
-	  	barPhotoCyan->setEnabled(true);
-		  barPhotoMagenta->setEnabled(true);
-		  barPhotoYellow->setEnabled(true);
-		  barCyan->setEnabled(true);
-		  barMagenta->setEnabled(true);
-		  barYellow->setEnabled(true);
-		  barBlack->setProgress(level.black);
-		  barPhotoCyan->setProgress(level.photocyan);
-		  barPhotoMagenta->setProgress(level.photomagenta);
-		  barPhotoYellow->setProgress(level.photoyellow);
-		  barCyan->setProgress(level.cyan);
-		  barMagenta->setProgress(level.magenta);
-		  barYellow->setProgress(level.yellow);
-      break;
-		case RESPONSE_INVALID:
-		  show_error(tr2i18n("<b>Invalid response read from device</b><br><br>Your printer reported that all ink tanks are empty or your printer is currently switched-off.<br><br>Power-on your device and verify the correct installation of cartdriges, then try again clicking <b>Update</b>."));
+		QProgressBar* ptrBar = 0;
+		for (int i = 0; i < MAX_CARTRIDGE_TYPES; i++)
+		{
+			switch (level.levels[i][INDEX_TYPE])
+			{
+				case CARTRIDGE_BLACK:
+					ptrBar = barBlack;
+					break;
+				case CARTRIDGE_COLOR:
+					ptrBar = barColor;
+					break;
+				case CARTRIDGE_PHOTO:
+					ptrBar = barPhoto;
+					break;
+				case CARTRIDGE_CYAN:
+					ptrBar = barCyan;
+					break;
+				case CARTRIDGE_MAGENTA:
+					ptrBar = barMagenta;
+					break;
+				case CARTRIDGE_YELLOW:
+					ptrBar = barYellow;
+					break;
+				case CARTRIDGE_PHOTOBLACK:
+					// Not implemented yet - add it?
+					break;
+				case CARTRIDGE_PHOTOCYAN:
+					ptrBar = barPhotoCyan;
+					break;
+				case CARTRIDGE_PHOTOMAGENTA:
+					ptrBar = barPhotoMagenta;
+					break;
+				case CARTRIDGE_PHOTOYELLOW:
+					ptrBar = barPhotoYellow;
+					break;
+			}
+			if (ptrBar)
+			{
+				ptrBar->setEnabled(true);
+				ptrBar->setProgress(level.levels[i][INDEX_LEVEL]);
+			}
+			ptrBar = 0;
 		}
-		break;
+	}
+	else
+	{
+//		show_error(tr2i18n("<b>Invalid response read from device</b><br><br>Your printer reported that all ink tanks are empty or your printer is currently switched-off.<br><br>Power-on your device and verify the correct installation of cartdriges, then try again clicking <b>Update</b>."));
+		switch(callback)
+		{
+			case DEV_PARPORT_INACCESSIBLE:
+			case DEV_LP_INACCESSIBLE:
+			case COULD_NOT_GET_DEVICE_ID:
+			case DEV_USB_LP_INACCESSIBLE:
+			case COULD_NOT_WRITE_TO_PRINTER:
+			case COULD_NOT_READ_FROM_PRINTER:
+			case ERROR:
+			case UNKNOWN_PORT_SPECIFIED:
+			case NO_DEVICE_CLASS_FOUND:
+			case NO_CMD_TAG_FOUND:
+			case NO_PRINTER_FOUND:
+			case COULD_NOT_PARSE_RESPONSE_FROM_PRINTER:
+			  show_error(tr2i18n("<b>Generic error</b><br><br>An error has occured communicating with the selected device. Click <b>Detect</b> and <b>Update</b> to refresh KInk status and try again. If the problem persists, e-mail me a description of the situation and all that can be helpful to me for reconstructing your execution environment."));
+				break;
+
+			case NO_INK_LEVEL_FOUND:
+			  show_error(tr2i18n("<b>Cannot read ink level from device</b><br><br>Cannot retrieve ink levels from the selected device. Ensure your printer is switched on and click on <b>Update</b> to try again."));
+				break;
 
-	case DEV_PARPORT_INACCESSIBLE:
-	case DEV_LP_INACCESSIBLE:
-	case COULD_NOT_GET_DEVICE_ID:
-	case DEV_USB_LP_INACCESSIBLE:
-	case COULD_NOT_WRITE_TO_PRINTER:
-	case COULD_NOT_READ_FROM_PRINTER:
-	case ERROR:
-	case UNKNOWN_PORT_SPECIFIED:
-	case NO_DEVICE_CLASS_FOUND:
-	case NO_CMD_TAG_FOUND:
-	case NO_PRINTER_FOUND:
-	case COULD_NOT_PARSE_RESPONSE_FROM_PRINTER:
-	  show_error(tr2i18n("<b>Generic error</b><br><br>An error has occured communicating with the selected device. Click <b>Detect</b> and <b>Update</b> to refresh KInk status and try again. If the problem persists, e-mail me a description of the situation and all that can be helpful to me for reconstructing your execution environment."));
-		break;
-
-	case NO_INK_LEVEL_FOUND:
-	  show_error(tr2i18n("<b>Cannot read ink level from device</b><br><br>Cannot retrieve ink levels from the selected device. Ensure your printer is switched on and click on <b>Update</b> to try again."));
-		break;
-
-	case PRINTER_NOT_SUPPORTED:
-	  show_error(tr2i18n("<b>Unsupported printer!</b><br><br>Selected printer is not supported by this version of libinklevel. Take a look to <a href='http://home.arcor.de/markusheinz'>http://home.arcor.de/markusheinz</a> for a complete list of devices supported by your version of libinklevel."));
-		break;
-  }
+			case PRINTER_NOT_SUPPORTED:
+			  show_error(tr2i18n("<b>Unsupported printer!</b><br><br>Selected printer is not supported by this version of libinklevel. Take a look to <a href='http://home.arcor.de/markusheinz'>http://home.arcor.de/markusheinz</a> for a complete list of devices supported by your version of libinklevel."));
+				break;
+  	}
+	}
 }
diff -u ../kink-0.2.1-orig/kink/kink.h kink/kink.h
--- ../kink-0.2.1-orig/kink/kink.h	2007-01-06 14:04:45.000000000 +0000
+++ kink/kink.h	2007-01-06 18:20:59.000000000 +0000
@@ -67,7 +67,7 @@
     DEVICE_INFO listed_devices[PARPORT_LAST_PORT + USB_LAST_PORT];
 
 private:
-    void add_device_to_list(int type, int port, unsigned char *model);
+    void add_device_to_list(int type, int port, char *model);
     void show_error(QString errStr);
     void update_view(void);
 };

openSUSE Build Service is sponsored by