Пример #1
0
bool MidpMountedRoots::isValidDisk(const QString& disk) const
{
    DEBUG_PRINT("isValidDisk");

    QString root, local;
    return getDiskInfo(disk, root, local);
}
void SensorFileSysWalker::sendNewDiskInfo() {
	logger.logInfo( "sendNewDiskInfo: execute..." );

	// send disk information
	float diskSpaceTotalGB;
	float diskSpaceUsedGB;
	float diskSpaceFreeGB;

	getDiskInfo( curDisk , &diskSpaceTotalGB , &diskSpaceUsedGB , &diskSpaceFreeGB );
	sendSignal( SIGNAL_DISK_NAME , curDisk );
	sendSignal( SIGNAL_DISK_SPACETOTAL , String("") + diskSpaceTotalGB + "GB" );
	sendSignal( SIGNAL_DISK_SPACEUSED , String("") + diskSpaceUsedGB + "GB" );
	sendSignal( SIGNAL_DISK_SPACEFREE , String("") + diskSpaceFreeGB + "GB" );
}
Пример #3
0
std::string
getDate::getInfo(int types)
{
    std::string retInfo;
    switch(types)
    {
        case cpuInfo:
            retInfo = getCpuInfo();
            break;

        case memInfo:
            retInfo = getMemInfo();
            break;

        case netInfo:
            retInfo = getNetInfo();
            break;
        
        case diskInfo:
            retInfo = getDiskInfo();
            break;
    }
    return retInfo;
}
Пример #4
0
void MidpMountedRoots::update(bool notify)
{
    DEBUG_PRINT("update");

#ifdef UNIX
    QValueList<QString> disks;
    QValueList<QString> paths;
    bool rebuild = false;
    int  count   = 0;

    // Read system mounts
    struct mntent *me;
    FILE *mntfp = setmntent("/etc/mtab", "r");
    if (mntfp)
    {
        while ((me = getmntent( mntfp )) != 0)
        {
            QString disk = me->mnt_fsname;
            if (isValidDisk(disk))
            {
                count++;

                disks.append(disk);

                QString path = QString(me->mnt_dir) + '/';
                paths.append(path);

                if (!isCachedDisk(disk))
                {
                    rebuild = true;
                }
            }
        }
        endmntent(mntfp);
    }

    // Add special roots for PIM, FC and Private
    const pcsl_string* storage = storage_get_root(INTERNAL_STORAGE_ID);
    if (pcsl_string_length(storage) >= 0)
    {
        const char* cstorage = (const char*)pcsl_string_get_utf8_data(storage);
        QString qstorage = cstorage;
        pcsl_string_release_utf8_data((const jbyte*)cstorage, storage);

        QString fc = qstorage + "storage/";
        QFile ffc(fc);
        // determine whether the path exists
        // Note: the path is created by the build system.
        if (ffc.exists())
        {
            count++;
            const QString name = "storage";

            disks.append(name);
            paths.append(fc);

            if (!isCachedDisk(name))
            {
                rebuild = true;
            }
        }

        QString pim = qstorage + "pimdb/";
        QFile fpim(pim);
        // determine whether the path exists
        // Note: the path is created by the build system.
        if (fpim.exists())
        {
            count++;
            const QString name = "pimdb";

            disks.append(name);
            paths.append(pim);

            if (!isCachedDisk(name))
            {
                rebuild = true;
            }
        }

        QString prv = qstorage + "private/";
        QFile fprv(prv);
        // determine whether the path exists
        // Note: the path is created by the build system.
        if (fprv.exists())
        {
            count++;
            const QString name = "private";

            disks.append(name);
            paths.append(prv);

            if (!isCachedDisk(name))
            {
                rebuild = true;
            }
        }
    }

    if (rebuild || count != (int)mRoots.count())
    {
        mRoots.clear();
        QStringList::ConstIterator it  = disks.begin();
        QStringList::ConstIterator pit = paths.begin();
        for (; it != disks.end(); ++it, ++pit)
        {
            QString disk = *it;
            QString path = *pit;
            QString root, local;
            if (getDiskInfo(disk, root, local))
            {
                MidpFileRoot* fs = new MidpFileRoot(disk, path, root, local);
                mRoots.append(fs);
            }
        }
        // Call the handler if required
        if (notify) {
            disksChanged();
        }
    }
#endif
}
Пример #5
0
bool DevCheck::devInfo(QString dev, QString* type, QString* label, QString* filesystem, QString* maxsize){
  //OUTPUT: bool isGoodDevice
  //INPUTS/OUTPUTS: type, label, filesystem, maxsize
  //INPUT: dev = device node (da0, not /dev/da0)
	
  //Clear the output variables
  type->clear(); label->clear(); filesystem->clear(); maxsize->clear();
  //make sure to have both the full path and just node
  QString node;
  QString fullDev;
  if(dev.startsWith(DEVICEDIR)){ fullDev = dev; node = dev.section("/",-1); }
  else{ node = dev; fullDev = DEVICEDIR + dev; }
  //Do not allow sym-links
  if(!QFile::symLinkTarget(fullDev).isEmpty()){ return FALSE; }
  //Do not allow currently active devices
  if(activeDevs.contains(node)){ return FALSE; }
  //Double check for valid device types (just in case)
  QString detType;
  for(int i=0; i<validDevs.length(); i++){
    if(node.startsWith(validDevs[i]) && node != "mdctl"){ 
	detType = validDevTypes[i]; 
	break; 
    }
  }
  //Make sure it is a no-child device (except memory disks or CD's, those need to be the parent)
  int children = devChildren(node).length();
  if( !node.startsWith("md") && detType!="CD9660" && detType!="ISO" && children>0 ){ return FALSE; }
  //Make sure we quit before running commands on any invalid device nodes
  if(detType.isEmpty() || !QFile::exists(fullDev) ){return FALSE;}
  //Get the camctl info and refine the device type if possible
  QString camctl;
  if(detType == "USB" && QFile::exists(fullDev)){
    //make sure that it is not a SCSI device
    camctl = pcbsd::Utils::runShellCommand( QString("camcontrol inquiry ")+node.section("s",0,0) ).join(" ");
    if(camctl.contains(" Fixed Direct Access SCSI")){ detType = "SCSI"; }
    if(camctl.contains("camcontrol")){ camctl.clear(); } //error or invalid device type
  }else if(detType == "SATA" && QFile::exists(fullDev)){
    camctl = pcbsd::Utils::runShellCommand( QString("camcontrol identify ")+node.section("s",0,0) ).join(" ");
    if(camctl.contains("camcontrol")){ camctl.clear(); } //error or invalid device type
  }
  if(!camctl.isEmpty()){
    //Alternate Device name for label later (if needed)
    camctl = camctl.section(">",0,0).section("<",-1).section(" ",0,0).simplified();
    QString partition = node.section("s",1,1);
    if(!partition.isEmpty()){ camctl.append("-"+partition); }
  }
  //Save the device type
  type->append(detType);
  
  bool isCD= (detType == "CD9660" || detType == "ISO"); //simplification for later
  //Run either "file -s" or "disktype" to get device info
  bool valid = false;
  QString fs, dlabel;
  if(QFile::exists("/usr/local/bin/disktype")){
    valid = getDiskInfo(fullDev, &fs, &dlabel);
  }else{
    // "file -s" should always work - use it as the backup method
    valid = getSpecialFileInfo(fullDev, &fs, &dlabel);
  }
  if(detType=="ISO" && fs.isEmpty() ){ valid = false; } //skip ISO's with unknown filesystems (swap, etc)
  else if(detType=="CD9660" &&  fs.isEmpty() ){
    //Try to determine which type of cd/dvd this is since it is not a data disk (which can be mounted)
    fs = "AVDISK"; //audio/video disk (not mountable)
  }
  if(!valid){ //don't bother continuing - already invalid
    if(DEBUG_MODE){ qDebug() << "Invalid Device:" << node << detType << dlabel << fs; } 
    return FALSE; 
  } 
 
  //If the filesystem could not be detected or is not supported
  if(fs.isEmpty()){ fs = "UNKNOWN"; }
  
  //Now get the device label (if there is one) using glabel
  QString glabel;
  //Don't use glabel for SATA devices right now because it is inconsistent
  if(!isCD){ glabel = devLabel(node, fs); }
  //Check to see if we have a label, otherwise assign one
  if( !glabel.isEmpty() ){ dlabel = glabel; } //glabel
  else if(!dlabel.isEmpty()){ } //device info label
  else if( !camctl.isEmpty() ){ dlabel = camctl; } //camcontrol device ID
  else{
    //Assign a device label
    if(isCD){
      if(detType == "ISO"){
	dlabel = "ISO_File";
      }else{
        dlabel = "Optical_Disk";
      }
    }else{
      dlabel = detType+"-Device"; //this is not a "detected" label
    }
  }
  //make sure that a device label does not contain "(" or ")"
  if(dlabel.contains("(")){ dlabel = dlabel.remove("(").simplified(); }
  if(dlabel.contains(")")){ dlabel = dlabel.remove(")").simplified(); }
  dlabel = dlabel.simplified();

  //Setup the outputs
  label->append(dlabel);
  filesystem->append(fs);
  return valid;
}
Пример #6
0
	eAboutScreen()
	{
		/* help text for about screen */
		setHelpText(_("\tAbout...\n\n>>> [MENU] >>> [4] Information >>> About...\n. . . . . . . . . .\n\n" \
									"Provides information about your Dreambox, like model, CPU, harddisk(s), software version, skin, etc.\n" \
									". . . . . . . . . .\n\nUsage:\n\n[GREEN]/[OK]/[EXIT]\tClose window"));

		machine=new eLabel(this);
		machine->setName("machine");

		vendor=new eLabel(this);
		vendor->setName("vendor");

		processor=new eLabel(this);
		processor->setName("processor");

		frontend=new eLabel(this);
		frontend->setName("frontend");

		harddisks=new eLabel(this);
		harddisks->setName("harddisks");

		okButton=new eButton(this);
		okButton->setName("okButton");

		dreamlogo=new eLabel(this);
		dreamlogo->setName("dreamlogo");

		triaxlogo=new eLabel(this);
		triaxlogo->setName("triaxlogo");

		version=new eLabel(this);
		version->setName("version");

		fpversion=new eLabel(this);
		fpversion->setName("fp_version");

		if (eSkin::getActive()->build(this, "eAboutScreen"))
			eFatal("skin load of \"eAboutScreen\" failed");

		dreamlogo->hide();
		triaxlogo->hide();
		
		if ( !eSystemInfo::getInstance()->hasHDD() )
		{
			harddisks->hide();
			eWidget *h=search("harddisk_label");
			if(h)
				h->hide();
		}

		machine->setText(eSystemInfo::getInstance()->getModel());
		vendor->setText(eSystemInfo::getInstance()->getManufacturer());
		processor->setText(eString().sprintf("Processor: %s", eSystemInfo::getInstance()->getCPUInfo()));

		switch (eSystemInfo::getInstance()->getFEType())
		{
			case eSystemInfo::feSatellite:
				frontend->setText(_("Frontend: Satellite"));
				break;
			case eSystemInfo::feCable:
				frontend->setText(_("Frontend: Cable"));
				break;
			case eSystemInfo::feTerrestrial:
				frontend->setText(_("Frontend: Terrestrial"));
				break;
			default:
				frontend->setText(_("Frontend: Unknown"));
		}

		eString sharddisks;
#ifndef DISABLE_FILE
		sharddisks = getDiskInfo(0);
#else
		sharddisks=_("none");
#endif //DISABLE_FILE
		harddisks->setText(sharddisks);

		{
			eString verid=getVersionInfo("version");
			if (!verid)
				version->setText(_("unknown"));
			else
			{
				if (eSystemInfo::getInstance()->isOpenEmbedded())
				{
					int length = verid.length();
					eString ver=verid.mid(1, length - 13);
					eString date=verid.mid(length - 12, 8);
					version->setText(eString(ver + eString(" ") + date.left(4) + "-" + date.mid(4, 2) + "-" + date.mid(6,2)));
				}
				else
				{
					int type=atoi(verid.left(1).c_str());
					char *typea[3];
					typea[0]=_("release");
					typea[1]=_("beta");
					typea[2]=_("internal");
					eString ver=verid.mid(1, 3);
					eString date=verid.mid(4, 8);
	//				eString time=verid.mid(12, 4);
					if ( eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7000 )
						version->setText(
							eString(typea[type%3]) + eString(" ") + ver[0] + "." + ver[1] + "." + ver[2]
								+ ", " + date.mid(6, 2) + "." + date.mid(4,2) + "." + date.left(4));
					else
						version->setText(
							eString().sprintf("%s %c.%d. %s", typea[type%3], ver[0],
								atoi( eString().sprintf("%c%c",ver[1],ver[2]).c_str()),
								(date.mid(6, 2) + "." + date.mid(4,2) + "." + date.left(4)).c_str())
								);
				}
			}
		}

		if ( !strcmp(eSystemInfo::getInstance()->getManufacturer(),"Triax") )
			triaxlogo->show();
		else if ( !strcmp(eSystemInfo::getInstance()->getManufacturer(),"Dream-Multimedia-TV") )
			dreamlogo->show();

		if ( eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7000
			|| eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM7020)
		{
			eString fp_version = fpversion->getText();
			fp_version += eString().sprintf(" 1.%02d", eDreamboxFP::getFPVersion());
			eDebug("%s", fp_version.c_str());
			fpversion->setText(fp_version);
		} 
		else
			fpversion->hide();

		CONNECT(okButton->selected, eWidget::accept);
	}