Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Pierogi
Summary Forums Tracker Lists Tasks Docs News SCM Files
1 #include "pirkeysetmanager.h"
2 #include "pirkeysetmetadata.h"
3 #include "keysets/apple.h"
4 #include "keysets/ei.h"
5 #include "keysets/goldstar.h"
6 #include "keysets/hauppauge.h"
7 #include "keysets/lg.h"
8 #include "keysets/nokia.h"
9 #include "keysets/panasonic.h"
10 #include "keysets/samsung.h"
11 #include "keysets/sanyo.h"
12 #include "keysets/sharp.h"
13 #include "keysets/sony.h"
14 #include "keysets/toshiba.h"
15 #include "keysets/zenith.h"
16 //#include "protocol.h"
17 #include "pirmakenames.h"
19 #include "pirexception.h"
21 #include <QObject>
22 //#include <QMetaType>
24 // I'll be handling the threading of the keyset commands in this object:
25 #include <QMutex>
27 // This file defines some global stuff!  First, threading globals:
29 // The stopRepeatingFlag boolean is the method used to tell running commands
30 // in the worker thread to stop:
31 bool stopRepeatingFlag;
32 QMutex stopRepeatingMutex;
34 // Next, a global for helping out with Make names:
36 PIRMakeMgr makeManager;
38 // Now, on to the actual method definitions:
40 PIRKeysetManager::PIRKeysetManager(
41   QObject *guiObject)
42   : counter(0)
43 {
44   // Create the keysets.  This needs to be worked on!
45   populateKeyset(new AppleWhiteRemote(guiObject, counter++));
46   populateKeyset(new EiKeyset(guiObject, counter++));
47   populateKeyset(new GoldStarTV1(guiObject, counter++));
48   populateKeyset(new GoldStarTV2(guiObject, counter++));
49   populateKeyset(new GoldStarVCR1(guiObject, counter++));
50   populateKeyset(new GoldStarVCR1a(guiObject, counter++));
51   populateKeyset(new GoldStarVCR1b(guiObject, counter++));
52   populateKeyset(new GoldStarVCR1c(guiObject, counter++));
53   populateKeyset(new GoldStarVCR1d(guiObject, counter++));
54   populateKeyset(new GoldStarCD1(guiObject, counter++));
55   populateKeyset(new HauppaugeGeneric(guiObject, counter++));
56   populateKeyset(new HauppaugeTV1(guiObject, counter++));
57   populateKeyset(new LGTV1(guiObject, counter++));
58   populateKeyset(new LGTV1a(guiObject, counter++));
59   populateKeyset(new LGTV1b(guiObject, counter++));
60   populateKeyset(new LGTV1c(guiObject, counter++));
61   populateKeyset(new LGTV2(guiObject, counter++));
62   populateKeyset(new LGTV2a(guiObject, counter++));
63   populateKeyset(new LGTV2b(guiObject, counter++));
64   populateKeyset(new LGDisc1(guiObject, counter++));
65   populateKeyset(new LGDisc2(guiObject, counter++));
66   populateKeyset(new LGDisc2a(guiObject, counter++));
67   populateKeyset(new LGVCR1(guiObject, counter++));
68   populateKeyset(new LGVCR1a(guiObject, counter++));
69   populateKeyset(new LGVCR1b(guiObject, counter++));
70   populateKeyset(new NokiaGenericVCR(guiObject, counter++));
71   populateKeyset(new PanasonicAmp(guiObject, counter++));
72   populateKeyset(new PanasonicCarAudio(guiObject, counter++));
73   populateKeyset(new PanasonicSat1(guiObject, counter++));
74   populateKeyset(new PanasonicSat1a(guiObject, counter++));
75   populateKeyset(new PanasonicTV1(guiObject, counter++));
76   populateKeyset(new PanasonicTV1a(guiObject, counter++));
77   populateKeyset(new PanasonicTV1b(guiObject, counter++));
78   populateKeyset(new PanasonicVCR1(guiObject, counter++));
79   populateKeyset(new PanasonicVCR1a(guiObject, counter++));
80   populateKeyset(new PanasonicVCR1b(guiObject, counter++));
81   populateKeyset(new PanasonicVCR1c(guiObject, counter++));
82   populateKeyset(new PanasonicDVD1(guiObject, counter++));
83   populateKeyset(new PanasonicDVD1a(guiObject, counter++));
84   populateKeyset(new PanasonicAudio(guiObject, counter++));
85   populateKeyset(new SamsungTV1(guiObject, counter++));
86   populateKeyset(new SamsungTV1a(guiObject, counter++));
87   populateKeyset(new SamsungTV1b(guiObject, counter++));
88   populateKeyset(new SamsungTV1c(guiObject, counter++));
89   populateKeyset(new SamsungTV1d(guiObject, counter++));
90   populateKeyset(new SamsungTV1e(guiObject, counter++));
91   populateKeyset(new SamsungTV1f(guiObject, counter++));
92   populateKeyset(new SamsungTV2(guiObject, counter++));
93   populateKeyset(new SamsungTV2a(guiObject, counter++));
94   populateKeyset(new SamsungVCR1(guiObject, counter++));
95   populateKeyset(new SamsungVCR1a(guiObject, counter++));
96   populateKeyset(new SamsungVCR1b(guiObject, counter++));
97   populateKeyset(new SamsungVCR1c(guiObject, counter++));
98   populateKeyset(new SamsungVCR1d(guiObject, counter++));
99   populateKeyset(new SamsungVCR1e(guiObject, counter++));
100   populateKeyset(new SamsungDVD1(guiObject, counter++));
101   populateKeyset(new SamsungDVD1a(guiObject, counter++));
102   populateKeyset(new SamsungDVD1b(guiObject, counter++));
103   populateKeyset(new SamsungDVD2(guiObject, counter++));
104   populateKeyset(new SamsungAC1(guiObject, counter++));
105   populateKeyset(new SanyoTV1(guiObject, counter++));
106   populateKeyset(new SanyoTV2(guiObject, counter++));
107   populateKeyset(new SanyoVCR1(guiObject, counter++));
108   populateKeyset(new SharpTV1(guiObject, counter++));
109   populateKeyset(new SharpTV1a(guiObject, counter++));
110   populateKeyset(new SharpTV1b(guiObject, counter++));
111   populateKeyset(new SharpTV1c(guiObject, counter++));
112   populateKeyset(new SharpTV1d(guiObject, counter++));
113   populateKeyset(new SharpTV1e(guiObject, counter++));
114   populateKeyset(new SharpVCR1(guiObject, counter++));
115   populateKeyset(new SharpReceiver1(guiObject, counter++));
116   populateKeyset(new SonyTV1(guiObject, counter++));
117   populateKeyset(new SonyTV1a(guiObject, counter++));
118   populateKeyset(new SonyTV1b(guiObject, counter++));
119   populateKeyset(new SonyTV1d(guiObject, counter++));
120   populateKeyset(new SonyAmp1(guiObject, counter++));
121   populateKeyset(new SonyAmp2(guiObject, counter++));
122   populateKeyset(new SonyCD1(guiObject, counter++));
123   populateKeyset(new SonyCD2(guiObject, counter++));
124   populateKeyset(new SonyCD3(guiObject, counter++));
125   populateKeyset(new SonyDAT1(guiObject, counter++));
126   populateKeyset(new SonyDVD1(guiObject, counter++));
127   populateKeyset(new SonyDVD1a(guiObject, counter++));
128   populateKeyset(new SonyDVD1b(guiObject, counter++));
129   populateKeyset(new SonyDVD1c(guiObject, counter++));
130   populateKeyset(new SonyVCR1(guiObject, counter++));
131   populateKeyset(new SonyVCR1a(guiObject, counter++));
132   populateKeyset(new SonyReceiver1(guiObject, counter++));
133   populateKeyset(new ToshibaTV1(guiObject, counter++));
134   populateKeyset(new ToshibaTV1a(guiObject, counter++));
135   populateKeyset(new ToshibaTV1b(guiObject, counter++));
136   populateKeyset(new ToshibaTV1c(guiObject, counter++));
137   populateKeyset(new ToshibaTV1d(guiObject, counter++));
138   populateKeyset(new ToshibaTV1e(guiObject, counter++));
139   populateKeyset(new ToshibaVCR1(guiObject, counter++));
140   populateKeyset(new ToshibaVCR1a(guiObject, counter++));
141   populateKeyset(new ToshibaDisc1(guiObject, counter++));
142   populateKeyset(new ToshibaDisc1a(guiObject, counter++));
143   populateKeyset(new ToshibaDisc1b(guiObject, counter++));
144   populateKeyset(new ToshibaDisc1c(guiObject, counter++));
145   populateKeyset(new ToshibaDisc1d(guiObject, counter++));
146   populateKeyset(new ZenithC32V37(guiObject, counter++));
148   // Start the thread running:
149   commandThread.start();
153 PIRKeysetManager::~PIRKeysetManager()
155   // Tell the keysets to stop doing any work:
156   stopRepeating();
158   // Tell the thread that we want it to stop:
159   commandThread.exit();
161   // Wait for the thread to stop:
162   commandThread.wait();
164   // Delete all the keysets:
165   PIRKeysetCollection::iterator i = keysetsInfo.begin();
166   while (i != keysetsInfo.end())
167   {
168     if ((*i).second) delete (*i).second;
169     ++i;
170   }
174 void PIRKeysetManager::stopRepeating()
176   QMutexLocker locker(&stopRepeatingMutex);
177   stopRepeatingFlag = true;
181 bool PIRKeysetManager::hasKey(
182   int keysetID,
183   PIRKeyName name)
185   PIRKeysetMetaData *meta = keysetsInfo[keysetID];
187   if (!meta) return false;
189   return meta->hasKey(name);
193 PIRMakeName PIRKeysetManager::getMake(
194   int keysetID)
196   PIRKeysetMetaData *meta = keysetsInfo[keysetID];
198   if (!meta) return Any_Make; // Work on this!
200   return meta->getMake();
204 QString PIRKeysetManager::getDisplayName(
205   int keysetID)
207   PIRKeysetMetaData *meta = keysetsInfo[keysetID];
209   if (!meta) return QString("Database Error");
211   return QString(meta->getKeysetName());
215 void PIRKeysetManager::populateKeyset(
216   PIRKeysetMetaData *keyset)
218   keysetsInfo[keyset->getID()] = keyset;
220   keyset->moveProtocolToThread(commandThread);
224 void PIRKeysetManager::populateGuiWidget(
225   SelectionWindow *widget)
227   PIRKeysetCollection::const_iterator i = keysetsInfo.begin();
229   PIRMakeName make;
231   while (i != keysetsInfo.end())
232   {
233     make = i->second->getMake();
234     QString tempString = makeManager.getMakeString(make);
235     tempString.append(" ");
236     tempString.append(i->second->getKeysetName());
237     widget->addNameToList(tempString, i->first, make);
238     ++i;
239   }

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment