Пример #1
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);
  }
}
Пример #2
0
ViewProperties::ViewProperties(const KUrl& url) :
    m_changedProps(false),
    m_autoSave(true),
    m_node(0)
{
    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
    const bool useGlobalViewProps = settings->globalViewProps();
    bool useDetailsViewWithPath = false;

    // We try and save it to the file .directory in the directory being viewed.
    // If the directory is not writable by the user or the directory is not local,
    // we store the properties information in a local file.
    if (useGlobalViewProps) {
        m_filePath = destinationDir("global");
    } else if (url.protocol().contains("search")) {
        m_filePath = destinationDir("search");
        useDetailsViewWithPath = true;
    } else if (url.protocol() == QLatin1String("trash")) {
        m_filePath = destinationDir("trash");
        useDetailsViewWithPath = true;
    } else if (url.isLocalFile()) {
        m_filePath = url.toLocalFile();
        const QFileInfo info(m_filePath);
        if (!info.isWritable() || !isPartOfHome(m_filePath)) {
            m_filePath = destinationDir("local") + m_filePath;
        }
    } else {
        m_filePath = destinationDir("remote") + m_filePath;
    }

    const QString file = m_filePath + QDir::separator() + QLatin1String(".directory");
    m_node = new ViewPropertySettings(KSharedConfig::openConfig(file));

    // If the .directory file does not exist or the timestamp is too old,
    // use default values instead.
    const bool useDefaultProps = (!useGlobalViewProps || useDetailsViewWithPath) &&
                                 (!QFileInfo(file).exists() ||
                                  (m_node->timestamp() < settings->viewPropsTimestamp()));
    if (useDefaultProps) {
        if (useDetailsViewWithPath) {
            setViewMode(DolphinView::DetailsView);
            setAdditionalInfo(KFileItemDelegate::InformationList() << KFileItemDelegate::LocalPathOrUrl);
        } else {
            // The global view-properties act as default for directories without
            // any view-property configuration
            settings->setGlobalViewProps(true);

            ViewProperties defaultProps(url);
            setDirProperties(defaultProps);

            settings->setGlobalViewProps(false);
            m_changedProps = false;
        }
    }
}
Пример #3
0
void TrashProtocol::copy( const KUrl &src, const KUrl &dest, int /*permissions*/, KIO::JobFlags flags )
{
    INIT_IMPL;

    kDebug()<<"TrashProtocol::copy(): " << src << " " << dest;

    if (src.protocol() == QLatin1String("trash") && dest.protocol() == QLatin1String("trash")) {
        error( KIO::ERR_UNSUPPORTED_ACTION, i18n( "This file is already in the trash bin." ) );
        return;
    }

    copyOrMove( src, dest, (flags & KIO::Overwrite), Copy );
}
Пример #4
0
void TrashProtocol::rename( const KUrl &oldURL, const KUrl &newURL, KIO::JobFlags flags )
{
    INIT_IMPL;

    kDebug()<<"TrashProtocol::rename(): old="<<oldURL<<" new="<<newURL<<" overwrite=" << (flags & KIO::Overwrite);

    if (oldURL.protocol() == QLatin1String("trash") && newURL.protocol() == QLatin1String("trash")) {
        error( KIO::ERR_CANNOT_RENAME, oldURL.prettyUrl() );
        return;
    }

    copyOrMove( oldURL, newURL, (flags & KIO::Overwrite), Move );
}
// We only generate pages when the user clicks on a link
void StatisticsDialog::slotOpenURLRequest ( const KUrl& url, const KParts::OpenUrlArguments &, const KParts::BrowserArguments & )
{
	if ( url.protocol() == "main" )
	{
		generatePageGeneral();
	}
	else if ( url.protocol() == "dayofweek" )
	{
		generatePageForDay ( url.path().toInt() );
	}
	else if ( url.protocol() == "monthofyear" )
	{
		generatePageForMonth ( url.path().toInt() );
	}
}
Пример #6
0
bool KMail::Util::handleClickedURL( const KUrl &url, const QSharedPointer<MailCommon::FolderCollection> &folder )
{
  if ( url.protocol() == QLatin1String( "mailto" ) )
  {
    KMime::Message::Ptr msg ( new KMime::Message );
    uint identity = folder->identity();
    MessageHelper::initHeader( msg, KMKernel::self()->identityManager(), identity );
    msg->contentType()->setCharset("utf-8");

    QMap<QString, QString> fields =  MessageCore::StringUtil::parseMailtoUrl( url );

    msg->to()->fromUnicodeString( fields.value( "to" ),"utf-8" );
    if ( !fields.value( "subject" ).isEmpty() )
      msg->subject()->fromUnicodeString( fields.value( "subject" ),"utf-8" );
    if ( !fields.value( "body" ).isEmpty() )
      msg->setBody( fields.value( "body" ).toUtf8() );
    if ( !fields.value( "cc" ).isEmpty() )
      msg->cc()->fromUnicodeString( fields.value( "cc" ),"utf-8" );

    TemplateParser::TemplateParser parser( msg, TemplateParser::TemplateParser::NewMessage );
    parser.setIdentityManager( KMKernel::self()->identityManager() );
    parser.process( msg, folder->collection() );

    KMail::Composer * win = KMail::makeComposer( msg, false, false, KMail::Composer::New, identity );
    win->setFocusToSubject();
    win->setCollectionForNewMessage( folder->collection() );
    win->show();
    return true;
  } else {
    kWarning() << "Can't handle URL:" << url;
    return false;
  }
}
Пример #7
0
bool KMail::Util::handleClickedURL( const KUrl &url )
{
  if ( url.protocol() == QLatin1String( "mailto" ) )
  {
    KMime::Message::Ptr msg ( new KMime::Message );
    MessageHelper::initHeader( msg, KMKernel::self()->identityManager(), 0 );
    msg->contentType()->setCharset("utf-8");

    QMap<QString, QString> fields =  MessageCore::StringUtil::parseMailtoUrl( url );

    msg->to()->fromUnicodeString( fields.value( "to" ),"utf-8" );
    if ( !fields.value( "subject" ).isEmpty() )
      msg->subject()->fromUnicodeString( fields.value( "subject" ),"utf-8" );
    if ( !fields.value( "body" ).isEmpty() )
      msg->setBody( fields.value( "body" ).toUtf8() );
    if ( !fields.value( "cc" ).isEmpty() )
      msg->cc()->fromUnicodeString( fields.value( "cc" ),"utf-8" );

    KMail::Composer * win = KMail::makeComposer( msg, false, false,KMail::Composer::New, 0 );
    win->setFocusToSubject();
    win->show();
    return true;
  } else {
    kWarning() << "Can't handle URL:" << url;
    return false;
  }
}
Пример #8
0
void Navigator::slotItemSelected( QTreeWidgetItem *currentItem )
{
  if ( !currentItem ) return;

  mSelected = true;

  NavigatorItem *item = static_cast<NavigatorItem *>( currentItem );

  kDebug(1400) << item->entry()->name() << endl;

  item->setExpanded( !item->isExpanded() );

  KUrl url ( item->entry()->url() );

  
  
  if ( url.protocol() == "khelpcenter" ) {
      mView->closeUrl();
      History::self().updateCurrentEntry( mView );
      History::self().createEntry();
      showOverview( item, url );
  } else {
   
    emit itemSelected( url.url() );
  }

  mLastUrl = url;
}
Пример #9
0
 static KUrl findUrlForAccount( const KMail::ImapAccountBase * a ) {
   assert( a );
   const SieveConfig sieve = a->sieveConfig();
   if ( !sieve.managesieveSupported() )
     return KUrl();
   if ( sieve.reuseConfig() ) {
     // assemble Sieve url from the settings of the account:
     KUrl u;
     u.setProtocol( "sieve" );
     u.setHost( a->host() );
     u.setUser( a->login() );
     u.setPass( a->passwd() );
     u.setPort( sieve.port() );
     u.addQueryItem( "x-mech", a->auth() == "*" ? "PLAIN" : a->auth() ); //translate IMAP LOGIN to PLAIN
     if ( !a->useSSL() && !a->useTLS() )
       u.addQueryItem( "x-allow-unencrypted", "true" );
     u.setFileName( sieve.vacationFileName() );
     return u;
   } else {
     KUrl u = sieve.alternateURL();
     if ( u.protocol().toLower() == "sieve" && !a->useSSL() && !a->useTLS() && u.queryItem("x-allow-unencrypted").isEmpty() )
       u.addQueryItem( "x-allow-unencrypted", "true" );
     u.setFileName( sieve.vacationFileName() );
     return u;
   }
 }
