Exemple #1
0
void TrashProtocol::del( const KUrl &url, bool /*isfile*/ )
{
    INIT_IMPL;
    int trashId;
    QString fileId, relativePath;

    bool ok = TrashImpl::parseURL( url, trashId, fileId, relativePath );
    if ( !ok ) {
        error( KIO::ERR_SLAVE_DEFINED, i18n( "Malformed URL %1", url.prettyUrl() ) );
        return;
    }

    ok = relativePath.isEmpty();
    if ( !ok ) {
        error( KIO::ERR_ACCESS_DENIED, url.prettyUrl() );
        return;
    }

    ok = impl.del(trashId, fileId);
    if ( !ok ) {
        error( impl.lastErrorCode(), impl.lastErrorMessage() );
        return;
    }

    finished();
}
Exemple #2
0
void BupSlave::open(const KUrl &pUrl, QIODevice::OpenMode pMode) {
	if(pMode & QIODevice::WriteOnly) {
		emit error(KIO::ERR_CANNOT_OPEN_FOR_WRITING, pUrl.prettyUrl());
		return;
	}

	QStringList lPathInRepo;
	if(!checkCorrectRepository(pUrl, lPathInRepo)) {
		emit error(KIO::ERR_SLAVE_DEFINED, i18n("No bup repository found.\n%1", pUrl.prettyUrl()));
		return;
	}

	Node *lNode = mRepository->resolve(lPathInRepo, true);
	if(lNode == NULL) {
		emit error(KIO::ERR_DOES_NOT_EXIST, lPathInRepo.join(QLatin1String("/")));
		return;
	}

	File *lFile = qobject_cast<File *>(lNode);
	if(lFile == NULL) {
		emit error(KIO::ERR_IS_DIRECTORY, lPathInRepo.join(QLatin1String("/")));
		return;
	}

	if(0 != lFile->seek(0)) {
		emit error(KIO::ERR_CANNOT_OPEN_FOR_READING, pUrl.prettyUrl());
		return;
	}

	mOpenFile = lFile;
	emit mimeType(lFile->mMimeType);
	emit totalSize(lFile->size());
	emit position(0);
	emit opened();
}
bool KAResourceRemote::setUrls(const KUrl& downloadUrl, const KUrl& uploadUrl)
{
	if (mReconfiguring == 1)
	{
		mNewDownloadUrl = downloadUrl;
		mNewUploadUrl   = uploadUrl;
		return true;
	}
	if (downloadUrl.equals(mDownloadUrl)
	&&  uploadUrl.equals(mUploadUrl))
		return false;
	kDebug(KARES_DEBUG) << downloadUrl.prettyUrl() << "," << uploadUrl.prettyUrl();
	if (isOpen())
		close();
	bool active = isActive();
	if (active)
		enableResource(false);
	mDownloadUrl = downloadUrl;
	mUploadUrl   = uploadUrl;
	if (active)
		enableResource(true);
	// Trigger loading the new resource, and ensure that the new configuration is saved
	emit locationChanged(this);
	return true;
}
Exemple #4
0
void KUrlCompletionTest::testLocalURL()
{
    // Completion from URL
    kDebug() ;
    KUrl url( m_dirURL.toLocalFile() + "file" );
    m_completion->makeCompletion( url.prettyUrl() );
    waitForCompletion();
    QStringList comp1all = m_completion->allMatches();
    kDebug() << comp1all;
    assert( comp1all.count() == 3 );
    kDebug() << "Looking for" << m_dirURL.prettyUrl() + "file1";
    assert( comp1all.contains( m_dirURL.prettyUrl() + "file1" ) );
    assert( comp1all.contains( m_dirURL.prettyUrl() + "file_subdir/" ) );
    QString filehash = m_dirURL.prettyUrl() + "file%23a";
    assert( comp1all.contains( filehash ) );
    QString filehashPath = m_completion->replacedPath( filehash ); // note that it returns a path!!
    kDebug() << filehashPath;
    assert( filehashPath == m_dirURL.toLocalFile() + "file#a" );

    // Completion from URL with no match
    url = KUrl( m_dirURL.toLocalFile() + "foobar" );
    kDebug() << "makeCompletion(" << url << ")";
    QString comp2 = m_completion->makeCompletion( url.prettyUrl() );
    assert( comp2.isEmpty() );
    waitForCompletion();
    assert( m_completion->allMatches().isEmpty() );

    // Completion from URL with a ref -> no match
    url = KUrl( m_dirURL.toLocalFile() + 'f' );
    url.setRef( "ref" );
    kDebug() << "makeCompletion(" << url << ")";
    m_completion->makeCompletion( url.prettyUrl() );
    waitForCompletion();
    assert( m_completion->allMatches().isEmpty() );
}
Exemple #5
0
void TrashProtocol::stat(const KUrl& url)
{
    INIT_IMPL;
    const QString path = url.path();
    if (path.isEmpty() || path == QLatin1String("/")) {
        // The root is "virtual" - it's not a single physical directory
        KIO::UDSEntry entry;
        createTopLevelDirEntry( entry );
        statEntry( entry );
        finished();
    } else {
        int trashId;
        QString fileId, relativePath;

        bool ok = TrashImpl::parseURL( url, trashId, fileId, relativePath );

        if ( !ok ) {
            // ######## do we still need this?
            kDebug() << url << " looks fishy, returning does-not-exist";
            // A URL like trash:/file simply means that CopyJob is trying to see if
            // the destination exists already (it made up the URL by itself).
            error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
            //error( KIO::ERR_SLAVE_DEFINED, i18n( "Malformed URL %1" ).arg( url.prettyUrl() ) );
            return;
        }

        kDebug() << "parsed" << url << "got" << trashId << fileId << relativePath;

        const QString filePath = impl.physicalPath( trashId, fileId, relativePath );
        if ( filePath.isEmpty() ) {
            error( impl.lastErrorCode(), impl.lastErrorMessage() );
            return;
        }

        // For a toplevel file, use the fileId as display name (to hide the trashId)
        // For a file in a subdir, use the fileName as is.
        QString fileDisplayName = relativePath.isEmpty() ? fileId : url.fileName();

        KUrl fileURL;
        if ( url.path().length() > 1 ) {
            fileURL = url;
        }

        KIO::UDSEntry entry;
        TrashedFileInfo info;
        ok = impl.infoForFile( trashId, fileId, info );
        if ( ok )
            ok = createUDSEntry( filePath, fileDisplayName, fileURL.fileName(), entry, info );

        if ( !ok ) {
            error( KIO::ERR_COULD_NOT_STAT, url.prettyUrl() );
            return;
        }

        statEntry( entry );
        finished();
    }
}
Exemple #6
0
QString DirSortPlugin::processFile( BatchRenamer* b, int index, const QString &, EPluginType )
{
    QString errorMsg = QString::null;

    if( index == 0 )
    {
        // Initialize plugin
        m_dirCounter = m_widget->spinStart->value();
        m_fileCounter = 0;
        m_filesPerDir = m_widget->spinFiles->value();
        m_digits = m_widget->spinDigits->value();
        m_baseDirectory = m_widget->outputUrl->url();

        if( !KIO::NetAccess::exists( m_baseDirectory, true, m_widget->spinStart ) ) 
        {
            m_valid = false;
            return this->name() + 
                i18n(": The output directory %1 does not exist.", 
                     m_baseDirectory.prettyUrl() ); 
        }
        else 
        {
            m_valid = true;

            m_currentDirectory = createNewSubdirectory();
        }
    }
    
    if( !m_valid ) 
        return errorMsg;

    if( m_fileCounter == m_filesPerDir ) 
    {
        m_fileCounter = 0;
        m_dirCounter++;

        m_currentDirectory = createNewSubdirectory();
    }

    KUrl srcUrl = b->buildDestinationUrl( (*b->files())[index] );
    KUrl dstUrl = m_currentDirectory;
    dstUrl.addPath( srcUrl.fileName() );
    KIO::JobFlags flags = KIO::DefaultFlags | KIO::HideProgressInfo;
    KIO::Job* job = KIO::file_move( srcUrl, dstUrl, -1, flags );
    m_fileCounter++;
    if( m_valid && job && !KIO::NetAccess::synchronousRun( job, m_widget->spinStart ) ) 
    {
        errorMsg = i18n("Error renaming %2 (to %1)", 
                        dstUrl.prettyUrl(), 
                        srcUrl.prettyUrl());
    } 

    return errorMsg;
}
Exemple #7
0
AudioPreview::AudioPreview( QWidget *parent, const KUrl &url, const QString &mimeType)
  : KVBox( parent )
{
  m_isTempFile = false;
  pic = 0;
  m_player = 0L;
  description = 0;
  setSpacing( 0 );
  if( url.isValid() && url.isLocalFile() ) {
    m_localFile = url.toLocalFile();
    pic = new QLabel(this);
    pic->setPixmap(KIO::pixmapForUrl( url ));
    pic->adjustSize();
    initView( mimeType );
  } else if( !url.isLocalFile() ) {
    KUrlLabel *label = new KUrlLabel( this );
    label->setText(i18n("This audio file is not stored\non the local host.\nClick on this label to load it.\n" ) );
    label->setUrl( url.prettyUrl() );
    connect(label, SIGNAL(leftClickedUrl(const QString&)), SLOT(downloadFile(const QString&)));
    pic = label;
  } else {
    description = new QLabel(this );
    description->setText(i18n("Unable to load audio file") );
  }
}
Exemple #8
0
void TrashProtocol::restore( const KUrl& trashURL )
{
    int trashId;
    QString fileId, relativePath;
    bool ok = TrashImpl::parseURL( trashURL, trashId, fileId, relativePath );
    if ( !ok ) {
        error( KIO::ERR_SLAVE_DEFINED, i18n( "Malformed URL %1", trashURL.prettyUrl() ) );
        return;
    }
    TrashedFileInfo info;
    ok = impl.infoForFile( trashId, fileId, info );
    if ( !ok ) {
        error( impl.lastErrorCode(), impl.lastErrorMessage() );
        return;
    }
    KUrl dest;
    dest.setPath( info.origPath );
    if ( !relativePath.isEmpty() )
        dest.addPath( relativePath );

    // Check that the destination directory exists, to improve the error code in case it doesn't.
    const QString destDir = dest.directory();
    KDE_struct_stat buff;
    if ( KDE_lstat( QFile::encodeName( destDir ), &buff ) == -1 ) {
        error( KIO::ERR_SLAVE_DEFINED,
               i18n( "The directory %1 does not exist anymore, so it is not possible to restore this item to its original location. "
                     "You can either recreate that directory and use the restore operation again, or drag the item anywhere else to restore it.", destDir ) );
        return;
    }

    copyOrMove( trashURL, dest, false /*overwrite*/, Move );
}
Exemple #9
0
    void Core::loadSilently(const KUrl& url, const QString& group)
    {
        if (url.protocol() == "magnet")
        {
            MagnetLinkLoadOptions options;
            options.silently = true;
            options.group = group;
            load(bt::MagnetLink(url.prettyUrl()), options);
        }
        else if (url.isLocalFile())
        {
            QString path = url.toLocalFile();
            QString dir = locationHint(group);

            if (dir != QString::null)
                loadFromFile(path, dir, group, true);
        }
        else
        {
            // download to a random file in tmp
            KIO::Job* j = KIO::storedGet(url);
            connect(j, SIGNAL(result(KJob*)), this, SLOT(downloadFinishedSilently(KJob*)));
            if (!group.isNull())
                add_to_groups.insert(url, group);
        }
    }
