Beispiel #1
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() );
        KUrl origURL;
        origURL.setPath( (*it).origPath );
        entry.clear();
        const QString fileDisplayName = (*it).fileId;
        if ( createUDSEntry( (*it).physicalPath, fileDisplayName, url.fileName(), entry, *it ) )
            listEntry( entry, false );
    }
    entry.clear();
    listEntry( entry, true );
    finished();
}
Beispiel #2
0
KritaShape::KritaShape(const KUrl& url, const QString & profileName)
        : m_d(new Private())
{
    m_d->url = url;
    m_d->doc = 0;
    if (!url.isEmpty()) {
        importImage(url);
    }
    m_d->displayProfile = KoColorSpaceRegistry::instance()->profileByName(profileName);
    setKeepAspectRatio(true);
    moveToThread(QCoreApplication::instance()->thread()); // it's a QObject; lets make sure it always has a proper thread.
}
bool
AmpacheServiceFactory::possiblyContainsTrack(const KUrl & url) const
{
    AmpacheConfig config;
    foreach( const AmpacheServerEntry &server, config.servers() )
    {
        if ( url.url().contains( server.url, Qt::CaseInsensitive ) )
            return true;
    }

    return false;
}
Beispiel #4
0
bool Document::getURL( const QString &types )
{
	KUrl url = KFileDialog::getSaveUrl( KUrl(), types, KTechlab::self(), i18n("Save Location"));
	
	if ( url.isEmpty() ) return false;
	
	if ( QFile::exists( url.path() ) )
	{
		int query = KMessageBox::warningYesNo( KTechlab::self(),
			   i18n( "A file named \"%1\" already exists. Are you sure you want to overwrite it?" ).arg( url.fileName() ),
			   i18n( "Overwrite File?" ),
			   //i18n( "Overwrite" ),
			   KStandardGuiItem::cancel() );
		if ( query == KMessageBox::No )
			return false;
	}
	
	setURL(url);
	
	return true;
}
Beispiel #5
0
void AccessManagerReply::slotRedirection(KIO::Job* job, const KUrl& u)
{
    Q_UNUSED(job);

    if (!KAuthorized::authorizeUrlAction(QLatin1String("redirect"), url(), u)) {
        kWarning(7007) << "Redirection from" << url() << "to" << u << "REJECTED by policy!";
        setError(QNetworkReply::ContentAccessDenied, u.url());
        emit error(error());
        return;
    }
    setAttribute(QNetworkRequest::RedirectionTargetAttribute, QUrl(u));
}
Beispiel #6
0
    ScanFolder::ScanFolder(ScanThread* scanner, const KUrl& dir, bool recursive)
        : scanner(scanner),
          scan_directory(dir),
          watch(0),
          recursive(recursive)
    {
        bt::Out(SYS_SNF | LOG_NOTICE) << "ScanFolder: scanning " << dir << endl;

        KConfigGroup config(KGlobal::config(), "DirWatch");
        config.writeEntry("NFSPollInterval", 5000);
        config.writeEntry("nfsPreferredMethod", "Stat"); // Force the usage of Stat method for NFS
        config.sync();

        watch = new KDirWatch(this);
        connect(watch, SIGNAL(dirty(QString)), this, SLOT(scanDir(QString)));
        connect(watch, SIGNAL(created(QString)), this, SLOT(scanDir(QString)));

        watch->addDir(dir.toLocalFile(), recursive ? KDirWatch::WatchSubDirs : KDirWatch::WatchDirOnly);

        scanner->addDirectory(dir.toLocalFile(), recursive);
    }