void KexiStartupFileHandler::init(const KUrl &startDirOrVariable, Mode mode)
{
/*    if (d->requester || d->dialog) {
        QWidget *w = d->requester ? static_cast<QWidget*>(d->requester) : 
            static_cast<QWidget*>(d->dialog);
        connect(w, SIGNAL(destroyed()), this, SLOT(saveRecentDir()));
    }*/
    connect(d->dialog, SIGNAL(accepted()), this, SLOT(slotAccepted()));
    //d->dialog->setStartDir(startDirOrVariable);
    KUrl url;
    if (startDirOrVariable.protocol() == "kfiledialog") {
        url = KFileDialog::getStartUrl(startDirOrVariable, d->recentDirClass);
    }
    else {
        url = startDirOrVariable;
    }
    if (d->requester)
        d->requester->setUrl(url);
    else
        d->dialog->setUrl(url);
    //setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    setMode(mode);
    QAction *previewAction = d->dialog->actionCollection()->action("preview");
    if (previewAction)
        previewAction->setChecked(false);

    // setFocusProxy(locationEdit());

//    connect(dialog, SIGNAL(fileHighlighted(QString)),
//            this, SLOT(slotExistingFileHighlighted(QString)));
}
BreadcrumbSiblingList
FileBrowser::Private::siblingsForDir( const KUrl &path )
{
    BreadcrumbSiblingList siblings;
    if( path.protocol() == "places" )
    {
        for( int i = 0; i < placesModel->rowCount(); i++ )
        {
            QModelIndex idx = placesModel->index( i, 0 );

            QString name = idx.data( Qt::DisplayRole ).toString();
            QString url = idx.data( KFilePlacesModel::UrlRole ).toString();
            if( url.isEmpty() )
                // the place perhaps needs mounting, use places url instead
                url = placesString + name;
            siblings << BreadcrumbSibling( idx.data( Qt::DecorationRole ).value<QIcon>(),
                                           name, url );
        }
    }
    else if( path.isLocalFile() )
    {
        QDir dir( path.toLocalFile() );
        dir.cdUp();
        foreach( const QString &item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
        {
            siblings << BreadcrumbSibling( KIcon( "folder-amarok" ), item,
                                           dir.absoluteFilePath( item ) );
        }
    }
Пример #12
0
void Connection::connectToRemote(const QString &address)
{
    //kDebug(7017) << "Connection requested to " << address;
    KUrl url = address;
    QString scheme = url.protocol();

    if (scheme == QLatin1String("local")) {
        d->setBackend(new SocketConnectionBackend(SocketConnectionBackend::LocalSocketMode, this));
    } else if (scheme == QLatin1String("tcp")) {
        d->setBackend(new SocketConnectionBackend(SocketConnectionBackend::TcpSocketMode, this));
    } else {
        kWarning(7017) << "Unknown requested KIO::Connection protocol='" << scheme
                       << "' (" << address << ")";
        Q_ASSERT(0);
        return;
    }

    // connection succeeded
    if (!d->backend->connectToRemote(url)) {
        //kWarning(7017) << "could not connect to " << url << "using scheme" << scheme ;
        delete d->backend;
        d->backend = 0;
        return;
    }

    d->dequeue();
}
Пример #13
0
void AsyncFileTester::checkIfFolder(const QModelIndex &index, QObject *object, const char *method)
{
    if (!index.isValid()) {
        callResultMethod(object, method, index, false);
        return;
    }

    KFileItem item = static_cast<const ProxyModel*>(index.model())->itemForIndex(index);
    KUrl url = item.targetUrl();
    
    if (item.isDir()) {
        callResultMethod(object, method, index, true);
        return;
    }
    
    if (item.isDesktopFile()) {
        // Check if the desktop file is a link to a local folder
        KDesktopFile file(url.path());
        if (file.readType() == "Link") {
            url = file.readUrl();
            if (url.isLocalFile()) {
                KFileItem destItem(KFileItem::Unknown, KFileItem::Unknown, url);
                callResultMethod(object, method, index, destItem.isDir());
                return;
            }
            
            if (KProtocolInfo::protocolClass(url.protocol()) == QString(":local")) {
                AsyncFileTester *tester = new AsyncFileTester(index, object, method);
                tester->delayedFolderCheck(url);
                return;
            }
        }
    }
    callResultMethod(object, method, index, false);
}
Пример #14
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);
        }
    }
