TQString TDEStorageDevice::friendlyName() { // Return the actual storage device name TQString devicevendorid = vendorEncoded(); TQString devicemodelid = modelEncoded(); devicevendorid.replace("\\x20", " "); devicemodelid.replace("\\x20", " "); devicevendorid = devicevendorid.stripWhiteSpace(); devicemodelid = devicemodelid.stripWhiteSpace(); devicevendorid = devicevendorid.simplifyWhiteSpace(); devicemodelid = devicemodelid.simplifyWhiteSpace(); TQString devicename = devicevendorid + " " + devicemodelid; devicename = devicename.stripWhiteSpace(); devicename = devicename.simplifyWhiteSpace(); if (devicename != "") { return devicename; } if (isDiskOfType(TDEDiskDeviceType::Camera)) { return TDEGenericDevice::friendlyName(); } if (isDiskOfType(TDEDiskDeviceType::Floppy)) { return friendlyDeviceType(); } TQString label = diskLabel(); if (label.isNull()) { if (deviceSize() > 0) { if (checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) { label = i18n("%1 Removable Device").arg(deviceFriendlySize()); } else { label = i18n("%1 Fixed Storage Device").arg(deviceFriendlySize()); } } } if (!label.isNull()) { return label; } return friendlyDeviceType(); }
void FileLog::onPrint(ELogLevel level, time_t t, const char *time, const char *msg) { EState s = State_Start; UtilDay d(t); for (;;) { switch (s) { case State_Start: { if (!mLogFile) { s = State_PreOpenCurFile; break; } if (mCurDay != d) { s = State_Dump; break; } s = State_Ready; } break; case State_PreOpenCurFile: { assert(!mLogFile && "State_PreOpenCurFile:mLogFile < 0"); const char *pathname = _getTodayFilePath(d); mCurDay = d; mLogFile = fopen(pathname, "at+"); if (!mLogFile) { s = State_Error; break; } s = State_Ready; } break; case State_Dump: { assert(mLogFile && "State_Dump:mLogFile >= 0"); // 如果磁盘空间不足则删除最早的日志文件 while (checkDiskStatus() == DiskStatus_Full) { if (_deleteEarliestFile() != ErrCode_Success) // 删除失败就不用继续了 break; } // 日志文件转储 (void)_dump(mCurDay); // 不管转储成不成功,都需要保证当前的日志可以写入 s = State_PreOpenCurFile; // 删除当前文件 fclose(mLogFile); mLogFile = NULL; unlink(_getTodayFilePath(mCurDay)); mCurDay.set((time_t)0); } break; case State_Ready: { assert(mLogFile && "State_Ready:mLogFile >= 0"); int rv = _writeLog(level, t, time, msg); if (ErrCode_CurFileFull == rv) { s = State_Dump; break; } if (rv != ErrCode_Success) { s = State_Error; break; } s = State_Done; } break; default: break; } if (State_Error == s || State_Done == s) { break; } } }
TQPixmap TDEStorageDevice::icon(TDEIcon::StdSizes size) { TQPixmap ret = DesktopIcon("hdd_unmount", size); if (isDiskOfType(TDEDiskDeviceType::Floppy)) { ret = DesktopIcon("3floppy_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::Optical)) { ret = DesktopIcon("cdrom_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::CDROM)) { ret = DesktopIcon("cdrom_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::CDRW)) { ret = DesktopIcon("cdwriter_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::DVDROM)) { ret = DesktopIcon("dvd_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::DVDRW)) { ret = DesktopIcon("dvd_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::DVDRAM)) { ret = DesktopIcon("dvd_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::Zip)) { ret = DesktopIcon("zip_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::Tape)) { ret = DesktopIcon("tape_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::Camera)) { ret = DesktopIcon("camera_unmount"); } if (isDiskOfType(TDEDiskDeviceType::HDD)) { ret = DesktopIcon("hdd_unmount", size); if (checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) { ret = DesktopIcon("usbpendrive_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::CompactFlash)) { ret = DesktopIcon("compact_flash_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::MemoryStick)) { ret = DesktopIcon("memory_stick_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::SmartMedia)) { ret = DesktopIcon("smart_media_unmount", size); } if (isDiskOfType(TDEDiskDeviceType::SDMMC)) { ret = DesktopIcon("sd_mmc_unmount", size); } } if (isDiskOfType(TDEDiskDeviceType::RAM)) { ret = DesktopIcon("memory", size); } if (isDiskOfType(TDEDiskDeviceType::Loop)) { ret = DesktopIcon("blockdevice", size); } return ret; }
TQString TDEStorageDevice::friendlyDeviceType() { TQString ret = i18n("Hard Disk Drive"); // Keep this in sync with TDEStorageDevice::icon(TDEIcon::StdSizes size) below if (isDiskOfType(TDEDiskDeviceType::Floppy)) { ret = i18n("Floppy Drive"); } if (isDiskOfType(TDEDiskDeviceType::Optical)) { ret = i18n("Optical Drive"); } if (isDiskOfType(TDEDiskDeviceType::CDROM)) { ret = i18n("CDROM Drive"); } if (isDiskOfType(TDEDiskDeviceType::CDRW)) { ret = i18n("CDRW Drive"); } if (isDiskOfType(TDEDiskDeviceType::DVDROM)) { ret = i18n("DVD Drive"); } if (isDiskOfType(TDEDiskDeviceType::DVDRW)) { ret = i18n("DVDRW Drive"); } if (isDiskOfType(TDEDiskDeviceType::DVDRAM)) { ret = i18n("DVDRAM Drive"); } if (isDiskOfType(TDEDiskDeviceType::Zip)) { ret = i18n("Zip Drive"); } if (isDiskOfType(TDEDiskDeviceType::Tape)) { ret = i18n("Tape Drive"); } if (isDiskOfType(TDEDiskDeviceType::Camera)) { ret = i18n("Digital Camera"); } if (isDiskOfType(TDEDiskDeviceType::HDD)) { ret = i18n("Hard Disk Drive"); if (checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) { ret = i18n("Removable Storage"); } if (isDiskOfType(TDEDiskDeviceType::CompactFlash)) { ret = i18n("Compact Flash"); } if (isDiskOfType(TDEDiskDeviceType::MemoryStick)) { ret = i18n("Memory Stick"); } if (isDiskOfType(TDEDiskDeviceType::SmartMedia)) { ret = i18n("Smart Media"); } if (isDiskOfType(TDEDiskDeviceType::SDMMC)) { ret = i18n("Secure Digital"); } } if (isDiskOfType(TDEDiskDeviceType::RAM)) { ret = i18n("Random Access Memory"); } if (isDiskOfType(TDEDiskDeviceType::Loop)) { ret = i18n("Loop Device"); } return ret; }