Esempio n. 1
0
void RemoteProtocol::listRoot()
{
	KIO::UDSEntry entry;

	KIO::UDSEntryList remote_entries;
        m_impl.listRoot(remote_entries);

	totalSize(remote_entries.count()+2);

	m_impl.createTopLevelEntry(entry);
	listEntry(entry, false);

	m_impl.createWizardEntry(entry);
	listEntry(entry, false);

	KIO::UDSEntryList::ConstIterator it = remote_entries.constBegin();
	const KIO::UDSEntryList::ConstIterator end = remote_entries.constEnd();
	for(; it!=end; ++it)
	{
		listEntry(*it, false);
	}

	entry.clear();
	listEntry(entry, true);

	finished();
}
Esempio n. 2
0
void MediaProtocol::listRoot()
{
    KIO::UDSEntry entry;

    KIO::UDSEntryList media_entries;
    bool ok = m_impl.listMedia(media_entries);

    if (!ok)
    {
        error( m_impl.lastErrorCode(), m_impl.lastErrorMessage() );
        return;
    }

    totalSize(media_entries.count()+1);

    m_impl.createTopLevelEntry(entry);
    listEntry(entry, false);

    KIO::UDSEntryListIterator it = media_entries.begin();
    KIO::UDSEntryListIterator end = media_entries.end();

    for(; it!=end; ++it)
    {
        listEntry(*it, false);
    }

    entry.clear();
    listEntry(entry, true);

    finished();
}
Esempio n. 3
0
void TrashProtocol::listDir(const KUrl& url)
{
    INIT_IMPL;
    kDebug() << "listdir: " << url;
    if ( url.path(KUrl::AddTrailingSlash) == QLatin1String("/") ) {
        listRoot();
        return;
    }
    int trashId;
    QString fileId;
    QString relativePath;
    bool ok = TrashImpl::parseURL( url, trashId, fileId, relativePath );
    if ( !ok ) {
        error( KIO::ERR_SLAVE_DEFINED, i18n( "Malformed URL %1", url.prettyUrl() ) );
        return;
    }
    //was: const QString physicalPath = impl.physicalPath( trashId, fileId, relativePath );

    // Get info for deleted directory - the date of deletion and orig path will be used
    // for all the items in it, and we need the physicalPath.
    TrashedFileInfo info;
    ok = impl.infoForFile( trashId, fileId, info );
    if ( !ok || info.physicalPath.isEmpty() ) {
        error( impl.lastErrorCode(), impl.lastErrorMessage() );
        return;
    }
    if ( !relativePath.isEmpty() ) {
        info.physicalPath += QLatin1Char('/');
        info.physicalPath += relativePath;
    }

    // List subdir. Can't use kio_file here since we provide our own info...
    kDebug() << "listing " << info.physicalPath;
    const QStringList entryNames = impl.listDir( info.physicalPath );
    totalSize( entryNames.count() );
    KIO::UDSEntry entry;
    for ( QStringList::const_iterator entryIt = entryNames.begin(), entryEnd = entryNames.end();
          entryIt != entryEnd ; ++entryIt )
    {
        const QString fileName = *entryIt;
        if (fileName == QLatin1String(".."))
            continue;
        const QString filePath = info.physicalPath + QLatin1Char('/') + fileName;
        // shouldn't be necessary
        //const QString url = TrashImpl::makeURL( trashId, fileId, relativePath + '/' + fileName );
        entry.clear();
        TrashedFileInfo infoForItem( info );
        infoForItem.origPath += QLatin1Char('/');
        infoForItem.origPath += fileName;

        if (createUDSEntry(filePath, fileName, fileName, entry, infoForItem)) {
            listEntry( entry, false );
        }
    }
    entry.clear();
    listEntry( entry, true );
    finished();
}
Esempio n. 4
0
void ApplicationsProtocol::listDir(const KUrl& url)
{
    QString groupPath = url.path( KUrl::AddTrailingSlash );
    groupPath.remove(0, 1); // remove starting '/'

    KServiceGroup::Ptr grp = KServiceGroup::group(groupPath);

    if (!grp || !grp->isValid()) {
        error(KIO::ERR_DOES_NOT_EXIST, groupPath);
        return;
    }

    unsigned int count = 0;
    KIO::UDSEntry entry;

    foreach (const KSycocaEntry::Ptr &e, grp->entries(true, true)) {
        if (e->isType(KST_KServiceGroup)) {
            KServiceGroup::Ptr g(KServiceGroup::Ptr::staticCast(e));
            QString groupCaption = g->caption();

            kDebug() << "ADDING SERVICE GROUP WITH PATH " << g->relPath();

            // Avoid adding empty groups.
            KServiceGroup::Ptr subMenuRoot = KServiceGroup::group(g->relPath());
            if (subMenuRoot->childCount() == 0)
                continue;

            // Ignore dotfiles.
            if ((g->name().at(0) == '.'))
                continue;

            QString relPath = g->relPath();
            KUrl dirUrl = url; // preserve protocol, whether that's programs:/ or applications:/
            dirUrl.setPath('/' + relPath);
            dirUrl.adjustPath(KUrl::RemoveTrailingSlash);
            kDebug() << "ApplicationsProtocol: adding entry" << dirUrl;
            createDirEntry(entry, groupCaption, dirUrl.url(), "inode/directory", g->icon());

        } else {
            KService::Ptr service(KService::Ptr::staticCast(e));

            kDebug() << "the entry name is" << service->desktopEntryName()
                     << "with path" << service->entryPath();

            if (!service->isApplication()) // how could this happen?
                continue;
            createFileEntry(entry, service, url);
        }

        listEntry(entry, false);
        count++;
    }

    totalSize(count);
    listEntry(entry, true);
    finished();
}
Esempio n. 5
0
void KioKdeconnect::listAllDevices()
{
    infoMessage(i18n("Listing devices..."));

    //TODO: Change to all devices and show different icons for connected and disconnected?
    QStringList devices = m_dbusInterface->devices(true, true);

    Q_FOREACH(const QString& deviceId, devices) {

        DeviceDbusInterface interface(deviceId);

        if (!interface.hasPlugin(QStringLiteral("kdeconnect_sftp"))) continue;

        const QString path = QStringLiteral("kdeconnect://").append(deviceId).append("/");
        const QString name = interface.name();
        const QString icon = QStringLiteral("kdeconnect");

        KIO::UDSEntry entry;
        entry.insert(KIO::UDSEntry::UDS_NAME, name);
        entry.insert(KIO::UDSEntry::UDS_ICON_NAME, icon);
        entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
        entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
        entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QLatin1String(""));
        entry.insert(KIO::UDSEntry::UDS_URL, path);
        listEntry(entry);
    }