Пример #15
0
QString KUrlNavigator::Private::firstButtonText() const
{
    QString text;

    // The first URL navigator button should get the name of the
    // place instead of the directory name
    if ((m_placesSelector != 0) && !m_showFullPath) {
        const KUrl placeUrl = m_placesSelector->selectedPlaceUrl();
        text = m_placesSelector->selectedPlaceText();
    }

    if (text.isEmpty()) {
        const KUrl currentUrl = q->locationUrl();
        if (currentUrl.isLocalFile()) {
            text = m_showFullPath ? QLatin1String("/") : i18n("Custom Path");
        } else {
            text = currentUrl.protocol() + QLatin1Char(':');
            if (!currentUrl.host().isEmpty()) {
                text += QLatin1Char(' ') + currentUrl.host();
            }
        }
    }

    return text;
}
Пример #16
0
void KDirSelectDialog::setCurrentUrl( const KUrl& url )
{
    if ( !url.isValid() )
        return;

    if (url.protocol() != d->m_rootUrl.protocol()) {
        KUrl u( url );
        u.cd("/");//NOTE portability?
        d->m_treeView->setRootUrl( u );
        d->m_rootUrl = u;
    }

    //Check if url represents a hidden folder and enable showing them
    QString fileName = url.fileName();
    //TODO a better hidden file check?
    bool isHidden = fileName.length() > 1 && fileName[0] == '.' &&
                                                (fileName.length() > 2 ? fileName[1] != '.' : true);
    bool showHiddenFiles = isHidden && !d->m_treeView->showHiddenFiles();
    if (showHiddenFiles) {
        d->showHiddenFoldersAction->setChecked(true);
        d->m_treeView->setShowHiddenFiles(true);
    }

    d->m_treeView->setCurrentUrl( url );
}
Пример #17
0
 bool destMatch(const KUrl &url, const QString &protClass, const KUrl &base, const QString &baseClass) const
 {
    if (destProtEqual)
    {
       if ( (url.protocol() != base.protocol()) &&
            (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass) )
          return false;
    }
    else if (destProtWildCard)
    {
       if ( !destProt.isEmpty() && !url.protocol().startsWith(destProt) &&
            (protClass.isEmpty() || (protClass != destProt)) )
          return false;
    }
    else
    {
       if ( (url.protocol() != destProt) &&
            (protClass.isEmpty() || (protClass != destProt)) )
          return false;
    }
    if (destHostWildCard)
    {
       if (!destHost.isEmpty() && !url.host().endsWith(destHost))
          return false;
    }
    else if (destHostEqual)
    {
       if (url.host() != base.host())
          return false;
    }
    else
    {
       if (url.host() != destHost)
          return false;
    }
    if (destPathWildCard)
    {
       if (!destPath.isEmpty() && !url.path().startsWith(destPath))
          return false;
    }
    else
    {
       if (url.path() != destPath)
          return false;
    }
    return true;
 }
