617889067cae503a165fd308446941d68f517f62
[pierogi] / pirkeysetmanager.cpp
1 #include "pirkeysetmanager.h"
2
3 #include "pirkeysetmetadata.h"
4 #include "pirselectkeysetform.h"
5 #include "pirkeysetwidgetitem.h"
6
7 #include "keysets/acer.h"
8 #include "keysets/admiral.h"
9 #include "keysets/aiwa.h"
10 #include "keysets/aoc.h"
11 #include "keysets/apple.h"
12 #include "keysets/arcam.h"
13 #include "keysets/beko.h"
14 #include "keysets/benq.h"
15 #include "keysets/bose.h"
16 #include "keysets/bush.h"
17 #include "keysets/cambridge.h"
18 #include "keysets/canon.h"
19 #include "keysets/compro.h"
20 #include "keysets/daewoo.h"
21 #include "keysets/dell.h"
22 #include "keysets/denon.h"
23 #include "keysets/digitalstream.h"
24 #include "keysets/directv.h"
25 #include "keysets/dish.h"
26 #include "keysets/dreambox.h"
27 #include "keysets/dse.h"
28 #include "keysets/dynex.h"
29 #include "keysets/ei.h"
30 #include "keysets/elgato.h"
31 #include "keysets/emerson.h"
32 #include "keysets/epson.h"
33 #include "keysets/fortec.h"
34 #include "keysets/foxtel.h"
35 #include "keysets/genius.h"
36 #include "keysets/goldstar.h"
37 #include "keysets/grundig.h"
38 #include "keysets/haier.h"
39 #include "keysets/harmankardon.h"
40 #include "keysets/hauppauge.h"
41 #include "keysets/hitachi.h"
42 #include "keysets/homecast.h"
43 #include "keysets/hp.h"
44 #include "keysets/huawei.h"
45 #include "keysets/humax.h"
46 #include "keysets/hyundai.h"
47 #include "keysets/jvc.h"
48 #include "keysets/kaon.h"
49 #include "keysets/kathrein.h"
50 #include "keysets/kenwood.h"
51 #include "keysets/lg.h"
52 #include "keysets/logitech.h"
53 #include "keysets/magnavox.h"
54 #include "keysets/magnum.h"
55 #include "keysets/mce.h"
56 #include "keysets/mitsubishi.h"
57 #include "keysets/motorola.h"
58 #include "keysets/nad.h"
59 #include "keysets/nokia.h"
60 #include "keysets/octagon.h"
61 #include "keysets/onida.h"
62 #include "keysets/panasonic.h"
63 #include "keysets/philco.h"
64 #include "keysets/philips.h"
65 #include "keysets/pinnacle.h"
66 #include "keysets/pioneer.h"
67 #include "keysets/qnap.h"
68 #include "keysets/raite.h"
69 #include "keysets/rca.h"
70 #include "keysets/roku.h"
71 #include "keysets/saba.h"
72 #include "keysets/sagem.h"
73 #include "keysets/samsung.h"
74 #include "keysets/sanyo.h"
75 #include "keysets/sharp.h"
76 #include "keysets/sky.h"
77 #include "keysets/sony.h"
78 #include "keysets/starsat.h"
79 #include "keysets/technics.h"
80 #include "keysets/telenet.h"
81 #include "keysets/thomson.h"
82 #include "keysets/tivo.h"
83 #include "keysets/topfield.h"
84 #include "keysets/toshiba.h"
85 #include "keysets/united.h"
86 #include "keysets/universum.h"
87 #include "keysets/vestel.h"
88 #include "keysets/viewsat.h"
89 #include "keysets/virgin.h"
90 #include "keysets/vizio.h"
91 #include "keysets/wd.h"
92 #include "keysets/westinghouse.h"
93 #include "keysets/xcruiser.h"
94 #include "keysets/yamaha.h"
95 #include "keysets/zenith.h"
96
97 #include "pirexception.h"
98
99 // I'll be handling the threading of the keyset commands in this object:
100 #include <QMutex>
101
102 // Global communications mechanism:
103 extern bool stopRepeatingFlag;
104 extern QMutex stopRepeatingMutex;
105
106 // Global helper objects:
107 PIRMakeMgr makeManager;
108
109 // Now, on to the actual method definitions:
110
111 PIRKeysetManager::PIRKeysetManager()
112   : counter(0)
113 {
114   // Create the keysets.  Ugly!  This needs to be worked on!
115   setupKeyset(new AcerTV1(counter++));
116   setupKeyset(new AcerPC1(counter++));
117
118   setupKeyset(new AdmiralTV1(counter++));
119   setupKeyset(new AdmiralTV2(counter++));
120   setupKeyset(new AdmiralVCR1(counter++));
121
122   setupKeyset(new AiwaVCR1(counter++));
123   setupKeyset(new AiwaVCR2(counter++));
124   setupKeyset(new AiwaVCR3(counter++));
125   setupKeyset(new AiwaAudio1(counter++));
126   setupKeyset(new AiwaAudio1a(counter++));
127   setupKeyset(new AiwaAudio2(counter++));
128   setupKeyset(new AiwaAudio2a(counter++));
129   setupKeyset(new AiwaAudio2b(counter++));
130   setupKeyset(new AiwaAudio2c(counter++));
131   setupKeyset(new AiwaAudio3(counter++));
132   setupKeyset(new AiwaAudio4(counter++));
133   setupKeyset(new AiwaAudio5(counter++));
134   setupKeyset(new AiwaAudio6(counter++));
135   setupKeyset(new AiwaCarStereo1(counter++));
136   setupKeyset(new AiwaDVD1(counter++));
137
138   setupKeyset(new AOCTV1(counter++));
139
140   setupKeyset(new AppleWhiteRemote(counter++));
141
142   setupKeyset(new ArcamReceiver1(counter++));
143
144   setupKeyset(new BekoTV1(counter++));
145
146   setupKeyset(new BenQTV1(counter++));
147
148   setupKeyset(new BoseRadio1(counter++));
149   setupKeyset(new BoseRadio2(counter++));
150   setupKeyset(new BoseRadio3(counter++));
151   setupKeyset(new BoseHomeTheater1(counter++));
152
153   setupKeyset(new BushTV1(counter++));
154   setupKeyset(new BushTV2(counter++));
155   setupKeyset(new BushSTB1(counter++));
156
157   setupKeyset(new CambridgeCD1(counter++));
158   setupKeyset(new CambridgeAudio1(counter++));
159   setupKeyset(new CambridgeAudio2(counter++));
160   setupKeyset(new CambridgeAudio3(counter++));
161   setupKeyset(new CambridgeDVD1(counter++));
162
163   setupKeyset(new CanonDSLR1(counter++));
164   setupKeyset(new CanonCamcorder1(counter++));
165   setupKeyset(new CanonPowershot1(counter++));
166
167   setupKeyset(new ComproTVCard1(counter++));
168
169   setupKeyset(new DaewooTV1(counter++));
170   setupKeyset(new DaewooTV2(counter++));
171   setupKeyset(new DaewooTV3(counter++));
172   setupKeyset(new DaewooTV4(counter++));
173   setupKeyset(new DaewooDVD1(counter++));
174   setupKeyset(new DaewooVCR1(counter++));
175   setupKeyset(new DaewooVCR2(counter++));
176
177   setupKeyset(new DenonDVD1(counter++));
178   setupKeyset(new DenonDVD2(counter++));
179   setupKeyset(new DenonDVD3(counter++));
180   setupKeyset(new DenonReceiver1(counter++));
181   setupKeyset(new DenonReceiver1a(counter++));
182   setupKeyset(new DenonReceiver1b(counter++));
183   setupKeyset(new DenonReceiver1c(counter++));
184   setupKeyset(new DenonReceiver1d(counter++));
185   setupKeyset(new DenonReceiver1e(counter++));
186   setupKeyset(new DenonReceiver1f(counter++));
187   setupKeyset(new DenonReceiver2(counter++));
188   setupKeyset(new DenonReceiver2a(counter++));
189   setupKeyset(new DenonReceiver3(counter++));
190   setupKeyset(new DenonAudio1(counter++));
191   setupKeyset(new DenonAudio1a(counter++));
192   setupKeyset(new DenonAudio1b(counter++));
193   setupKeyset(new DenonAudio1c(counter++));
194   setupKeyset(new DenonAudio1d(counter++));
195   setupKeyset(new DenonAudio2(counter++));
196   setupKeyset(new DenonAudio3(counter++));
197   setupKeyset(new DenonAudio4(counter++));
198
199   setupKeyset(new DellRemote1(counter++));
200
201   setupKeyset(new DigitalStreamReceiver(counter++));
202
203   setupKeyset(new DirectvReceiver1(counter++));
204   setupKeyset(new DirectvReceiver1a(counter++));
205   setupKeyset(new DirectvReceiver1b(counter++));
206   setupKeyset(new DirectvReceiver1c(counter++));
207   setupKeyset(new DirectvReceiver1d(counter++));
208   setupKeyset(new DirectvReceiver1e(counter++));
209
210   setupKeyset(new DishReceiver1(counter++));
211   setupKeyset(new DishReceiver1a(counter++));
212   setupKeyset(new DishReceiver1b(counter++));
213   setupKeyset(new DishReceiver1c(counter++));
214   setupKeyset(new DishReceiver1d(counter++));
215   setupKeyset(new DishReceiver1e(counter++));
216   setupKeyset(new DishReceiver1f(counter++));
217   setupKeyset(new DishReceiver1g(counter++));
218   setupKeyset(new DishReceiver1h(counter++));
219   setupKeyset(new DishReceiver1i(counter++));
220   setupKeyset(new DishReceiver1j(counter++));
221   setupKeyset(new DishReceiver1k(counter++));
222   setupKeyset(new DishReceiver1l(counter++));
223   setupKeyset(new DishReceiver1m(counter++));
224   setupKeyset(new DishReceiver1n(counter++));
225   setupKeyset(new DishReceiver1o(counter++));
226
227   setupKeyset(new DreamboxSat1(counter++));
228   setupKeyset(new DreamboxSat1a(counter++));
229   setupKeyset(new DreamboxSat1b(counter++));
230   setupKeyset(new DreamboxSat1c(counter++));
231   setupKeyset(new DreamboxSat2(counter++));
232   setupKeyset(new DreamboxSat3(counter++));
233   setupKeyset(new DreamboxSat4(counter++));
234   setupKeyset(new DreamboxSat5(counter++));
235
236   setupKeyset(new DSEDVD1(counter++));
237   setupKeyset(new DSESat1(counter++));
238
239   setupKeyset(new DynexTV1(counter++));
240
241   setupKeyset(new EiTV1(counter++));
242
243   setupKeyset(new ElgatoEyeTV1(counter++));
244
245   setupKeyset(new EmersonTV1(counter++));
246   setupKeyset(new EmersonDVD1(counter++));
247
248   setupKeyset(new EpsonProjector1(counter++));
249   setupKeyset(new EpsonProjector2(counter++));
250
251   setupKeyset(new FortecReceiver1(counter++));
252   setupKeyset(new FortecReceiver2(counter++));
253
254   setupKeyset(new FoxtelSTB1(counter++));
255   setupKeyset(new FoxtelSTB2(counter++));
256
257   setupKeyset(new GeniusSpeakers1(counter++));
258
259   setupKeyset(new GoldStarTV1(counter++));
260   setupKeyset(new GoldStarTV2(counter++));
261   setupKeyset(new GoldStarVCR1(counter++));
262   setupKeyset(new GoldStarVCR1a(counter++));
263   setupKeyset(new GoldStarVCR1b(counter++));
264   setupKeyset(new GoldStarVCR1c(counter++));
265   setupKeyset(new GoldStarCD1(counter++));
266
267   setupKeyset(new GrundigSat1(counter++));
268   setupKeyset(new GrundigSat2(counter++));
269   setupKeyset(new GrundigAmp1(counter++));
270   setupKeyset(new GrundigAudio1(counter++));
271   setupKeyset(new GrundigAudio2(counter++));
272   setupKeyset(new GrundigVCR1(counter++));
273   setupKeyset(new GrundigVCR1a(counter++));
274   setupKeyset(new GrundigTV1(counter++));
275   setupKeyset(new GrundigTV2(counter++));
276   setupKeyset(new GrundigTV3(counter++));
277   setupKeyset(new GrundigDVD1(counter++));
278
279   setupKeyset(new HaierTV1(counter++));
280
281   setupKeyset(new HarmanKardonAmp1(counter++));
282   setupKeyset(new HarmanKardonAmp2(counter++));
283   setupKeyset(new HarmanKardonReceiver2(counter++));
284   setupKeyset(new HarmanKardonTape1(counter++));
285   setupKeyset(new HarmanKardonDVD1(counter++));
286   setupKeyset(new HarmanKardonDVD1a(counter++));
287   setupKeyset(new HarmanKardonCD1(counter++));
288   setupKeyset(new HarmanKardonCD2(counter++));
289
290   setupKeyset(new HauppaugePCTV1(counter++));
291   setupKeyset(new HauppaugePCTV1a(counter++));
292   setupKeyset(new HauppaugePCTV1b(counter++));
293   setupKeyset(new HauppaugePCTV1c(counter++));
294   setupKeyset(new HauppaugePCTV2(counter++));
295
296   setupKeyset(new HitachiTV1(counter++));
297   setupKeyset(new HitachiTV1a(counter++));
298   setupKeyset(new HitachiTV1b(counter++));
299   setupKeyset(new HitachiTV1c(counter++));
300   setupKeyset(new HitachiTV2(counter++));
301   setupKeyset(new HitachiTV3(counter++));
302   setupKeyset(new HitachiProjector(counter++));
303   setupKeyset(new HitachiDVD1(counter++));
304   setupKeyset(new HitachiAudio1(counter++));
305   setupKeyset(new HitachiVCR1(counter++));
306
307   setupKeyset(new HomecastReceiver1(counter++));
308   setupKeyset(new HomecastReceiver2(counter++));
309
310   setupKeyset(new HPRemote1(counter++));
311
312   setupKeyset(new HuaweiSTB1(counter++));
313   setupKeyset(new HuaweiSTB2(counter++));
314
315   setupKeyset(new HumaxReceiver1(counter++));
316   setupKeyset(new HumaxReceiver2(counter++));
317   setupKeyset(new HumaxReceiver3(counter++));
318
319   setupKeyset(new HyundaiDVD1(counter++));
320   setupKeyset(new HyundaiAudio1(counter++));
321   setupKeyset(new HyundaiTV1(counter++));
322
323   setupKeyset(new JVCSat1(counter++));
324   setupKeyset(new JVCSat2(counter++));
325   setupKeyset(new JVCVCR1(counter++));
326   setupKeyset(new JVCVCR1a(counter++));
327   setupKeyset(new JVCVCRBmode1(counter++));
328   setupKeyset(new JVCVCRBmode1a(counter++));
329   setupKeyset(new JVCTV1(counter++));
330   setupKeyset(new JVCTV1a(counter++));
331   setupKeyset(new JVCTV1b(counter++));
332   setupKeyset(new JVCTV1c(counter++));
333   setupKeyset(new JVCTV1d(counter++));
334   setupKeyset(new JVCDAT1(counter++));
335   setupKeyset(new JVCCarDeck1(counter++));
336   setupKeyset(new JVCAudio1(counter++));
337   setupKeyset(new JVCAudio1a(counter++));
338   setupKeyset(new JVCAudio1b(counter++));
339   setupKeyset(new JVCAudio2(counter++));
340   setupKeyset(new JVCDVD1(counter++));
341
342   setupKeyset(new KaonSat1(counter++));
343
344   setupKeyset(new KathreinSat1(counter++));
345   setupKeyset(new KathreinSat2(counter++));
346   setupKeyset(new KathreinSat3(counter++));
347
348   setupKeyset(new KenwoodAudio1(counter++));
349   setupKeyset(new KenwoodComponent1(counter++));
350   setupKeyset(new KenwoodComponent2(counter++));
351   setupKeyset(new KenwoodComponent3(counter++));
352   setupKeyset(new KenwoodCD1(counter++));
353   setupKeyset(new KenwoodDVD1(counter++));
354   setupKeyset(new KenwoodTV1(counter++));
355
356   setupKeyset(new LGTV1(counter++));
357   setupKeyset(new LGTV1a(counter++));
358   setupKeyset(new LGTV1b(counter++));
359   setupKeyset(new LGTV1c(counter++));
360   setupKeyset(new LGTV2(counter++));
361   setupKeyset(new LGTV2a(counter++));
362   setupKeyset(new LGTV2b(counter++));
363   setupKeyset(new LGDisc1(counter++));
364   setupKeyset(new LGDisc2(counter++));
365   setupKeyset(new LGDisc2a(counter++));
366   setupKeyset(new LGVCR1(counter++));
367   setupKeyset(new LGVCR1a(counter++));
368   setupKeyset(new LGVCR1b(counter++));
369   setupKeyset(new LGAC1(counter++));
370
371   setupKeyset(new LogitechSpeakers(counter++));
372   setupKeyset(new LogitechSqueezebox(counter++));
373
374   setupKeyset(new MagnavoxDVD1(counter++));
375   setupKeyset(new MagnavoxVCR1(counter++));
376   setupKeyset(new MagnavoxConverterBox1(counter++));
377   setupKeyset(new MagnavoxTV1(counter++));
378
379   setupKeyset(new MagnumTV1(counter++));
380
381   setupKeyset(new MCERemote1(counter++));
382   setupKeyset(new MCERemote1a(counter++));
383   setupKeyset(new MCERemote1b(counter++));
384   setupKeyset(new MCERemote1c(counter++));
385   setupKeyset(new MCERemote1d(counter++));
386   setupKeyset(new MCERemote1e(counter++));
387   setupKeyset(new MCERemote1f(counter++));
388   setupKeyset(new MCERemote1g(counter++));
389
390   setupKeyset(new MitsubishiTV1(counter++));
391   setupKeyset(new MitsubishiTV1a(counter++));
392   setupKeyset(new MitsubishiVCR1(counter++));
393   setupKeyset(new MitsubishiVCR1a(counter++));
394
395   setupKeyset(new Motorola4DTV(counter++));
396   setupKeyset(new MotorolaSTB1(counter++));
397   setupKeyset(new MotorolaSTB1a(counter++));
398   setupKeyset(new MotorolaSTB1b(counter++));
399   setupKeyset(new MotorolaSkyDigital(counter++));
400
401   setupKeyset(new NADAudio1(counter++));
402   setupKeyset(new NADTuner1(counter++));
403   setupKeyset(new NADDVD1(counter++));
404   setupKeyset(new NADCD1(counter++));
405   setupKeyset(new NADCD2(counter++));
406   setupKeyset(new NADTape1(counter++));
407
408   setupKeyset(new NokiaGenericVCR(counter++));
409
410   setupKeyset(new OctagonSat1(counter++));
411   setupKeyset(new OctagonSat1a(counter++));
412   setupKeyset(new OctagonSat2(counter++));
413
414   setupKeyset(new OnidaTV1(counter++));
415   setupKeyset(new OnidaDVD1(counter++));
416
417   setupKeyset(new PanasonicCarAudio(counter++));
418   setupKeyset(new PanasonicSat1(counter++));
419   setupKeyset(new PanasonicSat1a(counter++));
420   setupKeyset(new PanasonicTV1(counter++));
421   setupKeyset(new PanasonicTV1a(counter++));
422   setupKeyset(new PanasonicTV1b(counter++));
423   setupKeyset(new PanasonicVCR1(counter++));
424   setupKeyset(new PanasonicVCR1a(counter++));
425   setupKeyset(new PanasonicVCR1b(counter++));
426   setupKeyset(new PanasonicVCR1c(counter++));
427   setupKeyset(new PanasonicDVD1(counter++));
428   setupKeyset(new PanasonicDVD1a(counter++));
429   setupKeyset(new PanasonicAudio1(counter++));
430   setupKeyset(new PanasonicAudio2(counter++));
431   setupKeyset(new PanasonicAudio2a(counter++));
432   setupKeyset(new PanasonicAC1(counter++));
433
434   setupKeyset(new PhilcoTV(counter++));
435
436   setupKeyset(new PhilipsTV1(counter++));
437   setupKeyset(new PhilipsTV1a(counter++));
438   setupKeyset(new PhilipsTV1b(counter++));
439   setupKeyset(new PhilipsTV1c(counter++));
440   setupKeyset(new PhilipsTV1d(counter++));
441   setupKeyset(new PhilipsTV1e(counter++));
442   setupKeyset(new PhilipsTV1f(counter++));
443   setupKeyset(new PhilipsTV2(counter++));
444   setupKeyset(new PhilipsTV2a(counter++));
445   setupKeyset(new PhilipsTV2b(counter++));
446   setupKeyset(new PhilipsTV3(counter++));
447   setupKeyset(new PhilipsDVD1(counter++));
448   setupKeyset(new PhilipsDVD1a(counter++));
449   setupKeyset(new PhilipsDVD1b(counter++));
450   setupKeyset(new PhilipsDVD1c(counter++));
451   setupKeyset(new PhilipsDVD1d(counter++));
452   setupKeyset(new PhilipsDVD2(counter++));
453   setupKeyset(new PhilipsDVD3(counter++));
454   setupKeyset(new PhilipsDVD3a(counter++));
455   setupKeyset(new PhilipsDVD4(counter++));
456   setupKeyset(new PhilipsVCR1(counter++));
457   setupKeyset(new PhilipsVCR1a(counter++));
458   setupKeyset(new PhilipsVCR1b(counter++));
459   setupKeyset(new PhilipsVCR1c(counter++));
460   setupKeyset(new PhilipsSat1(counter++));
461   setupKeyset(new PhilipsSat2(counter++));
462   setupKeyset(new PhilipsSat2a(counter++));
463   setupKeyset(new PhilipsSat3(counter++));
464   setupKeyset(new PhilipsAudio1(counter++));
465   setupKeyset(new PhilipsAudio1a(counter++));
466   setupKeyset(new PhilipsAudio1b(counter++));
467   setupKeyset(new PhilipsAudio2(counter++));
468   setupKeyset(new PhilipsAudio3(counter++));
469   setupKeyset(new PhilipsAudio4(counter++));
470
471   setupKeyset(new PinnaclePCTV1(counter++));
472   setupKeyset(new PinnaclePCTV2(counter++));
473   setupKeyset(new PinnaclePCTV3(counter++));
474
475   setupKeyset(new PioneerTV1(counter++));
476   setupKeyset(new PioneerTV2(counter++));
477   setupKeyset(new PioneerTV3(counter++));
478   setupKeyset(new PioneerAudio1(counter++));
479   setupKeyset(new PioneerAudio1a(counter++));
480   setupKeyset(new PioneerAudio2(counter++));
481   setupKeyset(new PioneerAudio3(counter++));
482   setupKeyset(new PioneerAudio4(counter++));
483   setupKeyset(new PioneerAudio5(counter++));
484   setupKeyset(new PioneerCD1(counter++));
485   setupKeyset(new PioneerLaserDisc1(counter++));
486   setupKeyset(new PioneerDVD1(counter++));
487
488   setupKeyset(new QNAPPlayer1(counter++));
489
490   setupKeyset(new RaiteDVD1(counter++));
491
492   setupKeyset(new RCATV1(counter++));
493   setupKeyset(new RCATV1a(counter++));
494   setupKeyset(new RCATV1b(counter++));
495 //  setupKeyset(new RCAAux1(counter++));
496 //  setupKeyset(new RCAAux2(counter++));
497 //  setupKeyset(new RCAAux2a(counter++));
498   setupKeyset(new RCAVCR1(counter++));
499   setupKeyset(new RCAVCR1a(counter++));
500   setupKeyset(new RCADVD1(counter++));
501   setupKeyset(new RCADVD1a(counter++));
502   setupKeyset(new RCASat1(counter++));
503   setupKeyset(new RCASat2(counter++));
504
505   setupKeyset(new RokuBox1(counter++));
506   setupKeyset(new RokuBox2(counter++));
507
508   setupKeyset(new SabaTV1(counter++));
509   setupKeyset(new SabaTV2(counter++));
510
511   setupKeyset(new SagemTVBox1(counter++));
512   setupKeyset(new SagemTVBox1a(counter++));
513
514   setupKeyset(new SamsungTV1(counter++));
515   setupKeyset(new SamsungTV1a(counter++));
516   setupKeyset(new SamsungTV1b(counter++));
517   setupKeyset(new SamsungTV1c(counter++));
518   setupKeyset(new SamsungTV1d(counter++));
519   setupKeyset(new SamsungTV1e(counter++));
520   setupKeyset(new SamsungTV1f(counter++));
521   setupKeyset(new SamsungTV2(counter++));
522   setupKeyset(new SamsungTV2a(counter++));
523   setupKeyset(new SamsungVCR1(counter++));
524   setupKeyset(new SamsungVCR1a(counter++));
525   setupKeyset(new SamsungVCR1b(counter++));
526   setupKeyset(new SamsungVCR1c(counter++));
527   setupKeyset(new SamsungVCR1d(counter++));
528   setupKeyset(new SamsungVCR1e(counter++));
529   setupKeyset(new SamsungDVD1(counter++));
530   setupKeyset(new SamsungDVD1a(counter++));
531   setupKeyset(new SamsungDVD1b(counter++));
532   setupKeyset(new SamsungDVD2(counter++));
533   setupKeyset(new SamsungAC1(counter++));
534   setupKeyset(new SamsungDVBT1(counter++));
535
536   setupKeyset(new SanyoVCR1(counter++));
537   setupKeyset(new SanyoDVD1(counter++));
538   setupKeyset(new SanyoTV1(counter++));
539   setupKeyset(new SanyoTV1a(counter++));
540   setupKeyset(new SanyoTV1b(counter++));
541   setupKeyset(new SanyoTV1c(counter++));
542   setupKeyset(new SanyoTV1d(counter++));
543   setupKeyset(new SanyoProjector(counter++));
544
545   setupKeyset(new SharpTV1(counter++));
546   setupKeyset(new SharpTV1a(counter++));
547   setupKeyset(new SharpTV1b(counter++));
548   setupKeyset(new SharpTV1c(counter++));
549   setupKeyset(new SharpTV1d(counter++));
550   setupKeyset(new SharpTV1e(counter++));
551   setupKeyset(new SharpVCR1(counter++));
552   setupKeyset(new SharpReceiver1(counter++));
553   setupKeyset(new SharpAC1(counter++));
554
555   setupKeyset(new SkyReceiver1(counter++));
556   setupKeyset(new SkyReceiver1a(counter++));
557
558   setupKeyset(new SonyTV1(counter++));
559   setupKeyset(new SonyTV1a(counter++));
560   setupKeyset(new SonyTV1b(counter++));
561   setupKeyset(new SonyTV1c(counter++));
562   setupKeyset(new SonyAmp1(counter++));
563   setupKeyset(new SonyAmp2(counter++));
564   setupKeyset(new SonyAudio1(counter++));
565   setupKeyset(new SonyAudio1a(counter++));
566   setupKeyset(new SonyDAT1(counter++));
567   setupKeyset(new SonyDVD1(counter++));
568   setupKeyset(new SonyDVD1a(counter++));
569   setupKeyset(new SonyDVD1b(counter++));
570   setupKeyset(new SonyDVD1c(counter++));
571   setupKeyset(new SonyVCR1(counter++));
572   setupKeyset(new SonyVCR1a(counter++));
573   setupKeyset(new SonyVCR1b(counter++));
574   setupKeyset(new SonyReceiver1(counter++));
575   setupKeyset(new SonyCD1(counter++));
576   setupKeyset(new SonyCD1a(counter++));
577   setupKeyset(new SonyCD1b(counter++));
578
579   setupKeyset(new StarsatSat1(counter++));
580
581   setupKeyset(new TechnicsAudio1(counter++));
582   setupKeyset(new TechnicsAudio1a(counter++));
583   setupKeyset(new TechnicsAudio2(counter++));
584   setupKeyset(new TechnicsAudio3(counter++));
585   setupKeyset(new TechnicsAudio3a(counter++));
586   setupKeyset(new TechnicsDVD1(counter++));
587
588   setupKeyset(new TelenetSTB1(counter++));
589
590   setupKeyset(new ThomsonConverter1(counter++));
591   setupKeyset(new ThomsonTV1(counter++));
592   setupKeyset(new ThomsonVCR1(counter++));
593   setupKeyset(new ThomsonVCR1a(counter++));
594   setupKeyset(new ThomsonDVD1(counter++));
595   setupKeyset(new ThomsonSat1(counter++));
596   setupKeyset(new ThomsonAudio1(counter++));
597
598   setupKeyset(new Tivo1(counter++));
599   setupKeyset(new Tivo1a(counter++));
600   setupKeyset(new Tivo1b(counter++));
601   setupKeyset(new Tivo1c(counter++));
602   setupKeyset(new Tivo1d(counter++));
603
604   setupKeyset(new TopfieldPVR1(counter++));
605   setupKeyset(new TopfieldSat1(counter++));
606
607   setupKeyset(new ToshibaTV1(counter++));
608   setupKeyset(new ToshibaTV1a(counter++));
609   setupKeyset(new ToshibaTV1b(counter++));
610   setupKeyset(new ToshibaTV1c(counter++));
611   setupKeyset(new ToshibaTV1d(counter++));
612   setupKeyset(new ToshibaTV1e(counter++));
613   setupKeyset(new ToshibaTV1f(counter++));
614   setupKeyset(new ToshibaTV1g(counter++));
615   setupKeyset(new ToshibaTV1h(counter++));
616   setupKeyset(new ToshibaVCR1(counter++));
617   setupKeyset(new ToshibaVCR1a(counter++));
618   setupKeyset(new ToshibaDisc1(counter++));
619   setupKeyset(new ToshibaDisc1a(counter++));
620   setupKeyset(new ToshibaDisc1b(counter++));
621   setupKeyset(new ToshibaDisc1c(counter++));
622   setupKeyset(new ToshibaDisc1d(counter++));
623
624   setupKeyset(new UnitedDVD1(counter++));
625   setupKeyset(new UnitedDVBT1(counter++));
626
627   setupKeyset(new UniversumVCR1(counter++));
628   setupKeyset(new UniversumVCR2(counter++));
629   setupKeyset(new UniversumVCR3(counter++));
630   setupKeyset(new UniversumTV1(counter++));
631   setupKeyset(new UniversumTV1a(counter++));
632   setupKeyset(new UniversumSat1(counter++));
633   setupKeyset(new UniversumAudio1(counter++));
634
635   setupKeyset(new VestelTV1(counter++));
636   setupKeyset(new VestelTV2(counter++));
637
638   setupKeyset(new ViewsatSat1(counter++));
639   setupKeyset(new ViewsatSat1a(counter++));
640
641   setupKeyset(new VirginSTB1(counter++));
642
643   setupKeyset(new VizioTV1(counter++));
644
645   setupKeyset(new WDMediaPlayer1(counter++));
646   setupKeyset(new WDMediaPlayer1a(counter++));
647   setupKeyset(new WDMediaPlayer1b(counter++));
648
649   setupKeyset(new WestinghouseTV1(counter++));
650   setupKeyset(new WestinghouseTV2(counter++));
651
652   setupKeyset(new XcruiserSat1(counter++));
653
654   setupKeyset(new YamahaDVD1(counter++));
655   setupKeyset(new YamahaDVD1a(counter++));
656   setupKeyset(new YamahaAudio1(counter++));
657   setupKeyset(new YamahaAudio1a(counter++));
658   setupKeyset(new YamahaAudio2(counter++));
659   setupKeyset(new YamahaAudio2a(counter++));
660   setupKeyset(new YamahaAudio2b(counter++));
661   setupKeyset(new YamahaAudio2c(counter++));
662   setupKeyset(new YamahaAudio2d(counter++));
663   setupKeyset(new YamahaAudio3(counter++));
664   setupKeyset(new YamahaAudio4(counter++));
665   setupKeyset(new YamahaTV1(counter++));
666   setupKeyset(new YamahaKaraoke1(counter++));
667
668   setupKeyset(new ZenithC32V37(counter++));
669
670   // Start the thread running:
671   commandThread.start();
672 }
673
674
675 PIRKeysetManager::~PIRKeysetManager()
676 {
677   // Tell the keysets to stop doing any work:
678   {
679     QMutexLocker locker(&stopRepeatingMutex);
680     stopRepeatingFlag = true;
681   }
682
683   // Tell the thread that we want it to stop:
684   commandThread.exit();
685
686   // Wait for the thread to stop:
687   commandThread.wait();
688
689   // Delete all the keysets:
690   PIRKeysetCollection::iterator i = keysetsInfo.begin();
691   while (i != keysetsInfo.end())
692   {
693     if ((*i).second) delete (*i).second;
694     ++i;
695   }
696 }
697
698
699 bool PIRKeysetManager::keysetExists(
700   unsigned int keysetID) const
701 {
702   PIRKeysetCollection::const_iterator i = keysetsInfo.find(keysetID);
703
704   return (i != keysetsInfo.end());
705 }
706
707
708 bool PIRKeysetManager::findKeysetID(
709   QString make,
710   QString name,
711   unsigned int &id) const
712 {
713   // Only modify the id if we actually find a match!
714
715   PIRKeysetMakeIndex::const_iterator i = makeIndex.find(make);
716   if (i == makeIndex.end())
717   {
718     return false;
719   }
720
721   PIRKeysetNameIndex::const_iterator ii = (*i).second.find(name);
722   if (ii == (*i).second.end())
723   {
724     return false;
725   }
726
727   //  Ok, we've found it, pull out the id:
728   id = (*ii).second;
729   return true;
730 }
731
732
733 PIRKeysetWidgetItem *PIRKeysetManager::makeKeysetItem(
734   QString make,
735   QString name) const
736 {
737   unsigned int id;
738
739   if (!findKeysetID(make, name, id))
740   {
741     return NULL;
742   }
743
744   QString fullname = make;
745   fullname.append(" ");
746   fullname.append(name);
747
748   return new PIRKeysetWidgetItem(fullname, id, getMake(id));
749 }
750
751
752 bool PIRKeysetManager::hasKey(
753   unsigned int keysetID,
754   PIRKeyName name) const
755 {
756   PIRKeysetCollection::const_iterator i = keysetsInfo.find(keysetID);
757
758   if ((i == keysetsInfo.end()) || !i->second) return false;
759
760   return i->second->hasKey(name);
761 }
762
763
764 PIRMakeName PIRKeysetManager::getMake(
765   unsigned int keysetID) const
766 {
767   PIRKeysetCollection::const_iterator i = keysetsInfo.find(keysetID);
768
769   if ((i == keysetsInfo.end()) || !i->second) return Any_Make;
770
771   return i->second->getMake();
772 }
773
774
775 QString PIRKeysetManager::getDisplayName(
776   unsigned int keysetID) const
777 {
778   PIRKeysetCollection::const_iterator i = keysetsInfo.find(keysetID);
779
780   if ((i == keysetsInfo.end()) || !i->second)
781     return QString("Database Error");
782
783   return QString(i->second->getKeysetName());
784 }
785
786
787 void PIRKeysetManager::populateKeyset(
788   QObject *guiObject,
789   unsigned int keysetID)
790 {
791   PIRKeysetCollection::iterator i = keysetsInfo.find(keysetID);
792
793   if (i == keysetsInfo.end())
794   {
795     // Should have some sort of error message here!
796     return;
797   }
798
799   i->second->populateProtocol(guiObject);
800   i->second->moveToThread(&commandThread);
801 }
802
803
804 void PIRKeysetManager::setupKeyset(
805   PIRKeysetMetaData *keyset)
806 {
807   // Set up the keyset collection:
808   keysetsInfo[keyset->getID()] = keyset;
809
810   // Set up a name-based index into the collection:
811   makeIndex
812     [QString(makeManager.getMakeString(keyset->getMake()))]
813     [QString(keyset->getKeysetName())]
814     = keyset->getID();
815 }
816
817
818 void PIRKeysetManager::populateSelectionWidget(
819   PIRSelectKeysetForm *skf) const
820 {
821   PIRMakeName make;
822   PIRKeysetWidgetItem *kwi;
823
824   PIRKeysetCollection::const_iterator i = keysetsInfo.begin();
825
826   while (i != keysetsInfo.end())
827   {
828     // Create a widget for the keyset:
829     make = i->second->getMake();
830     QString tempString = makeManager.getMakeString(make);
831     tempString.append(" ");
832     tempString.append(i->second->getKeysetName());
833     kwi = new PIRKeysetWidgetItem(tempString, i->first, make);
834     skf->addWidgetItem(kwi);
835
836     ++i;
837   }
838 }
839
840
841 /*
842 void PIRKeysetManager::populateDeviceTypes(
843   PIRKeysetWidgetItem *kwi,
844   unsigned int keysetID) const
845 {
846   PIRKeysetCollection::const_iterator i = keysetsInfo.find(keysetID);
847   if ((i != keysetsInfo.end()) && i->second)
848   {
849     i->second->populateDeviceTypes(kwi);
850   }
851 }
852 */