コード例 #1
0
/** expands an archiv, if possible */
bool BaseTreeView::expandArchiv (KFileTreeViewItem *item)
{
  if (!item) return false;
  KURL urlToOpen = item->url();

  if ( ! urlToOpen.isLocalFile()) return false;

  QString mimeType = KMimeType::findByURL(urlToOpen)->name();

  if ( mimeType == "application/x-tgz" ||
       mimeType == "application/x-tbz" ||
       mimeType == "application/x-tar" ) //it is an archiv
    urlToOpen.setProtocol("tar");
  else
    if ( mimeType == "application/x-zip" ) //it is an archiv
      urlToOpen.setProtocol("zip");
    else
      return false;

  // change status if there is already a sub branch
  if (item->isExpandable()) {
    item->setOpen( ! item->isOpen());
    return true;
  };

  KFileTreeBranch *kftb = new BaseTreeBranch(this, urlToOpen, item->text(0), *(item->pixmap(0)), true, item);
  addBranch(kftb);  // connecting some signals
  kftb->populate(urlToOpen, item);
  item->setExpandable(true);
  item->setOpen(true);
  return true;
}
コード例 #2
0
KURL* toDAV( const KURL* url ) {
  KURL* result = new KURL( *url );
  if ( result->protocol() == "http" )
     result->setProtocol( "webdav" );
  else if (  result->protocol() == "https" )
     result->setProtocol( "webdavs" );
  return result;
}
コード例 #3
0
ファイル: KURLTest.cpp プロジェクト: azureplus/chromium
TEST(KURLTest, Valid_HTTP_FTP_URLsHaveHosts)
{
    KURL kurl;
    EXPECT_TRUE(kurl.setProtocol("http"));
    EXPECT_TRUE(kurl.protocolIs("http"));
    EXPECT_FALSE(kurl.isValid());

    EXPECT_TRUE(kurl.setProtocol("https"));
    EXPECT_TRUE(kurl.protocolIs("https"));
    EXPECT_FALSE(kurl.isValid());

    EXPECT_TRUE(kurl.setProtocol("ftp"));
    EXPECT_TRUE(kurl.protocolIs("ftp"));
    EXPECT_FALSE(kurl.isValid());

    kurl = KURL(KURL(), "http://");
    EXPECT_TRUE(kurl.protocolIs("http"));
    EXPECT_FALSE(kurl.isValid());

    kurl = KURL(KURL(), "https://");
    EXPECT_TRUE(kurl.protocolIs("https"));
    EXPECT_FALSE(kurl.isValid());

    kurl = KURL(KURL(), "ftp://");
    EXPECT_TRUE(kurl.protocolIs("ftp"));
    EXPECT_FALSE(kurl.isValid());

    kurl = KURL(KURL(), "http://host/");
    EXPECT_TRUE(kurl.isValid());
    kurl.setHost("");
    EXPECT_FALSE(kurl.isValid());

    kurl = KURL(KURL(), "https://host/");
    EXPECT_TRUE(kurl.isValid());
    kurl.setHost("");
    EXPECT_FALSE(kurl.isValid());

    kurl = KURL(KURL(), "ftp://host/");
    EXPECT_TRUE(kurl.isValid());
    kurl.setHost("");
    EXPECT_FALSE(kurl.isValid());

    kurl = KURL(KURL(), "http:///noodles/pho.php");
    EXPECT_STREQ("http://noodles/pho.php", kurl.string().utf8().data());
    EXPECT_STREQ("noodles", kurl.host().utf8().data());
    EXPECT_TRUE(kurl.isValid());

    kurl = KURL(KURL(), "https://*****:*****@/");
    EXPECT_FALSE(kurl.isValid());

    kurl = KURL(KURL(), "https://*****:*****@host/");
    EXPECT_TRUE(kurl.isValid());
}
コード例 #4
0
ファイル: knnetaccess.cpp プロジェクト: serghei/kde3-kdepim
void KNNetAccess::startJobSmtp()
{
    if(smtpJobQueue.isEmpty())
        return;

    currentSmtpJob = smtpJobQueue.first();
    smtpJobQueue.remove(smtpJobQueue.begin());
    currentSmtpJob->prepareForExecution();
    if(currentSmtpJob->success())
    {
        KNLocalArticle *art = static_cast<KNLocalArticle *>(currentSmtpJob->data());
        // create url query part
        QString query("headers=0&from=");
        query += KURL::encode_string(art->from()->email());
        QStrList emails;
        art->to()->emails(&emails);
        for(char *e = emails.first(); e; e = emails.next())
        {
            query += "&to=" + KURL::encode_string(e);
        }
        // create url
        KURL destination;
        KNServerInfo *account = currentSmtpJob->account();
        if(account->encryption() == KNServerInfo::SSL)
            destination.setProtocol("smtps");
        else
            destination.setProtocol("smtp");
        destination.setHost(account->server());
        destination.setPort(account->port());
        destination.setQuery(query);
        if(account->needsLogon())
        {
            destination.setUser(account->user());
            destination.setPass(account->pass());
        }
        KIO::Job *job = KIO::storedPut(art->encodedContent(true), destination, -1, false, false, false);
        connect(job, SIGNAL(result(KIO::Job *)),
                SLOT(slotJobResult(KIO::Job *)));
        if(account->encryption() == KNServerInfo::TLS)
            job->addMetaData("tls", "on");
        else
            job->addMetaData("tls", "off");
        currentSmtpJob->setJob(job);

        kdDebug(5003) << "KNNetAccess::startJobSmtp(): job started" << endl;
    }
    else
    {
        threadDoneSmtp();
    }
}
コード例 #5
0
void DolphinView::updateURL()
{
    KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
                                               static_cast<KFileView*>(m_detailsView);

    KFileItem* fileItem = fileView->currentFileItem();
    if (fileItem == 0) {
        return;
    }

    if (fileItem->isDir()) {
        // Prefer the local path over the URL. This assures that the
        // volume space information is correct. Assuming that the URL is media:/sda1,
        // and the local path is /windows/C: For the URL the space info is related
        // to the root partition (and hence wrong) and for the local path the space
        // info is related to the windows partition (-> correct).
        const QString localPath(fileItem->localPath());
        if (localPath.isEmpty()) {
            setURL(fileItem->url());
        }
        else {
            setURL(KURL(localPath));
        }
    }
    else if (fileItem->isFile()) {
       // allow to browse through ZIP and tar files
       KMimeType::Ptr mime = fileItem->mimeTypePtr();
       if (mime->is("application/x-zip")) {
           KURL url = fileItem->url();
           url.setProtocol("zip");
           setURL(url);
       }
       else if (mime->is("application/x-tar") ||
                mime->is("application/x-tarz") ||
                mime->is("application/x-tbz") ||
                mime->is("application/x-tgz") ||
                mime->is("application/x-tzo")) {
           KURL url = fileItem->url();
           url.setProtocol("tar");
           setURL(url);
       }
       else {
           fileItem->run();
       }
    }
    else {
        fileItem->run();
    }
}
コード例 #6
0
void DocCHMPlugin::setCatalogURL(DocumentationCatalogItem* item)
{
    KURL chmURL = item->url();
    chmURL.setProtocol("ms-its");
    chmURL.addPath("/");
    item->setURL(chmURL);
}
コード例 #7
0
void MediaPlayerPrivate::load(const String& url)
{
    String modifiedUrl(url);

    if (modifiedUrl.startsWith("local://")) {
        KURL kurl = KURL(KURL(), modifiedUrl);
        kurl.setProtocol("file");
        String tempPath(BlackBerry::Platform::Client::get()->getApplicationLocalDirectory().c_str());
        tempPath.append(kurl.path());
        kurl.setPath(tempPath);
        modifiedUrl = kurl.string();
    }
    if (modifiedUrl.startsWith("file://")) {
        // The QNX Multimedia Framework cannot handle filenames containing URL escape sequences.
        modifiedUrl = decodeURLEscapeSequences(modifiedUrl);
    }

    String cookiePairs;
    if (!url.isEmpty())
        cookiePairs = cookieManager().getCookie(KURL(ParsedURLString, url.utf8().data()), WithHttpOnlyCookies);
    if (!cookiePairs.isEmpty() && cookiePairs.utf8().data())
        m_platformPlayer->load(modifiedUrl.utf8().data(), userAgent(modifiedUrl).utf8().data(), cookiePairs.utf8().data());
    else
        m_platformPlayer->load(modifiedUrl.utf8().data(), userAgent(modifiedUrl).utf8().data(), 0);
}
コード例 #8
0
void FrameFetchContext::upgradeInsecureRequest(FetchRequest& fetchRequest)
{
    KURL url = fetchRequest.resourceRequest().url();

    // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational requests, as described in
    // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect
    if (fetchRequest.resourceRequest().frameType() != WebURLRequest::FrameTypeNone)
        fetchRequest.mutableResourceRequest().addHTTPHeaderField("Upgrade-Insecure-Requests", "1");

    if (m_document && m_document->insecureRequestsPolicy() == SecurityContext::InsecureRequestsUpgrade && url.protocolIs("http")) {
        ASSERT(m_document->insecureNavigationsToUpgrade());

        // We always upgrade requests that meet any of the following criteria:
        //
        // 1. Are for subresources (including nested frames).
        // 2. Are form submissions.
        // 3. Whose hosts are contained in the document's InsecureNavigationSet.
        const ResourceRequest& request = fetchRequest.resourceRequest();
        if (request.frameType() == WebURLRequest::FrameTypeNone
            || request.frameType() == WebURLRequest::FrameTypeNested
            || request.requestContext() == WebURLRequest::RequestContextForm
            || (!url.host().isNull() && m_document->insecureNavigationsToUpgrade()->contains(url.host().impl()->hash())))
        {
            UseCounter::count(m_document, UseCounter::UpgradeInsecureRequestsUpgradedRequest);
            url.setProtocol("https");
            if (url.port() == 80)
                url.setPort(443);
            fetchRequest.mutableResourceRequest().setURL(url);
        }
    }
}
コード例 #9
0
void MediaPlayerPrivate::load(const WTF::String& url)
{
    WTF::String modifiedUrl(url);

    if (modifiedUrl.startsWith("local://")) {
        KURL kurl = KURL(KURL(), modifiedUrl);
        kurl.setProtocol("file");
        WTF::String tempPath(BlackBerry::Platform::Settings::instance()->applicationLocalDirectory().c_str());
        tempPath.append(kurl.path());
        kurl.setPath(tempPath);
        modifiedUrl = kurl.string();
    }
    if (modifiedUrl.startsWith("file://")) {
        // The QNX Multimedia Framework cannot handle filenames containing URL escape sequences.
        modifiedUrl = decodeURLEscapeSequences(modifiedUrl);
    }

    void* tabId = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient();
    int playerID = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->playerID();

    deleteGuardedObject(m_platformPlayer);
#if USE(ACCELERATED_COMPOSITING)
    m_platformPlayer = PlatformPlayer::create(this, tabId, true, modifiedUrl.utf8().data());
#else
    m_platformPlayer = PlatformPlayer::create(this, tabId, false, modifiedUrl.utf8().data());
#endif

    WTF::String cookiePairs;
    if (!url.isEmpty())
        cookiePairs = cookieManager().getCookie(KURL(ParsedURLString, url.utf8().data()), WithHttpOnlyCookies);
    if (!cookiePairs.isEmpty() && cookiePairs.utf8().data())
        m_platformPlayer->load(playerID, modifiedUrl.utf8().data(), m_webCorePlayer->userAgent().utf8().data(), cookiePairs.utf8().data());
    else
        m_platformPlayer->load(playerID, modifiedUrl.utf8().data(), m_webCorePlayer->userAgent().utf8().data(), 0);
}
コード例 #10
0
KNetworkProtocol::KNetworkProtocol(const QString& protocol)
    : m_isLocalFS(false),
      m_supportedOperations(0)
{
    if (!protocol.isEmpty())
    {
        m_isLocalFS = (protocol == "file");

        KURL url;

        url.setProtocol(protocol);

        if (KProtocolInfo::supportsListing(url))
            m_supportedOperations |= OpListChildren;
        if (KProtocolInfo::supportsMakeDir(url))
            m_supportedOperations |= OpMkDir;
        if (KProtocolInfo::supportsDeleting(url))
            m_supportedOperations |= OpRemove;
        if (KProtocolInfo::supportsMoving(url))
            m_supportedOperations |= OpRename;
        if (KProtocolInfo::supportsReading(url))
            m_supportedOperations |= OpGet;
        if (KProtocolInfo::supportsWriting(url))
            m_supportedOperations |= OpPut;
    }
    
    m_transfers.setAutoDelete(true);
}
コード例 #11
0
KURL WebSocketHandshake::httpURLForAuthenticationAndCookies() const
{
    KURL url = m_url.copy();
    bool couldSetProtocol = url.setProtocol(m_secure ? "https" : "http");
    ASSERT_UNUSED(couldSetProtocol, couldSetProtocol);
    return url;
}
コード例 #12
0
IconURL IconController::defaultURL(IconType iconType)
{
    // Don't return a favicon iconURL unless we're http or https
    KURL documentURL = m_frame->document()->url();
    if (!documentURL.protocolIsInHTTPFamily())
        return IconURL();

    KURL url;
    bool couldSetProtocol = url.setProtocol(documentURL.protocol());
    ASSERT_UNUSED(couldSetProtocol, couldSetProtocol);
    url.setHost(documentURL.host());
    if (documentURL.hasPort())
        url.setPort(documentURL.port());

    if (iconType == Favicon) {
        url.setPath("/favicon.ico");
        return IconURL::defaultIconURL(url, Favicon);
    }
#if ENABLE(TOUCH_ICON_LOADING)
    if (iconType == TouchPrecomposedIcon) {
        url.setPath("/apple-touch-icon-precomposed.png");
        return IconURL::defaultIconURL(url, TouchPrecomposedIcon);
    }
    if (iconType == TouchIcon) {
        url.setPath("/apple-touch-icon.png");
        return IconURL::defaultIconURL(url, TouchIcon);
    }
#endif
    return IconURL();
}
コード例 #13
0
// Right now, only one item for each action.
void subversionCore::svnLog( const KURL::List& list,
		int revstart, QString revKindStart, int revend, QString revKindEnd,
		bool discorverChangedPath, bool strictNodeHistory )
{
	// ensure that part has repository information. This info is used to retrieve root repository URL
    if( m_part->m_prjInfoMap.count() < 1 )
        clientInfo( KURL(m_part->project()->projectDirectory()), false, m_part->m_prjInfoMap );
	KURL servURL = m_part->baseURL();
	if ( servURL.isEmpty() ) servURL="kdevsvn+svn://blah/";
	if ( ! servURL.protocol().startsWith( "kdevsvn+" ) ) {
		servURL.setProtocol( "kdevsvn+" + servURL.protocol() ); //make sure it starts with "svn"
	}
	kdDebug(9036) << "servURL : " << servURL.prettyURL() << endl;
	QByteArray parms;
	QDataStream s( parms, IO_WriteOnly );
	// prepare arguments
	int cmd = 4;
// 	int revstart = -1, revend = 0;
// 	QString revKindStart = "HEAD", revKindEnd = "";
// 	bool repositLog = true, discorverChangedPath = true, strictNodeHistory = true;
	s << cmd << revstart << revKindStart << revend << revKindEnd;
	s << discorverChangedPath << strictNodeHistory;
	for ( QValueListConstIterator<KURL> it = list.begin(); it != list.end() ; ++it ) {
		kdDebug(9036) << "svnCore: adding to list: " << (*it).prettyURL() << endl;
		s << *it;
	}
	SimpleJob * job = KIO::special(servURL, parms, false);
	connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotLogResult( KIO::Job * ) ) );
	//  progress info. LogView is allowed and meaninful only for one url in KDev3.4
	initProcessDlg( (KIO::Job*)job, (*(list.begin())).prettyURL() , i18n("Subversion Log View") );
}
コード例 #14
0
void FrameFetchContext::upgradeInsecureRequest(FetchRequest& fetchRequest)
{
    KURL url = fetchRequest.resourceRequest().url();

    // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational requests, as described in
    // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect
    if (fetchRequest.resourceRequest().frameType() != WebURLRequest::FrameTypeNone)
        fetchRequest.mutableResourceRequest().addHTTPHeaderField("Upgrade-Insecure-Requests", "1");

    // If we don't yet have an |m_document| (because we're loading an iframe, for instance), check the FrameLoader's policy.
    WebInsecureRequestPolicy relevantPolicy = m_document ? m_document->getInsecureRequestPolicy() : frame()->loader().getInsecureRequestPolicy();
    SecurityContext::InsecureNavigationsSet* relevantNavigationSet = m_document ? m_document->insecureNavigationsToUpgrade() : frame()->loader().insecureNavigationsToUpgrade();

    if (url.protocolIs("http") && relevantPolicy & kUpgradeInsecureRequests) {
        // We always upgrade requests that meet any of the following criteria:
        //
        // 1. Are for subresources (including nested frames).
        // 2. Are form submissions.
        // 3. Whose hosts are contained in the document's InsecureNavigationSet.
        const ResourceRequest& request = fetchRequest.resourceRequest();
        if (request.frameType() == WebURLRequest::FrameTypeNone
            || request.frameType() == WebURLRequest::FrameTypeNested
            || request.requestContext() == WebURLRequest::RequestContextForm
            || (!url.host().isNull() && relevantNavigationSet->contains(url.host().impl()->hash())))
        {
            UseCounter::count(m_document, UseCounter::UpgradeInsecureRequestsUpgradedRequest);
            url.setProtocol("https");
            if (url.port() == 80)
                url.setPort(443);
            fetchRequest.mutableResourceRequest().setURL(url);
        }
    }
}
コード例 #15
0
ファイル: sites.cpp プロジェクト: serghei/kde3-kdemultimedia
    QValueList<Mirror>
  Sites::siteList()
  {
    KURL url;
    url.setProtocol( "http" );
    url.setHost( "freedb.freedb.org" );
    url.setPort( 80 );
    url.setPath( "/~cddb/cddb.cgi" );

    url.setQuery( QString::null );

    QString hello = QString("%1 %2 %3 %4")
        .arg(user_, localHostName_, clientName(), clientVersion());

    url.addQueryItem( "cmd", "sites" );
    url.addQueryItem( "hello", hello );
    url.addQueryItem( "proto", "5" );

    QValueList<Mirror> result;

    QString tmpFile;
    if( KIO::NetAccess::download( url, tmpFile, 0 ) )
    {
      result = readFile( tmpFile );
      KIO::NetAccess::removeTempFile( tmpFile );
    }

    return result;
  }