Пример #18
0
// static function
ContextHelp::LinkType ContextHelp::extractLinkType( const KUrl & url )
{
	QString path = url.path();
	
	if ( url.protocol() == "ktechlab-help" )
	{
		if ( itemLibrary()->haveDescription( path, KGlobal::locale()->language() ) )
			return HelpLink;
		else
			return NewHelpLink;
	}
	
	if ( url.protocol() == "ktechlab-example" )
		return ExampleLink;
	
	return ExternalLink;
}
Пример #19
0
KProtocolInfo::ExtraFieldList KProtocolInfo::extraFields( const KUrl &url )
{
  KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(url.protocol());
  if ( !prot )
    return ExtraFieldList();

  return prot->d_func()->extraFields;
}
Пример #20
0
AmpacheService::AmpacheService( AmpacheServiceFactory* parent, const QString & name, const QString &url, const QString &username, const QString &password )
    : ServiceBase( name,  parent )
    , m_authenticated( false )
    , m_server ( QString() )
    , m_sessionId ( QString() )
    , m_collection( 0 )
{
    DEBUG_BLOCK


    setShortDescription( i18n( "Use Amarok as a seamless frontend to your Ampache server." ) );
    setIcon( KIcon( "view-services-ampache-amarok" ) );

    //we are using http queries later on, so we require
    KUrl kurl;
    if( url.contains( "//" ) )
    {
        kurl.setUrl( url, KUrl::TolerantMode );
        if( kurl.protocol() != "http" && kurl.protocol() != "https" )
        {
            kurl.setProtocol( "http" );
        }
    }
    else
    {
        kurl.setProtocol( "http" );
        kurl.setAuthority( url );
    }

    m_server = kurl.url();

    // We need to check the version of Ampache we are attempting to authenticate against, as this changes how we deal with it

    QString versionString = "<server>/server/xml.server.php?action=ping";

    versionString.replace(QString("<server>"), m_server);

    debug() << "Verifying Ampache Version Using: " << versionString;

    m_username = username;
    m_password = password;

    m_xmlVersionJob = KIO::storedGet( versionString, KIO::Reload, KIO::HideProgressInfo );
    connect( m_xmlVersionJob, SIGNAL(result(KJob *)), this, SLOT( authenticate(KJob *) ) );
}
Пример #21
0
bool
NepomukCollection::possiblyContainsTrack( const KUrl &url ) const
{
    QString proto = url.protocol();
    if ( proto == "file" || proto == uidUrlProtocol() )
        return true;
    else
        return false;
}
Пример #22
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());
}
Пример #23
0
void ChecksumSearchController::registerSearch(ChecksumSearchTransferDataSource *search, const KUrl &baseUrl)
{
    if (m_finished.contains(baseUrl)) {
        kDebug(5001) << "Already downloaded" << baseUrl;
        const KUrl urlToFile = m_finished[baseUrl];
        if (!urlToFile.isEmpty()) {
            search->gotBaseUrl(m_finished[baseUrl]);
        }
    } else {
        const bool alreadySearchedFor = m_searches.contains(baseUrl);
        if (!m_searches.contains(baseUrl, search)) {
            m_searches.insert(baseUrl, search);

            if (alreadySearchedFor) {
                kDebug(5001) << "Search already started for" << baseUrl;
                return;
            }
            kDebug(5001) << "Creating download for" << baseUrl;
            static int files = 0;

            const KUrl dest = KUrl(KStandardDirs::locateLocal("appdata", "checksumsearch/") + QString::number(files++));
            if (QFile::exists(dest.toLocalFile())) {
                KIO::Job *del = KIO::del(dest, KIO::HideProgressInfo);
                KIO::NetAccess::synchronousRun(del, 0);
            }

            if (baseUrl.protocol() != "ftp" && baseUrl.protocol() != "sftp") {
                kDebug(5001) << "Downloading" << baseUrl;
                KIO::FileCopyJob *job = KIO::file_copy(baseUrl, dest, -1, KIO::HideProgressInfo);
                job->addMetaData("errorPage", "false");
                connect(job, SIGNAL(result(KJob*)), SLOT(slotResult(KJob*)));
                m_jobs[job] = qMakePair(baseUrl, dest);
            } else {
                kDebug(5001) << "ftp, doing a listjob";
                KIO::ListJob *job = KIO::listDir(baseUrl, KIO::HideProgressInfo);
                connect(job, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)), this, SLOT(slotEntries(KIO::Job*,KIO::UDSEntryList)));
                connect(job, SIGNAL(result(KJob*)), SLOT(slotResult(KJob*)));
                m_jobs[job] = qMakePair(baseUrl, dest);
            }
        }
    }
