bool KMpcPlugin::readInfo( KFileMetaInfo& info, uint what ) { bool readComment = false; bool readTech = false; if (what & (KFileMetaInfo::Fastest | KFileMetaInfo::DontCare | KFileMetaInfo::ContentInfo)) readComment = true; if (what & (KFileMetaInfo::Fastest | KFileMetaInfo::DontCare | KFileMetaInfo::TechnicalInfo)) readTech = true; if ( info.path().isEmpty() ) // remote file return false; TagLib::File *file = new TagLib::MPC::File(QFile::encodeName(info.path()).data(), readTech); if (!file->isOpen()) { kDebug(7034) << "Couldn't open " << file->name(); delete file; return false; } if(readComment) { KFileMetaInfoGroup commentgroup = appendGroup(info, "Comment"); QString date = file->tag()->year() > 0 ? QString::number(file->tag()->year()) : QString(); QString track = file->tag()->track() > 0 ? QString::number(file->tag()->track()) : QString(); appendItem(commentgroup, "Title", TStringToQString(file->tag()->title()).trimmed()); appendItem(commentgroup, "Artist", TStringToQString(file->tag()->artist()).trimmed()); appendItem(commentgroup, "Album", TStringToQString(file->tag()->album()).trimmed()); appendItem(commentgroup, "Date", date); appendItem(commentgroup, "Comment", TStringToQString(file->tag()->comment()).trimmed()); appendItem(commentgroup, "Tracknumber", track); appendItem(commentgroup, "Genre", TStringToQString(file->tag()->genre()).trimmed()); } if (readTech) { KFileMetaInfoGroup techgroup = appendGroup(info, "Technical"); TagLib::MPC::Properties *properties = (TagLib::MPC::Properties*)(file->audioProperties()); appendItem(techgroup, "Bitrate", properties->bitrate()); appendItem(techgroup, "Sample Rate", properties->sampleRate()); appendItem(techgroup, "Channels", properties->channels()); appendItem(techgroup, "Length", properties->length()); appendItem(techgroup, "Version", properties->mpcVersion()); } delete file; return true; }
bool KOfficePlugin::readInfo( KFileMetaInfo& info, uint what) { if ( info.path().isEmpty() ) // remote file return false; KFileMetaInfoGroup group = appendGroup(info, "DocumentInfo"); KoStore* store = KoStore::createStore(info.path(), KoStore::Read); if ( store && store->open( QString("documentinfo.xml") ) ) { KoStoreDevice dev( store ); QDomDocument doc; doc.setContent( &dev ); QDomNode authorNode = doc.namedItem("document-info").namedItem("author"); QDomNode aboutNode = doc.namedItem("document-info").namedItem("about"); QString author = stringFromNode(authorNode, "full-name"); QString title = stringFromNode(aboutNode, "title"); QString abstract = stringFromNode(aboutNode, "abstract"); appendItem(group, "Author", author); appendItem(group, "Title", title); appendItem(group, "Abstract", abstract); store->close(); delete store; return true; } delete store; return false; }
void QTlenRosterManager::showRoster() { for(int i = 0; i < addedItems.count(); i++) { //all the items should be painted, not emulated by widgets if (rosterBox->itemWidget(addedItems[i].item, 0)) rosterBox->itemWidget(addedItems[i].item, 0)->deleteLater(); } rosterBox->clear(); qSort( rosterItems.begin(), rosterItems.end() ); addedItems.clear(); addedGroups.clear(); AddedItem i; QTreeWidgetItem *node; for ( int n = 0; n < (int)rosterItems.count(); n++ ) { appendGroup(rosterItems[n].group); if (!dontShowOfflines || rosterItems[n].presence != Offline) { int group_index = getIndexOfGroup(rosterItems[n].group); if(group_index != -1) node = addedGroups[group_index].item; else { node = rosterBox->addRosterNode(rosterItems[n].group); AddedGroup g; g.item = node; g.group = rosterItems[n].group; addedGroups.append(g); } QPixmap tmpAvatar = QPixmap(rosterItems[n].avatar); if(!tmpAvatar.isNull()) tmpAvatar.setAlphaChannel(avMask); i.item = rosterBox->addRosterItem(rosterItems[n].name, rosterItems[n].presence, rosterItems[n].desc, rosterItems[n].jid, tmpAvatar, node); i.jid = rosterItems[n].jid; addedItems.append(i); } } }
/** * @details Constructs a LofarBeams object. */ LofarBeams::LofarBeams() { setName("LofarBeams"); // Main Instrument Definitions ParameterGroup g(QString("Lofar Settings")); g.addParameter(_lofar.clockSpeeds() ); appendGroup(g); // setup the beam parameter groups int maxBeams = 8; // Lofar can support up to 8 beams for(int i=0; i < maxBeams; ++i ) { ParameterGroup g(QString("Beam %1").arg( i+1 )); LofarBeam* beam = new LofarBeam( &_lofar ); beam->setName(QString("Beam %1").arg( i+1 )); //beam.setChannel(i/2); addBeam(beam); g.enableDeactivation(); if( i != 0 ) { g.setActiveState(false); beam->setActiveMode(false); } /* Parameter dataStream(QObject::tr("Stream"), "The Stream on which to output the data. Maximum of 2 beams per Channel"); QMap<QString,QString> dataStreamOptions; dataStreamOptions["Channel 1"] = "1"; dataStreamOptions["Channel 2"] = "2"; dataStreamOptions["Channel 3"] = "3"; dataStreamOptions["Channel 4"] = "4"; dataStream.setRestrictedValues( dataStreamOptions ); g.addParameter(dataStream); */ // add the finished group to the class //_groups.append(g); } }
bool KRfc822Plugin::readInfo(KFileMetaInfo &info, uint /*what*/) { QFile file(info.path()); if(!file.open(IO_ReadOnly)) { kdDebug(7034) << "Couldn't open " << QFile::encodeName(info.path()) << endl; return false; } /* Note to self: probably should use QCString for all this, but what we're doing is simple and self-contained so never mind.. */ char id_from[] = "From: "; char id_to[] = "To: "; char id_subject[] = "Subject: "; char id_date[] = "Date: "; char id_contenttype[] = "Content-Type: "; // we need a buffer for lines char linebuf[4096]; // we need a buffer for other stuff char buf_from[1000] = ""; char buf_to[1000] = ""; char buf_subject[1000] = ""; char buf_date[1000] = ""; char buf_contenttype[1000] = ""; memset(buf_from, 0, 999); memset(buf_to, 0, 999); memset(buf_subject, 0, 999); memset(buf_date, 0, 999); memset(buf_contenttype, 0, 999); char *myptr; bool done = false; while(!done) { // read a line file.readLine(linebuf, sizeof(linebuf)); // have we got something useful? if(memcmp(linebuf, id_from, 6) == 0) { // we have a name myptr = linebuf + 6; strncpy(buf_from, myptr, sizeof(buf_from)); buf_from[998] = '\0'; } else if(memcmp(linebuf, id_to, 4) == 0) { // we have a name myptr = linebuf + 4; strncpy(buf_to, myptr, sizeof(buf_to)); buf_to[998] = '\0'; } else if(memcmp(linebuf, id_subject, 9) == 0) { // we have a name myptr = linebuf + 9; strncpy(buf_subject, myptr, sizeof(buf_subject)); buf_subject[998] = '\0'; } else if(memcmp(linebuf, id_date, 6) == 0) { // we have a name myptr = linebuf + 6; strncpy(buf_date, myptr, sizeof(buf_date)); buf_date[998] = '\0'; } else if(memcmp(linebuf, id_contenttype, 14) == 0) { // we have a name myptr = linebuf + 14; strncpy(buf_contenttype, myptr, sizeof(buf_contenttype)); buf_contenttype[998] = '\0'; } // are we done yet? if( ((strlen(buf_from) > 0) && (strlen(buf_to) > 0) && (strlen(buf_subject) > 0) && (strlen(buf_date) > 0) && (strlen(buf_contenttype) > 0)) || (file.atEnd()) ) done = true; }; KFileMetaInfoGroup group = appendGroup(info, "Technical"); if(strlen(buf_from) > 0) appendItem(group, "From", buf_from); if(strlen(buf_to) > 0) appendItem(group, "To", buf_to); if(strlen(buf_subject) > 0) appendItem(group, "Subject", buf_subject); if(strlen(buf_date) > 0) appendItem(group, "Date", buf_date); if(strlen(buf_contenttype) > 0) appendItem(group, "Content-Type", buf_contenttype); return true; }
bool KCppPlugin::readInfo( KFileMetaInfo& info, uint ) { QFile f(info.path()); if (!f.open(IO_ReadOnly)) return false; int codeLines = 0; int commentLines = 0; int totalLines = 0; int emptyLines = 0; int Strings = 0; int Stringsi18n = 0; int Includes = 0; bool inComment = false; QString line; QTextStream stream( &f ); while (!stream.eof()) { line = stream.readLine(); totalLines++; if (line.stripWhiteSpace().isEmpty()) { emptyLines++; continue; } if (line.contains("/*")) inComment = true; if (!inComment) { codeLines++; if (line.contains(QRegExp("^\\s*#\\s*include"))) Includes++; int pos = line.find("//"); if (pos>=0) commentLines++; // truncate the comment - we don't want to count strings in it line.truncate(pos); Strings+=line.contains(QRegExp("\".*\"")); Stringsi18n+=line.contains(QRegExp("(?:i18n|I18N_NOOP)\\s*\\(")); } else commentLines++; if (line.contains("*/")) inComment = false; } KFileMetaInfoGroup group = appendGroup(info, "General"); appendItem(group, "Lines", int(totalLines)); appendItem(group, "Code", int(codeLines)); appendItem(group, "Comment", int(commentLines)); appendItem(group, "Blank", int(emptyLines)); appendItem(group, "Strings", int(Strings)); appendItem(group, "i18n Strings", int(Stringsi18n)); appendItem(group, "Included Files", int(Includes)); return true; }
bool KFileMediaPlugin::readInfo(KFileMetaInfo &info, uint /*what*/) { const Medium medium = askMedium(info); kdDebug() << "KFileMediaPlugin::readInfo " << medium.id() << endl; if (medium.id().isNull()) return false; QString mount_point = medium.mountPoint(); KURL base_url = medium.prettyBaseURL(); QString device_node = medium.deviceNode(); KFileMetaInfoGroup group = appendGroup(info, "mediumInfo"); if (base_url.isValid()) { appendItem(group, "baseURL", base_url.prettyURL()); } if (!device_node.isEmpty()) { appendItem(group, "deviceNode", device_node); } if (!mount_point.isEmpty() && medium.isMounted()) { m_total = 0; m_used = 0; m_free = 0; struct statvfs vfs; memset(&vfs, 0, sizeof(vfs)); if ( ::statvfs(QFile::encodeName(mount_point), &vfs) != -1 ) { m_total = static_cast<KIO::filesize_t>(vfs.f_blocks) * static_cast<KIO::filesize_t>(vfs.f_frsize); m_free = static_cast<KIO::filesize_t>(vfs.f_bavail) * static_cast<KIO::filesize_t>(vfs.f_frsize); m_used = m_total - m_free; int percent = 0; int length = 0; if (m_total != 0) { percent = 100 * m_used / m_total; length = 150 * m_used / m_total; } appendItem(group, "free", m_free); appendItem(group, "used", m_used); appendItem(group, "total", m_total); group = appendGroup(info, "mediumSummary"); appendItem(group, "percent", QString("%1%").arg(percent)); QPixmap bar(150, 20); QPainter p(&bar); p.fillRect(0, 0, length, 20, Qt::red); p.fillRect(length, 0, 150-length, 20, Qt::green); QColorGroup cg = QApplication::palette().active(); QApplication::style().drawPrimitive(QStyle::PE_Panel, &p, QRect(0, 0, 150, 20), cg, QStyle::Style_Sunken); appendItem( group, "thumbnail", bar ); } } return true; }
bool kfile_metadatPlugin::readInfo ( KFileMetaInfo& info, uint what ) { bool readTech = false; // add your "calculations" here // if something goes wrong, "return false;" if ( what & ( KFileMetaInfo::Fastest | KFileMetaInfo::DontCare | KFileMetaInfo::TechnicalInfo ) ) readTech = true; if ( info.path().isEmpty() ) // remote file cannot be handled return false; if ( readTech ) { KFileMetaInfoGroup group = appendGroup ( info, "Technical" ); char buffer[112]; QFile qf ( info.path() ); if ( ! qf.open ( IO_ReadOnly ) || ( qf.readBlock ( buffer, 112 ) != 112 ) ) return false; // File cannot be read --> no meta info qf.close(); try { comag::meta m ( ( const unsigned char * ) buffer ); appendItem ( group, "Title", QString::fromLatin1( m.gettitle().data() ) ); appendItem ( group, "Title Type", ( m.gettitle_type() == comag::meta::TT_TRANSMISSION ) ? i18n ( "Transmission" ) : ( m.gettitle_type() == comag::meta::TT_STATION ) ? i18n ( "Station" ) : i18n ( "Unknown" ) ); #ifdef ENABLE_DATETIMETWOLINES appendItem ( group, "Start Time", QTime ( m.getstart_time().hour, m.getstart_time().minute, m.getstart_time().second ) ); appendItem ( group, "Start Date", QDate ( m.getstart_date().year, m.getstart_date().month, m.getstart_date().day ) ); #else appendItem ( group, "Start Time", QDateTime ( QDate ( m.getstart_date().year, m.getstart_date().month, m.getstart_date().day ), QTime ( m.getstart_time().hour, m.getstart_time().minute, m.getstart_time().second ) ) ); #endif appendItem ( group, "Duration", QTime ( m.getduration().hour, m.getduration().minute, m.getduration().second ) ); appendItem ( group, "Packets", m.getpackets() ); appendItem ( group, "Service", ( m.getservice() == comag::meta::S_RADIO ) ? i18n ( "Radio" ) : ( m.getservice() == comag::meta::S_TV ) ? i18n ( "TV" ) : i18n ( "Unknown" ) ); appendItem ( group, "PID", m.getpid() ); appendItem ( group, "Timer", ( unsigned long long ) ( m.gettimer() ) ); } catch ( ... ) { return false; // Exceptions simply means: no meta info } // and finally display it! return true; } return false; }
bool KRgbPlugin::readInfo(KFileMetaInfo& info, uint /*what*/) { QFile file(info.path()); if (!file.open(QIODevice::ReadOnly)) { kDebug(7034) << "Couldn't open " << QFile::encodeName(info.path()); return false; } QDataStream dstream(&file); quint16 magic; quint8 storage; quint8 bpc; quint16 dimension; quint16 xsize; quint16 ysize; quint16 zsize; quint32 pixmin; quint32 pixmax; quint32 dummy; char imagename[80]; quint32 colormap; dstream >> magic; dstream >> storage; dstream >> bpc; dstream >> dimension; dstream >> xsize; dstream >> ysize; dstream >> zsize; dstream >> pixmin; dstream >> pixmax; dstream >> dummy; dstream.readRawBytes(imagename, 80); imagename[79] = '\0'; dstream >> colormap; quint8 u8; for (uint i = 0; i < 404; i++) dstream >> u8; if (magic != 474) return false; KFileMetaInfoGroup group; group = appendGroup(info, "Technical"); if (dimension == 1) ysize = 1; appendItem(group, "Dimensions", QSize(xsize, ysize)); appendItem(group, "BitDepth", zsize * 8 * bpc); if (zsize == 1) appendItem(group, "ColorMode", i18n("Grayscale")); else if (zsize == 2) appendItem(group, "ColorMode", i18n("Grayscale/Alpha")); else if (zsize == 3) appendItem(group, "ColorMode", i18n("RGB")); else if (zsize == 4) appendItem(group, "ColorMode", i18n("RGB/Alpha")); if (!storage) appendItem(group, "Compression", i18nc("Compression", "Uncompressed")); else if (storage == 1) { long compressed = file.size() - 512; long verbatim = xsize * ysize * zsize; appendItem(group, "Compression", i18nc("Compression", "Runlength Encoded") + QString(", %1%").arg(compressed * 100.0 / verbatim, 0, 'f', 1)); long k; quint32 offs; QMap<quint32, uint> map; QMap<quint32, uint>::Iterator it; QMap<quint32, uint>::Iterator end = map.end(); for (k = 0; k < (ysize * zsize); k++) { dstream >> offs; if ((it = map.find(offs)) != end) map.insert(offs, *it + 1); else map[offs] = 0; } for (k = 0, it = map.begin(); it != end; ++it) k += *it; if (k) appendItem(group, "SharedRows", QString("%1%").arg(k * 100.0 / (ysize * zsize), 0, 'f', 1)); else appendItem(group, "SharedRows", i18nc("SharedRows", "None")); } else
/** * @details Constructs a LofarBeam object. */ LofarBeam::LofarBeam( Lofar* lofar ) : State(true), _lofar(lofar), _localUpdate(false) { // construct parameters //_streams.reset(new MultiRangeParameter<unsigned int>( // "streams(beamlets)", // "the output channels to map the subbands to. Max of 64 per beam is allowed") ); //_streams.setRange( Range<unsigned int>(0,247) ); _array.reset(new SelectionParameter<RCU::Array>( "Antenna Array", "Defines the Antenna array to use in this beam" ) ); QList<QString> arrayDesc; arrayDesc << "Low Band" << "High Band"; QList<RCU::Array> arrayValues; arrayValues << RCU::LB << RCU::HB; _array->setAllowableValues( arrayDesc, arrayValues); _filter.reset( new SelectionParameter<RCU_Filter>( "RCU Filter", "The filter to apply to the RCU chain") ); _ids.reset( new MultiRangeParameter<unsigned int>( "rcu id", "The ids of all rcu's to be included in the beam") ); _frequency.reset( new SingleParameter<float>( "frequency", "The frequency range to observe" ) ); _bandwidth.reset( new SingleParameter<float>( "bandwidth", "The width of the frequecy band to observe" " relative to the start frequency" ) ); _subbands.reset( new MultiRangeParameter<unsigned int>( "subbands", "The subband identifiers associated with the frequen") ); _directionType.reset( new SelectionParameter<QString>( "direction", "The type " "of direction input. " "SKYSCAN will scan the sky with a L x M grid in " "the (l,m) plane") ); _directionType->setAllowableValues( _direction.types(), _direction.types() ); _directionType->set(_direction.types()[0]); _directionX.reset( new SingleParameter<float>("x", "The longitude in degrees for direction specification" ) ); _directionX->setRange( Range<float>(-180,180) ); _directionY.reset( new SingleParameter<float>("y", "The latitude in degrees for direction specification" ) ); _directionY->setRange( Range<float>(-90.0,90.0) ); updateDirection(); // set default values (pre-connection) _frequency->set(0.0); _bandwidth->set(0.0); _setupConnections(); // set default values _array->set(RCU::LB); refreshFilter(); _filter->set(RCU_Filter()); _ids->set( _lofar->rcuIds( _array->value()) ); _subbands->set( _lofar->subbandRanges() ); _subbands->setAllowableValues( _lofar->subbandRanges() ); _directionX->set(0.0); _directionY->set(0.0); refreshFrequency(); refreshRCU(); // set up the RCU group ParameterGroup g("RCU Selection"); g.addParameter( _array ); g.addParameter( _filter ); g.addParameter( _ids ); // set up the frequency group ParameterGroup f("Frequency"); f.addParameter( _frequency ); f.addParameter( _bandwidth ); f.addParameter( _subbands ); // set up the direction group ParameterGroup d("Direction"); d.addParameter( _directionType ); d.addParameter( _directionX ); d.addParameter( _directionY ); appendGroup( g ); appendGroup( f ); appendGroup( d ); }
bool KIcoPlugin::readInfo( KFileMetaInfo& info, uint what) { QFile file(info.path()); if (!file.open(IO_ReadOnly)) { kdDebug(7034) << "Couldn't open " << QFile::encodeName(info.path()) << endl; return false; } QDataStream dstream(&file); // ICO files are little-endian dstream.setByteOrder(QDataStream::LittleEndian); // read the beginning of the file and make sure it looks ok uint16_t ico_reserved; uint16_t ico_type; uint16_t ico_count; dstream >> ico_reserved; dstream >> ico_type; dstream >> ico_count; if ((ico_reserved != 0) || (ico_type != 1) || (ico_count < 1)) return false; // now loop through each of the icon entries uint8_t icoe_width; uint8_t icoe_height; uint8_t icoe_colorcount; uint8_t icoe_reserved; uint16_t icoe_planes; uint16_t icoe_bitcount; uint32_t icoe_bytesinres; uint32_t icoe_imageoffset; // read the data on the 1st icon dstream >> icoe_width; dstream >> icoe_height; dstream >> icoe_colorcount; dstream >> icoe_reserved; dstream >> icoe_planes; dstream >> icoe_bitcount; dstream >> icoe_bytesinres; dstream >> icoe_imageoffset; // output the useful bits KFileMetaInfoGroup group = appendGroup(info, "Technical"); appendItem(group, "Number", ico_count); if (ico_count == 1) { appendItem(group, "Dimensions", QSize(icoe_width, icoe_height)); if (icoe_colorcount > 0) appendItem(group, "Colors", icoe_colorcount); else if (icoe_bitcount > 0) appendItem(group, "Colors", 2 ^ icoe_bitcount); } else { appendItem(group, "DimensionsM", QSize(icoe_width, icoe_height)); if (icoe_colorcount > 0) appendItem(group, "ColorsM", icoe_colorcount); else if (icoe_bitcount > 0) appendItem(group, "ColorsM", 2 ^ icoe_bitcount); } return true; }
bool KFlacPlugin::readInfo( KFileMetaInfo& info, uint what ) { if ( info.path().isEmpty() ) // remote file return false; bool readComment = false; bool readTech = false; if (what & (KFileMetaInfo::Fastest | KFileMetaInfo::DontCare | KFileMetaInfo::ContentInfo)) readComment = true; if (what & (KFileMetaInfo::Fastest | KFileMetaInfo::DontCare | KFileMetaInfo::TechnicalInfo)) readTech = true; TagLib::File *file = 0; if (info.mimeType() == "audio/x-flac") file = new TagLib::FLAC::File(QFile::encodeName(info.path()).data(), readTech); #ifdef TAGLIB_1_2 else file = new TagLib::Ogg::FLAC::File(QFile::encodeName(info.path()).data(), readTech); #endif if (!file || !file->isValid()) { kdDebug(7034) << "Couldn't open " << file->name() << endl; delete file; return false; } if(readComment && file->tag()) { KFileMetaInfoGroup commentgroup = appendGroup(info, "Comment"); QString date = file->tag()->year() > 0 ? QString::number(file->tag()->year()) : QString::null; QString track = file->tag()->track() > 0 ? QString::number(file->tag()->track()) : QString::null; appendItem(commentgroup, "Title", TStringToQString(file->tag()->title()).stripWhiteSpace()); appendItem(commentgroup, "Artist", TStringToQString(file->tag()->artist()).stripWhiteSpace()); appendItem(commentgroup, "Album", TStringToQString(file->tag()->album()).stripWhiteSpace()); appendItem(commentgroup, "Date", date); appendItem(commentgroup, "Comment", TStringToQString(file->tag()->comment()).stripWhiteSpace()); appendItem(commentgroup, "Tracknumber", track); appendItem(commentgroup, "Genre", TStringToQString(file->tag()->genre()).stripWhiteSpace()); } if (readTech && file->audioProperties()) { KFileMetaInfoGroup techgroup = appendGroup(info, "Technical"); TagLib::FLAC::Properties *properties = (TagLib::FLAC::Properties*)(file->audioProperties()); appendItem(techgroup, "Bitrate", properties->bitrate()); appendItem(techgroup, "Sample Rate", properties->sampleRate()); appendItem(techgroup, "Sample Width", properties->sampleWidth()); appendItem(techgroup, "Channels", properties->channels()); appendItem(techgroup, "Length", properties->length()); } delete file; return true; }
bool KRpmPlugin::readInfo( KFileMetaInfo& info, uint what) { QFile file(info.path()); int pass; KFileMetaInfoGroup general, all; if (!file.open(QIODevice::ReadOnly)) { kDebug(7034) << "Couldn't open " << QFile::encodeName(info.path()); return false; } QDataStream dstream(&file); dstream.setByteOrder(QDataStream::BigEndian); general = appendGroup(info, "General"); if (what == KFileMetaInfo::Everything) all = appendGroup(info, "All tags"); file.seek(96); // Seek past old lead for (pass = 0; pass < 2; ++pass) { // RPMs have two headers uint32_t storepos, entries, size, reserved; unsigned char version; char magic[3]; dstream.readRawBytes(magic, 3); dstream >> version >> reserved >> entries >> size; if (memcmp(magic, RPM_HEADER_MAGIC, 3)) return false; if (version != 1) return false; // Only v1 headers supported storepos = file.pos() + entries * 16; if (pass == 0) { // Don't need the first batch of tags - pgp etc file.seek(storepos + size); file.seek(file.pos() + (8 - (file.pos() % 8)) % 8); // Skip padding continue; } if (entries < 500) while (entries--) { // Just in case something goes wrong, limit to 500 uint32_t tag, type, offset, count; QString tagname; dstream >> tag >> type >> offset >> count; offset += storepos; switch (tag) { case RPMTAG_NAME: tagname = "Name"; break; case RPMTAG_VERSION: tagname = "Version"; break; case RPMTAG_SUMMARY: tagname = "Summary"; break; case RPMTAG_GROUP: tagname = "Group"; break; case RPMTAG_SIZE: tagname = "Size"; break; case RPMTAG_RELEASE: tagname = "Release"; break; case RPMTAG_VENDOR: tagname = "Vendor"; break; case RPMTAG_PACKAGER: tagname = "Packager"; break; case RPMTAG_DESCRIPTION: tagname = "Comment"; break; } if ( !tagname.isEmpty() || all.isValid() ) { // kDebug(7034) << "Tag number: " << tag << " Type: " << type; int oldPos = file.pos(); file.seek(offset); // Set file position to correct place in store switch (type) { case RPM_INT32_TYPE: uint32_t int32tag; dstream >> int32tag; if ( !tagname.isEmpty() ) appendItem(general, tagname, int(int32tag)); if ( all.isValid() ) appendItem(all, QString("%1").arg( tag ), QString("%1").arg( int32tag )); break; case RPM_INT16_TYPE: uint16_t int16tag; dstream >> int16tag; if ( !tagname.isEmpty() ) appendItem(general, tagname, int(int16tag)); if ( all.isValid() ) appendItem(all, QString("%1").arg( tag ), QString("%1").arg( int16tag )); break; case RPM_I18NSTRING_TYPE: // Fallthru case RPM_STRING_TYPE: QString strtag; char in; while ( ( in = file.getch() ) != '\0' ) strtag += in; if ( !tagname.isEmpty() ) appendItem(general, tagname, strtag); if( all.isValid() ) appendItem(all, QString("%1").arg( tag ), strtag); break; } file.seek(oldPos); // Restore old position } } appendItem(general, "Archive Offset", (storepos + size) ); }
bool KAuPlugin::readInfo( KFileMetaInfo& info, uint what) { // the file signature, wants to be tidier... const char fsig[] = { 0x2e, 0x73, 0x6e, 0x64 }; // a dword buffer for input char inbuf[4]; // some vars for the file properties uint32_t datasize; uint32_t encoding; uint32_t samplerate; uint32_t channels; uint16_t bytespersample; if ( info.path().isEmpty() ) // remote file return false; QFile file(info.path()); if (!file.open(IO_ReadOnly)) { kdDebug(7034) << "Couldn't open " << QFile::encodeName(info.path()) << endl; return false; } QDataStream dstream(&file); // AU files are big-endian dstream.setByteOrder(QDataStream::BigEndian); // Read and verify the signature dstream.readRawBytes(inbuf, 4); if (memcmp(fsig, inbuf, 4)) return false; // skip unwanted bits file.at(8); // grab the bits we want dstream >> datasize; dstream >> encoding; dstream >> samplerate; dstream >> channels; // add the info KFileMetaInfoGroup group = appendGroup(info, "Technical"); appendItem(group, "Sample Rate", (uint) samplerate); appendItem(group, "Channels", (uint) channels); // work out the encoding switch (encoding) { case 1 : appendItem(group, "Encoding", i18n("8-bit ISDN u-law")); bytespersample = 1; break; case 2 : appendItem(group, "Encoding", i18n("8-bit linear PCM [REF-PCM]")); bytespersample = 1; break; case 3 : appendItem(group, "Encoding", i18n("16-bit linear PCM")); bytespersample = 2; break; case 4 : appendItem(group, "Encoding", i18n("24-bit linear PCM")); bytespersample = 3; break; case 5 : appendItem(group, "Encoding", i18n("32-bit linear PCM")); bytespersample = 4; break; case 6 : appendItem(group, "Encoding", i18n("32-bit IEEE floating point")); bytespersample = 4; break; case 7 : appendItem(group, "Encoding", i18n("64-bit IEEE floating point")); bytespersample = 8; break; case 23 : appendItem(group, "Encoding", i18n("8-bit ISDN u-law compressed")); bytespersample = 1; break; default : appendItem(group, "Encoding", i18n("Unknown")); bytespersample = 0; } // work out length from bytespersample + channels + size if ((channels > 0) && (datasize > 0) && (datasize != 0xFFFFFFFF) && (bytespersample > 0) && (samplerate > 0)) { uint32_t length = datasize / channels / bytespersample / samplerate; appendItem(group, "Length", (uint) length); } else { appendItem(group, "Length", "???"); } return true; }
bool KigPlugin::readInfo( KFileMetaInfo& metainfo, uint /*what*/ ) { KFileMetaInfoGroup metagroup = appendGroup( metainfo, "KigInfo"); QString sfile = metainfo.path(); bool iscompressed = false; QFile f( sfile ); if ( !sfile.endsWith( ".kig", false ) ) { iscompressed = true; QString tempdir = KGlobal::dirs()->saveLocation( "tmp" ); if ( tempdir.isEmpty() ) return false; QString tempname = sfile.section( '/', -1 ); if ( sfile.endsWith( ".kigz", false ) ) { tempname.remove( QRegExp( "\\.[Kk][Ii][Gg][Zz]$" ) ); } else return false; // reading compressed file KTar* ark = new KTar( sfile, "application/x-gzip" ); ark->open( IO_ReadOnly ); const KArchiveDirectory* dir = ark->directory(); QStringList entries = dir->entries(); QStringList kigfiles = entries.grep( QRegExp( "\\.kig$" ) ); if ( kigfiles.count() != 1 ) return false; const KArchiveEntry* kigz = dir->entry( kigfiles[0] ); if ( !kigz->isFile() ) return false; dynamic_cast<const KArchiveFile*>( kigz )->copyTo( tempdir ); f.setName( tempdir + kigz->name() ); } if ( !f.open( IO_ReadOnly ) ) return false; QDomDocument doc( "KigDocument" ); if ( !doc.setContent( &f ) ) return false; f.close(); // removing temp file if ( iscompressed ) f.remove(); QDomElement main = doc.documentElement(); // reading the version... QString version = main.attribute( "Version" ); if ( version.isEmpty() ) version = main.attribute( "version" ); if ( version.isEmpty() ) version = i18n( "Translators: Not Available", "n/a" ); appendItem( metagroup, "Version", version ); // reading the compatibility version... QString compatversion = main.attribute( "CompatibilityVersion" ); if ( compatversion.isEmpty() ) compatversion = i18n( "%1 represents Kig version", "%1 (as the version)" ).arg( version ); appendItem( metagroup, "CompatVersion", compatversion ); // reading the Coordinate System... QCString coordsystem; for ( QDomNode n = main.firstChild(); ! n.isNull(); n = n.nextSibling() ) { QDomElement e = n.toElement(); if ( e.isNull() ) continue; if ( e.tagName() == "CoordinateSystem" ) coordsystem = e.text().latin1(); } appendItem( metagroup, "CoordSystem", coordsystem ); // has Kig document the grid? bool btmp = true; QString stmp = main.attribute( "grid" ); if ( !( stmp.isEmpty() || ( stmp != "0" ) ) ) btmp = ( stmp != "0" ); QString stmp2 = btmp ? i18n( "Yes" ) : i18n( "No" ); appendItem( metagroup, "Grid", stmp2 ); // has Kig document the axes? btmp = true; stmp = main.attribute( "axes" ); if ( !( stmp.isEmpty() || ( stmp != "0" ) ) ) btmp = ( stmp != "0" ); stmp2 = btmp ? i18n( "Yes" ) : i18n( "No" ); appendItem( metagroup, "Axes", stmp2 ); stmp2 = iscompressed ? i18n( "Yes" ) : i18n( "No" ); appendItem( metagroup, "Compressed", stmp2 ); return true; }
bool KXpsPlugin::readInfo( KFileMetaInfo& info, uint /* what */) { KFileMetaInfoGroup generalGroup = appendGroup(info, "General"); KZip *xpsArchive = new KZip( info.path() ); if ( xpsArchive->open( IO_ReadOnly ) == true ) { // kdDebug(7115) << "Successful open of " << xpsArchive->fileName() << endl; } else { kDebug(7115) << "Could not open XPS archive: " << xpsArchive->fileName(); delete xpsArchive; return false; } const KZipFileEntry* relFile = static_cast<const KZipFileEntry *>(xpsArchive->directory()->entry("_rels/.rels")); if ( !relFile ) { delete xpsArchive; // this might occur if we can't read the zip directory, or it doesn't have the relationships entry return false; } if ( relFile->name().isEmpty() ) { delete xpsArchive; // this might occur if we can't read the zip directory, or it doesn't have the relationships entry return false; } QIODevice* relDevice = relFile->createDevice(); QDomDocument relDom; QString errMsg; int errLine, errCol; if ( relDom.setContent( relDevice, true, &errMsg, &errLine, &errCol ) == false ) { // parse error kDebug(7115) << "Could not parse relationship document: " << errMsg << " : " << errLine << " : " << errCol << endl; delete relDevice; delete xpsArchive; return false; } QDomElement docElem = relDom.documentElement(); QString thumbFileName; QString fixedRepresentationFileName; QString metadataFileName; QDomNode n = docElem.firstChild(); while( !n.isNull() ) { QDomElement e = n.toElement(); if( !e.isNull() ) { if ("http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail" == e.attribute("Type") ) { thumbFileName = e.attribute("Target"); } else if ("http://schemas.microsoft.com/xps/2005/06/fixedrepresentation" == e.attribute("Type") ) { fixedRepresentationFileName = e.attribute("Target"); } else if ("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" == e.attribute("Type") ) { metadataFileName = e.attribute("Target"); } } n = n.nextSibling(); } delete relDevice; if ( fixedRepresentationFileName.isEmpty() ) { delete xpsArchive; // FixedRepresentation is a required part of the XPS document return false; } const KZipFileEntry* fixedRepFile = static_cast<const KZipFileEntry *>(xpsArchive->directory()->entry( fixedRepresentationFileName )); QIODevice* fixedRepDevice = fixedRepFile->createDevice(); QDomDocument fixedRepDom; if ( fixedRepDom.setContent( fixedRepDevice, true, &errMsg, &errLine, &errCol ) == false ) { // parse error kDebug(7115) << "Could not parse Fixed Representation document: " << errMsg << " : " << errLine << " : " << errCol << endl; delete fixedRepDevice; delete xpsArchive; return false; } docElem = fixedRepDom.documentElement(); QString firstDocumentFileName; int numDocuments = 0; // the number of Documents in this FixedDocumentSequence n = docElem.firstChild(); while( !n.isNull() ) { QDomElement e = n.toElement(); if( !e.isNull() ) { if (e.tagName() == "DocumentReference") { if (firstDocumentFileName.isEmpty()) { // we don't already have a filename, so take this one firstDocumentFileName = e.attribute("Source"); } numDocuments++; } } n = n.nextSibling(); } delete fixedRepDevice; #if 0 // This stuff is used for detailed parsing - not really required // no document? bail out here. if ( firstDocumentFileName.isEmpty() ) { return false; } KZipFileEntry* firstDocumentFile = static_cast<const KZipFileEntry *>(xpsArchive->directory()->entry( firstDocumentFileName )); QIODevice* firstDocumentDevice = firstDocumentFile->device(); QDomDocument firstDocumentDom; if ( firstDocumentDom.setContent( firstDocumentDevice, true, &errMsg, &errLine, &errCol ) == false ) { // parse error kDebug(7115) << "Could not parse first document: " << errMsg << " : " << errLine << " : " << errCol << endl; return false; } n = firstDocumentDom.documentElement().firstChild(); while( !n.isNull() ) { QDomElement e = n.toElement(); if( !e.isNull() ) { kDebug(7155) << "DOcument: " << e.tagName() << " : " << e.text(); } n = n.nextSibling(); } #endif if ( ! metadataFileName.isEmpty() ) { const KZipFileEntry* corepropsFile = static_cast<const KZipFileEntry *>(xpsArchive->directory()->entry(metadataFileName)); kDebug(7115) << "metadata file name: " << metadataFileName; QDomDocument metadataDocumentDom; QIODevice *corepropsDevice = corepropsFile->createDevice(); if ( metadataDocumentDom.setContent( corepropsDevice, true, &errMsg, &errLine, &errCol ) == false ) { // parse error kDebug(7115) << "Could not parse core properties (metadata) document: " << errMsg << " : " << errLine << " : " << errCol << endl; delete corepropsDevice; delete xpsArchive; return false; } n = metadataDocumentDom.documentElement().firstChild(); // the <coreProperties> level while( !n.isNull() ) { QDomElement e = n.toElement(); if( !e.isNull() ) { if (e.tagName() == "title") { appendItem(generalGroup, "Title", e.text() ); } else if (e.tagName() == "subject") { appendItem(generalGroup, "Subject", e.text() ); } else if (e.tagName() == "description") { appendItem(generalGroup, "Description", e.text() ); } else if (e.tagName() == "creator") { appendItem(generalGroup, "Author", e.text() ); } else if (e.tagName() == "created") { appendItem(generalGroup, "CreationDate", QDateTime::fromString( e.text(), "yyyy-MM-ddThh:mm:ssZ" ) ); } else if (e.tagName() == "modified") { appendItem(generalGroup, "ModificationDate", QDateTime::fromString( e.text(), "yyyy-MM-ddThh:mm:ssZ" ) ); } else if (e.tagName() == "keywords") { appendItem(generalGroup, "Keywords", e.text() ); } else { kDebug(7155) << "unhandled metadata tag: " << e.tagName() << " : " << e.text(); } } n = n.nextSibling(); } delete corepropsDevice; } if ( ! thumbFileName.isEmpty() ) { const KZipFileEntry* thumbFile = static_cast<const KZipFileEntry *>(xpsArchive->directory()->entry(thumbFileName)); QImage img; img.loadFromData(thumbFile->data()); appendItem( generalGroup, "Thumbnail", img); appendItem( generalGroup, "ThumbnailDimensions", QSize( img.width(), img.height() ) ); } appendItem(generalGroup, "Documents", numDocuments); delete xpsArchive; return true; }
bool KPngPlugin::readInfo( KFileMetaInfo& info, uint what) { if ( info.path().isEmpty() ) // remote file return false; QFile f(info.path()); if ( !f.open(IO_ReadOnly) ) return false; QIODevice::Offset fileSize = f.size(); if (fileSize < 29) return false; // the technical group will be read from the first 29 bytes. If the file // is smaller, we can't even read this. bool readComments = false; if (what & (KFileMetaInfo::Fastest | KFileMetaInfo::DontCare | KFileMetaInfo::ContentInfo)) readComments = true; else fileSize = 29; // No need to read more uchar *data = new uchar[fileSize+1]; f.readBlock(reinterpret_cast<char*>(data), fileSize); data[fileSize]='\n'; // find the start if (data[0] == 137 && data[1] == 80 && data[2] == 78 && data[3] == 71 && data[4] == 13 && data[5] == 10 && data[6] == 26 && data[7] == 10 ) { // ok // the IHDR chunk should be the first if (!strncmp((char*)&data[12], "IHDR", 4)) { // we found it, get the dimensions ulong x,y; x = (data[16]<<24) + (data[17]<<16) + (data[18]<<8) + data[19]; y = (data[20]<<24) + (data[21]<<16) + (data[22]<<8) + data[23]; uint type = data[25]; uint bpp = data[24]; kdDebug(7034) << "dimensions " << x << "*" << y << endl; // the bpp are only per channel, so we need to multiply the with // the channel count switch (type) { case 0: break; // Grayscale case 2: bpp *= 3; break; // RGB case 3: break; // palette case 4: bpp *= 2; break; // grayscale w. alpha case 6: bpp *= 4; break; // RGBA default: // we don't get any sensible value here bpp = 0; } KFileMetaInfoGroup techgroup = appendGroup(info, "Technical"); appendItem(techgroup, "Dimensions", QSize(x, y)); appendItem(techgroup, "BitDepth", bpp); appendItem(techgroup, "ColorMode", (type < sizeof(colors)/sizeof(colors[0])) ? i18n(colors[data[25]]) : i18n("Unknown")); appendItem(techgroup, "Compression", (data[26] < sizeof(compressions)/sizeof(compressions[0])) ? i18n(compressions[data[26]]) : i18n("Unknown")); appendItem(techgroup, "InterlaceMode", (data[28] < sizeof(interlaceModes)/sizeof(interlaceModes[0])) ? i18n(interlaceModes[data[28]]) : i18n("Unknown")); } // look for a tEXt chunk if (readComments) { uint index = 8; index += CHUNK_SIZE(data, index) + CHUNK_HEADER_SIZE; KFileMetaInfoGroup commentGroup = appendGroup(info, "Comment"); while(index<fileSize-12) { while (index < fileSize - 12 && strncmp((char*)CHUNK_TYPE(data,index), "tEXt", 4) && strncmp((char*)CHUNK_TYPE(data,index), "zTXt", 4)) { if (!strncmp((char*)CHUNK_TYPE(data,index), "IEND", 4)) goto end; index += CHUNK_SIZE(data, index) + CHUNK_HEADER_SIZE; } if (index < fileSize - 12) { // we found a tEXt or zTXt field // get the key, it's a null terminated string at the // chunk start uchar* key = &CHUNK_DATA(data,index,0); int keysize=0; for (;key[keysize]!=0; keysize++) // look if we reached the end of the file // (it might be corrupted) if (8+index+keysize>=fileSize) goto end; QByteArray arr; if(!strncmp((char*)CHUNK_TYPE(data,index), "zTXt", 4)) { kdDebug(7034) << "We found a zTXt field\n"; // we get the compression method after the key uchar* compressionMethod = &CHUNK_DATA(data,index,keysize+1); if ( *compressionMethod != 0x00 ) { // then it isn't zlib compressed and we are sunk kdDebug(7034) << "Non-standard compression method." << endl; goto end; } // compressed string after the compression technique spec uchar* compressedText = &CHUNK_DATA(data, index, keysize+2); uint compressedTextSize = CHUNK_SIZE(data, index)-keysize-2; // security check, also considering overflow wraparound from the addition -- // we may endup with a /smaller/ index if we wrap all the way around uint firstIndex = (uint)(compressedText - data); uint onePastLastIndex = firstIndex + compressedTextSize; if ( onePastLastIndex > fileSize || onePastLastIndex <= firstIndex) goto end; uLongf uncompressedLen = compressedTextSize * 2; // just a starting point int zlibResult; do { arr.resize(uncompressedLen); zlibResult = uncompress((Bytef*)arr.data(), &uncompressedLen, compressedText, compressedTextSize); if (Z_OK == zlibResult) { // then it is all OK arr.resize(uncompressedLen); } else if (Z_BUF_ERROR == zlibResult) { // the uncompressedArray needs to be larger // kdDebug(7034) << "doubling size for decompression" << endl; uncompressedLen *= 2; // DoS protection. can't be bigger than 64k if ( uncompressedLen > 131072 ) break; } else { // something bad happened goto end; } } while (Z_BUF_ERROR == zlibResult); if (Z_OK != zlibResult) goto end; } else if (!strncmp((char*)CHUNK_TYPE(data,index), "tEXt", 4)) { kdDebug(7034) << "We found a tEXt field\n"; // the text comes after the key, but isn't null terminated uchar* text = &CHUNK_DATA(data,index, keysize+1); uint textsize = CHUNK_SIZE(data, index)-keysize-1; // security check, also considering overflow wraparound from the addition -- // we may endup with a /smaller/ index if we wrap all the way around uint firstIndex = (uint)(text - data); uint onePastLastIndex = firstIndex + textsize; if ( onePastLastIndex > fileSize || onePastLastIndex <= firstIndex) goto end; arr.resize(textsize); arr = QByteArray(textsize).duplicate((const char*)text, textsize); } else { kdDebug(7034) << "We found a field, not expected though\n"; goto end; } appendItem(commentGroup, QString(reinterpret_cast<char*>(key)), QString(arr)); kdDebug(7034) << "adding " << key << " / " << QString(arr) << endl; index += CHUNK_SIZE(data, index) + CHUNK_HEADER_SIZE; } } } } end: delete[] data; return true; }
bool KOfficePlugin::readInfo( KFileMetaInfo& info, uint /*what*/) { if ( info.path().isEmpty() ) // remote file return false; KFileMetaInfoGroup group = appendGroup(info, DocumentInfo); QDomDocument doc = getMetaDocument(info.path()); if (doc.isNull()) return false; QDomElement base = getBaseNode(doc).toElement(); if (base.isNull()) return false; for (int i = 0; Information[i]; i+=2) appendItem(group, Information[i], stringFromNode(base, Information[i])); // Special case for keyword QDomNodeList keywordList = base.elementsByTagName( metakeyword ); QString allKeywords; for (uint i = 0; i < keywordList.length(); i++){ QDomNode node = keywordList.item(i); if (node.isElement()){ if (i>0) allKeywords += ", "; allKeywords += node.toElement().text(); } } appendItem(group, metakeyword, allKeywords); KFileMetaInfoGroup group1 = appendGroup(info, DocAdvanced); for (int i = 0; Advanced[i]; i+=2){ QString txt = stringFromNode(base, Advanced[i]); if (!txt.isEmpty()){ // A silly way to do it... switch (i){ case 2: case 4: case 6: getDateTime(group1, Advanced[i], txt); break; case 14: getEditingTime(group1, Advanced[i], txt); break; default: appendItem(group1, Advanced[i], txt);} } } QDomNode dstat = base.namedItem(metadocstat); KFileMetaInfoGroup group2 = appendGroup(info, DocStatistics); if (!dstat.isNull() && dstat.isElement()){ QDomElement dinfo = dstat.toElement(); for (int i = 0; Statistics[i]; i+=2) addAttributeInfo(dinfo, group2, Statistics[i] ); } QDomNodeList userList = base.elementsByTagName( metauserdef ); KFileMetaInfoGroup groupuser = appendGroup(info, UserDefined); for (uint i = 0; i < userList.length(); i++){ QDomNode node = userList.item(i); if (node.isElement()){ appendItem(groupuser, node.toElement().attribute(metaname, QString("User %1").arg(i)), node.toElement().text()); } } return true; }
bool KTiffPlugin::readInfo(KFileMetaInfo& info, uint) { TIFF *tiff = TIFFOpen(QFile::encodeName(info.path()), "r"); if (!tiff) return false; uint32 imageLength=0, imageWidth=0; uint16 bitsPerSample=0, imageCompression=0, colorMode=0, samplesPerPixel=0, imageAlpha=0, imageResUnit=0, dummy=0, faxPages=0; float imageXResolution=0, imageYResolution=0; char *description=0, *copyright=0, *software=0, *datetime=0, *artist=0, *scannerMake=0, *scannerModel=0; TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &imageLength); TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &imageWidth); TIFFGetFieldDefaulted(tiff, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); TIFFGetFieldDefaulted(tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel); TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &colorMode); TIFFGetFieldDefaulted(tiff, TIFFTAG_COMPRESSION, &imageCompression); TIFFGetField(tiff, TIFFTAG_MATTEING, &imageAlpha); TIFFGetField(tiff, TIFFTAG_XRESOLUTION, &imageXResolution); TIFFGetField(tiff, TIFFTAG_YRESOLUTION, &imageYResolution); TIFFGetFieldDefaulted(tiff, TIFFTAG_RESOLUTIONUNIT, &imageResUnit); TIFFGetField(tiff, TIFFTAG_IMAGEDESCRIPTION, &description); TIFFGetField(tiff, TIFFTAG_SOFTWARE, &software); TIFFGetField(tiff, TIFFTAG_COPYRIGHT, ©right); TIFFGetField(tiff, TIFFTAG_DATETIME, &datetime); TIFFGetField(tiff, TIFFTAG_ARTIST, &artist); TIFFGetField(tiff, TIFFTAG_PAGENUMBER, &dummy, &faxPages); TIFFGetField(tiff, TIFFTAG_MAKE, &scannerMake); TIFFGetField(tiff, TIFFTAG_MODEL, &scannerModel); kDebug(7034) << "Description: " << description; kDebug(7034) << "Width: " << imageWidth; kDebug(7034) << "Height: " << imageLength; kDebug(7034) << "BitDepth: " << bitsPerSample; kDebug(7034) << "ColorMode: " << colorMode; kDebug(7034) << "Compression: " << imageCompression; kDebug(7034) << "SamplesPerPixel: " << samplesPerPixel; kDebug(7034) << "ImageAlpha: " << imageAlpha; kDebug(7034) << "XResolution: " << imageXResolution; kDebug(7034) << "YResolution: " << imageYResolution; kDebug(7034) << "ResolutionUnit: " << imageResUnit; kDebug(7034) << "FaxPages: " << faxPages; kDebug(7034) << "DateTime: " << datetime; kDebug(7034) << "Copyright: " << copyright; kDebug(7034) << "Software: " << software; kDebug(7034) << "Artist: " << artist; kDebug(7034) << "Make: " << scannerMake; kDebug(7034) << "Model: " << scannerModel; if (imageResUnit == RESUNIT_CENTIMETER) { imageXResolution *= 2.54; imageYResolution *= 2.54; } else if (imageResUnit == RESUNIT_NONE) { imageXResolution = 0; imageYResolution = 0; } int imageBpp = bitsPerSample*samplesPerPixel; if (imageAlpha && colorMode==PHOTOMETRIC_RGB) m_colorMode.replace(PHOTOMETRIC_RGB, new QString(I18N_NOOP("RGBA"))); KFileMetaInfoGroup group = appendGroup(info, "General"); if (description) appendItem(group, "Description", QString(description)); appendItem(group, "Dimensions", QSize(imageWidth, imageLength)); appendItem(group, "BitDepth", imageBpp); if (imageXResolution>0 && imageYResolution>0) appendItem(group, "Resolution", QSize( static_cast<int>(imageXResolution), static_cast<int>(imageYResolution))); if (m_colorMode[colorMode]) appendItem(group, "ColorMode", *m_colorMode[colorMode]); if (m_imageCompression[imageCompression]) appendItem(group, "Compression", *m_imageCompression[imageCompression]); if (datetime) { QDateTime dt = tiffDate(QString(datetime)); if (dt.isValid()) appendItem(group, "DateTime", dt); } if (copyright) appendItem(group, "Copyright", QString(copyright)); if (software) appendItem(group, "Software", QString(software)); if (artist) appendItem(group, "Artist", QString(artist)); if (faxPages>0 && (imageCompression==COMPRESSION_CCITTFAX3 || imageCompression==COMPRESSION_CCITTFAX4)) { appendItem(group, "FaxPages", faxPages); } if (scannerMake || scannerModel) { group = appendGroup(info, "Scanner"); if (scannerMake) appendItem(group, "Make", QString(scannerMake)); if (scannerModel) appendItem(group, "Model", QString(scannerModel)); } TIFFClose(tiff); return true; }
void r_makeDFA( FA *fa ) { ARC *prevarc = NULL; ARC *curarc; int inp; int bundleNum; FLAG reserved = 0; int i; FLAG newFlag; FALIST *volatileList = NULL; CLASSFLAGS unifyAccptFlag; CLASSFLAGS unifyStartFlag; verboseMes( "[func]r_makeDFA(FA %08x)", (long)fa ); DFAtravTotal++; if( fa->traversed == 1 ){ verboseMes( "traversed..." ); return; } fa->traversed = 1; DFAtravSuccess++; FAprocessed++; if( !SW_SemiQuiet ){ fprintf( stderr, "\rNow making deterministic finite automaton[%d/%d] ", FAprocessed, FAtotal ); NoNewLine = 1; } curarc = fa->nsList; while( curarc != NULL ){ FA *unifyingDstFA = NULL; { ARC *arc = curarc; int inp = arc->inp; FALIST *group = NULL; CLASSFLAGS accptFlag = 0; CLASSFLAGS startFlag = 0; bundleNum = 0; while( 1 ){ if( arc == NULL || arc->inp != inp ) break; group = appendGroup( group, arc->fa ); accptFlag |= arc->fa->accpt; startFlag |= arc->fa->start; arc = arc->next; bundleNum++; } if( bundleNum > 1 ){ unifyingDstFA = chkGroup( group, accptFlag, startFlag,&newFlag ); } else { /* この下4行はブロック外のwhileに対してのもの */ freeFAlist( group ); prevarc = curarc; curarc = curarc->next; continue; } } inp = curarc->inp; unifyAccptFlag = 0; unifyStartFlag = 0; for( i = 0; i < bundleNum; i++ ){ unifyAccptFlag |= curarc->accpt; unifyStartFlag |= curarc->start; if( !newFlag ){ /* volatileList = volatileFA( volatileList, curarc->ns );*/ curarc = unconnectFA( fa, prevarc, curarc ); } else { if( curarc->fa == fa /* self-loop */ ){ reserved = 1; /* volatileList = volatileFA( volatileList, fa );*/ curarc = unconnectFA( fa, prevarc, curarc ); } else { curarc = unifyFA( unifyingDstFA, prevarc, curarc, fa ); } } } connectUnifyFA( fa, inp, unifyingDstFA, reserved, unifyAccptFlag, unifyStartFlag ); reserved = 0; } usArc2nsArc( fa ); /* unvolatileFA( volatileList );*/ curarc = fa->nsList; while( curarc != NULL ){ r_makeDFA( curarc->fa ); curarc = curarc->next; } }