Esempio n. 6
0
static int timeInterrupt(IRQRegisters *reg,void *data)
{
   u64 rflags;
   ++ticks;

   for(;;){
      lockSpinLockCloseInterrupt(&timerLock,&rflags);

      if(listEmpty(&timers))
         break; /*Just break if empty.*/
      Timer *timer = listEntry(timers.next,Timer,list);
      if(timer->ticks > ticks)
         break; /*Break if timers are not timeout.*/
      listDelete(&timer->list); /*Timeout!Delete it.*/
      
      unlockSpinLockRestoreInterrupt(&timerLock,&rflags);
      
      (*timer->callback)(timer->data); /*Call callback.*/
   }

   unlockSpinLockRestoreInterrupt(&timerLock,&rflags);
      /*Need unlock.*/

   return 0;
}
Esempio n. 7
0
void MBoxProtocol::listDir(const QUrl &url)
{
    m_errorState = false;

    KIO::UDSEntry entry;
    UrlInfo info(url, UrlInfo::directory);
    ReadMBox mbox(&info, this, hasMetaData(QStringLiteral("onlynew")), hasMetaData(QStringLiteral("savetime")));

    if (m_errorState) {
        return;
    }

    if (info.type() != UrlInfo::directory) {
        error(KIO::ERR_DOES_NOT_EXIST, info.url());
        return;
    }

    while (!mbox.atEnd() && !m_errorState) {
        entry = Stat::stat(mbox, info);
        if (mbox.inListing()) {
            listEntry(entry);
        }
    }

    finished();
}
Esempio n. 8
0
void interCodesPrint(FILE *file, InterCodes *head) {
	assert(file != NULL);
	assert(head != NULL);
	static char buf[120];
	ListHead *p;
	listForeach(p, head) {
		InterCode *interCode = listEntry(p, InterCode, list);
		interCodeToStr(interCode, buf);
		fprintf(file, "%s\n", buf);
	}
Esempio n. 9
0
void TrashProtocol::listRoot()
{
    INIT_IMPL;
    const TrashedFileInfoList lst = impl.list();
    totalSize(lst.count());
    KIO::UDSEntry entry;
    createTopLevelDirEntry(entry);
    listEntry(entry, false);
    for(TrashedFileInfoList::ConstIterator it = lst.begin(); it != lst.end(); ++it)
    {
        const KURL url = TrashImpl::makeURL((*it).trashId, (*it).fileId, QString::null);
        KURL origURL;
        origURL.setPath((*it).origPath);
        entry.clear();
        if(createUDSEntry((*it).physicalPath, origURL.fileName(), url.url(), entry, *it))
            listEntry(entry, false);
    }
    entry.clear();
    listEntry(entry, true);
    finished();
}
Esempio n. 10
0
void ZeroConfProtocol::addService( DNSSD::RemoteService::Ptr service )
{
    UDSEntry entry;
    entry.insert( UDSEntry::UDS_NAME,      service->serviceName() );
    entry.insert( UDSEntry::UDS_ACCESS,    0666);
    entry.insert( UDSEntry::UDS_FILE_TYPE, S_IFDIR );
    const QString iconName = KProtocolInfo::icon( knownProtocols[service->type()].protocol );
    if (!iconName.isNull())
        entry.insert( UDSEntry::UDS_ICON_NAME, iconName );

    listEntry( entry, false );
}
Esempio n. 11
0
void ZeroConfProtocol::addServiceType( const QString& serviceType )
{
    if (ServiceTypesAdded.contains(serviceType))
        return;
    ServiceTypesAdded << serviceType;

    if (!knownProtocols.contains(serviceType))
        return;

    // action
    UDSEntry entry;
    feedEntryAsDir( &entry, serviceType, knownProtocols[serviceType].name );
    listEntry( entry, false );
}
Esempio n. 12
0
int addTimer(Timer *timer)
{
   u64 rflags;
   lockSpinLockCloseInterrupt(&timerLock,&rflags);

   for(ListHead *list = timers.next;list != &timers;list = list->next)
   {
      Timer *__timer = listEntry(list,Timer,list);
      if(__timer->ticks > timer->ticks)
      { /*Add this timer to a appropriate position.*/
         listAddTail(&timer->list,&__timer->list);
         goto end;
      }
   }
   /*Add this timer to the last position.*/
   listAddTail(&timer->list,&timers);
end:
   unlockSpinLockRestoreInterrupt(&timerLock,&rflags);
   return 0;
}
Esempio n. 13
0
void ZeroConfProtocol::onBrowserFinished()
{
    UDSEntry entry;
    listEntry( entry, true );
    finished();

    // cleanup
    if (serviceBrowser)
    {
        serviceBrowser->deleteLater();
        serviceBrowser = 0;
    }
    if (serviceTypeBrowser)
    {
        serviceTypeBrowser->deleteLater();
        serviceTypeBrowser = 0;
    }
    ServiceTypesAdded.clear();

    emit leaveModality();
}
Esempio n. 14
0
void TrashProtocol::listDir(const KURL &url)
{
    INIT_IMPL;
    kdDebug() << "listdir: " << url << endl;
    if(url.path().length() <= 1)
    {
        listRoot();
        return;
    }
    int trashId;
    QString fileId;
    QString relativePath;
    bool ok = TrashImpl::parseURL(url, trashId, fileId, relativePath);
    if(!ok)
    {
        error(KIO::ERR_SLAVE_DEFINED, i18n("Malformed URL %1").arg(url.prettyURL()));
        return;
    }
    // was: const QString physicalPath = impl.physicalPath( trashId, fileId, relativePath );

    // Get info for deleted directory - the date of deletion and orig path will be used
    // for all the items in it, and we need the physicalPath.
    TrashedFileInfo info;
    ok = impl.infoForFile(trashId, fileId, info);
    if(!ok || info.physicalPath.isEmpty())
    {
        error(impl.lastErrorCode(), impl.lastErrorMessage());
        return;
    }
    if(!relativePath.isEmpty())
    {
        info.physicalPath += "/";
        info.physicalPath += relativePath;
    }

    // List subdir. Can't use kio_file here since we provide our own info...
    kdDebug() << k_funcinfo << "listing " << info.physicalPath << endl;
    QStrList entryNames = impl.listDir(info.physicalPath);
    totalSize(entryNames.count());
    KIO::UDSEntry entry;
    QStrListIterator entryIt(entryNames);
    for(; entryIt.current(); ++entryIt)
    {
        QString fileName = QFile::decodeName(entryIt.current());
        if(fileName == "..")
            continue;
        const QString filePath = info.physicalPath + "/" + fileName;
        // shouldn't be necessary
        // const QString url = TrashImpl::makeURL( trashId, fileId, relativePath + "/" + fileName );
        entry.clear();
        TrashedFileInfo infoForItem(info);
        infoForItem.origPath += '/';
        infoForItem.origPath += fileName;
        if(ok && createUDSEntry(filePath, fileName, QString::null /*url*/, entry, infoForItem))
        {
            listEntry(entry, false);
        }
    }
    entry.clear();
    listEntry(entry, true);
    finished();
}
Esempio n. 15
0
void PakProtocol::listDir(const KURL &url) {
	kdDebug(PAK_DEBUG_ID) << "Entering listDir()" << endl;
	QString path;

	KIO::Error errorNum;
	if ( !checkNewFile( url, path, errorNum ) )
	{
		if ( errorNum == KIO::ERR_CANNOT_OPEN_FOR_READING )
		{
			// If we cannot open, it might be a problem with the archive header (e.g. unsupported format)
			// Therefore give a more specific error message
			error( KIO::ERR_SLAVE_DEFINED,
					i18n( "Could not open the file, probably due to an unsupported file format.\n%1")
					.arg( url.prettyURL() ) );
			return;
		}
		else if ( errorNum != KIO::ERR_IS_DIRECTORY )
		{
			// We have any other error
			error( errorNum, url.prettyURL() );
			return;
		}
		// It's a real dir -> redirect
		KURL redir;
		redir.setPath( url.path() );
		kdDebug( PAK_DEBUG_ID ) << "Ok, redirection to " << redir.url() << endl;
		redirection( redir );
		finished();
		// And let go of the tar file - for people who want to unmount a cdrom after that
		delete _pakFile;
		_pakFile = 0L;
		return;
	}

	if ( path.isEmpty() )
	{
		KURL redir( url.protocol() + QString::fromLatin1( ":/") );
		kdDebug( PAK_DEBUG_ID ) << "url.path()==" << url.path() << endl;
		redir.setPath( url.path() + QString::fromLatin1("/") );
		kdDebug( PAK_DEBUG_ID ) << "ArchiveProtocol::listDir: redirection " << redir.url() << endl;
		redirection( redir );
		finished();
		return;
	}

	path = QString::fromLocal8Bit(remoteEncoding()->encode(path));

	kdDebug( PAK_DEBUG_ID ) << "checkNewFile done" << endl;
	const KArchiveDirectory* root = _pakFile->directory();
	const KArchiveDirectory* dir;
	if (!path.isEmpty() && path != "/")
	{
		kdDebug(PAK_DEBUG_ID) << QString("Looking for entry %1").arg(path) << endl;
		const KArchiveEntry* e = root->entry( path );
		if ( !e )
		{
			error( KIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
			return;
		}
		if ( ! e->isDirectory() )
		{
			error( KIO::ERR_IS_FILE, url.prettyURL() );
			return;
		}
		dir = (KArchiveDirectory*)e;
	} else {
		dir = root;
	}

	QStringList l = dir->entries();
	totalSize( l.count() );

	KIO::UDSEntry entry;
	QStringList::Iterator it = l.begin();
	for( ; it != l.end(); ++it )
	{
		kdDebug(PAK_DEBUG_ID) << (*it) << endl;
		const KArchiveEntry* archiveEntry = dir->entry( (*it) );

		createUDSEntry( archiveEntry, entry );

		listEntry( entry, false );
	}

	listEntry( entry, true ); // ready

	finished();

	kdDebug( PAK_DEBUG_ID ) << "ArchiveProtocol::listDir done" << endl;

	/*kdDebug(PAK_DEBUG_ID) << "Entering listDir()" << endl;
	totalSize(1);		// ONE file (Magic!!)
	KIO::UDSEntry entry;
	createUDSEntry(NULL, entry);
	kdDebug(PAK_DEBUG_ID) << "Giving file away" << endl;
	listEntry(entry, false);
	listEntry(entry, true);		// End
	finished();
	kdDebug(PAK_DEBUG_ID) << "-<> Exiting listDir()" << endl;*/
}