// The opposite of parseURL
static QString splitURL( int mRealArgType, const KUrl& url )
{
  if ( mRealArgType == 33 ) { // LDAP server
    // The format is HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN
    Q_ASSERT( url.protocol() == "ldap" );
    return urlpart_encode( url.host() ) + ':' +
      ( url.port() != -1 ? QString::number( url.port() ) : QString() ) + ':' + // -1 is used for default ports, omit
      urlpart_encode( url.user() ) + ':' +
      urlpart_encode( url.pass() ) + ':' +
      // KUrl automatically encoded the query (e.g. for spaces inside it),
      // so decode it before writing it out to gpgconf (issue119)
      urlpart_encode( KUrl::fromPercentEncoding( url.query().mid(1).toLatin1() ) );
  }
  return url.path();
}
Пример #25
0
 bool baseMatch(const KUrl &url, const QString &protClass) const
 {
    if (baseProtWildCard)
    {
       if ( !baseProt.isEmpty() && !url.protocol().startsWith(baseProt) &&
            (protClass.isEmpty() || (protClass != baseProt)) )
          return false;
    }
    else
    {
       if ( (url.protocol() != baseProt) &&
            (protClass.isEmpty() || (protClass != baseProt)) )
          return false;
    }
    if (baseHostWildCard)
    {
       if (!baseHost.isEmpty() && !url.host().endsWith(baseHost))
          return false;
    }
    else
    {
       if (url.host() != baseHost)
          return false;
    }
    if (basePathWildCard)
    {
       if (!basePath.isEmpty() && !url.path().startsWith(basePath))
          return false;
    }
    else
    {
       if (url.path() != basePath)
          return false;
    }
    return true;
 }
