void SynchronizerDirList::slotEntries(KIO::Job * job, const KIO::UDSEntryList& entries)
{
    KIO::UDSEntryList::const_iterator it = entries.begin();
    KIO::UDSEntryList::const_iterator end = entries.end();

    int rwx = -1;
    QString prot = ((KIO::ListJob *)job)->url().scheme();

    if (prot == "krarc" || prot == "tar" || prot == "zip")
        rwx = PERM_ALL;

    while (it != end) {
        KFileItem kfi(*it, ((KIO::ListJob *)job)->url(), true, true);
        QString key = kfi.text();
        if (key != "." && key != ".." && (!ignoreHidden || !key.startsWith(QLatin1String(".")))) {
            mode_t mode = kfi.mode() | kfi.permissions();
            QString perm = KRpermHandler::mode2QString(mode);
            if (kfi.isDir())
                perm[ 0 ] = 'd';

            vfile *item = new vfile(kfi.text(), kfi.size(), perm, kfi.time(KFileItem::ModificationTime).toTime_t(),
                                    kfi.isLink(), false, kfi.user(), kfi.group(), kfi.user(),
                                    kfi.mimetype(), kfi.linkDest(), mode, rwx
#ifdef HAVE_POSIX_ACL
                                    , kfi.ACL().asString()
#endif
                                   );
            insert(key, item);
        }
        ++it;
    }
}
Example #2
0
void
AudioCdCollection::audioCdEntries( KIO::Job *job, const KIO::UDSEntryList &list )
{
    if( job->error() )
    {
        error() << job->error();
        job->deleteLater();
    }
    else
    {
        KIO::UDSEntryList::ConstIterator it = list.begin();
        const KIO::UDSEntryList::ConstIterator end = list.end();
        for( ; it != end; ++it )
        {
            const KIO::UDSEntry &entry = *it;
            QString name = entry.stringValue( KIO::UDSEntry::UDS_NAME );
            if( name.endsWith( QLatin1String(".txt") ) )
            {
                KUrl url =  audiocdUrl( name );
                KIO::StoredTransferJob *tjob = KIO::storedGet( url, KIO::NoReload, KIO::HideProgressInfo );
                connect( tjob, SIGNAL(result(KJob*)), SLOT(infoFetchComplete(KJob*)) );
                job->deleteLater();
                break;
            }
        }
    }
}
Example #3
0
void ClientApp::slotEntries(KIO::Job* job, const KIO::UDSEntryList& list)
{
    KUrl url = static_cast<KIO::ListJob*>( job )->url();
    KIO::UDSEntryList::ConstIterator it=list.begin();
    for (; it != list.end(); ++it) {
        // For each file...
        QString name = (*it).stringValue( KIO::UDSEntry::UDS_NAME );
        std::cout << qPrintable(name) << std::endl;
    }
}
Example #4
0
void KQuery::slotListEntries(KIO::Job*, const KIO::UDSEntryList& list)
{
  KFileItem * file = 0;
  KIO::UDSEntryListConstIterator end = list.end();
  for (KIO::UDSEntryListConstIterator it = list.begin(); it != end; ++it)
  {
    file = new KFileItem(*it, m_url, true, true);
    m_fileItems.enqueue(file);
  }
  checkEntries();
}
void TestRegressionWindow::directoryListingResult(KIO::Job *, const KIO::UDSEntryList &list)
{
	KIO::UDSEntryList::ConstIterator it = list.constBegin();
	const KIO::UDSEntryList::ConstIterator end = list.constEnd();

	for(; it != end; ++it)
	{
		const KIO::UDSEntry &entry = *it;

		QString name = entry.stringValue(KIO::UDSEntry::UDS_NAME);
		if(entry.isDir()) // Create new map entry...
		{
			assert(m_directoryMap.constFind(name) == m_directoryMap.constEnd());
			m_directoryMap.insert(name, QStringList());

			QString ignoreFile = m_testsUrl.path() + "/tests/" + name + "/ignore";
			QString failureFile = m_testsUrl.path() + "/tests/" + name + "/KNOWN_FAILURES";

			QStringList ignoreFileList = readListFile(ignoreFile);
			QStringList failureFileList = readListFile(failureFile);

			if(!ignoreFileList.isEmpty())
				m_ignoreMap.insert(name, ignoreFileList);

			if(!failureFileList.isEmpty())
				m_failureMap.insert(name, failureFileList);
		}
		else if(name.endsWith(".html") || name.endsWith(".htm") ||
				name.endsWith(".xhtml") || name.endsWith(".xml") || name.endsWith(".js"))
		{
			int lastSlashPos = name.lastIndexOf('/');

			QString cachedDirectory = (lastSlashPos > 0 ? name.mid(0, lastSlashPos) : QString());
			QString cachedFilename = name.mid(lastSlashPos + 1);

			assert(m_directoryMap.constFind(cachedDirectory) != m_directoryMap.constEnd());
			m_directoryMap[cachedDirectory].append(cachedFilename);
		}
	}
}
Example #6
0
void JobTest::slotEntries(KIO::Job *, const KIO::UDSEntryList &lst)
{
    for(KIO::UDSEntryList::ConstIterator it = lst.begin(); it != lst.end(); ++it)
    {
        KIO::UDSEntry::ConstIterator it2 = (*it).begin();
        QString displayName;
        KURL url;
        for(; it2 != (*it).end(); it2++)
        {
            switch((*it2).m_uds)
            {
                case KIO::UDS_NAME:
                    displayName = (*it2).m_str;
                    break;
                case KIO::UDS_URL:
                    url = (*it2).m_str;
                    break;
            }
        }
        m_names.append(displayName);
    }
}
Example #7
0
void QExtFileInfo::slotNewDetailedEntries(KIO::Job *job, const KIO::UDSEntryList& udsList)
{
  KURL url = static_cast<KIO::ListJob *>(job)->url();
  url.adjustPath(-1);
  // avoid creating these QStrings again and again
  static const QString& dot = KGlobal::staticQString(".");
  static const QString& dotdot = KGlobal::staticQString("..");

  KIO::UDSEntryListConstIterator it = udsList.begin();
  KIO::UDSEntryListConstIterator end = udsList.end();
  KURL itemURL;
  for ( ; it != end; ++it )
  {
    QString name;

    // find out about the name
    KIO::UDSEntry::ConstIterator entit = (*it).begin();
    for( ; entit != (*it).end(); ++entit )
      if ( (*entit).m_uds == KIO::UDS_NAME )
      {
        name = (*entit).m_str;
        break;
      }

    if ( ! name.isEmpty() && name != dot && name != dotdot)
    {
      KFileItem *item=  new KFileItem(*it, url, false, true );
      bool added = false;
      for ( QPtrListIterator<QRegExp> filterIt( lstFilters ); filterIt.current(); ++filterIt )
        if ( filterIt.current()->exactMatch( item->text() ) )
        {
          detailedDirListItems.insert(item->url().url(), item);
          added = true;    
        }
      if (!added) 
        delete item; 
    }
  }
}
Example #8
0
void DirectoryAdder::slotEntries(KIO::Job *, const KIO::UDSEntryList &entries)
{
	QMap<QString,KURL> __list; // temp list to sort entries

	KIO::UDSEntryListConstIterator it = entries.begin();
	KIO::UDSEntryListConstIterator end = entries.end();

	for (; it != end; ++it)
	{
		KFileItem file(*it, currentJobURL, false /* no mimetype detection */, true);
		// "prudhomm:
		// insert the path + url in the map to sort automatically by path
		// note also that you use audiocd to rip your CDs then it will be sorted the right way
		// now it is an easy fix to have a nice sort BUT it is not the best
		// we should sort based on the tracknumber"
		// - copied over from old kdirlister hack <*****@*****.**>
		__list.insert(file.url().path(), file.url());
	}
	QMap<QString,KURL>::Iterator __it;
	for( __it = __list.begin(); __it != __list.end(); ++__it )
	{
		oblique()->addFile(__it.data(), false);
	}
}
Example #9
0
/*
 * slotEntries
 *
 * Receive files listed by KIO and call addMatches()
 */
void KURLCompletion::slotEntries(KIO::Job *, const KIO::UDSEntryList &entries)
{
    QStringList matches;

    KIO::UDSEntryListConstIterator it = entries.begin();
    KIO::UDSEntryListConstIterator end = entries.end();

    QString filter = d->list_urls_filter;

    int filter_len = filter.length();

    // Iterate over all files
    //
    for(; it != end; ++it)
    {
        QString name;
        QString url;
        bool is_exe = false;
        bool is_dir = false;

        KIO::UDSEntry e = *it;
        KIO::UDSEntry::ConstIterator it_2 = e.begin();

        for(; it_2 != e.end(); it_2++)
        {
            switch((*it_2).m_uds)
            {
                case KIO::UDS_NAME:
                    name = (*it_2).m_str;
                    break;
                case KIO::UDS_ACCESS:
                    is_exe = ((*it_2).m_long & MODE_EXE) != 0;
                    break;
                case KIO::UDS_FILE_TYPE:
                    is_dir = ((*it_2).m_long & S_IFDIR) != 0;
                    break;
                case KIO::UDS_URL:
                    url = (*it_2).m_str;
                    break;
            }
        }

        if(!url.isEmpty())
        {
            // kdDebug() << "KURLCompletion::slotEntries url: " << url << endl;
            name = KURL(url).fileName();
        }

        // kdDebug() << "KURLCompletion::slotEntries name: " << name << endl;

        if(name[0] == '.' && (d->list_urls_no_hidden || name.length() == 1 || (name.length() == 2 && name[1] == '.')))
            continue;

        if(d->mode == DirCompletion && !is_dir)
            continue;

        if(filter_len == 0 || name.left(filter_len) == filter)
        {
            if(is_dir)
                name.append('/');

            if(is_exe || !d->list_urls_only_exe)
                matches.append(name);
        }
    }

    addMatches(matches);
}
Example #10
0
void ftp_vfs::slotAddFiles(KIO::Job *, const KIO::UDSEntryList& entries)
{
    int rwx = -1;

    QString prot = vfs_origin.scheme();
    if (prot == "krarc" || prot == "tar" || prot == "zip")
        rwx = PERM_ALL;

    KIO::UDSEntryList::const_iterator it = entries.begin();
    KIO::UDSEntryList::const_iterator end = entries.end();

    // as long as u can find files - add them to the vfs
    for (; it != end; ++it) {
        KFileItem kfi(*it, vfs_origin, true, true);
        vfile *temp;

        // get file statistics
        QString name = kfi.text();
        // ignore un-needed entries
        if (name.isEmpty() || name == "." || name == "..") continue;

        KIO::filesize_t size = kfi.size();
        time_t mtime = kfi.time(KFileItem::ModificationTime).toTime_t();
        bool symLink = kfi.isLink();
        mode_t mode = kfi.mode() | kfi.permissions();
        QString perm = KRpermHandler::mode2QString(mode);
        // set the mimetype
        QString mime = kfi.mimetype();
        QString symDest = "";
        if (symLink) {
            symDest = kfi.linkDest();
            if (kfi.isDir()) perm[ 0 ] = 'd';
        }

        // create a new virtual file object
        if (kfi.user().isEmpty())
            temp = new vfile(name, size, perm, mtime, symLink, false, getuid(), getgid(), mime, symDest, mode, rwx);
        else {
            QString currentUser = vfs_origin.userName();
            if (currentUser.contains("@"))      /* remove the FTP proxy tags from the username */
                currentUser.truncate(currentUser.indexOf('@'));
            if (currentUser.isEmpty()) {
                if (vfs_origin.host().isEmpty())
                    currentUser = KRpermHandler::uid2user(getuid());
                else {
                    currentUser = ""; // empty, but not QString()
                }
            }
            temp = new vfile(name, size, perm, mtime, symLink, false,
                             kfi.user(), kfi.group(), currentUser,
                             mime, symDest, mode, rwx, kfi.ACL().asString(),
                             kfi.defaultACL().asString());
        }

        if (!kfi.localPath().isEmpty()) {
            temp->vfile_setUrl(QUrl::fromLocalFile(kfi.localPath()));
        } else {
            temp->vfile_setUrl(kfi.url());
        }
        temp->vfile_setIcon(kfi.iconName());
        foundVfile(temp);
    }
}