summaryrefslogtreecommitdiff
blob: 7d0a6750b148cb0a123e11b7346a25cc94db0d1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# 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);
 };