From ae35100db0302f629251d4a8b4f976bea8afbdd3 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 25 Aug 2015 00:26:06 -0500 Subject: [PATCH] Add preliminary cryptographic card support to the TDE hardware device manager --- kcontrol/hwmanager/devicepropsdlg.cpp | 35 +++++++++++++++ kcontrol/hwmanager/devicepropsdlg.h | 4 ++ kcontrol/hwmanager/devicepropsdlgbase.ui | 54 ++++++++++++++++++++++++ kcontrol/hwmanager/hwmanager.cpp | 11 +++++ 4 files changed, 104 insertions(+) diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp index 12de8cea9..b14177ca3 100644 --- a/kcontrol/hwmanager/devicepropsdlg.cpp +++ b/kcontrol/hwmanager/devicepropsdlg.cpp @@ -283,6 +283,9 @@ DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidge if (m_device->type() != TDEGenericDeviceType::Event) { base->tabBarWidget->removePage(base->tabEvent); } + if (m_device->type() != TDEGenericDeviceType::CryptographicCard) { + base->tabBarWidget->removePage(base->tabCryptographicCard); + } if (m_device->type() == TDEGenericDeviceType::CPU) { connect(base->comboCPUGovernor, TQT_SIGNAL(activated(const TQString &)), this, TQT_SLOT(setCPUGovernor(const TQString &))); @@ -753,6 +756,38 @@ void DevicePropertiesDialog::populateDeviceInformation() { } base->labelEventSwitchActive->setText(activeSwitches); } + + if (m_device->type() == TDEGenericDeviceType::CryptographicCard) { + TDECryptographicCardDevice* cdevice = static_cast(m_device); + + connect(cdevice, TQT_SIGNAL(cardInserted()), this, TQT_SLOT(cryptographicCardInserted())); + connect(cdevice, TQT_SIGNAL(cardRemoved()), this, TQT_SLOT(cryptographicCardRemoved())); + + updateCryptographicCardStatusDisplay(); + } + } +} + +void DevicePropertiesDialog::cryptographicCardInserted() { + updateCryptographicCardStatusDisplay(); +} + +void DevicePropertiesDialog::cryptographicCardRemoved() { + updateCryptographicCardStatusDisplay(); +} + +void DevicePropertiesDialog::updateCryptographicCardStatusDisplay() { + TDECryptographicCardDevice* cdevice = static_cast(m_device); + + int status = cdevice->cardPresent(); + if ((status < 0) ||(status > 1)) { + base->labelCardStatus->setText(i18n("Unknown")); + } + else if (status == 0) { + base->labelCardStatus->setText(i18n("Empty")); + } + else if (status == 1) { + base->labelCardStatus->setText(i18n("Inserted") + TQString("
") + i18n("ATR: %1").arg(cdevice->cardATR())); } } diff --git a/kcontrol/hwmanager/devicepropsdlg.h b/kcontrol/hwmanager/devicepropsdlg.h index bbff43977..0b8553c96 100644 --- a/kcontrol/hwmanager/devicepropsdlg.h +++ b/kcontrol/hwmanager/devicepropsdlg.h @@ -191,6 +191,10 @@ private slots: void mountDisk(); void unmountDisk(); + void cryptographicCardInserted(); + void cryptographicCardRemoved(); + void updateCryptographicCardStatusDisplay(); + private: TDEGenericDevice* m_device; DevicePropertiesDialogBase* base; diff --git a/kcontrol/hwmanager/devicepropsdlgbase.ui b/kcontrol/hwmanager/devicepropsdlgbase.ui index 74afdf5f3..1be078c43 100644 --- a/kcontrol/hwmanager/devicepropsdlgbase.ui +++ b/kcontrol/hwmanager/devicepropsdlgbase.ui @@ -1528,6 +1528,60 @@ + + + tabCryptographicCard + + + Cryptographic Card + + + + unnamed + + + + groupInput + + + Card Status + + + + unnamed + + + + labelCardStatus + + + + + + AlignTop|AlignLeft + + + + + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + diff --git a/kcontrol/hwmanager/hwmanager.cpp b/kcontrol/hwmanager/hwmanager.cpp index a82daf1be..00b5143bf 100644 --- a/kcontrol/hwmanager/hwmanager.cpp +++ b/kcontrol/hwmanager/hwmanager.cpp @@ -47,6 +47,8 @@ #include #include +#include + #include "hwmanager.h" using namespace std; @@ -144,6 +146,9 @@ void TDEHWManager::populateTreeView() TDEGenericHardwareList hwlist = hwdevices->listByDeviceClass(TDEGenericDeviceType::RootSystem); TDEGenericDevice *hwdevice; for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { + if (hwdevice->type() == TDEGenericDeviceType::CryptographicCard) { + static_cast(hwdevice)->enableCardMonitoring(true); + } DeviceIconItem* item = new DeviceIconItem(base->deviceTree, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) { base->deviceTree->ensureItemVisible(item); @@ -160,6 +165,9 @@ void TDEHWManager::populateTreeView() TDEGenericDevice *hwdevice; TDEGenericHardwareList hwlist = hwdevices->listByDeviceClass((TDEGenericDeviceType::TDEGenericDeviceType)i); for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { + if (hwdevice->type() == TDEGenericDeviceType::CryptographicCard) { + static_cast(hwdevice)->enableCardMonitoring(true); + } DeviceIconItem* item = new DeviceIconItem(rootitem, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) { base->deviceTree->ensureItemVisible(item); @@ -177,6 +185,9 @@ void TDEHWManager::populateTreeViewLeaf(DeviceIconItem *parent, bool show_by_con TDEGenericHardwareList hwlist = hwdevices->listAllPhysicalDevices(); TDEGenericDevice *hwdevice; for ( hwdevice = hwlist.first(); hwdevice; hwdevice = hwlist.next() ) { + if (hwdevice->type() == TDEGenericDeviceType::CryptographicCard) { + static_cast(hwdevice)->enableCardMonitoring(true); + } if (hwdevice->parentDevice() == parent->device()) { DeviceIconItem* item = new DeviceIconItem(parent, hwdevice->detailedFriendlyName(), hwdevice->icon(base->deviceTree->iconSize()), hwdevice); if ((!selected_syspath.isNull()) && (hwdevice->systemPath() == selected_syspath)) {