Exemple #10
0
void ZeroConfProtocol::stat( const KUrl& url )
{
    if (!dnssdOK())
        return;

    const ZeroConfUrl zeroConfUrl( url );

    ZeroConfUrl::Type type = zeroConfUrl.type();

    switch (type)
    {
    case ZeroConfUrl::RootDir:
    case ZeroConfUrl::ServiceDir:
    {
        UDSEntry entry;
        feedEntryAsDir( &entry, QString() );
        statEntry( entry );
        finished();
        break;
    }
    case ZeroConfUrl::Service:
        resolveAndRedirect( zeroConfUrl );
        break;
    default:
        error( ERR_MALFORMED_URL, url.prettyUrl() );
    }
}
Exemple #11
0
void Nepomuk2::TvshowProtocol::put( const KUrl& url, int permissions, KIO::JobFlags flags )
{
    Q_UNUSED(permissions);
    Q_UNUSED(flags);

    error( KIO::ERR_UNSUPPORTED_ACTION, url.prettyUrl() );
}
void KexiBlobTableEdit::handleInsertFromFileAction(const KUrl& url)
{
    if (isReadOnly())
        return;

    QString fileName(url.isLocalFile() ? url.toLocalFile() : url.prettyUrl());

    //! @todo download the file if remote, then set fileName properly
    QFile f(fileName);
    if (!f.open(IO_ReadOnly)) {
        //! @todo err msg
        return;
    }
    QByteArray ba = f.readAll();
    if (f.error() != QFile::NoError) {
        //! @todo err msg
        f.close();
        return;
    }
    f.close();
// m_valueMimeType = KImageIO::mimeType( fileName );
    setValueInternal(ba, true);
    signalEditRequested();
    //emit acceptRequested();
}
Exemple #13
0
void BupSlave::listDir(const KUrl& pUrl) {
	KProcess lP;
	lP <<"logger" <<"listdir: " <<pUrl.url();
	lP.execute();

	if(!checkRunnningFuse(pUrl) || !pUrl.path(KUrl::AddTrailingSlash).startsWith(mFuseRunner->mRepoPath)) {
		error(KIO::ERR_SLAVE_DEFINED, i18n("No bup repository found.\n%1", pUrl.prettyUrl()));
		return;
	}

	QString lPathInRepo = pUrl.path();
	lPathInRepo.remove(0, mFuseRunner->mRepoPath.length());
	fileListDir(KUrl::fromPath(mFuseRunner->mMountPath + lPathInRepo));


//	const QByteArray _path(QFile::encodeName("/tmp/lala"));
//	KProcess p;
//	p <<"logger" <<"filelistdir listing: " <<_path;
//	p.execute();

//	DIR* dp = opendir(_path.data());
//	struct dirent *ep;
//	while ( ( ep = readdir( dp ) ) != 0 ) {
//		KProcess lP;
//		lP <<"logger" <<"filelistdir listed: " <<ep->d_name;
//		lP.execute();
//	}

//	closedir( dp );

}
Exemple #14
0
void BupSlave::listDir(const KUrl& pUrl) {
	QStringList lPathInRepo;
	if(!checkCorrectRepository(pUrl, lPathInRepo)) {
		emit error(KIO::ERR_SLAVE_DEFINED, i18n("No bup repository found.\n%1", pUrl.prettyUrl()));
		return;
	}
	Node *lNode = mRepository->resolve(lPathInRepo, true);
	if(lNode == NULL) {
		emit error(KIO::ERR_DOES_NOT_EXIST, lPathInRepo.join(QLatin1String("/")));
		return;
	}
	Directory *lDir = qobject_cast<Directory *>(lNode);
	if(lDir == NULL) {
		emit error(KIO::ERR_IS_FILE, lPathInRepo.join(QLatin1String("/")));
		return;
	}

	// give the directory a chance to reload if necessary.
	lDir->reload();

	const QString sDetails = metaData(QLatin1String("details"));
	const int lDetails = sDetails.isEmpty() ? 2 : sDetails.toInt();

	NodeMapIterator i(lDir->subNodes());
	UDSEntry lEntry;
	while(i.hasNext()) {
		createUDSEntry(i.next().value(), lEntry, lDetails);
		emit listEntry(lEntry, false);
	}
	emit listEntry(lEntry, true);
	emit finished();
}
Exemple #15
0
void RemoteProtocol::listDir(const KUrl &url)
{
	kDebug(1220) << "RemoteProtocol::listDir: " << url;

	if ( url.path().length() <= 1 )
	{
		listRoot();
		return;
	}

	int second_slash_idx = url.path().indexOf( '/', 1 );
	const QString root_dirname = url.path().mid( 1, second_slash_idx-1 );

	KUrl target = m_impl.findBaseURL( root_dirname );
	kDebug(1220) << "possible redirection target : " << target;
	if( target.isValid() )
	{
		if ( second_slash_idx < 0 ) {
			second_slash_idx = url.path().size();
		}
		target.addPath( url.path().remove(0, second_slash_idx) );
		kDebug(1220) << "complete redirection target : " << target;
		redirection(target);
		finished();
		return;
	}

	error(KIO::ERR_MALFORMED_URL, url.prettyUrl());
}
Exemple #16
0
void TrashProtocol::mkdir( const KUrl& url, int /*permissions*/ )
{
    INIT_IMPL;
    // create info about deleted dir
    // ############ Problem: we don't know the original path.
    // Let's try to avoid this case (we should get to copy() instead, for local files)
    kDebug() << "mkdir: " << url;
    QString dir = url.directory();

    if ( dir.length() <= 1 ) // new toplevel entry
    {
        // ## we should use TrashImpl::parseURL to give the right filename to createInfo
        int trashId;
        QString fileId;
        if ( !impl.createInfo( url.path(), trashId, fileId ) ) {
            error( impl.lastErrorCode(), impl.lastErrorMessage() );
        } else {
            if ( !impl.mkdir( trashId, fileId, permissions ) ) {
                (void)impl.deleteInfo( trashId, fileId );
                error( impl.lastErrorCode(), impl.lastErrorMessage() );
            } else
                finished();
        }
    } else {
        // Well it's not allowed to add a directory to an existing deleted directory.
        error( KIO::ERR_ACCESS_DENIED, url.prettyUrl() );
    }
}
KoShape *KPrPlaceholderPictureStrategy::createShape(KoDocumentResourceManager *rm)
{
    KoShape * shape = 0;

    KUrl url = KFileDialog::getOpenUrl();
    if ( !url.isEmpty() ) {
        shape = KPrPlaceholderStrategy::createShape(rm);

        KoImageCollection *collection = rm->imageCollection();
        Q_ASSERT(collection);

        QString tmpFile;
        if (KIO::NetAccess::download(url, tmpFile, 0)) {
            QImage image(tmpFile);
            if (!image.isNull()) {
                //setSuffix(url.prettyUrl());
                KoImageData *data = collection->createImageData(image);
                if (data->isValid()) {
                    shape->setUserData( data );
                    // TODO the pic should be fit into the space provided
                    shape->setSize( data->imageSize() );
                }
            }
        } else {
            kWarning() << "open image " << url.prettyUrl() << "failed";
        }
    }
    return shape;
}
Exemple #18
0
void ScanGallery::addImage(const QImage *img, const ImageMetaInfo *info)
{
    if (img==NULL) return;				// nothing to save!
    kDebug() << "size" << img->size() << "depth" << img->depth();

    if (mSaver==NULL) prepareToSave(NULL);		// if not done already
    if (mSaver==NULL) return;				// should never happen

    ImgSaver::ImageSaveStatus isstat = mSaver->saveImage(img);
							// try to save the image
    KUrl lurl = mSaver->lastURL();			// record where it ended up

    if (isstat!=ImgSaver::SaveStatusOk &&		// image saving failed
        isstat!=ImgSaver::SaveStatusCanceled)		// user cancelled, just ignore
    {
        KMessageBox::error(this, i18n("<qt>Could not save the image<br><filename>%2</filename><br><br>%1",
                                      mSaver->errorString(isstat),
                                      lurl.prettyUrl()),
                           i18n("Image Save Error"));
    }

    delete mSaver; mSaver = NULL;			// now finished with this

    if (isstat==ImgSaver::SaveStatusOk)			// image was saved OK,
    {							// select the new image
        slotSetNextUrlToSelect(lurl);
        m_nextUrlToShow = lurl;
        if (mSavedTo!=NULL) updateParent(mSavedTo);
    }
}
Exemple #19
0
void MonthWidget::setImage( const KUrl &url )
{
    if (!url.isValid())
        return;

    // check if the file is an image
    QFileInfo fi(url.path());

    QString rawFilesExt(KDcrawIface::KDcraw::rawFiles());

    // Check if RAW image.
    if (!rawFilesExt.toUpper().contains( fi.suffix().toUpper() ))
    {
        // Check if image can be loaded by native Qt loader.
        if ( QImageReader::imageFormat( url.path() ).isEmpty() )
        {
            kWarning( AREA_CODE_LOADING ) << "Unknown image format for: " << url.prettyUrl();
            return;
        }
    }

    imagePath_ = url;
    CalSettings::instance()->setImage(month_, imagePath_);

    interface_->thumbnail( url, thumbSize.width() );
}
Exemple #20
0
QString PixmapEdit::selectPixmapFileName()
{
    /*#ifdef PURE_QT
      QString url = QFileDialog::getOpenFileName();
      if (!url.isEmpty()) {
        m_edit->setPixmap(QPixmap(url));
        emit valueChanged(this);
      }
    #endif*/
    const QString caption(i18n("Insert Image From File (for \"%1\" property)", m_property->caption()));
    /*KDE4:
    #ifdef Q_WS_WIN
      QString recentDir;
      QString fileName = Q3FileDialog::getOpenFileName(
        KFileDialog::getStartURL(":lastVisitedImagePath", recentDir).path(),
        convertKFileDialogFilterToQFileDialogFilter(KImageIO::pattern(KImageIO::Reading)),
        this, 0, caption);
    #else*/
    const KUrl url(KFileDialog::getImageOpenUrl(
                 KUrl(":lastVisitedImagePath"), this, caption));
    QString fileName = url.isLocalFile() ? url.toLocalFile() : url.prettyUrl();

    //! @todo download the file if remote, then set fileName properly
//#endif
    return fileName;
}
Exemple #21
0
void Nepomuk2::TvshowProtocol::stat( const KUrl& url )
{
    // for basic functionality we only need to stat the folders
    const QStringList pathTokens = url.path().split('/', QString::SkipEmptyParts);
    if(pathTokens.count() == 1 && pathTokens.first() == QLatin1String("latest")) {
        KIO::UDSEntry uds = createFolderUDSEntry(QLatin1String("latest"), i18n("Next Episodes To Watch"));
        uds.insert(KIO::UDSEntry::UDS_ICON_NAME, QLatin1String("favorites"));
        statEntry(uds);
        finished();
    }

    else if(pathTokens.count() == 1) {
        // stat series folder
        Soprano::QueryResultIterator it
                = Nepomuk2::ResourceManager::instance()->mainModel()->executeQuery(QString::fromLatin1("select distinct * where { "
                                                                                                      "?r a nmm:TVSeries ; "
                                                                                                      "nie:title %1 ; "
                                                                                                      "nao:created ?cd ; "
                                                                                                      "nao:lastModified ?md ; "
                                                                                                      "nie:description ?d . } LIMIT 1")
                                                                                  .arg(Soprano::Node::literalToN3(pathTokens[0])),
                                                                                  Soprano::Query::QueryLanguageSparql);
        if(it.next()) {
            statEntry(createSeriesUDSEntry(it["r"].uri(),
                                           pathTokens[0],
                                           pathTokens[0],
                                           it["d"].toString(),
                                           it["cd"].literal().toDateTime(),
                                           it["md"].literal().toDateTime()));
            finished();
        }
        else {
            error( ERR_DOES_NOT_EXIST, url.prettyUrl() );
        }
    }

    else if(pathTokens.count() == 2) {
        // stat season folder
        statEntry(createFolderUDSEntry(pathTokens[0], pathTokens[1]));
        finished();
    }

    else {
        // FIXME
        error( ERR_UNSUPPORTED_ACTION, url.prettyUrl() );
    }
}
QVariantHash ChooseSocket::values() const
{
    QVariantHash ret = m_args;
    KUrl url = KUrl(QLatin1String("socket://") % ui->addressLE->text());
    url.setPort(ui->portISB->value());
    ret[KCUPS_DEVICE_URI] = url.prettyUrl();
    return ret;
}
Exemple #23
0
void TrashProtocol::put( const KUrl& url, int /*permissions*/, KIO::JobFlags )
{
    INIT_IMPL;
    kDebug() << "put: " << url;
    // create deleted file. We need to get the mtime and original location from metadata...
    // Maybe we can find the info file for url.fileName(), in case ::rename() was called first, and failed...
    error( KIO::ERR_ACCESS_DENIED, url.prettyUrl() );
}
Exemple #24
0
void KNewStuff2Download::slotPreviewLoaded(KUrl preview)
{
    kDebug() << "-- preview downloaded successfully";
    kDebug() << "-- downloaded to " << preview.prettyUrl();

    FeedWidget *fw = static_cast<FeedWidget*>(m_activefeed);
    fw->addPreview(preview);
}
void ImageViewer::saveFile (KUrl &url) {
    // synchronous access to prevent segfaults
    if (!KIO::NetAccess::file_copy (KUrl (file.fileName()), url, (QWidget*) 0))
    {
        QString text = i18n ("Saving of the image %1 failed.", url.prettyUrl());
        KMessageBox::error (this, text);
    }
}
Exemple #26
0
void Nepomuk2::TvshowProtocol::rename( const KUrl& src, const KUrl& dest, KIO::JobFlags flags )
{
    Q_UNUSED(src);
    Q_UNUSED(dest);
    Q_UNUSED(flags);

    error( ERR_UNSUPPORTED_ACTION, src.prettyUrl() );
}
Exemple #27
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();
}
Exemple #28
0
void RemoteProtocol::rename(const KUrl &src, const KUrl &dest,
                            KIO::JobFlags flags)
{
	if (src.protocol()!="remote" || dest.protocol()!="remote"
         || m_impl.isWizardURL(src) || m_impl.isWizardURL(dest))
	{
		error(KIO::ERR_UNSUPPORTED_ACTION, src.prettyUrl());
		return;
	}

	if (m_impl.renameFolders(src.fileName(), dest.fileName(), flags & KIO::Overwrite))
	{
		finished();
		return;
	}

	error(KIO::ERR_CANNOT_RENAME, src.prettyUrl());
}
void StartupSettingsPage::selectHomeUrl()
{
    const QString homeUrl = m_homeUrl->text();
    KUrl url = KFileDialog::getExistingDirectoryUrl(homeUrl, this);
    if (!url.isEmpty()) {
        m_homeUrl->setText(url.prettyUrl());
        slotSettingsChanged();
    }
}
Exemple #30
0
void Nepomuk2::TvshowProtocol::copy( const KUrl& src, const KUrl& dest, int permissions, KIO::JobFlags flags )
{
    Q_UNUSED(src);
    Q_UNUSED(dest);
    Q_UNUSED(permissions);
    Q_UNUSED(flags);

    error( ERR_UNSUPPORTED_ACTION, src.prettyUrl() );
}