#include #include #include "infrared.h" #include using namespace std; extern HostParms hostparm; // READS IN REMOTES DESIGNATED AS favorites HostRemoteTypeIR_favorites::HostRemoteTypeIR_favorites(): HostImageSelect("HostRemoteType_favorites") { setLabel(QObject::tr("Remote")); QString dirtxt; QString previewpath; //scan templates dirtxt=MV_ROOT; dirtxt.append("templates/remotes/favorites"); QDir remotes_global(dirtxt); remotes_global.setFilter(QDir::Dirs); remotes_global.setSorting(QDir::Name | QDir::IgnoreCase); QFileInfoList fil_global = remotes_global.entryInfoList(QDir::Dirs); QString previewpath_global; previewpath_global = dirtxt; for( QFileInfoList::iterator it = fil_global.begin(); it != fil_global.end(); ++it ) { QFileInfo &remote = *it; previewpath=dirtxt; previewpath+="/"; previewpath+=remote.fileName() ; previewpath+="/preview.jpg" ; QFileInfo preview_global(previewpath); if ( !preview_global.exists() ) { continue; } QImage* previewImage = new QImage(preview_global.absoluteFilePath()); addImageSelection(remote.fileName(), previewImage); } }; // READS IN REMOTES DESIGNATED AS OTHER HostRemoteTypeIR_other::HostRemoteTypeIR_other(): HostImageSelect("HostRemoteType_other") { setLabel(QObject::tr("Remote")); QString dirtxt; QString previewpath; //scan templates dirtxt=MV_ROOT; dirtxt.append("templates/remotes/other"); QDir remotes_global(dirtxt); remotes_global.setFilter(QDir::Dirs); remotes_global.setSorting(QDir::Name | QDir::IgnoreCase); QFileInfoList fil_global = remotes_global.entryInfoList(QDir::Dirs); QString previewpath_global; previewpath_global = dirtxt; for( QFileInfoList::iterator it = fil_global.begin(); it != fil_global.end(); ++it ) { QFileInfo &remote = *it; previewpath=dirtxt; previewpath+="/"; previewpath+=remote.fileName() ; previewpath+="/preview.jpg" ; QFileInfo preview_global(previewpath); if ( !preview_global.exists() ) { continue; } QImage* previewImage = new QImage(preview_global.absoluteFilePath()); addImageSelection(remote.fileName(), previewImage); } }; // READS IN REMOTES DESIGNATED AS hauppauge HostRemoteTypeIR_hauppauge::HostRemoteTypeIR_hauppauge(): HostImageSelect("HostRemoteType_hauppauge") { setLabel(QObject::tr("Remote")); QString dirtxt; QString previewpath; //scan templates dirtxt=MV_ROOT; dirtxt.append("templates/remotes/hauppauge"); QDir remotes_global(dirtxt); remotes_global.setFilter(QDir::Dirs); remotes_global.setSorting(QDir::Name | QDir::IgnoreCase); QFileInfoList fil_global = remotes_global.entryInfoList(QDir::Dirs); QString previewpath_global; previewpath_global = dirtxt; for( QFileInfoList::iterator it = fil_global.begin(); it != fil_global.end(); ++it ) { QFileInfo &remote = *it; previewpath=dirtxt; previewpath+="/"; previewpath+=remote.fileName() ; previewpath+="/preview.jpg" ; QFileInfo preview_global(previewpath); if ( !preview_global.exists() ) { continue; } QImage* previewImage = new QImage(preview_global.absoluteFilePath()); addImageSelection(remote.fileName(), previewImage); } }; // READS IN REMOTES DESIGNATED AS ATI HostRemoteTypeIR_ATI::HostRemoteTypeIR_ATI(): HostImageSelect("HostRemoteType_ATI") { setLabel(QObject::tr("Remote")); QString dirtxt; QString previewpath; //scan templates dirtxt=MV_ROOT; dirtxt.append("templates/remotes/ATI"); QDir remotes_global(dirtxt); remotes_global.setFilter(QDir::Dirs); remotes_global.setSorting(QDir::Name | QDir::IgnoreCase); QFileInfoList fil_global = remotes_global.entryInfoList(QDir::Dirs); QString previewpath_global; previewpath_global = dirtxt; for( QFileInfoList::iterator it = fil_global.begin(); it != fil_global.end(); ++it ) { QFileInfo &remote = *it; previewpath=dirtxt; previewpath+="/"; previewpath+=remote.fileName() ; previewpath+="/preview.jpg" ; QFileInfo preview_global(previewpath); if ( !preview_global.exists() ) { continue; } QImage* previewImage = new QImage(preview_global.absoluteFilePath()); addImageSelection(remote.fileName(), previewImage); } }; // READS IN REMOTES DESIGNATED AS USER HostRemoteTypeIR_user::HostRemoteTypeIR_user(): HostImageSelect("HostRemoteType_user") { setLabel(QObject::tr("Remote")); QString dirtxt; QString previewpath; //scan home dir $HOME/remotes dirtxt=QDir::homePath() ; dirtxt.append("/remotes"); QDir remotes_global(dirtxt); remotes_global.setFilter(QDir::Dirs); remotes_global.setSorting(QDir::Name | QDir::IgnoreCase); QFileInfoList fil_global = remotes_global.entryInfoList(QDir::Dirs); QString previewpath_global; previewpath_global = dirtxt; int count = 0; for( QFileInfoList::iterator it = fil_global.begin(); it != fil_global.end(); ++it ) { QFileInfo &remote = *it; previewpath=dirtxt; previewpath+="/"; previewpath+=remote.fileName() ; previewpath+="/preview.jpg" ; QFileInfo preview_global(previewpath); if ( !preview_global.exists() ) { continue; } QImage* previewImage = new QImage(preview_global.absoluteFilePath()); addImageSelection(remote.fileName(), previewImage); count++; } QFileInfo preview_global(previewpath); QImage* previewImage = new QImage(preview_global.absoluteFilePath()); if ( count == 0 ) addImageSelection("none found", previewImage); }; static HostComboBox *HostReceiverType() { HostComboBox *gc = new HostComboBox("HostReceiverType"); gc->setLabel(QObject::tr("Receiver")); gc->addSelection("Default"); gc->addSelection("tinker"); gc->addSelection("serial"); gc->addSelection("streamzap"); gc->addSelection("mce"); //gc->addSelection("imon"); gc->addSelection("Hauppauge"); gc->addSelection("hd_pvr"); gc->addSelection("CommandIR"); gc->addSelection("iguanaIR-usb"); gc->addSelection("SiliconDust_HDHR"); gc->setHelpText(QObject::tr("The type of infrared receiver used. Default will use ALL remote devices found.")); gc->setValue("Default"); return gc; }; static HostComboBox *HostSerialPortlirc() { HostComboBox *gc = new HostComboBox("HostSerialPortlirc",false); gc->setLabel(QObject::tr("Serial Port")); gc->addSelection("ttyS0"); gc->addSelection("ttyS1"); gc->addSelection("ttyS2"); gc->addSelection("ttyS3"); gc->setHelpText(QObject::tr("Serial port with the lirc receiver or transmitter")); return gc; } static HostComboBox *HostHDHRlirc_device() { QString temphdhr; temphdhr = gCoreContext->GetSetting("HostHDHRlirc_device"); MSqlQuery query(MSqlQuery::InitCon()); query.prepare( "delete from settings where hostname=:HOSTNAME and value = 'HostHDHRlirc_device'; " ); query.bindValue( ":HOSTNAME" , gCoreContext->GetHostName() ); query.exec(); HostComboBox *gc = new HostComboBox("HostHDHRlirc_device",false); system ("hdhomerun_config discover > /tmp/.hdhrdiscover"); gc->setLabel(QObject::tr("HDHR device")); gc->setHelpText(QObject::tr("HDHomeRun device to use as remote receiver. Identifier listed is the Device id found on the bottom of the HDHomeRun.")); QString currentitem; QString line; QFile file("/tmp/.hdhrdiscover"); bool foundhdhr; foundhdhr = false; if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) { QTextStream t( &file ); // use a text stream while ( !t.atEnd() ) { line = t.readLine(); if ( line.startsWith("hdhomerun device")) { currentitem = line.section( " ", 2, 2 ); gc->addSelection(currentitem); foundhdhr = true; } } file.close(); } //These are all hoops to jump through to clear out the device list and save when the combobox isn't touched by the user and they just accept the defaults if ( foundhdhr == false ) { gc->clearSelections(); gc->addSelection("No devices found"); gc->setValue("No devices found"); gCoreContext->SaveSetting("HostHDHRlirc_device","No devices found"); } else { int findhdhr=gc->findSelection(temphdhr); //JM VERBOSE(VB_IMPORTANT, findhdhr); if ( findhdhr > -1 ) { gc->addSelection(temphdhr); gc->setValue(temphdhr); gCoreContext->SaveSetting("HostHDHRlirc_device", temphdhr ); } else { gCoreContext->SaveSetting("HostHDHRlirc_device", gc->getValue()); } } return gc; } class LIRC_ReceiverSettings: public TriggeredConfigurationGroup { public: LIRC_ReceiverSettings(): TriggeredConfigurationGroup(false, false, true, true,false, false, true, true) { Setting* trigger = HostReceiverType() ; addChild(trigger); setTrigger(trigger); ConfigurationGroup* blanksettings = new GridConfigurationGroup(2,true); ConfigurationGroup* settings = new GridConfigurationGroup(2,true); settings->addChild(HostSerialPortlirc()); ConfigurationGroup* hdhrsettings = new GridConfigurationGroup(2,true); hdhrsettings->addChild(HostHDHRlirc_device()); addTarget("Default", blanksettings); addTarget("tinker", blanksettings ); addTarget("serial", settings); addTarget("imon", blanksettings ); //addTarget("Hauppauge",blanksettings); addTarget("hd_pvr",blanksettings); addTarget("CommandIR", blanksettings); addTarget("iguanaIR-usb", blanksettings); addTarget("mce", blanksettings); addTarget("streamzap", blanksettings); addTarget("SiliconDust_HDHR", hdhrsettings); }; }; static HostComboBox *HostRemotebucket() { HostComboBox *gc = new HostComboBox("HostRemotebucket"); gc->setLabel(QObject::tr("Remote Class")); gc->addSelection("favorites"); gc->addSelection("hauppauge"); gc->addSelection("ATI"); gc->addSelection("user"); gc->addSelection("other"); gc->setHelpText(QObject::tr("Remote classification. Favorites are remotes fully supported by LinHES.")); return gc; }; class Remote_bucket: public TriggeredConfigurationGroup { public: Remote_bucket(): TriggeredConfigurationGroup(false, false, true, true,false, false, true, true) { Setting* trigger = HostRemotebucket() ; addChild(trigger); setTrigger(trigger); ConfigurationGroup* blanksettings = new GridConfigurationGroup(2,true); ConfigurationGroup* favorites_def = new GridConfigurationGroup(2,true); favorites_def-> addChild(new HostRemoteTypeIR_favorites()); ConfigurationGroup* other_def = new GridConfigurationGroup(2,true); other_def-> addChild(new HostRemoteTypeIR_other()); ConfigurationGroup* hauppauge_def = new GridConfigurationGroup(2,true); hauppauge_def-> addChild(new HostRemoteTypeIR_hauppauge()); ConfigurationGroup* ATI_def = new GridConfigurationGroup(2,true); ATI_def-> addChild(new HostRemoteTypeIR_ATI()); ConfigurationGroup* user_def = new GridConfigurationGroup(2,true); user_def-> addChild(new HostRemoteTypeIR_user()); addTarget("favorites", favorites_def); addTarget("hauppauge", hauppauge_def); addTarget("ATI", ATI_def); addTarget("user", user_def); addTarget("other", other_def); }; }; IRFrame::IRFrame(): VerticalConfigurationGroup(false,false,false,false) { setLabel(QObject::tr("Remotes Settings")); LIRC_ReceiverSettings *receiversettings = new LIRC_ReceiverSettings(); //addChild(new HostRemoteTypeIR()); addChild(new Remote_bucket()); addChild(receiversettings); } //----------------transmit settings-------------- static HostComboBox *HostTransmitproto_1() { HostComboBox *gc = new HostComboBox("HostTransmitproto_1",false); gc->setLabel(QObject::tr("Transmitter 1")); gc->addSelection("none"); gc->setValue(0); gc->setHelpText(QObject::tr("Remote codes to control a cable box")); QString dirtxt; dirtxt=MV_ROOT; dirtxt.append("templates/transmit"); QDir transmit(dirtxt); transmit.setFilter(QDir::Dirs); transmit.setSorting(QDir::Name | QDir::IgnoreCase); QFileInfoList fil = transmit.entryInfoList(QDir::Dirs); for( QFileInfoList::iterator it = fil.begin(); it != fil.end(); ++it ) { QFileInfo ¤titem = *it; // //JM VERBOSE(VB_IMPORTANT, currentitem.fileName()); if ( currentitem.fileName() != ".." && currentitem.fileName() != "." && currentitem.fileName() != "") { gc->addSelection(currentitem.fileName()); } } return gc; }; static HostComboBox *HostTransmitproto_2() { HostComboBox *gc = new HostComboBox("HostTransmitproto_2",false); gc->setLabel(QObject::tr("Transmitter 2")); gc->addSelection("none"); gc->setValue(0); gc->setHelpText(QObject::tr("Remote codes to control a cable box")); QString dirtxt; dirtxt=MV_ROOT; dirtxt.append("templates/transmit"); QDir transmit(dirtxt); transmit.setFilter(QDir::Dirs); transmit.setSorting(QDir::Name | QDir::IgnoreCase); QFileInfoList fil = transmit.entryInfoList(QDir::Dirs); for( QFileInfoList::iterator it = fil.begin(); it != fil.end(); ++it ) { QFileInfo ¤titem = *it; // //JM VERBOSE(VB_IMPORTANT, currentitem.fileName()); if ( currentitem.fileName() != ".." && currentitem.fileName() != "." && currentitem.fileName() != "") { gc->addSelection(currentitem.fileName()); } } return gc; }; static HostComboBox *HostTransmitproto_3() { HostComboBox *gc = new HostComboBox("HostTransmitproto_3",false); gc->setLabel(QObject::tr("Transmitter 3")); gc->addSelection("none"); gc->setValue(0); gc->setHelpText(QObject::tr("Remote codes to control a cable box")); QString dirtxt; dirtxt=MV_ROOT; dirtxt.append("templates/transmit"); QDir transmit(dirtxt); transmit.setFilter(QDir::Dirs); QFileInfoList fil = transmit.entryInfoList(QDir::Dirs); for( QFileInfoList::iterator it = fil.begin(); it != fil.end(); ++it ) { QFileInfo ¤titem = *it; // //JM VERBOSE(VB_IMPORTANT, currentitem.fileName()); if ( currentitem.fileName() != ".." && currentitem.fileName() != "." && currentitem.fileName() != "") { gc->addSelection(currentitem.fileName()); } } return gc; }; static HostComboBox *HostTransmitproto_4() { HostComboBox *gc = new HostComboBox("HostTransmitproto_4",false); gc->setLabel(QObject::tr("Transmitter 4")); gc->addSelection("none"); gc->setValue(0); gc->setHelpText(QObject::tr("Remote codes to control a cable box")); QString dirtxt; dirtxt=MV_ROOT; dirtxt.append("templates/transmit"); QDir transmit(dirtxt); QFileInfoList fil = transmit.entryInfoList(QDir::Dirs); for( QFileInfoList::iterator it = fil.begin(); it != fil.end(); ++it ) { QFileInfo ¤titem = *it; // //JM VERBOSE(VB_IMPORTANT, currentitem.fileName()); if ( currentitem.fileName() != ".." && currentitem.fileName() != "." && currentitem.fileName() != "") { gc->addSelection(currentitem.fileName()); } } return gc; }; static HostComboBox *HostBlasterType() { HostComboBox *gc = new HostComboBox("HostBlasterType"); gc->setLabel(QObject::tr("Blaster")); gc->addSelection("None"); gc->addSelection("Receiver"); gc->addSelection("serial"); gc->addSelection("CommandIR"); //gc->addSelection("Hauppauge"); gc->addSelection("mce"); //gc->addSelection("pvr150"); gc->addSelection("iguanaIR-usb"); gc->addSelection("hd_pvr"); gc->setHelpText(QObject::tr("The type of infrared transmitter being used. Receiver will use the receiver settings. Selecting CommandIR or iguanaIR-usb will use that device for both transmitting and receiving. All other receivers will be disabled.")); gc->setValue("None"); return gc; }; static HostComboBox *HostSerialPort_blasterlirc() { HostComboBox *gc = new HostComboBox("HostSerialPort_blasterlirc",false); gc->setLabel(QObject::tr("Serial Port")); gc->addSelection("ttyS0"); gc->addSelection("ttyS1"); gc->addSelection("ttyS2"); gc->addSelection("ttyS3"); gc->setHelpText(QObject::tr("Serial port with the lirc transmitter")); return gc; } static HostSpinBox *HostTransmitDelay_1() { HostSpinBox *gc = new HostSpinBox("HostTransmitDelay_1", 1 , 200, 1, true); gc->setLabel(QObject::tr("Delay")); gc->setValue(2); gc->setHelpText(QObject::tr("Amount of delay in tenths of a second between transmits")); return gc; } static HostComboBox *HostTransmitSend_after_1() { HostComboBox *gc = new HostComboBox("HostTransmitSend_after_1",false); gc->setLabel(QObject::tr("Key:")); gc->addSelection("Enter"); gc->addSelection("Select"); gc->setHelpText(QObject::tr("Name of the key to send after transmitting the numbers. For example Enter or Select")); return gc; } static HostSpinBox *HostTransmitDelay_2() { HostSpinBox *gc = new HostSpinBox("HostTransmitDelay_2", 1 , 200, 1, true); gc->setLabel(QObject::tr("Delay")); gc->setValue(2); gc->setHelpText(QObject::tr("Amount of delay in tenths of a second between transmits")); return gc; } static HostComboBox *HostTransmitSend_after_2() { HostComboBox *gc = new HostComboBox("HostTransmitSend_after_2",false); gc->setLabel(QObject::tr("Key:")); gc->addSelection("Enter"); gc->addSelection("Select"); gc->setHelpText(QObject::tr("Name of the key to send after transmitting the numbers. For example Enter or Select")); return gc; } static HostSpinBox *HostTransmitDelay_3() { HostSpinBox *gc = new HostSpinBox("HostTransmitDelay_3", 1 , 200, 1, true); gc->setLabel(QObject::tr("Delay")); gc->setValue(2); gc->setHelpText(QObject::tr("Amount of delay in tenths of a second between transmits")); return gc; } static HostComboBox *HostTransmitSend_after_3() { HostComboBox *gc = new HostComboBox("HostTransmitSend_after_3",false); gc->setLabel(QObject::tr("Key:")); gc->addSelection("Enter"); gc->addSelection("Select"); gc->setHelpText(QObject::tr("Name of the key to send after transmitting the numbers. For example Enter or Select")); return gc; } static HostSpinBox *HostTransmitDelay_4() { HostSpinBox *gc = new HostSpinBox("HostTransmitDelay_4", 1 , 200, 1, true); gc->setLabel(QObject::tr("Delay")); gc->setValue(2); gc->setHelpText(QObject::tr("Amount of delay in tenths of a second between transmits")); return gc; } static HostComboBox *HostTransmitSend_after_4() { HostComboBox *gc = new HostComboBox("HostTransmitSend_after_4",false); gc->setLabel(QObject::tr("Key:")); gc->addSelection("Enter"); gc->addSelection("Select"); gc->setHelpText(QObject::tr("Name of the key to send after transmitting the numbers. For example Enter or Select")); return gc; } class LIRC_BlasterSettings: public TriggeredConfigurationGroup { public: LIRC_BlasterSettings(): TriggeredConfigurationGroup(false, false, true, true,false, false, true, true) { Setting* trigger = HostBlasterType() ; addChild(trigger); setTrigger(trigger); ConfigurationGroup* blanksettings = new GridConfigurationGroup(2,true); ConfigurationGroup* transmit_1 = new GridConfigurationGroup(3,true); transmit_1->addChild(HostTransmitproto_1()); transmit_1->addChild(HostTransmitDelay_1()); //transmit_1->addChild(HostTransmitSend_after_1()); ConfigurationGroup* transmit_2 = new GridConfigurationGroup(3,true); transmit_2->addChild(HostTransmitproto_2()); transmit_2->addChild(HostTransmitDelay_2()); //transmit_2->addChild(HostTransmitSend_after_2()); ConfigurationGroup* transmit_3 = new GridConfigurationGroup(3,true); transmit_3->addChild(HostTransmitproto_3()); transmit_3->addChild(HostTransmitDelay_3()); //transmit_3->addChild(HostTransmitSend_after_3()); ConfigurationGroup* transmit_4 = new GridConfigurationGroup(3,true); transmit_4->addChild(HostTransmitproto_4()); transmit_4->addChild(HostTransmitDelay_4()); //transmit_4->addChild(HostTransmitSend_after_4()); ConfigurationGroup* CommandIRsettings = new GridConfigurationGroup(1,true); CommandIRsettings->addChild(transmit_1); CommandIRsettings->addChild(transmit_2); CommandIRsettings->addChild(transmit_3); CommandIRsettings->addChild(transmit_4); ConfigurationGroup* mcesettings = new GridConfigurationGroup(1,true); mcesettings->addChild(transmit_1); mcesettings->addChild(transmit_2); ConfigurationGroup* serial_settings = new GridConfigurationGroup(1,true); serial_settings->addChild(HostSerialPort_blasterlirc()); serial_settings->addChild(transmit_1); addTarget("None", blanksettings); addTarget("Receiver", transmit_1); addTarget("serial", serial_settings); addTarget("CommandIR", CommandIRsettings); //addTarget("pvr150",blanksettings); addTarget("hd_pvr",transmit_1); addTarget("mce",mcesettings); addTarget("iguanaIR-usb",mcesettings); // addTarget("tinker", blanksettings ); }; }; IR_TransmitFrame::IR_TransmitFrame(): VerticalConfigurationGroup(false,false,false,false) { setLabel(QObject::tr("Blaster Settings")); LIRC_BlasterSettings *blastersettings = new LIRC_BlasterSettings(); addChild(blastersettings); } //------------------LCD settings------------- static HostComboBox *HostLCDType() { HostComboBox *gc = new HostComboBox("HostLCDType",false); gc->setLabel(QObject::tr("LCD/VFD model")); gc->addSelection("no_lcd"); gc->addSelection("tinker"); gc->setValue(0); gc->setHelpText(QObject::tr("VFD or LCD")); QString dirtxt; dirtxt=MV_ROOT; dirtxt.append("templates/LCD"); QDir transmit(dirtxt); transmit.setFilter(QDir::Dirs); QFileInfoList fil = transmit.entryInfoList(QDir::Dirs); for( QFileInfoList::iterator it = fil.begin(); it != fil.end(); ++it ) { QFileInfo ¤titem = *it; //JM VERBOSE(VB_IMPORTANT, currentitem.fileName()); if ( currentitem.fileName() != ".." && currentitem.fileName() != "." && currentitem.fileName() != "") { gc->addSelection(currentitem.fileName()); } } return gc; }; LCDFrame::LCDFrame(): VerticalConfigurationGroup(false,false,false,false) { setLabel(QObject::tr("LCD Settings")); addChild(HostLCDType()); }