Ejemplo n.º 1
0
qlonglong DeviceInfo::availableDiskSpace() const
{
    QStorageInfo info;
    qlonglong diskSpace = 0;
    QStringList drives = info.allLogicalDrives();

    drives.removeDuplicates();

    foreach (const QString &drive, drives)
    {
        if (info.driveType(drive) == QStorageInfo::InternalDrive)
        {
            diskSpace += info.availableDiskSpace(drive);
        }
    }

    return diskSpace;
}
Ejemplo n.º 2
0
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 ++;
	}
   }
Ejemplo n.º 3
0
qint64 qast::get_freespace(){
    QStorageInfo storage = QStorageInfo::root();
    qDebug() << "Read Only:" << storage.isReadOnly();
    qDebug() << "Volume Name:" << storage.name();
    qDebug() << "File System:" << storage.fileSystemType();
    qDebug() << "Total Size:" << storage.bytesTotal()/1048576 << "MB";
    qDebug() << "Available Size:" << storage.bytesAvailable()/1048576 << "MB";
    return storage.bytesAvailable();
}
Ejemplo n.º 4
0
inline HddDriveType HddDevice::GetHddType(astring &strDevice)
{
	return (HddDriveType)(m_Info.driveType(strDevice.c_str()));
}
Ejemplo n.º 5
0
/* Total size is in M */
inline s64 HddDevice::GetavailableDiskSpace(astring &strDevice)
{
	return m_Info.availableDiskSpace(strDevice.c_str()) / (1024 * 1024);
}
Ejemplo n.º 6
0
/* Total size is in M */
inline s64 HddDevice::GetTotalDiskSpace(astring &strDevice)
{
	return m_Info.totalDiskSpace(strDevice.c_str()) / (1024 * 1024);
}
Ejemplo n.º 7
0
inline QStringList HddDevice::GetDeviceList()
{
	return m_Info.allLogicalDrives();
}
Ejemplo n.º 8
0
void settingswindow::loadSettings()
{
//    QSettings settings(settingsFileName, settingsFileFormat);
//    settings.sync();
//    QStringList Groups = settings.childGroups();
//    foreach (QString group, Groups) {
//        QTreeWidgetItem *wi = new QTreeWidgetItem(ui->treeWidget);
//        wi->setForeground(0, QColor(255,255,255));
//        wi->setText(0, group);
//        settings.beginGroup(group);
//        QStringList List = settings.allKeys();
//        foreach (QString item, List) {
//            QTreeWidgetItem *wi2 = new QTreeWidgetItem(wi);
//            wi2->setForeground(0, QColor(180,180,180));
//            wi2->setText(0, item);
//        }
//        settings.endGroup();
//    }

    QStorageInfo storage = QStorageInfo::root();
    QString downloadPath = settings.value("Download/downloadPath", storage.rootPath()).toString();

    int debugLevel = settings.value("Debug/Level", 1).toInt();
    int currentLanguage = settings.value("Language", 0).toInt();
    int downLimit = settings.value("libtorrent/download_rate_limit", 0).toInt();
    int upLimit = settings.value("libtorrent/upload_rate_limit", 0).toInt();
    int port = settings.value("libtorrent/port", 6881).toInt();

    // HTTP and WebSocket server settings
    bool webEnabled = settings.value("WebInterfaceOn", true).toBool();
    int webport = settings.value("listener/port", 8080).toInt();
    int websocketport = settings.value("websocket/port", 8081).toInt();

    bool msgOnFinish = settings.value("Messages/onFinish", true).toBool();
    bool msgOnChat = settings.value("Messages/onChat", false).toBool();


    ui->txtDownloadPath->setText(downloadPath);
    qDebug() << "download path" << downloadPath;

    ui->cmbDebugLevel->setCurrentIndex(debugLevel);
    qDebug() << "debug level" << ui->cmbDebugLevel->currentText();

    ui->cmbLanguage->setCurrentIndex(currentLanguage);
    qDebug() << "current language" << ui->cmbLanguage->currentText();

    ui->numLimitDown->setValue(downLimit);
    ui->numLimitUp->setValue(upLimit);
    qDebug() << QString("limits: download %0 KB/s, upload %1 KB/s").arg(downLimit).arg(upLimit);

    ui->numPort->setValue(port);
    qDebug() << "libtorrent listening on port" << port;

    ui->chkMsgDownFinish->setChecked(msgOnFinish);
    ui->chkMsgNewChat->setChecked(msgOnChat);
    ui->chkActivateWeb->setChecked(webEnabled);

    ui->numWebPort->setValue(webport);
    ui->numWebSocketPort->setValue(websocketport);

    // needed by downloadwindow when a tsuCard emit a downloadFinished event
    qApp->setProperty("msgOnFinish", ui->chkMsgDownFinish->isChecked());

    qInfo("settings loaded and applied");
}
Ejemplo n.º 9
0
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;
}