VSCHddDevice::VSCHddDevice(QWidget *parent) : QDialog(parent) { m_SelectedDisk = 0; m_TotalDisks = 0; int i = 0; s8 DiskTitle[1024]; ui.setupUi(this); QList<QStorageInfo> hdd = QStorageInfo::mountedVolumes(); QListIterator<QStorageInfo> it(hdd); while(it.hasNext()) { QStorageInfo disk = it.next(); if (i >= VSC_SUPPORTED_DISKS) { break; } astring strHdd = disk.rootPath().toStdString(); VDC_DEBUG( "%s strHdd %s \n",__FUNCTION__, strHdd.c_str()); s64 totalSize = disk.bytesTotal() / (1024 * 1024); s64 leftSize = disk.bytesFree()/ (1024 * 1024); VDC_DEBUG( "%s Total %lld M Left %lld M \n",__FUNCTION__, totalSize, leftSize); QString strQtHdd = disk.rootPath(); HddDriveType diskType = HddGetDriveType(strQtHdd); VDC_DEBUG( "%s Type %d \n",__FUNCTION__, diskType); if (totalSize/1024 < 16 || leftSize/1024 < 4) { continue; } if (diskType == HddInternalDrive) { /* Add to UI */ m_Disks[i] = new VSCHddOne(false, i, strHdd, totalSize, leftSize, this); ui.verticalLayout->addWidget(m_Disks[i] ); if (i == 0) { m_Disks[i]->diskSetChecked(true); } m_TotalDisks ++; connect(m_Disks[i], SIGNAL(diskSelectedUpdated(int)), this, SLOT(masterDiskSelected(int))); i ++; } }
BOOL OAPIServer::ProcessGetSysDisk(s32 len) { if (len == 0) { return FALSE; } char *pRecv = new char[len + 1]; s32 nRetBody = m_pSocket->Recv((void *)pRecv, len); oapi::OAPISysDiskListReq req; if (nRetBody == len) { autojsoncxx::ParsingResult result; if (!autojsoncxx::from_json_string(pRecv, req, result)) { std::cerr << result << '\n'; delete [] pRecv; return FALSE; } } oapi::OAPISysDiskListRsp dataList; QList<QStorageInfo> hdd = QStorageInfo::mountedVolumes(); QListIterator<QStorageInfo> it(hdd); while(it.hasNext()) { QStorageInfo disk = it.next(); astring strHdd = disk.rootPath().toStdString(); VDC_DEBUG( "%s strHdd %s \n",__FUNCTION__, strHdd.c_str()); s64 totalSize = disk.bytesTotal() / (1024 * 1024); s64 leftSize = disk.bytesFree()/ (1024 * 1024); VDC_DEBUG( "%s Total %lld M Left %lld M \n",__FUNCTION__, totalSize, leftSize); QString strQtHdd = disk.rootPath(); HddDriveType diskType = HddGetDriveType(strQtHdd); VDC_DEBUG( "%s Type %d \n",__FUNCTION__, diskType); if (totalSize/1024 < 4 || leftSize/1024 < 2) /* In G */ { continue; } if (diskType == HddInternalDrive || diskType == HddRemovableDrive || diskType == HddRemoteDrive) { oapi::OAPIDisk oapiDisk; oapiDisk.strId = disk.device().toStdString(); oapiDisk.strPath = disk.rootPath().toStdString(); oapiDisk.nTotalSize = disk.bytesTotal(); oapiDisk.nFreeSize = disk.bytesFree(); oapiDisk.nStorSize = 0; dataList.list.push_back(oapiDisk); } } std::string strJson = autojsoncxx::to_pretty_json_string(dataList); s32 nJsonLen = strJson.length(); if (nJsonLen <= 0) { return FALSE; } OAPIHeader header; header.cmd = htonl(OAPI_CMD_SYS_DISK_LIST_RSP); header.length = htonl(nJsonLen + 1); m_pSocket->Send((void *)&header, sizeof(header)); m_pSocket->Send((void *)strJson.c_str(), nJsonLen + 1); return TRUE; }