コード例 #16
0
bool LprHandler::completePrinter(KMPrinter *prt, PrintcapEntry *entry, bool)
{
	prt->setDescription(i18n("Unknown (unrecognized entry)"));
	QString val = entry->field("lp");
	KURL uri;
	if (!val.isEmpty() && val != "/dev/null")
	{
		int	p = val.find('@');
		if (p != -1)
		{
			prt->setLocation(i18n("Remote queue (%1) on %2").arg(val.left(p)).arg(val.mid(p+1)));
			uri.setProtocol("lpd");
			uri.setHost(val.mid(p+1));
			uri.setPath("/" + val.left(p));
		}
		else if ((p = val.find('%')) != -1)
		{
			prt->setLocation(i18n("Network printer (%1)").arg("socket"));
			uri.setProtocol("socket");
			uri.setHost(val.left(p));
			uri.setPort(val.mid(p+1).toInt());
		}
		else
		{
			prt->setLocation(i18n("Local printer on %1").arg(val));
			uri.setProtocol("parallel");
			uri.setPath(val);
		}
	}
	else if (!(val = entry->field("rp")).isEmpty())
	{
		QString rm = entry->has("rm") ?
				entry->field("rm") :
				LprSettings::self()->defaultRemoteHost();
		prt->setLocation(i18n("Remote queue (%1) on %2").arg(val).arg(rm));
		uri.setProtocol("lpd");
		uri.setHost(rm);
		uri.setPath("/" + val);
	}
	else
		prt->setLocation(i18n("Unknown (unrecognized entry)"));
	prt->setDevice(uri.url());
	return true;
}
コード例 #17
0
void JSLocation::setProtocol(ExecState* exec, JSValue value)
{
    Frame* frame = impl()->frame();
    ASSERT(frame);

    KURL url = frame->loader()->url();
    url.setProtocol(value.toString(exec));

    navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
}
コード例 #18
0
KURL NetworkAccount::getUrl() const
{
    KURL url;
    url.setProtocol(protocol());
    url.setUser(login());
    url.setPass(passwd());
    url.setHost(host());
    url.setPort(port());
    return url;
}
コード例 #19
0
void ProjectNewGeneral::slotLinePrjFile( const QString & )
{

  bool valid = !(linePrjFile->text().isEmpty() ||
                 linePrjName->text().isEmpty() ||
                 linePrjDir ->text().isEmpty() ||
                 linePrjTmpl->text().isEmpty() ||
                 linePrjToolbar->text().isEmpty());
  KURL url;
  QString s = lineHost->text();
  if (! s.isEmpty())
    url.setHost(s);

  s = lineUser->text();
  if (! s.isEmpty())
    url.setUser(s);
  s = linePasswd->text();
  if (! s.isEmpty())
    url.setPass(s);

  s = linePort->text();
  if (! s.isEmpty())
    url.setPort(linePort->text().toInt());

  url.setProtocol(comboProtocol->currentText());
  if (url.protocol() == i18n("Local")) url.setProtocol("file");
  url.setPath(linePrjDir->text());
  url.adjustPath(1);
  if (!url.path().startsWith("/")) url.setPath("/"+url.path());

  if (url.isValid())
  {
    emit setBaseURL(url);
    baseUrl = url;
    if (baseUrl.isLocalFile())
    {
      s = QExtFileInfo::canonicalPath(baseUrl.path());
      if (!s.isEmpty())
        baseUrl.setPath(s);
    }
  }
  emit enableNextButton( this, valid );
}
コード例 #20
0
void JSLocation::setProtocol(ExecState* exec, JSValue* value)
{
    Frame* frame = impl()->frame();
    ASSERT(frame);

    KURL url = frame->loader()->url();
    url.setProtocol(value->toString(exec));

    navigateIfAllowed(exec, frame, url, false);
}
コード例 #21
0
void KMWIpp::updatePrinter(KMPrinter *p)
{
	KURL	url;
	url.setProtocol("ipp");
	url.setHost(text(0));
	url.setPort(text(1).toInt());
	if (!p->option("kde-login").isEmpty()) url.setUser(p->option("kde-login"));
	if (!p->option("kde-password").isEmpty()) url.setPass(p->option("kde-password"));
	p->setDevice(url.url());
}
コード例 #22
0
ファイル: proxy.cpp プロジェクト: gms8994/amarok-1.4
KURL Proxy::realStreamUrl( KURL fakeStream, int sessionId )
{
    KURL realStream;
    realStream.setProtocol( "http" );
    realStream.setHost(fakeStream.host());
    realStream.setPort(fakeStream.port());
    realStream.setPath( "/databases" + fakeStream.directory() + "/items/" + fakeStream.fileName() );
    realStream.setQuery( QString("?session-id=") + QString::number(sessionId) );
    return realStream;
}
コード例 #23
0
void Location::setProtocol(const String& protocol, DOMWindow* activeWindow, DOMWindow* firstWindow, ExceptionCode& ec)
{
    if (!m_frame)
        return;
    KURL url = m_frame->document()->url();
    if (!url.setProtocol(protocol)) {
        ec = SYNTAX_ERR;
        return;
    }
    setLocation(url.string(), activeWindow, firstWindow);
}
コード例 #24
0
void Location::setProtocol(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, const String& protocol, ExceptionState& exceptionState)
{
    if (!m_frame)
        return;
    KURL url = m_frame->document()->url();
    if (!url.setProtocol(protocol)) {
        exceptionState.throwDOMException(SyntaxError, "'" + protocol + "' is an invalid protocol.");
        return;
    }
    setLocation(url.string(), callingWindow, enteredWindow);
}
コード例 #25
0
ファイル: IconURL.cpp プロジェクト: mirror/chromium
IconURL IconURL::defaultFavicon(const KURL& documentURL) {
  DCHECK(documentURL.protocolIsInHTTPFamily());
  KURL url;
  bool couldSetProtocol = url.setProtocol(documentURL.protocol());
  DCHECK(couldSetProtocol);
  url.setHost(documentURL.host());
  if (documentURL.hasPort())
    url.setPort(documentURL.port());
  url.setPath("/favicon.ico");

  IconURL result(url, Vector<IntSize>(), emptyString(), Favicon);
  result.m_isDefaultIcon = true;
  return result;
}
コード例 #26
0
ファイル: settings.cpp プロジェクト: serghei/kde3-kdepim
KURL Settings::accountUrl() const
{
    KConfig config("scalixadminrc");
    KConfigGroup group(&config, "Account");

    KURL url;
    url.setProtocol(group.readBoolEntry("use-ssl") ? "imaps" : "imap");
    url.setUser(group.readEntry("user"));
    url.setPass(KStringHandler::obscure(group.readEntry("pass")));
    url.setHost(group.readEntry("host"));
    url.setPort(group.readNumEntry("port"));

    return url;
}
コード例 #27
0
ファイル: KURLTest.cpp プロジェクト: azureplus/chromium
// WebKit will make empty URLs and set components on them. kurl doesn't allow
// replacements on invalid URLs, but here we do.
TEST(KURLTest, ReplaceInvalid)
{
    KURL kurl;

    EXPECT_FALSE(kurl.isValid());
    EXPECT_TRUE(kurl.isEmpty());
    EXPECT_STREQ("", kurl.string().utf8().data());

    kurl.setProtocol("http");
    // GKURL will say that a URL with just a scheme is invalid, KURL will not.
    EXPECT_FALSE(kurl.isValid());
    EXPECT_FALSE(kurl.isEmpty());
    // At this point, we do things slightly differently if there is only a scheme.
    // We check the results here to make it more obvious what is going on, but it
    // shouldn't be a big deal if these change.
    EXPECT_STREQ("http:", kurl.string().utf8().data());

    kurl.setHost("www.google.com");
    EXPECT_TRUE(kurl.isValid());
    EXPECT_FALSE(kurl.isEmpty());
    EXPECT_STREQ("http://www.google.com/", kurl.string().utf8().data());

    kurl.setPort(8000);
    EXPECT_TRUE(kurl.isValid());
    EXPECT_FALSE(kurl.isEmpty());
    EXPECT_STREQ("http://www.google.com:8000/", kurl.string().utf8().data());

    kurl.setPath("/favicon.ico");
    EXPECT_TRUE(kurl.isValid());
    EXPECT_FALSE(kurl.isEmpty());
    EXPECT_STREQ("http://www.google.com:8000/favicon.ico", kurl.string().utf8().data());

    // Now let's test that giving an invalid replacement fails. Invalid
    // protocols fail without modifying the URL, which should remain valid.
    EXPECT_FALSE(kurl.setProtocol("f/sj#@"));
    EXPECT_TRUE(kurl.isValid());
}
コード例 #28
0
ファイル: trashimpl.cpp プロジェクト: Fat-Zer/tdebase
// Helper method. Creates a URL with the format trash:/trashid-fileid or
// trash:/trashid-fileid/relativePath/To/File for a file inside a trashed directory.
KURL TrashImpl::makeURL( int trashId, const TQString& fileId, const TQString& relativePath )
{
    KURL url;
    url.setProtocol( "trash" );
    TQString path = "/";
    path += TQString::number( trashId );
    path += '-';
    path += fileId;
    if ( !relativePath.isEmpty() ) {
        path += '/';
        path += relativePath;
    }
    url.setPath( path );
    return url;
}
コード例 #29
0
void MediaPlayerPrivateGStreamer::setPlaybinURL(KURL& url)
{
    // Clean out everything after file:// url path.
    if (url.isLocalFile()) {
        url.setQuery(String());
        url.removeFragmentIdentifier();
    }

    m_url = url;

    if (url.protocolIsInHTTPFamily())
        url.setProtocol("webkit+" + url.protocol());

    LOG_MEDIA_MESSAGE("Load %s", url.string().utf8().data());
    g_object_set(m_playBin.get(), "uri", url.string().utf8().data(), NULL);
}
コード例 #30
0
ファイル: kmanpart.cpp プロジェクト: serghei/kde3-kdebase
bool KManPart::openFile()
{
    if(m_job != 0)
        m_job->kill();

    begin();

    KURL url;
    url.setProtocol("man");
    url.setPath(m_file);

    m_job = KIO::get(url, true, false);
    connect(m_job, SIGNAL(data(KIO::Job *, const QByteArray &)), SLOT(readData(KIO::Job *, const QByteArray &)));
    connect(m_job, SIGNAL(result(KIO::Job *)), SLOT(jobDone(KIO::Job *)));
    return true;
}