KAResourceRemote::KAResourceRemote(Type type, const KUrl& downloadUrl, const KUrl& uploadUrl)
	: AlarmResource(type),
	  mDownloadUrl(downloadUrl),
	  mUploadUrl(uploadUrl.isEmpty() ? mDownloadUrl : uploadUrl),
	  mDownloadJob(0),
	  mUploadJob(0),
	  mShowProgress(false),
	  mUseCacheFile(false),
	  mRemoteReadOnly(false)
{
	init();
}
Beispiel #8
0
SecurityOrigin::SecurityOrigin(const KUrl& url) :
      m_protocol(url.protocol().toLower())
    , m_host(url.host().toLower())
    , m_port(url.port())
    , m_domainWasSetInDOM(false)
    , m_isUnique(false)
{
    // These protocols do not create security origins; the owner frame provides the origin
    if (m_protocol == "about" || m_protocol == "javascript")
        m_protocol = "";

    // For edge case URLs that were probably misparsed, make sure that the origin is unique.
    if (m_host.isEmpty() && KProtocolInfo::protocolClass(m_protocol) == QLatin1String(":internet"))
        m_isUnique = true;

    // document.domain starts as m_host, but can be set by the DOM.
    m_domain = m_host;

    if (url.port() == -1 || isDefaultPortForProtocol(m_port, m_protocol))
        m_port = 0;
}
QString BatchProcessImagesDialog::RenameTargetImageFile(QFileInfo* fi)
{
    QString Temp;
    int Enumerator = 0;
    KUrl NewDestUrl;

    do
    {
        ++Enumerator;
        Temp = Temp.setNum(Enumerator);
        NewDestUrl = fi->filePath().left(fi->filePath().lastIndexOf('.', -1)) + '_' + Temp + '.'
                     + fi->filePath().section('.', -1);
    }
    while (Enumerator < 100 &&
           KIO::NetAccess::exists(NewDestUrl, KIO::NetAccess::SourceSide, kapp->activeWindow()) == true);

    if (Enumerator == 100)
        return QString();

    return (NewDestUrl.path());
}
Beispiel #10
0
void ScanGallery::slotImportFile()
{
    FileTreeViewItem *curr = highlightedFileTreeViewItem();
    if( ! curr ) return;

    KUrl impTarget = curr->url();

    if( ! curr->isDir() )
    {
        FileTreeViewItem *pa = static_cast<FileTreeViewItem*>(curr->parent());
        impTarget = pa->url();
    }
    kDebug() << "Importing to" << impTarget;

    KUrl impUrl = KFileDialog::getImageOpenUrl(KUrl("kfiledialog:///importImage"), this, i18n("Import Image File to Gallery"));
    if (impUrl.isEmpty()) return;

    impTarget.addPath(impUrl.fileName());		// append the name of the sourcefile to the path
    m_nextUrlToShow = impTarget;
    ImgSaver::copyImage(impUrl, impTarget);
}
void PhotoLayoutsEditor::open(const KUrl & fileUrl)
{
    if (m_canvas && m_canvas->file() == fileUrl)
        return;

    if (fileUrl.isValid())
    {
        closeDocument();
        createCanvas(fileUrl);
        refreshActions();
    }
}
/**
 * This constructor can be used to load previously translated and saved unit:
 * the typical way is to load a PCH files
 */
TranslationUnit::TranslationUnit(
    CXIndex index
  , const KUrl& filename_url
  )
  : m_filename(filename_url.toLocalFile().toUtf8())
  , m_unit(clang_createTranslationUnit(index, m_filename.constData()))
{
    if (!m_unit)
        throw Exception::LoadFailure(
            i18nc("@item:intext", "Fail to load a preparsed file").toAscii().constData()
          );
}
void unsaved_files_list::update(const KUrl& file, const QString& text)
{
    if (!m_updating)
        initiate_updating();

    assert("Sanity check" && m_updating);
    assert("Sanity check" && !file.toLocalFile().isEmpty());

    auto it = m_index.find(file);
    if (it == end(m_index))                                 // Is it in a primary index already?
    {                                                       // (prevent double update)
        // No! Try to find it in a previous generation
        it = m_index_prev.find(file);
        if (it == end(m_index_prev))
        {
            // That is really new file: add content to the storage
            auto entry_it = m_unsaved_files.emplace(
                end(m_unsaved_files)
              , file.toLocalFile().toUtf8()
              , text.toUtf8()
              );
            // ... and update the primary index
            m_index.emplace(file, entry_it);
        }
        else
        {
            // Ok, lets set a new content to previously existed file
            auto tmp = text.toUtf8();
            it->second->second.swap(tmp);
            m_index.emplace(file, it->second);
        }
    }
    else
    {
        // Huh, file already in the new/updated index,
        // so lets update the content again
        auto tmp = text.toUtf8();
        it->second->second.swap(tmp);
    }
}
Beispiel #14
0
/*
 这个函数是webdav的辅助函数。
 检查webdav的destination头,把destination解析,别名映射检查,并检查扩展映射。
 如果成功,则会把注册变量DAV_DESTINATION,映射到物理地址上。
 */
