1 #include "pirkeysetmetadata.h"
2 #include "pirselectdeviceform.h"
3 #include "pirkeysetwidgetitem.h"
4 #include "protocols/pirprotocol.h"
8 // Global helper object:
9 extern PIRMakeMgr makeManager;
11 // Static member definition:
12 PIRDeviceCollection PIRKeysetMetaData::controlledDevices;
14 // Thread synchronization stuff:
15 extern bool commandInFlight;
17 PIRKeysetMetaData::PIRKeysetMetaData(
21 : threadableProtocol(NULL),
29 PIRKeysetMetaData::~PIRKeysetMetaData()
35 bool PIRKeysetMetaData::hasKey(
36 PIRKeyName name) const
38 return (keys.find(name) != keys.end());
42 void PIRKeysetMetaData::moveToThread(
45 if (threadableProtocol)
47 // Do I need some error checking here?
48 threadableProtocol->moveToThread(thread);
53 void PIRKeysetMetaData::populateDevices(
54 PIRSelectDeviceForm *sdf)
56 PIRKeysetWidgetItem *kwi;
58 PIRDeviceCollection::const_iterator i = controlledDevices.begin();
60 while (i != controlledDevices.end())
62 // Create a widget for the keyset:
63 QString tempString = makeManager.getMakeString(i->first.make);
64 tempString.append(" ");
65 tempString.append(i->first.model);
67 kwi = new PIRKeysetWidgetItem(
68 tempString, i->first.model, i->second, i->first.make, i->first.type);
70 sdf->addWidgetItem(kwi);
77 unsigned int PIRKeysetMetaData::getID() const
83 PIRMakeName PIRKeysetMetaData::getMake() const
88 const char *PIRKeysetMetaData::getKeysetName() const
94 void PIRKeysetMetaData::addControlledDevice(
97 PIRDeviceTypeName type)
99 controlledDevices.insert(
101 DeviceInfo(make, model, type),
106 void PIRKeysetMetaData::addKey(
112 // Don't have a system for the unmapped keys yet!
113 if (key != Unmapped_Key)
117 threadableProtocol->addKey(key, data, size);
122 void PIRKeysetMetaData::addSIRC12Key(
125 unsigned int addressData,
126 unsigned int commandData)
128 if (key != Unmapped_Key)
131 threadableProtocol->addSIRCKey(key, addressData, 5, commandData);
136 void PIRKeysetMetaData::addSIRC15Key(
139 unsigned int addressData,
140 unsigned int commandData)
142 if (key != Unmapped_Key)
145 threadableProtocol->addSIRCKey(key, addressData, 8, commandData);
150 void PIRKeysetMetaData::addSIRC20Key(
153 unsigned int secondaryAddressData,
154 unsigned int primaryAddressData,
155 unsigned int commandData)
157 if (key != Unmapped_Key)
160 threadableProtocol->addSIRC20Key(
161 key, secondaryAddressData, primaryAddressData, commandData);
166 void PIRKeysetMetaData::addSharpKey(
169 unsigned int addressData,
170 unsigned int commandData)
172 if (key != Unmapped_Key)
175 threadableProtocol->addSharpKey(key, addressData, commandData);
180 void PIRKeysetMetaData::addNECKey(
183 unsigned int addressData,
184 unsigned int commandData)
186 if (key != Unmapped_Key)
189 threadableProtocol->addNECKey(key, addressData, commandData);
194 void PIRKeysetMetaData::addPanOldKey(
197 unsigned int addressData,
198 unsigned int commandData)
200 if (key != Unmapped_Key)
203 threadableProtocol->addPanOldKey(key, addressData, commandData);
208 void PIRKeysetMetaData::addPioneerKey(
211 unsigned int addressOne,
212 unsigned int commandOne,
213 unsigned int addressTwo,
214 unsigned int commandTwo)
216 if (key != Unmapped_Key)
219 threadableProtocol->addPioneerKey(
220 key, addressOne, commandOne, addressTwo, commandTwo);
226 void PIRKeysetMetaData::addRCAKey(
229 unsigned int addressData,
230 unsigned int commandData)
232 if (key != Unmapped_Key)
235 threadableProtocol->addPioneerKey(
236 key, addressData, commandData);
242 void PIRKeysetMetaData::addKaseikyoKey(
245 unsigned int addressData,
246 unsigned int commandData)
248 if (key != Unmapped_Key)
251 threadableProtocol->addKaseikyoKey(key, addressData, commandData);
256 void PIRKeysetMetaData::addDishKey(
259 unsigned int firstCommand,
260 unsigned int secondCommand)
262 if (key != Unmapped_Key)
265 threadableProtocol->addDishKey(key, firstCommand, secondCommand);
270 void PIRKeysetMetaData::addXMPKey(
273 unsigned int firstCommand,
274 unsigned int secondCommand)
276 if (key != Unmapped_Key)
279 threadableProtocol->addXMPKey(key, firstCommand, secondCommand);
284 void PIRKeysetMetaData::setPreData(
288 threadableProtocol->setPreData(data, bits);
292 void PIRKeysetMetaData::setPostData(
296 threadableProtocol->setPostData(data, bits);
300 void PIRKeysetMetaData::setKeysetName(
307 bool PIRKeysetMetaData::clearProtocol()
309 if (!threadableProtocol)
313 else if (!commandInFlight)
315 delete threadableProtocol;
316 threadableProtocol = 0;