Пример #26
0
bool SecurityOrigin::taintsCanvas(const KUrl& url) const
{
    if (canRequest(url))
        return false;

    // This function exists because we treat data URLs as having a unique origin,
    // contrary to the current (9/19/2009) draft of the HTML5 specification.
    // We still want to let folks paint data URLs onto untainted canvases, so
    // we special case data URLs below. If we change to match HTML5 w.r.t.
    // data URL security, then we can remove this function in favor of
    // !canRequest.
    if (url.protocol().toLower() == QLatin1String("data"))
        return false;

    return true;
}
Пример #27
0
void
App::handleCliArgs() //static
{
    DEBUG_BLOCK

    KCmdLineArgs* const args = KCmdLineArgs::parsedArgs();

    if( args->isSet( "cwd" ) )
        KCmdLineArgs::setCwd( args->getOption( "cwd" ).toLocal8Bit() );

    bool haveArgs = true; // assume having args in first place
    if( args->count() > 0 )
    {
        KUrl::List list;
        for( int i = 0; i < args->count(); i++ )
        {
            KUrl url = args->url( i );
            //TODO:PORTME
            if( Podcasts::PodcastProvider::couldBeFeed( url.url() ) )
            {
                KUrl feedUrl = Podcasts::PodcastProvider::toFeedUrl( url.url() );
                The::playlistManager()->defaultPodcasts()->addPodcast( feedUrl );
            }
            else if( url.protocol() == "amarok" )
            {
                s_delayedAmarokUrls.append( url.url() );
            }
            else
            {
                list << url;
                DEBUG_LINE_INFO
            }
        }

        int options = Playlist::AppendAndPlay;
        if( args->isSet( "queue" ) )
           options = Playlist::Queue;
        else if( args->isSet( "append" ) )
           options = Playlist::Append;
        else if( args->isSet( "load" ) )
            options = Playlist::Replace;

        if( args->isSet( "play" ) )
            options |= Playlist::DirectPlay;

        The::playlistController()->insertOptioned( list, options );
    }
void KonqSidebarTree::addUrl(KonqSidebarTreeTopLevelItem* item, const KUrl & url)
{
    QString path;
    if (item)
        path = item->path();
    else
        path = m_dirtreeDir.dir.path();

    KUrl destUrl;

    if (url.isLocalFile() && url.fileName().endsWith(".desktop"))
    {
        QString filename = findUniqueFilename(path, url.fileName());
        destUrl.setPath(filename);
        KIO::NetAccess::file_copy(url, destUrl, this);
    }
    else
    {
        QString name = url.host();
        if (name.isEmpty())
            name = url.fileName();
        QString filename = findUniqueFilename(path, name);
        destUrl.setPath(filename);

        KDesktopFile desktopFile(filename);
        KConfigGroup cfg = desktopFile.desktopGroup();
        cfg.writeEntry("Encoding", "UTF-8");
        cfg.writeEntry("Type","Link");
        cfg.writeEntry("URL", url.url());
        QString icon = "folder";
        if (!url.isLocalFile())
            icon = KMimeType::favIconForUrl(url);
        if (icon.isEmpty())
            icon = KProtocolInfo::icon( url.protocol() );
        cfg.writeEntry("Icon", icon);
        cfg.writeEntry("Name", name);
        cfg.writeEntry("Open", false);
        cfg.sync();
    }

    destUrl.setPath( destUrl.directory() );
    OrgKdeKDirNotifyInterface::emitFilesAdded( destUrl.url() );

    if (item)
        item->setOpen(true);
}
Пример #29
0
void KonqRun::slotRedirection(KIO::Job *job, const KUrl& redirectedToURL)
{
    KUrl redirectFromURL = static_cast<KIO::TransferJob *>(job)->url();
    kDebug() << redirectFromURL << "->" << redirectedToURL;
    KonqHistoryManager::kself()->confirmPending(redirectFromURL);

    if (redirectedToURL.protocol() == "mailto") {
       m_mailto = redirectedToURL;
       return; // Error will follow
    }
    KonqHistoryManager::kself()->addPending(redirectedToURL);

    // Do not post data on reload if we were redirected to a new URL when
    // doing a POST request.
    if (redirectFromURL != redirectedToURL)
        browserArguments().setDoPost (false);
    browserArguments().setRedirectedRequest(true);
}
Пример #30
0
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);
    setFocusProxy(locationEdit());
    connect(this, SIGNAL(fileHighlighted(QString)),
            this, SLOT(slotExistingFileHighlighted(QString)));
}