bool make_webdav_destination_env(KHttpRequest *rq, KRedirect *rd,
		KEnvInterface *env, bool chrooted) {
	bool make_result = false;
	size_t skip_length = 0;
	if (chrooted && rq->svh) {
		skip_length = rq->svh->vh->doc_root.size() - 1;
	}
	KHttpHeader *av = rq->parser.getHeaders();
	while (av) {
		if (is_attr(av, "Destination")) {
			KUrl url;
			memset(&url, 0, sizeof(url));
			char *val = xstrdup(av->val);
			url_decode(val, 0, &url);
			if (parse_url(val, &url)) {
				KFileName file;
				char *tripedDir = file.tripDir2(url.path, PATH_SPLIT_CHAR);
				char *new_path = rq->svh->vh->alias(TEST(rq->workModel,WORK_MODEL_INTERNAL)>0,tripedDir);
				//bool result;
				if (new_path) {
					file.giveName(new_path);
				} else {
					file.setName(rq->svh->vh->doc_root.c_str(),
							tripedDir, rq->getFollowLink());
				}
				xfree(tripedDir);
				if (rq->svh->vh->isPathRedirect(rq, &file, true, rd)) {
					//todo register env
					env->addEnv("DAV_DESTINATION", file.getName() + skip_length);
					make_result = true;
				}
			}
			url.destroy();
			xfree(val);
			break;
		}
		av = av->next;
	}
	return make_result;
}
Beispiel #15
0
void
CoverFetchInfoPayload::prepareDiscogsUrls( const QByteArray &data )
{
    QXmlStreamReader xml( QString::fromUtf8(data) );
    while( !xml.atEnd() && !xml.hasError() )
    {
        xml.readNext();
        if( xml.isStartElement() && xml.name() == "searchresults" )
        {
            while( !xml.atEnd() && !xml.hasError() )
            {
                xml.readNext();
                const QStringRef &n = xml.name();
                if( xml.isEndElement() && n == "searchresults" )
                    break;
                if( !xml.isStartElement() )
                    continue;
                if( n == "result" )
                {
                    while( !xml.atEnd() && !xml.hasError() )
                    {
                        xml.readNext();
                        if( xml.isEndElement() && n == "result" )
                            break;
                        if( !xml.isStartElement() )
                            continue;
                        if( xml.name() == "uri" )
                        {
                            KUrl releaseUrl( xml.readElementText() );
                            QString releaseStr = releaseUrl.url( KUrl::RemoveTrailingSlash );
                            QString releaseId = releaseStr.split( '/' ).last();

                            KUrl url;
                            url.setScheme( "http" );
                            url.setHost( "www.discogs.com" );
                            url.setPath( "/release/" + releaseId );
                            url.addQueryItem( "api_key", Amarok::discogsApiKey() );
                            url.addQueryItem( "f", "xml" );

                            CoverFetch::Metadata metadata;
                            metadata[ "source" ] = "Discogs";

                            if( url.isValid() )
                                m_urls.insert( url, metadata );
                        }
                        else
                            xml.skipCurrentElement();
                    }
                }
                else
                    xml.skipCurrentElement();
            }
        }
    }
}
KexiFileWidget::KexiFileWidget(
    const KUrl &startDirOrVariable, Mode mode, QWidget *parent)
        :  KFileWidget(startDirOrVariable, parent)
        , d(new Private())
{
    kDebug() << startDirOrVariable.scheme();
    if (startDirOrVariable.protocol() == "kfiledialog") {
        KFileDialog::getStartUrl(startDirOrVariable, d->recentDirClass);
    }
    setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    setMode(mode);
    QAction *previewAction = actionCollection()->action("preview");
    if (previewAction)
        previewAction->setChecked(false);

    //setMinimumHeight(100);
    //setSizeGripEnabled ( false );

    //dirty hack to customize filedialog view:
    /* {
        QList<QPushButton*> l = findChildren<QPushButton*>();
        foreach (QPushButton* btn, l)
          btn->hide();
        QList<QWidget*> wl = findChildren<QWidget*>();
        foreach (QWidget* w, wl)
          w->installEventFilter(this);
      } */

    /* Qt4
    #ifdef Q_WS_WIN
      if (startDirOrVariable.startsWith(":"))
        m_lastVisitedPathsVariable = startDirOrVariable; //store for later use
    #else*/
// toggleSpeedbar(false);
    setFocusProxy(locationEdit());
//#endif

    connect(this, SIGNAL(fileHighlighted(QString)),
            this, SLOT(slotExistingFileHighlighted(QString)));
}
static KUrl::List thread_getProjectFiles(const KUrl dir, bool recursive, const QStringList include,
                                         const QStringList exlude, volatile bool &abort)
{
    ///@todo This is not thread-safe!
    KDevelop::IProject *project = KDevelop::ICore::self()->projectController()->findProjectForUrl( dir );
    KUrl::List res;
    if(!project)
        return res;

    const QSet<IndexedString> fileSet = project->fileSet();
    foreach( const IndexedString &item, fileSet )
    {
        if(abort)
            break;
        KUrl url = item.toUrl();
        if( !url.equals(dir) )
        {
            if( recursive && !dir.isParentOf(url) )
                continue;
            if( !recursive && !url.upUrl().equals(dir, KUrl::CompareWithoutTrailingSlash))
                continue;
        }
        if( QDir::match(include, url.fileName()) && !QDir::match(exlude, url.toLocalFile()) )
            res << url;
    }

    return res;
}
Beispiel #18
0
NetServicePrivate* SimpleItemFactory::createNetService( const DNSSD::RemoteService::Ptr& dnssdService, const NetDevice& device ) const
{
    NetServicePrivate* result;

    const QString dnssdServiceType = dnssdService->type();

    const DNSSDServiceDatum* serviceDatum = &UnknownServiceDatum;
    for( int i = 0; i< DNSSDServiceDataSize; ++i )
    {
        const DNSSDServiceDatum* datum = &DNSSDServiceData[i];
        if( dnssdServiceType == QLatin1String(datum->dnssdTypeName) )
        {
            serviceDatum = datum;
            break;
        }
    }

    KUrl url;
    if( serviceDatum->protocol )
        serviceDatum->feedUrl( &url, dnssdService.data() );

    const bool isUnknown = ( serviceDatum == &UnknownServiceDatum );
    const QString typeName = isUnknown ?
        dnssdServiceType.mid( 1, dnssdServiceType.lastIndexOf(QLatin1Char('.'))-1 ) :
        QString::fromLatin1( serviceDatum->typeName );

    QString iconName = QString::fromLatin1(serviceDatum->fallbackIconName);
    if ( serviceDatum->iconField ) {
        const QMap<QString,QByteArray> serviceTextData = dnssdService->textData();
        QString serviceIconName = QString::fromUtf8(serviceTextData[QString::fromLatin1(serviceDatum->iconField)]);
        if ( QIcon::hasThemeIcon(serviceIconName) ) {
            iconName = serviceIconName;
        }
    }

    result = new NetServicePrivate( dnssdService->serviceName(), iconName,
        typeName, device, url.url(), SimpleItemFactory::dnssdId(dnssdService) );

    return result;
}
Beispiel #19
0
Nepomuk2::SimpleResource Nepomuk2::SimpleIndexingJob::createSimpleResource(const KUrl& fileUrl, QString* mimeType)
{
    SimpleResource res;

    res.addProperty(NIE::url(), fileUrl);
    res.addProperty(NFO::fileName(), fileUrl.fileName());

    res.addType(NFO::FileDataObject());
    res.addType(NIE::InformationElement());

    QFileInfo fileInfo(fileUrl.toLocalFile());
    if( fileInfo.isDir() ) {
        res.addType(NFO::Folder());
    }
    else {
        res.addProperty(NFO::fileSize(), fileInfo.size());
    }

    // Types by mime type
    QString mime;
    if( mimeType )
        mime = *mimeType;

    if( mime.isEmpty() ) {
        mime = KMimeType::findByUrl( fileUrl )->name();
        if( mimeType )
            *mimeType = mime;
    }
    QSet<QUrl> types = typesForMimeType( mime );
    foreach(const QUrl& type, types)
        res.addType( type );

    res.addProperty(NIE::mimeType(), mime );

    res.setProperty(NIE::created(), fileInfo.created());
    res.setProperty(NIE::lastModified(), fileInfo.lastModified());

    return res;
}
Beispiel #20
0
KisImageBuilder_Result PSDLoader::buildImage(const KUrl& uri)
{
    if (uri.isEmpty())
        return KisImageBuilder_RESULT_NO_URI;

    if (!KIO::NetAccess::exists(uri, KIO::NetAccess::SourceSide, qApp->activeWindow())) {
        return KisImageBuilder_RESULT_NOT_EXIST;
    }

    // We're not set up to handle asynchronous loading at the moment.
    KisImageBuilder_Result result = KisImageBuilder_RESULT_FAILURE;
    QString tmpFile;

    if (KIO::NetAccess::download(uri, tmpFile, qApp->activeWindow())) {
        KUrl uriTF;
        uriTF.setPath( tmpFile );
        result = decode(uriTF);
        KIO::NetAccess::removeTempFile(tmpFile);
    }

    return result;
}
Beispiel #21
0
void DocumentChild::setFileInfo( const KUrl &url )
{
    m_fileinfo.setFile( url.path() );
    //kDebug(planworkDbg())<<url;
    bool res = connect( m_fileSystemWatcher, SIGNAL(fileChanged(QString)), this, SLOT(slotDirty(QString)) );
    //kDebug(planworkDbg())<<res<<filePath();
#ifndef NDEBUG
    Q_ASSERT( res );
#else
    Q_UNUSED( res );
#endif
    m_fileSystemWatcher->addPath( filePath() );
}
void KioExportWindow::slotCopyingDone(KIO::Job *job, const KUrl& from,
                                      const KUrl& to, time_t mtime, bool directory, bool renamed)
{
    Q_UNUSED(job);
    Q_UNUSED(to);
    Q_UNUSED(mtime);
    Q_UNUSED(directory);
    Q_UNUSED(renamed);

    kDebug() << "copied " << to.prettyUrl();

    m_exportWidget->imagesList()->removeItemByUrl(from);
}
Beispiel #23
0
void DirSelectWidget::setCurrentPath(const KUrl& currentUrl)
{
    if ( !currentUrl.isValid() )
    {
        return;
    }

    QString currentPath = QDir::cleanPath(currentUrl.toLocalFile());
    currentPath = currentPath.mid(d->m_rootUrl.toLocalFile().length());
    d->m_pendingPath.clear();
    d->m_handled = QString("");
    d->m_pendingPath = currentPath.split('/', QString::KeepEmptyParts);

    if (!d->m_pendingPath[0].isEmpty())
    {
        d->m_pendingPath.prepend("");    // ensure we open the root first.
    }

    connect( d->m_item, SIGNAL( populateFinished(K3FileTreeViewItem*) ),
             this, SLOT( load() ) );
    load();
}
Beispiel #24
0
QString KFileItemPrivate::user() const
{
    QString userName = m_entry.stringValue(KIO::UDSEntry::UDS_USER);
    if (userName.isEmpty() && m_bIsLocalUrl) {
#ifdef Q_WS_WIN
        QFileInfo a(m_url.toLocalFile( KUrl::RemoveTrailingSlash ));
        userName = a.owner();
        m_entry.insert( KIO::UDSEntry::UDS_USER, userName );
#else
        KDE_struct_stat buff;
        if ( KDE::lstat( m_url.toLocalFile( KUrl::RemoveTrailingSlash ), &buff ) == 0) // get uid/gid of the link, if it's a link
        {
            struct passwd *pwuser = getpwuid( buff.st_uid );
            if ( pwuser != 0 ) {
                userName = QString::fromLocal8Bit(pwuser->pw_name);
                m_entry.insert( KIO::UDSEntry::UDS_USER, userName );
            }
        }
#endif
    }
    return userName;
}
Beispiel #25
0
void KFileItemPrivate::readUDSEntry( bool _urlIsDirectory )
{
    // extract fields from the KIO::UDS Entry

    m_fileMode = m_entry.numberValue( KIO::UDSEntry::UDS_FILE_TYPE );
    m_permissions = m_entry.numberValue( KIO::UDSEntry::UDS_ACCESS );
    m_strName = m_entry.stringValue( KIO::UDSEntry::UDS_NAME );

    const QString displayName = m_entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_NAME );
    if (!displayName.isEmpty())
      m_strText = displayName;
    else
      m_strText = KIO::decodeFileName( m_strName );

    const QString urlStr = m_entry.stringValue( KIO::UDSEntry::UDS_URL );
    const bool UDS_URL_seen = !urlStr.isEmpty();
    if ( UDS_URL_seen ) {
        m_url = KUrl( urlStr );
        if ( m_url.isLocalFile() )
            m_bIsLocalUrl = true;
    }
    const QString mimeTypeStr = m_entry.stringValue( KIO::UDSEntry::UDS_MIME_TYPE );
    m_bMimeTypeKnown = !mimeTypeStr.isEmpty();
    if ( m_bMimeTypeKnown )
        m_pMimeType = KMimeType::mimeType( mimeTypeStr );

    m_guessedMimeType = m_entry.stringValue( KIO::UDSEntry::UDS_GUESSED_MIME_TYPE );
    m_bLink = !m_entry.stringValue( KIO::UDSEntry::UDS_LINK_DEST ).isEmpty(); // we don't store the link dest

    const int hiddenVal = m_entry.numberValue( KIO::UDSEntry::UDS_HIDDEN, -1 );
    m_hidden = hiddenVal == 1 ? Hidden : ( hiddenVal == 0 ? Shown : Auto );

    // avoid creating these QStrings again and again
    static const QString& dot = KGlobal::staticQString(".");
    if ( _urlIsDirectory && !UDS_URL_seen && !m_strName.isEmpty() && m_strName != dot )
        m_url.addPath( m_strName );

    m_iconName.clear();
}
Beispiel #26
0
void ThemeListBox::mouseMoveEvent(QMouseEvent *e)
{
   if (((e->buttons() & Qt::LeftButton) != 0) && !mDragFile.isEmpty())
   {
      int delay = KGlobalSettings::dndEventDelay();
      QPoint newPos = e->globalPos();
      if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay ||
         newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay)
      {
         KUrl url;
         url.setPath(mDragFile);
         KUrl::List urls;
         urls.append(url);
         QDrag *drag = new QDrag(this);
         QMimeData *mime = new QMimeData();
         urls.populateMimeData(mime);
         drag->setMimeData(mime);
         drag->start();
      }
   }
   KListWidget::mouseMoveEvent(e);
}
Beispiel #27
0
void KstChangeFileDialog::sourceChanged(const QString& text)
{
  delete _configWidget;
  _configWidget = 0L;
  _configureSource->setEnabled(false);
  _file = QString::null;
  if (!text.isEmpty() && text != "stdin" && text != "-") {
    KUrl url;
    QString txt = _dataFile->completionObject()->replacedPath(text);
    if (QFile::exists(txt) && QFileInfo(txt).isRelative()) {
      url.setPath(txt);
    } else {
      url = KUrl::fromPathOrURL(txt);
    }

    if (!url.isLocalFile() && url.protocol() != "file" && !url.protocol().isEmpty()) {
      _fileType->setText(QString::null);
      return;
    }

    if (!url.isValid()) {
      _fileType->setText(QString::null);
      return;
    }

    QString file = txt;

    KstDataSourcePtr ds = *KST::dataSourceList.findReusableFileName(file);
    QStringList fl;
    QString fileType;

    if (ds) {
      ds->readLock();
      fl = ds->fieldList();
      fileType = ds->fileType();
      ds->unlock();
      ds = 0L;
    } else {
      bool complete = false;
      fl = KstDataSource::fieldListForSource(file, QString::null, &fileType, &complete);
    }

    if (!fl.isEmpty() && !fileType.isEmpty()) {
      if (ds) {
        ds->writeLock();
        _configWidget = ds->configWidget();
        ds->unlock();
      } else {
        _configWidget = KstDataSource::configWidgetForSource(file, fileType);
      }
    }

    _configureSource->setEnabled(_configWidget);
    _file = file;
    _fileType->setText(fileType.isEmpty() ? QString::null : tr("Data source of type: %1").arg(fileType));
  } else {
    _fileType->setText(QString::null);
  }
}
Beispiel #28
0
void ZeroConfProtocol::get( const KUrl& url )
{
    if (!dnssdOK())
        return;

    const ZeroConfUrl zeroConfUrl( url );

    ZeroConfUrl::Type type = zeroConfUrl.type();
    if (type==ZeroConfUrl::Service)
        resolveAndRedirect( zeroConfUrl );
    else
        error( ERR_MALFORMED_URL, url.prettyUrl() );
}
Beispiel #29
0
void DocumentChild::setFileInfo( const KUrl &url )
{
    m_fileinfo.setFile( url.path() );
    //kDebug()<<url;
    bool res = connect( KDirWatch::self(), SIGNAL( dirty( const QString & ) ), this, SLOT( slotDirty( const QString &) ) );
    //kDebug()<<res<<filePath();
#ifndef NDEBUG
    Q_ASSERT( res );
#else
    Q_UNUSED( res );
#endif
    KDirWatch::self()->addFile( filePath() );
}
Beispiel #30
0
void MetaInfoProtocol::get(const KUrl &url)
{
    QString mimeType = metaData("mimeType");
    KFileMetaInfo info(url.toLocalFile(), mimeType);

    QByteArray arr;
    QDataStream stream(&arr, QIODevice::WriteOnly);

    stream << info;

    data(arr);
    finished();
}